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-08 17:22:03 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2011-12-08 17:22:03 +0000
commit1ff3fa2d954f9d1e74585ee6652339bb8a1aff4a (patch)
tree0fd31d1fac430449574a201cb48e7b6814607ac8 /src/integration-tests/test_integration_bootstrap_and_connect.py.in
parent3ec5e14c7071bfb39ad7af8f98365d6e81cbe026 (diff)
downloadgnunet-1ff3fa2d954f9d1e74585ee6652339bb8a1aff4a.tar.gz
gnunet-1ff3fa2d954f9d1e74585ee6652339bb8a1aff4a.zip
-more
Diffstat (limited to 'src/integration-tests/test_integration_bootstrap_and_connect.py.in')
-rwxr-xr-xsrc/integration-tests/test_integration_bootstrap_and_connect.py.in153
1 files changed, 88 insertions, 65 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 44e8df3df..e88c2988a 100755
--- a/src/integration-tests/test_integration_bootstrap_and_connect.py.in
+++ b/src/integration-tests/test_integration_bootstrap_and_connect.py.in
@@ -23,6 +23,7 @@ import os
23import subprocess 23import subprocess
24import re 24import re
25import shutil 25import shutil
26import time
26 27
27# 28#
28# This test tests if a fresh peer bootstraps from a hostlist server and then 29# This test tests if a fresh peer bootstraps from a hostlist server and then
@@ -31,80 +32,102 @@ import shutil
31 32
32#definitions 33#definitions
33 34
34def vpfrint (msg):
35 if verbose == True:
36 print msg
37
38
39testname = "test_integration_bootstrap_and_connect" 35testname = "test_integration_bootstrap_and_connect"
40verbose = True 36verbose = True
37gnunetarm = ""
38#fix this!
39success = True
40timeout = 2
41 41
42# setup 42def vprintf (msg):
43 43 if verbose == True:
44srcdir = "../.." 44 print msg
45gnunet_pyexpect_dir = os.path.join (srcdir, "contrib")
46if gnunet_pyexpect_dir not in sys.path:
47 sys.path.append (gnunet_pyexpect_dir)
48
49from gnunet_pyexpect import pexpect
50
51if os.name == 'posix':
52 gnunetarm = 'gnunet-arm'
53elif os.name == 'nt':
54 gnunetarm = 'gnunet-arm.exe'
55
56if os.name == "nt":
57 shutil.rmtree (os.path.join (os.getenv ("TEMP"), testname), True)
58else:
59 shutil.rmtree ("/tmp/" + testname, True)
60
61vpfrint ("Running " + testname)
62 45
46def setup ():
47 srcdir = "../.."
48 gnunet_pyexpect_dir = os.path.join (srcdir, "contrib")
49 if gnunet_pyexpect_dir not in sys.path:
50 sys.path.append (gnunet_pyexpect_dir)
51
52 from gnunet_pyexpect import pexpect
53
54 global gnunetarm
55 if os.name == 'posix':
56 gnunetarm = 'gnunet-arm'
57 elif os.name == 'nt':
58 gnunetarm = 'gnunet-arm.exe'
59
60 if os.name == "nt":
61 shutil.rmtree (os.path.join (os.getenv ("TEMP"), testname), True)
62 else:
63 shutil.rmtree ("/tmp/" + testname, True)
64
65def start ():
66 vprintf ("Starting bootstrap server & client")
67 try:
68 server = subprocess.Popen ([gnunetarm, '-sq', '-c', './confs/c_bootstrap_server.conf'])
69 server.communicate ()
70 except OSError:
71 print "Can not start bootstrap server, exiting..."
72 exit (1)
73 try:
74 client = subprocess.Popen ([gnunetarm, '-sq', '-c', 'confs/c_no_nat_client.conf'])
75 client.communicate ()
76 except OSError:
77 print "Can not start bootstrap client, exiting..."
78 exit (1)
79 vprintf ("Bootstrap server & client started")
80
81def stop ():
82 vprintf ("Shutting down bootstrap server")
83 try:
84 server = subprocess.Popen ([gnunetarm, '-eq', '-c', './confs/c_bootstrap_server.conf'])
85 server.communicate ()
86 except OSError:
87 print "Can not stop bootstrap server, exiting..."
88 exit (1)
89 try:
90 client = subprocess.Popen ([gnunetarm, '-eq', '-c', 'confs/c_no_nat_client.conf'])
91 client.communicate ()
92 except OSError:
93 print "Can not stop bootstrap client, exiting..."
94 exit (1)
95 vprintf ("Bootstrap server & client stopped")
96
97
98def cleanup ():
99 if os.name == "nt":
100 shutil.rmtree (os.path.join (os.getenv ("TEMP"), "gnunet-test-fs-py-ns"), True)
101 else:
102 shutil.rmtree ("/tmp/gnunet-test-fs-py-ns", True)
103
104def check ():
105 global success
106 global timeout
107 count = 1
108
109 while ((success == False) and (count < timeout)):
110 time.sleep(1)
111 count += 1
63 112
113#
114# Test execution
115#
64 116
65# start nodes 117vprintf ("Running " + testname)
118setup ()
119start ()
66 120
67vpfrint ("Starting bootstrap server & client") 121check ()
68try:
69 server = subprocess.Popen ([gnunetarm, '-sq', '-c', './confs/c_bootstrap_server.conf'])
70 server.communicate ()
71except OSError:
72 print "Can not start bootstrap server, exiting..."
73 exit (1)
74try:
75 client = subprocess.Popen ([gnunetarm, '-sq', '-c', 'confs/c_no_nat_client.conf'])
76 client.communicate ()
77except OSError:
78 print "Can not start bootstrap client, exiting..."
79 exit (1)
80vpfrint ("Bootstrap server & client started")
81 122
123stop ()
124cleanup ()
82 125
83import time 126if (success == False):
84time.sleep(5) 127 print ('Test failed')
85 128 exit (1)
86# shutdown
87vpfrint ("Shutting down bootstrap server")
88try:
89 server = subprocess.Popen ([gnunetarm, '-eq', '-c', './confs/c_bootstrap_server.conf'])
90 server.communicate ()
91except OSError:
92 print "Can not stop bootstrap server, exiting..."
93 exit (1)
94try:
95 client = subprocess.Popen ([gnunetarm, '-eq', '-c', 'confs/c_no_nat_client.conf'])
96 client.communicate ()
97except OSError:
98 print "Can not stop bootstrap client, exiting..."
99 exit (1)
100vpfrint ("Bootstrap server & client stopped")
101
102# clean up
103
104if os.name == "nt":
105 shutil.rmtree (os.path.join (os.getenv ("TEMP"), "gnunet-test-fs-py-ns"), True)
106else: 129else:
107 shutil.rmtree ("/tmp/gnunet-test-fs-py-ns", True) 130 print ('Test successful')
131 exit (0)
108 132
109exit (0)
110 133