aboutsummaryrefslogtreecommitdiff
path: root/src/testing/test_testing_topology.c
diff options
context:
space:
mode:
authorNathan S. Evans <evans@in.tum.de>2010-06-28 16:41:11 +0000
committerNathan S. Evans <evans@in.tum.de>2010-06-28 16:41:11 +0000
commit9748ddd31e98f2775851c8b24a735ba67d31e87a (patch)
treefdff70d7a8c35f227b403e80aeee5290054b1591 /src/testing/test_testing_topology.c
parentceae03698d503c88e96d18984e11079cb95a2184 (diff)
downloadgnunet-9748ddd31e98f2775851c8b24a735ba67d31e87a.tar.gz
gnunet-9748ddd31e98f2775851c8b24a735ba67d31e87a.zip
add test case for NO topology restrictions, connect in ring. good for maximum number of peers testing
Diffstat (limited to 'src/testing/test_testing_topology.c')
-rw-r--r--src/testing/test_testing_topology.c152
1 files changed, 123 insertions, 29 deletions
diff --git a/src/testing/test_testing_topology.c b/src/testing/test_testing_topology.c
index ba9084e31..0c569880b 100644
--- a/src/testing/test_testing_topology.c
+++ b/src/testing/test_testing_topology.c
@@ -25,7 +25,7 @@
25#include "gnunet_testing_lib.h" 25#include "gnunet_testing_lib.h"
26#include "gnunet_core_service.h" 26#include "gnunet_core_service.h"
27 27
28#define VERBOSE GNUNET_NO 28#define VERBOSE GNUNET_YES
29 29
30/** 30/**
31 * How long until we fail the whole testcase? 31 * How long until we fail the whole testcase?
@@ -37,6 +37,8 @@
37 */ 37 */
38#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 500) 38#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 500)
39 39
40#define SECONDS_PER_PEER_START 45
41
40#define DEFAULT_NUM_PEERS 4 42#define DEFAULT_NUM_PEERS 4
41 43
42#define MAX_OUTSTANDING_CONNECTIONS 300 44#define MAX_OUTSTANDING_CONNECTIONS 300
@@ -83,6 +85,10 @@ static int transmit_ready_failed;
83 85
84static int transmit_ready_called; 86static int transmit_ready_called;
85 87
88static unsigned int modnum;
89
90static unsigned int dotnum;
91
86static enum GNUNET_TESTING_Topology topology; 92static enum GNUNET_TESTING_Topology topology;
87 93
88static enum GNUNET_TESTING_Topology blacklist_topology = GNUNET_TESTING_TOPOLOGY_NONE; /* Don't do any blacklisting */ 94static enum GNUNET_TESTING_Topology blacklist_topology = GNUNET_TESTING_TOPOLOGY_NONE; /* Don't do any blacklisting */
@@ -196,7 +202,7 @@ finish_testing ()
196 } 202 }
197#if VERBOSE 203#if VERBOSE
198 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 204 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
199 "transmit_ready's scheduled %d, failed %d, transmit_ready's called %d\n", transmit_ready_scheduled, transmit_ready_failed, transmit_ready_called); 205 "Transmit_ready's scheduled %d, failed %d, transmit_ready's called %d\n", transmit_ready_scheduled, transmit_ready_failed, transmit_ready_called);
200#endif 206#endif
201 207
202#if VERBOSE 208#if VERBOSE
@@ -221,13 +227,13 @@ disconnect_cores (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
221 struct TestMessageContext *pos = cls; 227 struct TestMessageContext *pos = cls;
222 228
223 /* Disconnect from the respective cores */ 229 /* Disconnect from the respective cores */
224#if VERBOSE 230#if VERBOSE > 1
225 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 231 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
226 "Disconnecting from peer 1 `%4s'\n", GNUNET_i2s (&pos->peer1->id)); 232 "Disconnecting from peer 1 `%4s'\n", GNUNET_i2s (&pos->peer1->id));
227#endif 233#endif
228 if (pos->peer1handle != NULL) 234 if (pos->peer1handle != NULL)
229 GNUNET_CORE_disconnect(pos->peer1handle); 235 GNUNET_CORE_disconnect(pos->peer1handle);
230#if VERBOSE 236#if VERBOSE > 1
231 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 237 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
232 "Disconnecting from peer 2 `%4s'\n", GNUNET_i2s (&pos->peer2->id)); 238 "Disconnecting from peer 2 `%4s'\n", GNUNET_i2s (&pos->peer2->id));
233#endif 239#endif
@@ -253,8 +259,26 @@ process_mtype (void *cls,
253 if (pos->uid != ntohl(msg->uid)) 259 if (pos->uid != ntohl(msg->uid))
254 return GNUNET_OK; 260 return GNUNET_OK;
255 261
256 total_messages_received++;
257#if VERBOSE 262#if VERBOSE
263 if ((total_messages_received) % modnum == 0)
264 {
265 if (total_messages_received == 0)
266 fprintf (stdout, "0%%");
267 else
268 fprintf (stdout, "%d%%",
269 (int) (((float) total_messages_received /
270 expected_messages) * 100));
271
272 }
273 else if (total_messages_received % dotnum == 0)
274 {
275 fprintf (stdout, ".");
276 }
277 fflush (stdout);
278#endif
279
280 total_messages_received++;
281#if VERBOSE > 1
258 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 282 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
259 "Received message from `%4s', type %d.\n", GNUNET_i2s (peer), ntohs(message->type)); 283 "Received message from `%4s', type %d.\n", GNUNET_i2s (peer), ntohs(message->type));
260 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 284 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -263,6 +287,9 @@ process_mtype (void *cls,
263 287
264 if (total_messages_received == expected_messages) 288 if (total_messages_received == expected_messages)
265 { 289 {
290#if VERBOSE
291 fprintf(stdout, "100%%]\n");
292#endif
266 GNUNET_SCHEDULER_cancel (sched, die_task); 293 GNUNET_SCHEDULER_cancel (sched, die_task);
267 GNUNET_SCHEDULER_add_now (sched, &finish_testing, NULL); 294 GNUNET_SCHEDULER_add_now (sched, &finish_testing, NULL);
268 } 295 }
@@ -328,7 +355,7 @@ transmit_ready (void *cls, size_t size, void *buf)
328 m->header.size = htons (sizeof (struct GNUNET_TestMessage)); 355 m->header.size = htons (sizeof (struct GNUNET_TestMessage));
329 m->uid = htonl(pos->uid); 356 m->uid = htonl(pos->uid);
330 transmit_ready_called++; 357 transmit_ready_called++;
331#if VERBOSE 358#if VERBOSE > 1
332 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 359 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
333 "transmit ready for peer %s\ntransmit_ready's scheduled %d, transmit_ready's called %d\n", GNUNET_i2s(&pos->peer1->id), transmit_ready_scheduled, transmit_ready_called); 360 "transmit ready for peer %s\ntransmit_ready's scheduled %d, transmit_ready's called %d\n", GNUNET_i2s(&pos->peer1->id), transmit_ready_scheduled, transmit_ready_called);
334#endif 361#endif
@@ -353,7 +380,7 @@ init_notify_peer2 (void *cls,
353{ 380{
354 struct TestMessageContext *pos = cls; 381 struct TestMessageContext *pos = cls;
355 382
356#if VERBOSE 383#if VERBOSE > 1
357 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 384 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
358 "Core connection to `%4s' established, scheduling message send\n", 385 "Core connection to `%4s' established, scheduling message send\n",
359 GNUNET_i2s (my_identity)); 386 GNUNET_i2s (my_identity));
@@ -388,7 +415,7 @@ init_notify_peer1 (void *cls,
388 struct TestMessageContext *pos = cls; 415 struct TestMessageContext *pos = cls;
389 total_server_connections++; 416 total_server_connections++;
390 417
391#if VERBOSE 418#if VERBOSE > 1
392 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 419 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
393 "Core connection to `%4s' established, setting up handles\n", 420 "Core connection to `%4s' established, setting up handles\n",
394 GNUNET_i2s (my_identity)); 421 GNUNET_i2s (my_identity));
@@ -474,11 +501,28 @@ topology_callback (void *cls,
474 struct TestMessageContext *temp_context; 501 struct TestMessageContext *temp_context;
475 if (emsg == NULL) 502 if (emsg == NULL)
476 { 503 {
477 total_connections++;
478#if VERBOSE 504#if VERBOSE
505 if ((total_connections) % modnum == 0)
506 {
507 if (total_connections == 0)
508 fprintf (stdout, "0%%");
509 else
510 fprintf (stdout, "%d%%",
511 (int) (((float) total_connections /
512 expected_connections) * 100));
513
514 }
515 else if (total_connections % dotnum == 0)
516 {
517 fprintf (stdout, ".");
518 }
519 fflush (stdout);
520#endif
521 total_connections++;
522#if VERBOSE > 1
479 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "connected peer %s to peer %s\n", 523 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "connected peer %s to peer %s\n",
480 first_daemon->shortname, 524 first_daemon->shortname,
481 second_daemon->shortname); 525 second_daemon->shortname);
482#endif 526#endif
483 temp_context = GNUNET_malloc(sizeof(struct TestMessageContext)); 527 temp_context = GNUNET_malloc(sizeof(struct TestMessageContext));
484 temp_context->peer1 = first_daemon; 528 temp_context->peer1 = first_daemon;
@@ -505,15 +549,21 @@ topology_callback (void *cls,
505 if (total_connections == expected_connections) 549 if (total_connections == expected_connections)
506 { 550 {
507#if VERBOSE 551#if VERBOSE
552 fprintf(stdout, "100%%]\n");
553#endif
554#if VERBOSE
508 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 555 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
509 "Created %d total connections, which is our target number! Calling send messages.\n", 556 "Created %d total connections, which is our target number! Calling send messages.\n",
510 total_connections); 557 total_connections);
511#endif 558#endif
512 559 modnum = expected_messages / 4;
560 dotnum = (expected_messages / 50) + 1;
561#if VERBOSE
562 fprintf(stdout, "Test message progress: [");
563#endif
513 GNUNET_SCHEDULER_cancel (sched, die_task); 564 GNUNET_SCHEDULER_cancel (sched, die_task);
514 die_task = GNUNET_SCHEDULER_NO_TASK; 565 die_task = GNUNET_SCHEDULER_NO_TASK;
515 GNUNET_SCHEDULER_add_now (sched, &send_test_messages, test_messages); 566 GNUNET_SCHEDULER_add_now (sched, &send_test_messages, test_messages);
516 //GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 1), &send_test_messages, test_messages);
517 } 567 }
518 else if (total_connections + failed_connections == expected_connections) 568 else if (total_connections + failed_connections == expected_connections)
519 { 569 {
@@ -522,7 +572,6 @@ topology_callback (void *cls,
522 GNUNET_SCHEDULER_cancel (sched, die_task); 572 GNUNET_SCHEDULER_cancel (sched, die_task);
523 die_task = GNUNET_SCHEDULER_NO_TASK; 573 die_task = GNUNET_SCHEDULER_NO_TASK;
524 GNUNET_SCHEDULER_add_now (sched, &send_test_messages, test_messages); 574 GNUNET_SCHEDULER_add_now (sched, &send_test_messages, test_messages);
525 //GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 1), &send_test_messages, test_messages);
526 } 575 }
527 else 576 else
528 { 577 {
@@ -533,7 +582,7 @@ topology_callback (void *cls,
533 } 582 }
534 else 583 else
535 { 584 {
536#if VERBOSE 585#if VERBOSE > 1
537 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 586 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
538 "Have %d total connections, %d failed connections, Want %d (at least %d)\n", 587 "Have %d total connections, %d failed connections, Want %d (at least %d)\n",
539 total_connections, failed_connections, expected_connections, expected_connections - (unsigned int)(fail_percentage * expected_connections)); 588 total_connections, failed_connections, expected_connections, expected_connections - (unsigned int)(fail_percentage * expected_connections));
@@ -548,7 +597,7 @@ connect_topology ()
548 if ((pg != NULL) && (peers_left == 0)) 597 if ((pg != NULL) && (peers_left == 0))
549 { 598 {
550 expected_connections = GNUNET_TESTING_connect_topology (pg, connection_topology, connect_topology_option, connect_topology_option_modifier); 599 expected_connections = GNUNET_TESTING_connect_topology (pg, connection_topology, connect_topology_option, connect_topology_option_modifier);
551#if VERBOSE 600#if VERBOSE > 1
552 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 601 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
553 "Have %d expected connections\n", expected_connections); 602 "Have %d expected connections\n", expected_connections);
554#endif 603#endif
@@ -564,6 +613,11 @@ connect_topology ()
564 die_task = GNUNET_SCHEDULER_add_delayed (sched, 613 die_task = GNUNET_SCHEDULER_add_delayed (sched,
565 TEST_TIMEOUT, 614 TEST_TIMEOUT,
566 &end_badly, "from connect topology (timeout)"); 615 &end_badly, "from connect topology (timeout)");
616 modnum = expected_connections / 4;
617 dotnum = (expected_connections / 50) + 1;
618#if VERBOSE
619 fprintf(stdout, "Peer connection progress: [");
620#endif
567} 621}
568 622
569static void 623static void
@@ -576,6 +630,7 @@ create_topology ()
576 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 630 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
577 "Topology set up, now starting peers!\n"); 631 "Topology set up, now starting peers!\n");
578#endif 632#endif
633 fprintf(stdout, "Daemon start progress [");
579 GNUNET_TESTING_daemons_continue_startup(pg); 634 GNUNET_TESTING_daemons_continue_startup(pg);
580 } 635 }
581 else 636 else
@@ -604,16 +659,36 @@ peers_started_callback (void *cls,
604 return; 659 return;
605 } 660 }
606 GNUNET_assert (id != NULL); 661 GNUNET_assert (id != NULL);
607#if VERBOSE 662#if VERBOSE > 1
608 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Started daemon %llu out of %llu\n", 663 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Started daemon %llu out of %llu\n",
609 (num_peers - peers_left) + 1, num_peers); 664 (num_peers - peers_left) + 1, num_peers);
610#endif 665#endif
666#if VERBOSE
667 if ((num_peers - peers_left) % modnum == 0)
668 {
669 if (num_peers - peers_left == 0)
670 fprintf (stdout, "0%%");
671 else
672 fprintf (stdout, "%d%%",
673 (int) (((float) (num_peers - peers_left) /
674 num_peers) * 100));
675
676 }
677 else if ((num_peers - peers_left) % dotnum == 0)
678 {
679 fprintf (stdout, ".");
680 }
681 fflush (stdout);
682#endif
611 peers_left--; 683 peers_left--;
612 if (peers_left == 0) 684 if (peers_left == 0)
613 { 685 {
614#if VERBOSE 686#if VERBOSE
687 fprintf(stdout, "100%%]\n");
688#endif
689#if VERBOSE
615 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 690 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
616 "All %d daemons started, now creating topology!\n", 691 "All %d daemons started, now connecting peers!\n",
617 num_peers); 692 num_peers);
618#endif 693#endif
619 GNUNET_SCHEDULER_cancel (sched, die_task); 694 GNUNET_SCHEDULER_cancel (sched, die_task);
@@ -647,15 +722,34 @@ void hostkey_callback (void *cls,
647 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Hostkey callback received error: %s\n", emsg); 722 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Hostkey callback received error: %s\n", emsg);
648 } 723 }
649 724
650#if VERBOSE 725#if VERBOSE > 1
651 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 726 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
652 "Hostkey created for peer `%s'\n", 727 "Hostkey (%d/%d) created for peer `%s'\n",
653 GNUNET_i2s(id)); 728 num_peers - peers_left, num_peers, GNUNET_i2s(id));
729#endif
730
731#if VERBOSE
732 if ((num_peers - peers_left) % modnum == 0)
733 {
734 if (num_peers - peers_left == 0)
735 fprintf (stdout, "0%%");
736 else
737 fprintf (stdout, "%d%%",
738 (int) (((float) (num_peers - peers_left) /
739 num_peers) * 100));
740
741 }
742 else if ((num_peers - peers_left) % dotnum == 0)
743 {
744 fprintf (stdout, ".");
745 }
746 fflush (stdout);
654#endif 747#endif
655 peers_left--; 748 peers_left--;
656 if (peers_left == 0) 749 if (peers_left == 0)
657 { 750 {
658#if VERBOSE 751#if VERBOSE
752 fprintf(stdout, "100%%]\n");
659 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 753 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
660 "All %d hostkeys created, now creating topology!\n", 754 "All %d hostkeys created, now creating topology!\n",
661 num_peers); 755 num_peers);
@@ -664,9 +758,8 @@ void hostkey_callback (void *cls,
664 /* Set up task in case topology creation doesn't finish 758 /* Set up task in case topology creation doesn't finish
665 * within a reasonable amount of time */ 759 * within a reasonable amount of time */
666 die_task = GNUNET_SCHEDULER_add_delayed (sched, 760 die_task = GNUNET_SCHEDULER_add_delayed (sched,
667 GNUNET_TIME_relative_multiply 761 TIMEOUT,
668 (GNUNET_TIME_UNIT_MINUTES, 5), 762 &end_badly, "from create_topology");
669 &end_badly, "from hostkey_callback");
670 GNUNET_SCHEDULER_add_now(sched, &create_topology, NULL); 763 GNUNET_SCHEDULER_add_now(sched, &create_topology, NULL);
671 ok = 0; 764 ok = 0;
672 } 765 }
@@ -766,15 +859,16 @@ run (void *cls,
766 main_cfg = cfg; 859 main_cfg = cfg;
767 860
768 peers_left = num_peers; 861 peers_left = num_peers;
769 862 modnum = num_peers / 4;
863 dotnum = (num_peers / 50) + 1;
864 fprintf (stdout, "Hostkey generation progress: \[");
770 /* Set up a task to end testing if peer start fails */ 865 /* Set up a task to end testing if peer start fails */
771 die_task = GNUNET_SCHEDULER_add_delayed (sched, 866 die_task = GNUNET_SCHEDULER_add_delayed (sched,
772 GNUNET_TIME_relative_multiply 867 GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, SECONDS_PER_PEER_START * num_peers),
773 (GNUNET_TIME_UNIT_MINUTES, 5), 868 &end_badly, "didn't generate all hostkeys within a reasonable amount of time!!!");
774 &end_badly, "didn't start all daemons in reasonable amount of time!!!");
775 869
776 pg = GNUNET_TESTING_daemons_start (sched, cfg, 870 pg = GNUNET_TESTING_daemons_start (sched, cfg,
777 peers_left, TIMEOUT, &hostkey_callback, NULL, &peers_started_callback, NULL, 871 peers_left, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, SECONDS_PER_PEER_START * num_peers), &hostkey_callback, NULL, &peers_started_callback, NULL,
778 &topology_callback, NULL, NULL); 872 &topology_callback, NULL, NULL);
779 873
780} 874}