diff options
author | Nathan S. Evans <evans@in.tum.de> | 2010-08-05 12:11:41 +0000 |
---|---|---|
committer | Nathan S. Evans <evans@in.tum.de> | 2010-08-05 12:11:41 +0000 |
commit | 88c11d3a2219762a919e49872d6d24108b06b987 (patch) | |
tree | 3e8a04cd9f5c4015221827621b95343dd1743b5b /src/testing/test_testing_topology.c | |
parent | 86a9316f0f9b422e6b3fae8c75255a92e326dd51 (diff) | |
download | gnunet-88c11d3a2219762a919e49872d6d24108b06b987.tar.gz gnunet-88c11d3a2219762a919e49872d6d24108b06b987.zip |
topology stability testcase
Diffstat (limited to 'src/testing/test_testing_topology.c')
-rw-r--r-- | src/testing/test_testing_topology.c | 47 |
1 files changed, 37 insertions, 10 deletions
diff --git a/src/testing/test_testing_topology.c b/src/testing/test_testing_topology.c index a2bb350f0..f357862c5 100644 --- a/src/testing/test_testing_topology.c +++ b/src/testing/test_testing_topology.c | |||
@@ -33,7 +33,7 @@ | |||
33 | /** | 33 | /** |
34 | * How long until we fail the whole testcase? | 34 | * How long until we fail the whole testcase? |
35 | */ | 35 | */ |
36 | #define TEST_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 600) | 36 | #define TEST_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 240) |
37 | 37 | ||
38 | /** | 38 | /** |
39 | * How long until we give up on starting the peers? | 39 | * How long until we give up on starting the peers? |
@@ -52,6 +52,8 @@ static int ok; | |||
52 | 52 | ||
53 | static unsigned long long num_peers; | 53 | static unsigned long long num_peers; |
54 | 54 | ||
55 | static unsigned int topology_connections; | ||
56 | |||
55 | static unsigned int total_connections; | 57 | static unsigned int total_connections; |
56 | 58 | ||
57 | static unsigned int failed_connections; | 59 | static unsigned int failed_connections; |
@@ -76,6 +78,8 @@ GNUNET_SCHEDULER_TaskIdentifier die_task; | |||
76 | 78 | ||
77 | static char *dotOutFileName; | 79 | static char *dotOutFileName; |
78 | 80 | ||
81 | static struct GNUNET_TIME_Relative settle_time; | ||
82 | |||
79 | static FILE *dotOutFile; | 83 | static FILE *dotOutFile; |
80 | 84 | ||
81 | static char *topology_string; | 85 | static char *topology_string; |
@@ -184,6 +188,7 @@ static void gather_log_data () | |||
184 | } | 188 | } |
185 | 189 | ||
186 | #endif | 190 | #endif |
191 | |||
187 | static void | 192 | static void |
188 | finish_testing () | 193 | finish_testing () |
189 | { | 194 | { |
@@ -219,8 +224,8 @@ finish_testing () | |||
219 | GNUNET_free(free_pos); | 224 | GNUNET_free(free_pos); |
220 | } | 225 | } |
221 | #if VERBOSE | 226 | #if VERBOSE |
222 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 227 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
223 | "Transmit_ready's scheduled %d, failed %d, transmit_ready's called %d\n", transmit_ready_scheduled, transmit_ready_failed, transmit_ready_called); | 228 | "Transmit_ready's scheduled %d, failed %d, transmit_ready's called %d\n", transmit_ready_scheduled, transmit_ready_failed, transmit_ready_called); |
224 | #endif | 229 | #endif |
225 | 230 | ||
226 | #if VERBOSE | 231 | #if VERBOSE |
@@ -276,23 +281,22 @@ void topology_cb (void *cls, | |||
276 | outfile = cls; | 281 | outfile = cls; |
277 | if (first != NULL) | 282 | if (first != NULL) |
278 | { | 283 | { |
279 | if (outfile == NULL) | 284 | if (outfile != NULL) |
280 | fprintf(stderr, "Peer %s connected to %s\n", GNUNET_i2s(first), GNUNET_h2s(&second->hashPubKey)); | ||
281 | else | ||
282 | { | 285 | { |
283 | fprintf(outfile, "\t\"%s\" -- ", GNUNET_i2s(first)); | 286 | fprintf(outfile, "\t\"%s\" -- ", GNUNET_i2s(first)); |
284 | fprintf(outfile, "\"%s\";\n", GNUNET_i2s(second)); | 287 | fprintf(outfile, "\"%s\";\n", GNUNET_i2s(second)); |
285 | } | 288 | } |
289 | topology_connections++; | ||
286 | } | 290 | } |
287 | else | 291 | else |
288 | { | 292 | { |
289 | fprintf(stderr, "Finished iterating over topology!\n"); | 293 | fprintf(stderr, "Finished iterating over topology, %d total connections!\n", topology_connections); |
290 | if (outfile != NULL) | 294 | if (outfile != NULL) |
291 | { | 295 | { |
292 | fprintf(outfile, "}\n"); | 296 | fprintf(outfile, "}\n"); |
293 | fclose(outfile); | 297 | fclose(outfile); |
298 | GNUNET_SCHEDULER_add_now (sched, &finish_testing, NULL); | ||
294 | } | 299 | } |
295 | GNUNET_SCHEDULER_add_now (sched, &finish_testing, NULL); | ||
296 | } | 300 | } |
297 | } | 301 | } |
298 | 302 | ||
@@ -348,6 +352,7 @@ process_mtype (void *cls, | |||
348 | { | 352 | { |
349 | fprintf(dotOutFileFinished, "strict graph G {\n"); | 353 | fprintf(dotOutFileFinished, "strict graph G {\n"); |
350 | } | 354 | } |
355 | topology_connections = 0; | ||
351 | GNUNET_TESTING_get_topology (pg, &topology_cb, dotOutFileFinished); | 356 | GNUNET_TESTING_get_topology (pg, &topology_cb, dotOutFileFinished); |
352 | //GNUNET_SCHEDULER_add_now (sched, &finish_testing, NULL); | 357 | //GNUNET_SCHEDULER_add_now (sched, &finish_testing, NULL); |
353 | } | 358 | } |
@@ -386,6 +391,13 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | |||
386 | GNUNET_free(free_pos); | 391 | GNUNET_free(free_pos); |
387 | } | 392 | } |
388 | 393 | ||
394 | #if VERBOSE | ||
395 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
396 | "Transmit_ready's scheduled %d, failed %d, transmit_ready's called %d\n", transmit_ready_scheduled, transmit_ready_failed, transmit_ready_called); | ||
397 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
398 | "Total messages received %d, expected %d.\n", total_messages_received, expected_messages); | ||
399 | #endif | ||
400 | |||
389 | if (pg != NULL) | 401 | if (pg != NULL) |
390 | { | 402 | { |
391 | GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); | 403 | GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); |
@@ -500,6 +512,11 @@ send_test_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | |||
500 | { | 512 | { |
501 | struct TestMessageContext *pos = cls; | 513 | struct TestMessageContext *pos = cls; |
502 | 514 | ||
515 | if ((pos == test_messages) && (settle_time.value > 0)) | ||
516 | { | ||
517 | topology_connections = 0; | ||
518 | GNUNET_TESTING_get_topology (pg, &topology_cb, NULL); | ||
519 | } | ||
503 | if ((tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN) || (cls == NULL)) | 520 | if ((tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN) || (cls == NULL)) |
504 | return; | 521 | return; |
505 | 522 | ||
@@ -507,7 +524,7 @@ send_test_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | |||
507 | { | 524 | { |
508 | die_task = GNUNET_SCHEDULER_add_delayed (sched, | 525 | die_task = GNUNET_SCHEDULER_add_delayed (sched, |
509 | TEST_TIMEOUT, | 526 | TEST_TIMEOUT, |
510 | &end_badly, "from create topology (timeout)"); | 527 | &end_badly, "from send test messages (timeout)"); |
511 | } | 528 | } |
512 | 529 | ||
513 | if (total_server_connections >= MAX_OUTSTANDING_CONNECTIONS) | 530 | if (total_server_connections >= MAX_OUTSTANDING_CONNECTIONS) |
@@ -626,7 +643,11 @@ topology_callback (void *cls, | |||
626 | &send_test_messages, test_messages); | 643 | &send_test_messages, test_messages); |
627 | gather_log_data(); | 644 | gather_log_data(); |
628 | #else | 645 | #else |
629 | GNUNET_SCHEDULER_add_now (sched, &send_test_messages, test_messages); | 646 | if (settle_time.value > 0) |
647 | { | ||
648 | GNUNET_TESTING_get_topology (pg, &topology_cb, NULL); | ||
649 | } | ||
650 | GNUNET_SCHEDULER_add_delayed (sched, settle_time, &send_test_messages, test_messages); | ||
630 | #endif | 651 | #endif |
631 | #if VERBOSE | 652 | #if VERBOSE |
632 | fprintf(stdout, "Test message progress: ["); | 653 | fprintf(stdout, "Test message progress: ["); |
@@ -852,6 +873,7 @@ run (void *cls, | |||
852 | char * blacklist_topology_str; | 873 | char * blacklist_topology_str; |
853 | char * connect_topology_option_str; | 874 | char * connect_topology_option_str; |
854 | char * connect_topology_option_modifier_string; | 875 | char * connect_topology_option_modifier_string; |
876 | unsigned long long temp_settle; | ||
855 | sched = s; | 877 | sched = s; |
856 | ok = 1; | 878 | ok = 1; |
857 | 879 | ||
@@ -927,6 +949,11 @@ run (void *cls, | |||
927 | GNUNET_free_non_null(topology_str); | 949 | GNUNET_free_non_null(topology_str); |
928 | GNUNET_free_non_null(blacklist_topology_str); | 950 | GNUNET_free_non_null(blacklist_topology_str); |
929 | 951 | ||
952 | if (GNUNET_OK == | ||
953 | GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "settle_time", | ||
954 | &temp_settle)) | ||
955 | settle_time = GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, temp_settle); | ||
956 | |||
930 | if (GNUNET_SYSERR == | 957 | if (GNUNET_SYSERR == |
931 | GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "num_peers", | 958 | GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "num_peers", |
932 | &num_peers)) | 959 | &num_peers)) |