Updated VNET+ tests
authorSapan Bhatia <sapanb@cs.princeton.edu>
Fri, 1 Aug 2008 02:45:28 +0000 (02:45 +0000)
committerSapan Bhatia <sapanb@cs.princeton.edu>
Fri, 1 Aug 2008 02:45:28 +0000 (02:45 +0000)
qaapi/qa/tests/node/nmapitest.py [new file with mode: 0755]
qaapi/qa/tests/node/ping.pl [new file with mode: 0755]
qaapi/qa/tests/node/synacks.pl
qaapi/qa/tests/node/traceroutes.pl

diff --git a/qaapi/qa/tests/node/nmapitest.py b/qaapi/qa/tests/node/nmapitest.py
new file mode 100755 (executable)
index 0000000..f934eb1
--- /dev/null
@@ -0,0 +1,10 @@
+#!/usr/bin/python
+# Module: VNET+
+# Description:         
+# Connect to the node manager
+# Author: acb@cs.princeton.edu
+
+from xmlrpclib import ServerProxy
+
+nodemanager = ServerProxy('http://127.0.0.1:812/')
+nodemanager.SetLoans('pl_sirius', [])
diff --git a/qaapi/qa/tests/node/ping.pl b/qaapi/qa/tests/node/ping.pl
new file mode 100755 (executable)
index 0000000..bbc4b58
--- /dev/null
@@ -0,0 +1,40 @@
+#!/usr/bin/perl
+
+# Module: VNET+
+# Description: Generate ping packets and count the responses
+# Author: sapanb@cs.princeton.edu
+
+use strict;
+use threads;
+
+#please change to something local
+my $guineapig='planetlab-1.cs.princeton.edu';
+my $numiter=1000;
+
+sub run {
+       system("ping -c $numiter -i 0.1 $guineapig");
+       }
+
+
+sub open_tcpdump {
+       my $filter="icmp and src $guineapig";
+       my $cmdline="/usr/sbin/tcpdump -c $numiter $filter";
+       
+       system($cmdline);
+}
+
+sub alhandler {
+       print "[FAILED] tcpdump apparently did not intercept all SYN/ACK packets\n";
+       exit(-1);
+}
+
+print "Starting tcpdump...\n";
+my $tcpdthr=threads->create(\&open_tcpdump);
+sleep 10;
+print "Generating connections...\n";
+run;
+$SIG{ALRM}=\&alhandler;
+alarm(60);
+
+$tcpdthr->join;
+print "[SUCCESS] Test completed OK.\n";
index 092a509..6f7ef6a 100755 (executable)
@@ -1,5 +1,9 @@
 #!/usr/bin/perl
-# Generate a ton of connections and check if we can see syn/ack packets via tcpdump
+
+# Module: VNET+
+# Description:         
+# Generate a ton of connections and check if we can see syn/ack packets via tcpdump.
+# Author: sapanb@cs.princeton.edu
 
 use strict;
 use IO::Socket;
index 1586dbc..948c90c 100755 (executable)
 #!/usr/bin/perl
-# Generate a ton of connections and check if we can see syn/ack packets via tcpdump
 
+# Module: VNET+
+# Description:         Trace the route path to a node using two methods: TCP-related ICMP errors, and TTL expiry. 
+# Then match the two paths to see that they concord. If there's a slight difference, it's probably OK given that
+# some routers might support one type of error but not the other, and that the routes are not guaranteed to be the
+# same.
+# Dependencies: tcptraceroute, traceroute, which
+# Author: sapanb@cs.princeton.edu
+
+$|=1;
+
+# ********************************************************************************
+# CONFIGURATION
+
+
+# The node that we're going to trace route. It's probably a good idea to change it
+# periodically so that we don't harass the same host.
 my $guineapig="vini-veritas.net";
-my $ttraceroute="/usr/sbin/tcptraceroute";
-my $traceroute="/usr/sbin/tracepath";
+
+# Location of traceroute, tcptraceroute
+my $ttraceroute=`which tcptraceroute 2>/dev/null`;
+my $traceroute=`which traceroute 2>/dev/null`;
+
+chop($ttraceroute);
+chop($traceroute);
+
+if ($traceroute !~ /^\//) {
+       $traceroute=`which tracepath 2>/dev/null`;
+       chop($traceroute);
+}
+
+if (!-e "$ttraceroute") {
+       print $ttraceroute."\n";
+       die("[FAILED] Please install tcptraceroute in the slice before running this test\n");
+}      
+else {
+       print "Found rcptraceroute. Good.\n";
+}
+
+if ($traceroute !~ /^\//) {
+       die("[FAILED] Please install traceroute in the slice before running this test\n");
+}      
+
+my %hash;
 
 sub open_tcptraceroute {
-       if (!-e "$ttraceroute") {
-               die("[FAILED] Please install tcptraceroute in the slice before running this test\n");
-       }       
        my $cmdline="$ttraceroute $guineapig";
        my $out='';
-       my %result;
        open TT,"$cmdline|";
 
        while (<TT>) {
                if (/\((\d+\.\d+\.\d+\.\d+)\)/) {
-                       $result{$1}=$result{$1}+1;
+                       glob %hash;
+                       print ">>> $_";
+                       $hash{$1}++;
                }
        }
-       return %result;
-
 }
 
 sub open_traceroute {
-       if (!-e "$traceroute") {
-               die("[FAILED] Please install tcptraceroute in the slice before running this test\n");
-       }       
        my $ref=shift;
        my $cmdline="$traceroute $guineapig";
        my $out='';
-       my %result=%$ref;;
+       print $cmdline."\n";
        open TT,"$cmdline|";
 
        while (<TT>) {
                if (/\((\d+\.\d+\.\d+\.\d+)\)/) {
-                       $result{$1}=$results{$1}+1;
+                       glob %hash;
+                       print ">>> $_";
+                       $hash{$1}=$hash{$1}+1;
                }
        }
-       return %result;
-
 }
 
 sub compare {
        my $ref=shift;
-       my %a1=%$ref;
        my $ret=1;
        my $double=0;
        my $single=0;
-       foreach (keys %a1) {
-               print "$_->".$a1{$_}."\n";
-               if ($a1{$_}==1) {
-                       print "Single: $_\n";
+       glob %hash;
+       foreach (keys %hash) {
+               if ($hash{$_}==1) {
                        $single++;
-               } elsif ($a1{$_}==2) {
-                       print "Double: $_\n";
+               } elsif ($hash{$_}==2) {
+                       print "Concorded on $_\n";
                        $double++;
                }
-               else { die ("bug in test script");}
+               else { die ("[FAILED] Could not complete test.\n");}
 
        }
        return ($single,$double);
 }
 
 sub alhandler {
-       print "[FAILED] Timed out waiting\n";
+       print "[FAILED] Timed out waiting.\n";
        exit(-1);
 }
 
@@ -74,9 +104,9 @@ if (fork==0) {
        my $s;
        my $d;
 
-       %r1=open_tcptraceroute;
-       %r1=open_traceroute %r1;
-       ($s,$d)=compare(\%r1);
+       open_tcptraceroute;
+       open_traceroute;
+       ($s,$d)=compare;
        if ($s==0 && $d>2) {
                print "[SUCCESS] traceroute and tcptraceroute reported the same result. $d hops.\n";
                exit(0);