diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2011-12-09 12:41:18 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2011-12-09 12:41:18 +0000 |
commit | a7acd081b77cb34147578be4cab5e9e0ad0a69c3 (patch) | |
tree | 78f82d2090b34fda102c4b3f17c05619fbcd2da0 /src/integration-tests/test_integration_bootstrap_and_connect.py.in | |
parent | 1c1693d9c1aa6d23032a6f3e6caff3a53b6df4ec (diff) | |
download | gnunet-a7acd081b77cb34147578be4cab5e9e0ad0a69c3.tar.gz gnunet-a7acd081b77cb34147578be4cab5e9e0ad0a69c3.zip |
test now checks if boths transports are connecting
Diffstat (limited to 'src/integration-tests/test_integration_bootstrap_and_connect.py.in')
-rwxr-xr-x | src/integration-tests/test_integration_bootstrap_and_connect.py.in | 91 |
1 files changed, 64 insertions, 27 deletions
diff --git a/src/integration-tests/test_integration_bootstrap_and_connect.py.in b/src/integration-tests/test_integration_bootstrap_and_connect.py.in index e88c2988a..2d0290a26 100755 --- a/src/integration-tests/test_integration_bootstrap_and_connect.py.in +++ b/src/integration-tests/test_integration_bootstrap_and_connect.py.in | |||
@@ -24,6 +24,10 @@ import subprocess | |||
24 | import re | 24 | import re |
25 | import shutil | 25 | import shutil |
26 | import time | 26 | import time |
27 | import pexpect | ||
28 | |||
29 | |||
30 | |||
27 | 31 | ||
28 | # | 32 | # |
29 | # This test tests if a fresh peer bootstraps from a hostlist server and then | 33 | # This test tests if a fresh peer bootstraps from a hostlist server and then |
@@ -35,32 +39,45 @@ import time | |||
35 | testname = "test_integration_bootstrap_and_connect" | 39 | testname = "test_integration_bootstrap_and_connect" |
36 | verbose = True | 40 | verbose = True |
37 | gnunetarm = "" | 41 | gnunetarm = "" |
42 | gnunetstatistics = "" | ||
38 | #fix this! | 43 | #fix this! |
39 | success = True | 44 | success = False |
40 | timeout = 2 | 45 | timeout = 10 |
46 | |||
47 | #test conditions | ||
48 | |||
49 | #server | ||
50 | server_transport_connected = False | ||
51 | server_topology_connected = False | ||
52 | server_core_connected = False | ||
53 | |||
54 | client_transport_connected = False | ||
55 | client_topology_connected = False | ||
56 | client_core_connected = False | ||
57 | |||
41 | 58 | ||
42 | def vprintf (msg): | 59 | def vprintf (msg): |
43 | if verbose == True: | 60 | if verbose == True: |
44 | print msg | 61 | print msg |
45 | 62 | ||
46 | def setup (): | 63 | def setup (): |
47 | srcdir = "../.." | 64 | srcdir = "../.." |
48 | gnunet_pyexpect_dir = os.path.join (srcdir, "contrib") | 65 | gnunet_pyexpect_dir = os.path.join (srcdir, "contrib") |
49 | if gnunet_pyexpect_dir not in sys.path: | 66 | if gnunet_pyexpect_dir not in sys.path: |
50 | sys.path.append (gnunet_pyexpect_dir) | 67 | sys.path.append (gnunet_pyexpect_dir) |
51 | 68 | from gnunet_pyexpect import pexpect | |
52 | from gnunet_pyexpect import pexpect | 69 | global gnunetarm |
53 | 70 | global gnunetstatistics | |
54 | global gnunetarm | 71 | if os.name == 'posix': |
55 | if os.name == 'posix': | 72 | gnunetarm = 'gnunet-arm' |
56 | gnunetarm = 'gnunet-arm' | 73 | gnunetstatistics = 'gnunet-statistics' |
57 | elif os.name == 'nt': | 74 | elif os.name == 'nt': |
58 | gnunetarm = 'gnunet-arm.exe' | 75 | gnunetarm = 'gnunet-arm.exe' |
59 | 76 | gnunetstatistics = 'gnunet-statistics.exe' | |
60 | if os.name == "nt": | 77 | if os.name == "nt": |
61 | shutil.rmtree (os.path.join (os.getenv ("TEMP"), testname), True) | 78 | shutil.rmtree (os.path.join (os.getenv ("TEMP"), testname), True) |
62 | else: | 79 | else: |
63 | shutil.rmtree ("/tmp/" + testname, True) | 80 | shutil.rmtree ("/tmp/" + testname, True) |
64 | 81 | ||
65 | def start (): | 82 | def start (): |
66 | vprintf ("Starting bootstrap server & client") | 83 | vprintf ("Starting bootstrap server & client") |
@@ -101,14 +118,33 @@ def cleanup (): | |||
101 | else: | 118 | else: |
102 | shutil.rmtree ("/tmp/gnunet-test-fs-py-ns", True) | 119 | shutil.rmtree ("/tmp/gnunet-test-fs-py-ns", True) |
103 | 120 | ||
104 | def check (): | 121 | def check_statistics (conf, subsystem, name, value): |
105 | global success | 122 | from gnunet_pyexpect import pexpect |
106 | global timeout | 123 | server = pexpect () |
107 | count = 1 | 124 | server.spawn (None, [gnunetstatistics, '-c', conf ,'-q','-n', name, '-s', subsystem ], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) |
125 | #server.expect ("stdout", re.compile (r"")) | ||
126 | test = server.read("stdout", 10240) | ||
127 | if (test.find(str(value)) == -1): | ||
128 | return False | ||
129 | else: | ||
130 | return True | ||
131 | |||
132 | |||
108 | 133 | ||
109 | while ((success == False) and (count < timeout)): | 134 | def check (): |
110 | time.sleep(1) | 135 | global success |
111 | count += 1 | 136 | global timeout |
137 | global publish | ||
138 | |||
139 | count = 1 | ||
140 | print 'check' | ||
141 | while ((success == False) and (count <= timeout)): | ||
142 | if (True == check_statistics ('./confs/c_bootstrap_server.conf', 'transport', '# peers connected',1)): | ||
143 | vprintf ('Server transport services is connected') | ||
144 | if (True == check_statistics ('./confs/c_no_nat_client.conf', 'transport', '# peers connected',1)): | ||
145 | vprintf ('Client transport services is connected') | ||
146 | time.sleep(1) | ||
147 | count += 1 | ||
112 | 148 | ||
113 | # | 149 | # |
114 | # Test execution | 150 | # Test execution |
@@ -120,7 +156,7 @@ start () | |||
120 | 156 | ||
121 | check () | 157 | check () |
122 | 158 | ||
123 | stop () | 159 | #stop () |
124 | cleanup () | 160 | cleanup () |
125 | 161 | ||
126 | if (success == False): | 162 | if (success == False): |
@@ -131,3 +167,4 @@ else: | |||
131 | exit (0) | 167 | exit (0) |
132 | 168 | ||
133 | 169 | ||
170 | |||