diff options
author | ng0 <ng0@n0.is> | 2019-10-12 18:16:07 +0000 |
---|---|---|
committer | ng0 <ng0@n0.is> | 2019-10-12 18:16:07 +0000 |
commit | a5f5e7ed9b07b902af4438d76087e034abcba9b2 (patch) | |
tree | 6f376f93f1c785103d0b30f54311a0f61d2bdced /src/integration-tests/test_integration_disconnect_nat.py.in | |
parent | 8e827de2a1db34dfe15f5f9da2850ca469b5ecc3 (diff) | |
download | gnunet-a5f5e7ed9b07b902af4438d76087e034abcba9b2.tar.gz gnunet-a5f5e7ed9b07b902af4438d76087e034abcba9b2.zip |
format python
Diffstat (limited to 'src/integration-tests/test_integration_disconnect_nat.py.in')
-rwxr-xr-x | src/integration-tests/test_integration_disconnect_nat.py.in | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/integration-tests/test_integration_disconnect_nat.py.in b/src/integration-tests/test_integration_disconnect_nat.py.in index c3d5d8901..d3ff84ebe 100755 --- a/src/integration-tests/test_integration_disconnect_nat.py.in +++ b/src/integration-tests/test_integration_disconnect_nat.py.in | |||
@@ -32,7 +32,6 @@ from gnunet_testing import Check | |||
32 | from gnunet_testing import Condition | 32 | from gnunet_testing import Condition |
33 | from gnunet_testing import * | 33 | from gnunet_testing import * |
34 | 34 | ||
35 | |||
36 | # | 35 | # |
37 | # This test tests if a fresh peer bootstraps from a hostlist server and then | 36 | # This test tests if a fresh peer bootstraps from a hostlist server and then |
38 | # successfully connects to the server. When both peers are connected | 37 | # successfully connects to the server. When both peers are connected |
@@ -68,7 +67,9 @@ def cleanup_onerror(function, path, excinfo): | |||
68 | 67 | ||
69 | 68 | ||
70 | def cleanup(): | 69 | def cleanup(): |
71 | shutil.rmtree(os.path.join(tmp, "c_bootstrap_server"), False, cleanup_onerror) | 70 | shutil.rmtree( |
71 | os.path.join(tmp, "c_bootstrap_server"), False, cleanup_onerror | ||
72 | ) | ||
72 | shutil.rmtree(os.path.join(tmp, "c_nat_client"), False, cleanup_onerror) | 73 | shutil.rmtree(os.path.join(tmp, "c_nat_client"), False, cleanup_onerror) |
73 | 74 | ||
74 | 75 | ||
@@ -80,7 +81,7 @@ def success_disconnect_cont(check): | |||
80 | 81 | ||
81 | def fail_disconnect_cont(check): | 82 | def fail_disconnect_cont(check): |
82 | global success | 83 | global success |
83 | success = False; | 84 | success = False |
84 | print('Peers failed to disconnect') | 85 | print('Peers failed to disconnect') |
85 | check.evaluate(True) | 86 | check.evaluate(True) |
86 | 87 | ||
@@ -96,7 +97,9 @@ def check_disconnect(): | |||
96 | check.add(StatisticsCondition(server, 'topology', '# peers connected', 0)) | 97 | check.add(StatisticsCondition(server, 'topology', '# peers connected', 0)) |
97 | check.add(StatisticsCondition(server, 'dht', '# peers connected', 0)) | 98 | check.add(StatisticsCondition(server, 'dht', '# peers connected', 0)) |
98 | check.add(StatisticsCondition(server, 'fs', '# peers connected', 0)) | 99 | check.add(StatisticsCondition(server, 'fs', '# peers connected', 0)) |
99 | check.run_blocking(check_timeout, success_disconnect_cont, fail_disconnect_cont) | 100 | check.run_blocking( |
101 | check_timeout, success_disconnect_cont, fail_disconnect_cont | ||
102 | ) | ||
100 | 103 | ||
101 | 104 | ||
102 | def success_connect_cont(check): | 105 | def success_connect_cont(check): |
@@ -115,9 +118,13 @@ def check_connect(): | |||
115 | global server | 118 | global server |
116 | global nat_client | 119 | global nat_client |
117 | check = Check(test) | 120 | check = Check(test) |
118 | check.add(StatisticsCondition(nat_client, 'transport', '# peers connected', 1)) | 121 | check.add( |
122 | StatisticsCondition(nat_client, 'transport', '# peers connected', 1) | ||
123 | ) | ||
119 | check.add(StatisticsCondition(nat_client, 'core', '# peers connected', 1)) | 124 | check.add(StatisticsCondition(nat_client, 'core', '# peers connected', 1)) |
120 | check.add(StatisticsCondition(nat_client, 'topology', '# peers connected', 1)) | 125 | check.add( |
126 | StatisticsCondition(nat_client, 'topology', '# peers connected', 1) | ||
127 | ) | ||
121 | check.add(StatisticsCondition(nat_client, 'dht', '# peers connected', 1)) | 128 | check.add(StatisticsCondition(nat_client, 'dht', '# peers connected', 1)) |
122 | check.add(StatisticsCondition(nat_client, 'fs', '# peers connected', 1)) | 129 | check.add(StatisticsCondition(nat_client, 'fs', '# peers connected', 1)) |
123 | 130 | ||
@@ -134,6 +141,7 @@ def check_connect(): | |||
134 | # Test execution | 141 | # Test execution |
135 | # | 142 | # |
136 | 143 | ||
144 | |||
137 | def SigHandler(signum=None, frame=None): | 145 | def SigHandler(signum=None, frame=None): |
138 | global success | 146 | global success |
139 | global server | 147 | global server |
@@ -204,7 +212,7 @@ def run(): | |||
204 | 212 | ||
205 | try: | 213 | try: |
206 | run() | 214 | run() |
207 | except(KeyboardInterrupt, SystemExit): | 215 | except (KeyboardInterrupt, SystemExit): |
208 | print('Test interrupted') | 216 | print('Test interrupted') |
209 | server.stop() | 217 | server.stop() |
210 | nat_client.stop() | 218 | nat_client.stop() |