Commit ecd22e9d authored by Leigh B. Stoller's avatar Leigh B. Stoller

A few little changes to help with regression mode in the

wrapper/mapper, so that DB tables are ordered in a consistent manner,
and can be easily compared with just diff.
parent ecb66ab5
......@@ -29,7 +29,7 @@ use overload ('""' => 'Stringify');
use libtblog_simple;
use vars qw($EXPT_PRELOAD $EXPT_START $EXPT_SWAPIN $EXPT_SWAPUPDATE
$EXPT_SWAPOUT $EXPT_SWAPMOD @physicalTables @virtualTables
$EXPT_SWAPOUT $EXPT_SWAPMOD %physicalTables @virtualTables
@EXPORT_OK);
# Configure variables
......@@ -67,7 +67,7 @@ my $EXPT_RESOURCESHOSED = 0;
# Why, why, why?
@EXPORT_OK = qw($EXPT_PRELOAD $EXPT_START $EXPT_SWAPUPDATE
$EXPT_SWAPIN $EXPT_SWAPOUT $EXPT_SWAPMOD
@physicalTables @virtualTables);
%physicalTables @virtualTables);
#
# List of tables used for experiment removal/backup/restore.
......@@ -99,12 +99,12 @@ my $EXPT_RESOURCESHOSED = 0;
"virt_tiptunnels",
"ipsubnets");
@physicalTables = ("delays",
"ipport_ranges",
"v2pmap",
"linkdelays",
"traces",
"portmap");
%physicalTables = ("delays" => ["node_id", "vname", "vnode0", "vnode1"],
"ipport_ranges" => undef,
"v2pmap" => ["node_id", "vname"],
"linkdelays" => ["node_id", "vlan", "vnode"],
"traces" => ["idx"],
"portmap" => undef);
# These are slots in the node table that need to be restored.
my @nodetable_fields = ("def_boot_osid",
......@@ -3088,7 +3088,7 @@ sub RemovePhysicalState($)
or $errors++;
}
foreach my $table (@physicalTables) {
foreach my $table (keys(%physicalTables)) {
DBQueryWarn("DELETE FROM $table WHERE pid='$pid' AND eid='$eid'")
or $errors++;
}
......@@ -3138,8 +3138,14 @@ sub BackupPhysicalState($;$)
# Reserved table is special; we do not want to bring it back in during
# the restore. We just want the info from it.
foreach my $table (@physicalTables, "reserved") {
foreach my $table (keys(%physicalTables), "reserved") {
my $orderby = "";
if (exists($physicalTables{$table}) &&
defined($physicalTables{$table})) {
$orderby = "order by " . join(",", @{$physicalTables{$table}});
}
DBQueryWarn("SELECT * FROM $table WHERE pid='$pid' AND eid='$eid' ".
"$orderby ".
"INTO OUTFILE '$pstateDir/$table' ")
or $errors++;
}
......@@ -3162,7 +3168,8 @@ sub RestorePhysicalState($)
return -1
if (Lan->RestoreExperimentLans($self, $pstateDir) != 0);
foreach my $table (@physicalTables, "vinterfaces", "interface_settings") {
foreach my $table (keys(%physicalTables),
"vinterfaces", "interface_settings") {
DBQueryWarn("LOAD DATA INFILE '$pstateDir/$table' INTO TABLE $table")
or $errors++;
}
......
......@@ -1519,6 +1519,7 @@ sub Create($$$;$)
$self->{"TYPE"} = '';
$self->{"ROLE"} = '';
$self->{"ENCAPSTYLE"} = '';
$self->{"IDX"} = undef; # used in regression mode.
$self->{"INSTANCE"} = undef;
bless($self, $class);
......@@ -1572,6 +1573,7 @@ sub Instantiate($)
my $experiment = $self->{'EXPT'};
my $vname = $self->{'VNAME'};
my $type = $self->{'TYPE'};
my $idx = $self->{'IDX'}; # defaults to undef when not regression.
my $link = undef;
# Already created.
......@@ -1589,7 +1591,7 @@ sub Instantiate($)
}
# The new lan has the 'ready' bit set to zero.
my $lan = Lan->Create($experiment, $vname, $type, undef, $link);
my $lan = Lan->Create($experiment, $vname, $type, $idx, $link);
return -1
if (!defined($lan));
......@@ -1633,9 +1635,21 @@ sub Instantiate($)
#
# Instantiate all protolans
#
sub InstantiateAll($)
sub InstantiateAll($$)
{
my ($class) = @_;
my ($class, $regression) = @_;
if ($regression) {
#
# Need to make sure the id numbers will compare exactly. At some
# point a few years from now, this will fail.
#
my $idx = 999990000;
foreach my $protolan (values(%protolans)) {
$protolan->{'IDX'} = $idx++;
}
}
foreach my $protolan (values(%protolans)) {
if ($protolan->Instantiate() != 0) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment