Commit 37a8e824 authored by Kevin Atkinson's avatar Kevin Atkinson
Browse files

Added test for emulab synchronization mechanism.
parent 6f8d31fb
......@@ -148,7 +148,7 @@ sub get_parms ($) {
sub get_numnodes ($) {
# FIXME: needs better error detection
my ($test) = @_;
open F, "$testsdir/$test/num-nodes";
open F, "$testsdir/$test/num-nodes" or die "Unable to open $test/num-nodes\n";
local $_ = <F>;
chop;
return $_;
......
Test emulab synchronization mechanism.
set ns [new Simulator]
source tb_compat.tcl
set node0 [$ns node]
set node1 [$ns node]
set node2 [$ns node]
set node3 [$ns node]
set node4 [$ns node]
tb-set-sync-server $node0
tb-set-node-startcmd $node0 "@DATADIR@/startcmd0.sh /proj/@PID@/exp/@EID@/tmp/"
tb-set-node-startcmd $node1 "@DATADIR@/startcmd1.sh /proj/@PID@/exp/@EID@/tmp/"
tb-set-node-startcmd $node2 "@DATADIR@/startcmd2.sh /proj/@PID@/exp/@EID@/tmp/"
tb-set-node-startcmd $node3 "@DATADIR@/startcmd3.sh /proj/@PID@/exp/@EID@/tmp/"
tb-set-node-startcmd $node4 "@DATADIR@/startcmd4.sh /proj/@PID@/exp/@EID@/tmp/"
$ns run
#!/bin/sh
cd $1
perl -e 'sleep(rand()*30)'
echo 0 > node0up
/usr/testbed/bin/emulab-sync -i 2
cat node0up node1up node2up > node0res
#!/bin/sh
cd $1
perl -e 'sleep(rand()*30)'
echo 1 > node1up
/usr/testbed/bin/emulab-sync
cat node0up node1up node2up > node1res
#!/bin/sh
cd $1;
/usr/testbed/bin/emulab-sync -a -i 2 -n barrier2
perl -e 'sleep(rand()*30)'
echo 2 > node2up
/usr/testbed/bin/emulab-sync
cat node0up node1up node2up > node2res
#!/bin/sh
cd $1
sleep 55
echo 3 > node3up
/usr/testbed/bin/emulab-sync -n barrier2
cat node3up node4up > node3res
#!/bin/sh
cd $1
sleep 60
echo 4 > node4up
/usr/testbed/bin/emulab-sync -n barrier2
cat node3up node4up > node4res
sub compare_file($@) {
my $n = shift;
my $f = new IO::File "/proj/$pid/exp/$eid/tmp/node${n}res" or
die "*** Unable to open result file for node$n.\n";
while (<$f>) {
chop;
my $expected = shift;
die "*** Results file for node$n did not match expected output\n"
unless $_ eq $expected;
}
die "*** Results file for node$n did not match expected output\n"
if <$f>;
return 1;
}
print "Sleeping 45 seconds...\n";
sleep 45;
test 'sync1', [], sub {
compare_file 0, 0,1,2;
compare_file 1, 0,1,2;
compare_file 2, 0,1,2;
};
print "Sleeping 30 seconds...\n";
sleep 30;
test 'sync2', [], sub {
compare_file 3, 3,4;
compare_file 4, 3,4;
};
Supports Markdown
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