aboutsummaryrefslogtreecommitdiff
path: root/src/integration-tests/test_integration_bootstrap_and_connect.py.in
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2011-12-09 12:41:18 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2011-12-09 12:41:18 +0000
commita7acd081b77cb34147578be4cab5e9e0ad0a69c3 (patch)
tree78f82d2090b34fda102c4b3f17c05619fbcd2da0 /src/integration-tests/test_integration_bootstrap_and_connect.py.in
parent1c1693d9c1aa6d23032a6f3e6caff3a53b6df4ec (diff)
downloadgnunet-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-xsrc/integration-tests/test_integration_bootstrap_and_connect.py.in91
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
24import re 24import re
25import shutil 25import shutil
26import time 26import time
27import 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
35testname = "test_integration_bootstrap_and_connect" 39testname = "test_integration_bootstrap_and_connect"
36verbose = True 40verbose = True
37gnunetarm = "" 41gnunetarm = ""
42gnunetstatistics = ""
38#fix this! 43#fix this!
39success = True 44success = False
40timeout = 2 45timeout = 10
46
47#test conditions
48
49#server
50server_transport_connected = False
51server_topology_connected = False
52server_core_connected = False
53
54client_transport_connected = False
55client_topology_connected = False
56client_core_connected = False
57
41 58
42def vprintf (msg): 59def vprintf (msg):
43 if verbose == True: 60 if verbose == True:
44 print msg 61 print msg
45 62
46def setup (): 63def 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
65def start (): 82def 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
104def check (): 121def 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)): 134def 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
121check () 157check ()
122 158
123stop () 159#stop ()
124cleanup () 160cleanup ()
125 161
126if (success == False): 162if (success == False):
@@ -131,3 +167,4 @@ else:
131 exit (0) 167 exit (0)
132 168
133 169
170