diff options
author | Nathan S. Evans <evans@in.tum.de> | 2010-04-22 14:56:18 +0000 |
---|---|---|
committer | Nathan S. Evans <evans@in.tum.de> | 2010-04-22 14:56:18 +0000 |
commit | ca5b942e92761ac2e5ec00dcaaeb2b57427ec6cf (patch) | |
tree | 8a86db13f5b7a04ce3d2a781baec3be8dfe15291 /src/testing/test_testing_topology.c | |
parent | 2f393b8e200600d1dfb1ced22cc4ef8269a49c2a (diff) | |
download | gnunet-ca5b942e92761ac2e5ec00dcaaeb2b57427ec6cf.tar.gz gnunet-ca5b942e92761ac2e5ec00dcaaeb2b57427ec6cf.zip |
testing changes, which hopefully make testing code more robust, though problems are inevitable
Diffstat (limited to 'src/testing/test_testing_topology.c')
-rw-r--r-- | src/testing/test_testing_topology.c | 47 |
1 files changed, 33 insertions, 14 deletions
diff --git a/src/testing/test_testing_topology.c b/src/testing/test_testing_topology.c index 5e8d1f45f..334f1c78d 100644 --- a/src/testing/test_testing_topology.c +++ b/src/testing/test_testing_topology.c | |||
@@ -27,8 +27,11 @@ | |||
27 | 27 | ||
28 | #define VERBOSE GNUNET_NO | 28 | #define VERBOSE GNUNET_NO |
29 | 29 | ||
30 | /** | ||
31 | * How long until we fail the whole testcase? | ||
32 | */ | ||
33 | #define TEST_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 600) | ||
30 | 34 | ||
31 | #define TEST_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 360) | ||
32 | /** | 35 | /** |
33 | * How long until we give up on connecting the peers? | 36 | * How long until we give up on connecting the peers? |
34 | */ | 37 | */ |
@@ -36,12 +39,16 @@ | |||
36 | 39 | ||
37 | #define DEFAULT_NUM_PEERS 4; | 40 | #define DEFAULT_NUM_PEERS 4; |
38 | 41 | ||
42 | static float fail_percentage = 0.05; | ||
43 | |||
39 | static int ok; | 44 | static int ok; |
40 | 45 | ||
41 | static unsigned long long num_peers; | 46 | static unsigned long long num_peers; |
42 | 47 | ||
43 | static unsigned int total_connections; | 48 | static unsigned int total_connections; |
44 | 49 | ||
50 | static unsigned int failed_connections; | ||
51 | |||
45 | static unsigned int total_server_connections; | 52 | static unsigned int total_server_connections; |
46 | 53 | ||
47 | static unsigned int total_messages_received; | 54 | static unsigned int total_messages_received; |
@@ -177,11 +184,9 @@ process_mtype (void *cls, | |||
177 | static void | 184 | static void |
178 | end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | 185 | end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) |
179 | { | 186 | { |
180 | #if VERBOSE | ||
181 | char *msg = cls; | 187 | char *msg = cls; |
182 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 188 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
183 | "End badly was called (%s)... stopping daemons.\n", msg); | 189 | "End badly was called (%s)... stopping daemons.\n", msg); |
184 | #endif | ||
185 | struct Connection *pos; | 190 | struct Connection *pos; |
186 | 191 | ||
187 | pos = global_connections; | 192 | pos = global_connections; |
@@ -266,7 +271,7 @@ transmit_ready (void *cls, size_t size, void *buf) | |||
266 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 271 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
267 | "transmit ready for peer %s\ntransmit_ready's scheduled %d, transmit_ready's called %d\n", GNUNET_i2s(peer), transmit_ready_scheduled, transmit_ready_called); | 272 | "transmit ready for peer %s\ntransmit_ready's scheduled %d, transmit_ready's called %d\n", GNUNET_i2s(peer), transmit_ready_scheduled, transmit_ready_called); |
268 | #endif | 273 | #endif |
269 | GNUNET_SCHEDULER_add_now(sched, &schedule_transmission, NULL); | 274 | GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 50), &schedule_transmission, NULL); |
270 | return sizeof (struct GNUNET_MessageHeader); | 275 | return sizeof (struct GNUNET_MessageHeader); |
271 | } | 276 | } |
272 | 277 | ||
@@ -299,9 +304,6 @@ send_test_messages () | |||
299 | if (conn_pos->peer == pos->peer1) | 304 | if (conn_pos->peer == pos->peer1) |
300 | { | 305 | { |
301 | pos->peer1handle = conn_pos->server; | 306 | pos->peer1handle = conn_pos->server; |
302 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
303 | "Peer matched conn_count %d\n", | ||
304 | conn_count); | ||
305 | break; | 307 | break; |
306 | } | 308 | } |
307 | conn_count++; | 309 | conn_count++; |
@@ -328,11 +330,12 @@ send_test_messages () | |||
328 | */ | 330 | */ |
329 | pos = pos->next; | 331 | pos = pos->next; |
330 | count++; | 332 | count++; |
331 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 333 | |
332 | "Prepared %d messages\n", | ||
333 | count); | ||
334 | } | 334 | } |
335 | 335 | ||
336 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
337 | "Prepared %d messages\n", | ||
338 | count); | ||
336 | global_pos = test_messages; | 339 | global_pos = test_messages; |
337 | 340 | ||
338 | GNUNET_SCHEDULER_add_now(sched, &schedule_transmission, NULL); | 341 | GNUNET_SCHEDULER_add_now(sched, &schedule_transmission, NULL); |
@@ -437,7 +440,8 @@ topology_callback (void *cls, | |||
437 | #if VERBOSE | 440 | #if VERBOSE |
438 | else | 441 | else |
439 | { | 442 | { |
440 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Failed to connect peer %s to peer %s with error %s\n", | 443 | failed_connections++; |
444 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Failed to connect peer %s to peer %s with error :\n%s\n", | ||
441 | first_daemon->shortname, | 445 | first_daemon->shortname, |
442 | second_daemon->shortname, emsg); | 446 | second_daemon->shortname, emsg); |
443 | } | 447 | } |
@@ -455,12 +459,27 @@ topology_callback (void *cls, | |||
455 | /* die_task = GNUNET_SCHEDULER_add_now (sched, &setup_handlers, NULL); */ | 459 | /* die_task = GNUNET_SCHEDULER_add_now (sched, &setup_handlers, NULL); */ |
456 | die_task = GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 1), &setup_handlers, NULL); | 460 | die_task = GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 1), &setup_handlers, NULL); |
457 | } | 461 | } |
462 | else if (total_connections + failed_connections == expected_connections) | ||
463 | { | ||
464 | if (failed_connections < (unsigned int)(fail_percentage * total_connections)) | ||
465 | { | ||
466 | GNUNET_SCHEDULER_cancel (sched, die_task); | ||
467 | /* die_task = GNUNET_SCHEDULER_add_now (sched, &setup_handlers, NULL); */ | ||
468 | die_task = GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 1), &setup_handlers, NULL); | ||
469 | } | ||
470 | else | ||
471 | { | ||
472 | GNUNET_SCHEDULER_cancel (sched, die_task); | ||
473 | die_task = GNUNET_SCHEDULER_add_now (sched, | ||
474 | &end_badly, "from topology_callback (too many failed connections)"); | ||
475 | } | ||
476 | } | ||
458 | else | 477 | else |
459 | { | 478 | { |
460 | #if VERBOSE | 479 | #if VERBOSE |
461 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 480 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
462 | "Have %d total connections, Need %d\n", | 481 | "Have %d total connections, %d failed connections, Want %d (at least %d)\n", |
463 | total_connections, expected_connections); | 482 | total_connections, failed_connections, expected_connections, expected_connections - (unsigned int)(fail_percentage * expected_connections)); |
464 | #endif | 483 | #endif |
465 | } | 484 | } |
466 | } | 485 | } |