-
Notifications
You must be signed in to change notification settings - Fork 94
/
Copy pathmerkle1
executable file
·84 lines (67 loc) · 1.91 KB
/
merkle1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/perl -w
use strict;
use POSIX qw(:signal_h);
use Cwd qw(abs_path);
use File::Basename;
use ChordTestHarness;
if ($> == 0) {
warn "You probably don't want to run this as root. Hit Ctrl-C now to cancel.\n";
sleep 5;
}
my $SRC = abs_path (dirname ($0));
sub usage {
print STDERR "Usage: $0 outputroot buildroot\n";
print STDERR @_, "\n" if @_;
exit (1);
}
my $r = shift || usage ("no output dir");
my $build = shift || usage ("no build dir");
$build = abs_path ($build);
my $n = 2;
my $v = 15;
my $routeprot = "chord";
my $logbase = 1;
my $ip = guessip ();
my $wkport = 10903; # first prime after my uid
my $harness = ChordTestHarness->new ($build, $r);
# Make sure we'll clean up after ourselves properly. Or at least, try.
$SIG{"INT"} = sub { exit (1); };
END {
if (defined ($harness)) {
$harness->reaplsds ();
$harness = undef
}
}
######
# Shift to directory where we will store our working files and results.
warn "Old $r exists; may lead to incorrect results!\n" if (-d $r);
mkdir $r, 0755;
my @CONFS;
# however, leave a mode where we can force all localhost behavior.
my $i = 1;
my @args = ("-f",
"-j", "$ip:$wkport",
"-l", $ip,
"-v", $v,
"-m", $routeprot,
"-b", $logbase,
"-n", 5);
# always start a well-known node running on a particular port.
$harness->spawnlsd ("a", @args, "-p", $wkport);
sleep 10;
print "Storing.\n";
$harness->store ("a", 0, "store.log");
sleep 30; # wait till a replicates
$harness->spawnlsd ("b", @args);
sleep 30; # wait till b gets its blocks
$harness->killlsd ("a"); # kill a
sleep 60; # give b time to recover
print "Fetching.\n";
$harness->fetch ("b", 0, "fetch.log"); # now blocks should be available on b
sleep 10;
$harness->reaplsds ();
foreach my $conf (@CONFS) {
my $s = "============= NODE $conf ============";
system ("echo $s >> $r/dump-$n-$v");
system ("cat $r/lsd-$conf/log >> $r/dump-$n-$v");
}