(no commit message)
[tests.git] / qaapi / qa / tests / node / vsys_launch.pl
1 #!/usr/bin/perl
2 use strict;
3
4 my $prefix;
5
6 if ($#ARGV>0) {
7                 $prefix=$ARGV[0];
8                 print "Setting prefix = $prefix\n";
9 }
10 else {
11     # Setting temporarily for Thierry's test environment
12         $prefix="pl";
13 }
14
15 my $timeout=600;
16
17 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;}
18
19 if (!$timeout) {
20     die ("Timed out waiting for pl_netflow to appear\n");
21 }
22
23 my $slice="$prefix"."_netflow";
24 my $slicedir="/vservers/$slice";
25
26 # Subtest #1 Create new vsys entry
27 print "Creating entries...\t";
28
29 my $vsys_entry="#!/bin/bash\n\ncat /etc/passwd";
30 my $vsys_entry_acl = "$slice";
31
32 open ACL,">/vsys/test.acl" || die ("Could not create acl for test entry.");
33 print ACL $vsys_entry_acl;
34 close ACL;
35
36 open FIL,">/vsys/test" || die ("Could not create test entry.");
37 print FIL $vsys_entry;
38 close $vsys_entry;
39
40 chmod 0755,"/vsys/test";
41
42 # Check if it has shown up
43 sleep(2);
44
45 (-p "/vservers/$slice/vsys/test.in") || die ("in file didn't show up in the slice");
46 (-p "/vservers/$slice/vsys/test.out") || die ("out file didn't show up in the slice");
47
48 # OK, SUBTEST #1 SUCCEEDED
49 print "[SUCCESS] The new entried appeared OK\n";
50
51 # Subtest #2 
52
53 print "Multiple-connection test...\t";
54 mkdir ("/vservers/$slice/support");
55 system("cp vsys_conctest /vservers/$slice/support");
56 system("su -c '/support/vsys_conctest $slice' $slice -");
57 ($? && die ("[FAILED] Multiple-connection test failed\n"));
58
59
60 # OK, SUBTEST #2 SUCCEEDED
61 print "[SUCCESS])\n";
62
63 # Subtest #3
64 unlink "/vsys/test.acl";
65 unlink "/vsys/test";
66
67 (-f "$slicedir/test.in" || -f "$slicedir/test.out") && die ("cleanup failed");
68