Added test for planetflow 2.
[tests.git] / qaapi / qa / tests / node / pf2test.pl
1 #!/usr/bin/perl
2
3 print "Warning! This test runs only once. I.e., it will usually not run twice in succession till syslog sees some new activitt\n";
4 print "Preparing...";
5
6 system("cp /var/log/messages /tmp/pf2_test");
7
8 # ping magic IP address
9 print "Sending out packet...\n";
10 system("su -c \"ping -c 1 64.34.177.39\" pl_netflow -"); # hm. Sapan doesn't own this IP anymore. We should change it at some point.
11
12 print "Waiting for flow to appear...\n";
13 sleep(10);
14
15 open PIP,"|/usr/bin/diff -u /tmp/pf2_test /var/log/messages";
16
17 while (<PIP>) {
18         if (/Received test flow to corewars.org from slice ([0-9]+)/) {
19                 $xid = int($1);
20                 print "Slice id: $xid";
21                 ($xid==0 || $xid==-1) && die("Slice id incorrect");
22         }
23 }
24
25 close PIP;
26
27 print "Test successful.";
28