ceb81b50122f070327d081a260651a94fcd6284b
[tests.git] / qaapi / qa / tests / node / pf2test.pl
1 #!/usr/bin/perl
2
3 $netflow_slice="pl_netflow";
4
5 print "Warning! This test runs only once. I.e., it will usually not run twice in succession till syslog sees some new activitt\n";
6 print "Preparing...";
7
8
9 system("cp /var/log/messages /tmp/pf2_test");
10
11
12 # Wait for pl_netflow to come up
13
14 $timeout=600;
15
16 until ((-f "/var/run/vservers/pl_netflow" && -d "/home/pl_netflow") || ($timeout==0)) {sleep (15);print "Waiting for pl_netflow to show up...\n";$timeout-=15;}
17
18 if ($timeout>0) {
19 # ping magic IP address
20 print "Sending out packet...\n";
21 system("su -c \"ping -I eth0 -c 1 10.0.0.8\" $netflow_slice -"); 
22
23 print "Waiting for flow to appear...\n";
24 sleep(10);
25
26 open PIP,"|/usr/bin/diff -u /tmp/pf2_test /var/log/messages";
27
28 while (<PIP>) {
29         if (/Received test flow to corewars.org from slice ([0-9]+)/) {
30                 $xid = int($1);
31                 print "Slice id: $xid\n";
32         $success=1;
33                 ($xid==0 || $xid==-1) && die("Slice id incorrect");
34         }
35 }
36
37 if ($success) {
38         print "[SUCCESS]";
39 }
40 else {
41         print "[FAILED]";
42 }
43 }
44 else {
45     die("[FAILED] Timed out.. pl_netflow didn't come up for 10 minutes...\n");
46 }
47
48
49 close PIP;
50