Commit 64c21c1a authored by Kevin Atkinson's avatar Kevin Atkinson

Added some basic prechecks.

Added test of manual routing and tb-set-ip/netmask.

Moved test_traceroute from router tests to ImageTest.pm

Added test on pc3000w.

Other minor changes.
parent edcf6adf
......@@ -194,6 +194,32 @@ sub test_rcmd ($$$$;&) {
"ssh-node $node $cmd", $output_test);
}
#
#
#
sub test_traceroute ($$@) {
my ($src,$dest,@path) = @_;
test_rcmd "traceroute-${src}_$dest", [], $src, "/usr/sbin/traceroute $dest",
sub {
local @_ = split /\n/;
if (@_+0 != @path+0) {
printf "*** traceroute $src->$dest: expected %d hops but got %d.\n",
@path+0, @_+0;
return 0;
}
for (my $i = 0; $i < @_; $i++) {
local $_ = $_[$i];
my ($n) = /^\s*\d+\s*(\S+)/;
next if $n eq $path[$i];
printf "*** traceroute $src->$dest: expected %s for hop %d but got %s\n",
$path[0], $i+1, $n;
return 0;
}
return 1;
};
}
#
# Scans a log file for any errors or serious warnings. The log file
# may also be a pipe as the string is passed directly to open.
......
#!/usr/bin/perl -w
########################################################################
#
# This value is prefixed to all experiments to avoid conflicts with
# existing experient names
#
# This value is prefixed to all experiments to avoid conflicts with
# existing experient names
my $eid_prefix = 'it-';
# Maxium length of experment name
my $max_eid_length = 19;
# Where libxmlrpc is
use lib "/usr/testbed/lib";
########################################################################
#
# Prelude
......@@ -22,6 +26,8 @@ use POSIX 'setsid';
use POSIX ':sys_wait_h';
use Errno 'EINTR';
use libxmlrpc;
sub true() {1}
sub false() {0}
......@@ -33,7 +39,7 @@ sub LARGE_NUM {100000}
#
sub usage() {
die "usage: $0 -h | -l | [OPTIONS] IMAGE [EXPS ...]\n";
die "usage: $0 -? | -l | [OPTIONS] IMAGE [EXPS ...]\n";
}
sub help() {
......@@ -108,7 +114,7 @@ $soft_limit = LARGE_NUM if $soft_limit == 0;
$hard_limit = LARGE_NUM if $hard_limit == 0;
$soft_limit = $hard_limit if $soft_limit > $hard_limit;
if (@ARGV == 0) {
if (@ARGV == 0 && !$just_list) {
print STDERR "Must specify an image.\n";
usage();
}
......@@ -282,18 +288,76 @@ if ($just_list) {
#
#
# Check to make sure the image exists by creating a simple experment
# Check to make sure the image exists
#
if ($stages =~ /c/ || $os ne '.') {
my $res = CallMethod0("osid", "getlist", {});
die $res->{output} unless $res->{code} == 0;
my $found_image = false;
while (my ($k,$v) = each %{$res->{value}}) {
next unless $v->{pid} eq 'emulab-ops' || $v->{pid} eq $pid;
$found_image = true if ($k eq $os);
}
if (!$found_image) {
print STDERR "The osid \"$os\" doesn't exists in the \"emulab-ops\" or \"$pid\" project.\n";
exit 2;
}
}
#
# Check to make sure that each experiment is a valid name and
# it doesn't already exists.
#
sub experment_precheck() {
my $eid_to_long = '';
foreach my $e (@exps) {
my $eid = "$eid_prefix$e";
if (length($eid) > $max_eid_length) {
$eid_to_long = $eid unless length($eid_to_long) > length($eid);
}
}
if (length($eid_to_long) > 0) {
print STDERR "The experiment name \"$eid_to_long\" is longer than $max_eid_length characters.\n";
exit 2;
}
if ($stages ne 'e') {
my $exp_errors = 0;
foreach my $e (@exps) {
my $eid = "$eid_prefix$e";
my $res = CallMethod0("experiment", "state", {proj=>$pid, exp=>$eid});
die $res->{output} unless $res->{code} == 0 || $res->{code} == 2;
if ($stages =~ /c/) {
# should't exist
if ($res->{code} != 2) {
print STDERR "Experiment \"$eid\" in \"$pid\" must not exist.\n";
$exp_errors++;
}
} elsif ($stages =~ /s/) {
# need to exist, but not be swapped in
if ($res->{code} != 0 || $res->{value} ne 'swapped') {
print STDERR "Experiment \"$eid\" in \"$pid\" must be in the \"swapped\" state.\n";
$exp_errors++;
}
} else {
# need to exist, and be swapped in
if ($res->{code} != 0 || $res->{value} ne 'active') {
print STDERR "Experiment \"$eid\" in \"$pid\" must be in the \"active\" state.\n";
$exp_errors++;
}
}
}
if ($exp_errors) {
exit 2;
}
}
#sub experment_precheck($) {
# if ($
#}
########################################################################
#
......
Tests manual routing and tb-set-ip/netmask.
set ns [new Simulator]
source tb_compat.tcl
set node1 [$ns node]
set node2 [$ns node]
set node3 [$ns node]
set nodeA [$ns node]
tb-set-node-os $node1 @OS@
tb-set-node-os $node2 @OS@
tb-set-node-os $node3 @OS@
tb-set-node-os $nodeA @OS@
set lan [$ns make-lan "$node1 $node2 $node3" 100Mb 0ms]
set link [$ns duplex-link $node3 $nodeA 100Mb 0ms DropTail]
tb-set-ip $node1 192.168.1.1
tb-set-ip $node2 192.168.1.2
tb-set-ip-lan $node3 $lan 192.168.1.3
tb-set-netmask $lan 255.255.255.248
tb-set-ip-link $node3 $link 192.168.1.9
tb-set-ip-link $nodeA $link 192.168.1.10
tb-set-netmask $link 255.255.255.252
$node1 add-route $nodeA $node3
$node2 add-route $nodeA $node3
$nodeA add-route $lan $node3
$ns rtproto Manual
$ns run
test_traceroute 'node1', 'nodeA', qw(node3-lan nodeA-link);
test_traceroute 'nodeA', 'node1', qw(node3-link node1-lan);
test_traceroute 'node2', 'nodeA', qw(node3-lan nodeA-link);
test_traceroute 'nodeA', 'node2', qw(node3-link node2-lan);
test_traceroute 'node3', 'nodeA', qw(nodeA-link);
test_traceroute 'nodeA', 'node3', qw(node3-link);
test_traceroute 'node1', 'node3', qw(node3-lan);
test_traceroute 'node3', 'node1', qw(node1-lan);
sub test_traceroute ($$@) {
my ($src,$dest,@path) = @_;
test_rcmd "traceroute-$src_$dest", [], $src, "/usr/sbin/traceroute $dest",
sub {
local @_ = split /\n/;
if (@_+0 != @path+0) {
printf "*** traceroute $src->$dest: expected %d hops but got %d.\n",
@path+0, @_+0;
return 0;
}
for (my $i = 0; $i < @_; $i++) {
local $_ = $_[$i];
my ($n) = /^\s*\d+\s*(\S+)/;
next if $n eq $path[$i];
printf "*** traceroute $src->$dest: expected %s for hop %d but got %s\n",
$path[0], $i+1, $n;
return 0;
}
return 1;
};
}
# need the delay here to give time for the routes to converge when the
# routing protocol is session
if ($parms{rtproto} eq 'Session') {
......
hardware: pc600 pc850 pc2000 pc3000
hardware: pc600 pc850 pc2000 pc3000 pc3000w
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