diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2011-12-16 12:25:28 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2011-12-16 12:25:28 +0000 |
commit | 4997b98b69d53d14085f0da4d7d4b002f3d59100 (patch) | |
tree | 95dc9c487b9a23124f7aae48409d18fa6c20b574 /src/integration-tests/test_integration_bootstrap_and_connect.py.in | |
parent | 17f94e7fc0dfabbbd9868b72f957209549a16b5a (diff) | |
download | gnunet-4997b98b69d53d14085f0da4d7d4b002f3d59100.tar.gz gnunet-4997b98b69d53d14085f0da4d7d4b002f3d59100.zip |
added support for interupting a test
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 | 78 |
1 files changed, 53 insertions, 25 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 581179f99..a8aff73d7 100755 --- a/src/integration-tests/test_integration_bootstrap_and_connect.py.in +++ b/src/integration-tests/test_integration_bootstrap_and_connect.py.in | |||
@@ -39,11 +39,18 @@ from gnunet_testing import * | |||
39 | # Conditions for successful exit: | 39 | # Conditions for successful exit: |
40 | # Both peers have 1 connected peer in transport, core, topology, fs | 40 | # Both peers have 1 connected peer in transport, core, topology, fs |
41 | 41 | ||
42 | # | ||
43 | # This test tests if a fresh peer bootstraps from a hostlist server and then | ||
44 | # successfully connects to the server | ||
45 | # | ||
46 | # Conditions for successful exit: | ||
47 | # Both peers have 1 connected peer in transport, core, topology, fs | ||
48 | |||
42 | #definitions | 49 | #definitions |
43 | 50 | ||
44 | testname = "test_integration_bootstrap_and_connect" | 51 | testname = "test_integration_bootstrap_and_connect" |
45 | verbose = False | 52 | verbose = True |
46 | timeout = 100 | 53 | check_timeout = 30 |
47 | 54 | ||
48 | 55 | ||
49 | def cleanup (): | 56 | def cleanup (): |
@@ -64,7 +71,10 @@ def fail_cont (check): | |||
64 | check.eval(True) | 71 | check.eval(True) |
65 | 72 | ||
66 | def check (): | 73 | def check (): |
67 | 74 | global test | |
75 | global server | ||
76 | global client | ||
77 | global success | ||
68 | check = Check (test) | 78 | check = Check (test) |
69 | check.add (StatisticsCondition (client, 'transport', '# peers connected',1)) | 79 | check.add (StatisticsCondition (client, 'transport', '# peers connected',1)) |
70 | check.add (StatisticsCondition (client, 'core', '# neighbour entries allocated',1)) | 80 | check.add (StatisticsCondition (client, 'core', '# neighbour entries allocated',1)) |
@@ -79,32 +89,50 @@ def check (): | |||
79 | check.add (StatisticsCondition (server, 'topology', '# peers connected',1)) | 89 | check.add (StatisticsCondition (server, 'topology', '# peers connected',1)) |
80 | check.add (StatisticsCondition (server, 'fs', '# peers connected',1)) | 90 | check.add (StatisticsCondition (server, 'fs', '# peers connected',1)) |
81 | 91 | ||
82 | check.run_blocking (10, success_cont, fail_cont) | 92 | check.run_blocking (check_timeout, success_cont, fail_cont) |
83 | 93 | ||
84 | # | 94 | # |
85 | # Test execution | 95 | # Test execution |
86 | # | 96 | # |
87 | success = False | ||
88 | |||
89 | test = Test ('test_integration_bootstrap_and_connect.py', verbose) | ||
90 | 97 | ||
91 | server = Peer(test, './confs/c_bootstrap_server.conf'); | 98 | def run (): |
92 | server.start(); | 99 | global test |
93 | 100 | global server | |
94 | client = Peer(test, './confs/c_no_nat_client.conf'); | 101 | global client |
95 | client.start(); | 102 | global success |
96 | 103 | ||
97 | if ((client.started == True) and (server.started == True)): | 104 | success = False |
98 | test.p ('Peers started, running check') | 105 | test = Test ('test_integration_bootstrap_and_connect.py', verbose) |
99 | check () | 106 | |
100 | 107 | server = Peer(test, './confs/c_bootstrap_server.conf'); | |
101 | server.stop () | 108 | client = Peer(test, './confs/c_no_nat_client.conf'); |
102 | client.stop () | ||
103 | 109 | ||
104 | cleanup () | 110 | server.start(); |
111 | client.start(); | ||
112 | |||
113 | if ((client.started == True) and (server.started == True)): | ||
114 | test.p ('Peers started, running check') | ||
115 | time.sleep(5) | ||
116 | check () | ||
117 | |||
118 | print 'stop in run' | ||
119 | server.stop () | ||
120 | client.stop () | ||
121 | |||
122 | cleanup () | ||
123 | |||
124 | if (success == False): | ||
125 | print ('Test failed') | ||
126 | return False | ||
127 | else: | ||
128 | return True | ||
105 | 129 | ||
106 | if (success == False): | 130 | try: |
107 | print ('Test failed') | 131 | run () |
108 | exit (1) | 132 | except (KeyboardInterrupt, SystemExit): |
109 | else: | 133 | print 'Test interrupted' |
110 | exit (0) | 134 | server.stop () |
135 | client.stop () | ||
136 | cleanup () | ||
137 | sys.exit(success) | ||
138 | \ No newline at end of file | ||