aboutsummaryrefslogtreecommitdiff
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
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
-rw-r--r--src/testing/Makefile.am7
-rw-r--r--src/testing/test_testing_data_topology_none.conf56
-rw-r--r--src/testing/test_testing_topology.c152
-rw-r--r--src/testing/testing_group.c150
4 files changed, 306 insertions, 59 deletions
diff --git a/src/testing/Makefile.am b/src/testing/Makefile.am
index 163b4f9c9..3f68411f5 100644
--- a/src/testing/Makefile.am
+++ b/src/testing/Makefile.am
@@ -38,6 +38,7 @@ check_PROGRAMS = \
38 test_testing_topology_small_world_torus \ 38 test_testing_topology_small_world_torus \
39 test_testing_topology_erdos_renyi \ 39 test_testing_topology_erdos_renyi \
40 test_testing_topology_internat \ 40 test_testing_topology_internat \
41 test_testing_topology_none \
41 test_testing_topology_scale_free 42 test_testing_topology_scale_free
42 43
43TESTS = \ 44TESTS = \
@@ -168,6 +169,12 @@ test_testing_topology_scale_free_SOURCES = \
168test_testing_topology_scale_free_LDADD = \ 169test_testing_topology_scale_free_LDADD = \
169 $(top_builddir)/src/testing/libgnunettesting.la \ 170 $(top_builddir)/src/testing/libgnunettesting.la \
170 $(top_builddir)/src/util/libgnunetutil.la 171 $(top_builddir)/src/util/libgnunetutil.la
172
173test_testing_topology_none_SOURCES = \
174 test_testing_topology.c
175test_testing_topology_none_LDADD = \
176 $(top_builddir)/src/testing/libgnunettesting.la \
177 $(top_builddir)/src/util/libgnunetutil.la
171 178
172 179
173EXTRA_DIST = \ 180EXTRA_DIST = \
diff --git a/src/testing/test_testing_data_topology_none.conf b/src/testing/test_testing_data_topology_none.conf
new file mode 100644
index 000000000..9ff8ca390
--- /dev/null
+++ b/src/testing/test_testing_data_topology_none.conf
@@ -0,0 +1,56 @@
1[PATHS]
2SERVICEHOME = /tmp/test-gnunet-testing/
3DEFAULTCONFIG = test_testing_data_topology_clique.conf
4
5[resolver]
6PORT = 0
7
8[transport]
9PORT = 0
10PLUGINS = tcp
11#PREFIX = xterm -e xterm -T transport -e gdb --args
12#BINARY = /home/mrwiggles/documents/research/gnunet/gnunet-ng/src/transport/.libs/gnunet-service-transport
13#PREFIX = valgrind --tool=memcheck --log-file=logs%p
14#PREFIX = valgrind --tool=callgrind --log-file=callgrind.%p
15#DEBUG = YES
16
17[topology]
18PORT = 0
19
20[arm]
21PORT = 0
22DEFAULTSERVICES =
23
24[statistics]
25PORT = 0
26
27[transport-tcp]
28PORT = 2568
29
30[peerinfo]
31PORT = 0
32#DEBUG = YES
33#PREFIX = xterm -e xterm -T peerinfo -e gdb --args
34#BINARY = /home/mrwiggles/documents/research/gnunet/gnunet-ng/src/peerinfo/.libs/gnunet-service-peerinfo
35#PREFIX = valgrind --tool=memcheck --log-file=peerinfo%p
36
37[core]
38PORT = 0
39#PREFIX = xterm -e xterm -T CORE -e gdb --args
40#PREFIX = valgrind --tool=memcheck --log-file=logs%p
41#DEBUG = YES
42
43[hostlist]
44PORT = 0
45
46[fs]
47PORT = 0
48
49[testing]
50NUM_PEERS = 200
51WEAKRANDOM = YES
52TOPOLOGY = NONE
53F2F = NO
54BLACKLIST_TOPOLOGY = NONE
55CONNECT_TOPOLOGY = RING
56#DEBUG = YES
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}
diff --git a/src/testing/testing_group.c b/src/testing/testing_group.c
index 831657305..6770cf446 100644
--- a/src/testing/testing_group.c
+++ b/src/testing/testing_group.c
@@ -31,8 +31,6 @@
31 31
32#define VERBOSE_TESTING GNUNET_NO 32#define VERBOSE_TESTING GNUNET_NO
33 33
34#define VERBOSE_TOPOLOGY GNUNET_NO
35
36#define DEBUG_CHURN GNUNET_NO 34#define DEBUG_CHURN GNUNET_NO
37 35
38/** 36/**
@@ -52,6 +50,8 @@
52 50
53#define MAX_OUTSTANDING_CONNECTIONS 50 51#define MAX_OUTSTANDING_CONNECTIONS 50
54 52
53#define MAX_CONCURRENT_HOSTKEYS 16
54
55#define CONNECT_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 300) 55#define CONNECT_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 300)
56 56
57#define CONNECT_ATTEMPTS 8 57#define CONNECT_ATTEMPTS 8
@@ -318,6 +318,11 @@ struct GNUNET_TESTING_PeerGroup
318 * At what time should we fail the peer startup process? 318 * At what time should we fail the peer startup process?
319 */ 319 */
320 struct GNUNET_TIME_Absolute max_timeout; 320 struct GNUNET_TIME_Absolute max_timeout;
321
322 /**
323 * How many peers are being started right now?
324 */
325 unsigned int starting;
321}; 326};
322 327
323/** 328/**
@@ -640,10 +645,8 @@ make_config (const struct GNUNET_CONFIGURATION_Handle *cfg,
640 * @param first index of the first peer 645 * @param first index of the first peer
641 * @param second index of the second peer 646 * @param second index of the second peer
642 * 647 *
643 * @return the number of connections added (can be 0, 1 or 2) 648 * @return the number of connections added
644 * technically should only be 0 or 2, but the small price 649 * technically should only be 0 or 2
645 * of iterating over the lists (hashmaps in the future)
646 * for being sure doesn't bother me!
647 * 650 *
648 */ 651 */
649static int 652static int
@@ -2057,8 +2060,8 @@ connect_topology (struct GNUNET_TESTING_PeerGroup *pg)
2057 * by the topology. This will only have an effect once peers 2060 * by the topology. This will only have an effect once peers
2058 * are started if the FRIENDS_ONLY option is set in the base 2061 * are started if the FRIENDS_ONLY option is set in the base
2059 * config. Also takes an optional restrict topology which 2062 * config. Also takes an optional restrict topology which
2060 * disallows direct TCP connections UNLESS they are specified in 2063 * disallows connections based on a particular transport
2061 * the restricted topology. 2064 * UNLESS they are specified in the restricted topology.
2062 * 2065 *
2063 * @param pg the peer group struct representing the running peers 2066 * @param pg the peer group struct representing the running peers
2064 * @param topology which topology to connect the peers in 2067 * @param topology which topology to connect the peers in
@@ -2086,49 +2089,49 @@ GNUNET_TESTING_create_topology (struct GNUNET_TESTING_PeerGroup *pg,
2086 switch (topology) 2089 switch (topology)
2087 { 2090 {
2088 case GNUNET_TESTING_TOPOLOGY_CLIQUE: 2091 case GNUNET_TESTING_TOPOLOGY_CLIQUE:
2089#if VERBOSE_TOPOLOGY 2092#if VERBOSE_TESTING
2090 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2093 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2091 _("Creating clique topology\n")); 2094 _("Creating clique topology\n"));
2092#endif 2095#endif
2093 num_connections = create_clique (pg, &add_allowed_connections); 2096 num_connections = create_clique (pg, &add_allowed_connections);
2094 break; 2097 break;
2095 case GNUNET_TESTING_TOPOLOGY_SMALL_WORLD_RING: 2098 case GNUNET_TESTING_TOPOLOGY_SMALL_WORLD_RING:
2096#if VERBOSE_TOPOLOGY 2099#if VERBOSE_TESTING
2097 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2100 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2098 _("Creating small world (ring) topology\n")); 2101 _("Creating small world (ring) topology\n"));
2099#endif 2102#endif
2100 num_connections = create_small_world_ring (pg, &add_allowed_connections); 2103 num_connections = create_small_world_ring (pg, &add_allowed_connections);
2101 break; 2104 break;
2102 case GNUNET_TESTING_TOPOLOGY_SMALL_WORLD: 2105 case GNUNET_TESTING_TOPOLOGY_SMALL_WORLD:
2103#if VERBOSE_TOPOLOGY 2106#if VERBOSE_TESTING
2104 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2107 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2105 _("Creating small world (2d-torus) topology\n")); 2108 _("Creating small world (2d-torus) topology\n"));
2106#endif 2109#endif
2107 num_connections = create_small_world (pg, &add_allowed_connections); 2110 num_connections = create_small_world (pg, &add_allowed_connections);
2108 break; 2111 break;
2109 case GNUNET_TESTING_TOPOLOGY_RING: 2112 case GNUNET_TESTING_TOPOLOGY_RING:
2110#if VERBOSE_TOPOLOGY 2113#if VERBOSE_TESTING
2111 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2114 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2112 _("Creating ring topology\n")); 2115 _("Creating ring topology\n"));
2113#endif 2116#endif
2114 num_connections = create_ring (pg, &add_allowed_connections); 2117 num_connections = create_ring (pg, &add_allowed_connections);
2115 break; 2118 break;
2116 case GNUNET_TESTING_TOPOLOGY_2D_TORUS: 2119 case GNUNET_TESTING_TOPOLOGY_2D_TORUS:
2117#if VERBOSE_TOPOLOGY 2120#if VERBOSE_TESTING
2118 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2121 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2119 _("Creating 2d torus topology\n")); 2122 _("Creating 2d torus topology\n"));
2120#endif 2123#endif
2121 num_connections = create_2d_torus (pg, &add_allowed_connections); 2124 num_connections = create_2d_torus (pg, &add_allowed_connections);
2122 break; 2125 break;
2123 case GNUNET_TESTING_TOPOLOGY_ERDOS_RENYI: 2126 case GNUNET_TESTING_TOPOLOGY_ERDOS_RENYI:
2124#if VERBOSE_TOPOLOGY 2127#if VERBOSE_TESTING
2125 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2128 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2126 _("Creating Erdos-Renyi topology\n")); 2129 _("Creating Erdos-Renyi topology\n"));
2127#endif 2130#endif
2128 num_connections = create_erdos_renyi (pg, &add_allowed_connections); 2131 num_connections = create_erdos_renyi (pg, &add_allowed_connections);
2129 break; 2132 break;
2130 case GNUNET_TESTING_TOPOLOGY_INTERNAT: 2133 case GNUNET_TESTING_TOPOLOGY_INTERNAT:
2131#if VERBOSE_TOPOLOGY 2134#if VERBOSE_TESTING
2132 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2135 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2133 _("Creating InterNAT topology\n")); 2136 _("Creating InterNAT topology\n"));
2134#endif 2137#endif
@@ -2149,38 +2152,43 @@ GNUNET_TESTING_create_topology (struct GNUNET_TESTING_PeerGroup *pg,
2149 num_connections = create_line (pg, &add_allowed_connections); 2152 num_connections = create_line (pg, &add_allowed_connections);
2150 break; 2153 break;
2151 case GNUNET_TESTING_TOPOLOGY_NONE: 2154 case GNUNET_TESTING_TOPOLOGY_NONE:
2155#if VERBOSE_TESTING
2156 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2157 _("Creating no allowed topology (all peers can connect at core level)\n"));
2158#endif
2152 num_connections = 0; 2159 num_connections = 0;
2153 break; 2160 break;
2154 default: 2161 default:
2155 num_connections = 0; 2162 num_connections = 0;
2156 break; 2163 break;
2157 } 2164 }
2158 if (num_connections < 1) 2165
2166 if (num_connections < 0)
2159 return GNUNET_SYSERR; 2167 return GNUNET_SYSERR;
2160 2168
2161 if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno (pg->cfg, "TESTING", "F2F")) 2169 if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno (pg->cfg, "TESTING", "F2F"))
2162 { 2170 {
2163 ret = create_and_copy_friend_files(pg); 2171 ret = create_and_copy_friend_files(pg);
2164 } 2172 if (ret != GNUNET_OK)
2165 2173 {
2166 if (ret != GNUNET_OK)
2167 {
2168#if VERBOSE_TESTING 2174#if VERBOSE_TESTING
2169 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2175 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2170 _("Failed during friend file copying!\n")); 2176 _("Failed during friend file copying!\n"));
2171#endif 2177#endif
2172 return GNUNET_SYSERR; 2178 return GNUNET_SYSERR;
2173 } 2179 }
2174 else 2180 else
2175 { 2181 {
2176#if VERBOSE_TESTING 2182#if VERBOSE_TESTING
2177 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2183 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2178 _("Friend files created/copied successfully!\n")); 2184 _("Friend files created/copied successfully!\n"));
2179#endif 2185#endif
2186 }
2180 } 2187 }
2181 2188
2182 /* Use the create clique method to initially set all connections as blacklisted. */ 2189 /* Use the create clique method to initially set all connections as blacklisted. */
2183 create_clique (pg, &blacklist_connections); 2190 if (restrict_topology != GNUNET_TESTING_TOPOLOGY_NONE)
2191 create_clique (pg, &blacklist_connections);
2184 unblacklisted_connections = 0; 2192 unblacklisted_connections = 0;
2185 /* Un-blacklist connections as per the topology specified */ 2193 /* Un-blacklist connections as per the topology specified */
2186 switch (restrict_topology) 2194 switch (restrict_topology)
@@ -2249,7 +2257,10 @@ GNUNET_TESTING_create_topology (struct GNUNET_TESTING_PeerGroup *pg,
2249 unblacklisted_connections = create_line (pg, &unblacklist_connections); 2257 unblacklisted_connections = create_line (pg, &unblacklist_connections);
2250 break; 2258 break;
2251 case GNUNET_TESTING_TOPOLOGY_NONE: 2259 case GNUNET_TESTING_TOPOLOGY_NONE:
2252 /* Fall through */ 2260#if VERBOSE_TESTING
2261 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2262 _("Creating no blacklist topology (all peers can connect at transport level)\n"));
2263#endif
2253 default: 2264 default:
2254 break; 2265 break;
2255 } 2266 }
@@ -2798,6 +2809,69 @@ GNUNET_TESTING_daemons_continue_startup(struct GNUNET_TESTING_PeerGroup *pg)
2798 } 2809 }
2799} 2810}
2800 2811
2812struct InternalStartContext
2813{
2814 struct PeerData *peer;
2815 struct GNUNET_SCHEDULER_Handle *sched;
2816 const struct GNUNET_CONFIGURATION_Handle *pcfg;
2817 struct GNUNET_TIME_Relative timeout;
2818 GNUNET_TESTING_NotifyHostkeyCreated hostkey_callback;
2819 void *hostkey_cls;
2820 GNUNET_TESTING_NotifyDaemonRunning cb;
2821 void *cb_cls;
2822 const char *hostname;
2823};
2824
2825
2826/**
2827 * Prototype of a function that will be called whenever
2828 * a daemon was started by the testing library.
2829 *
2830 * @param cls closure
2831 * @param id identifier for the daemon, NULL on error
2832 * @param d handle for the daemon
2833 * @param emsg error message (NULL on success)
2834 */
2835static void internal_hostkey_callback (void *cls,
2836 const struct GNUNET_PeerIdentity *id,
2837 struct GNUNET_TESTING_Daemon *d,
2838 const char *emsg)
2839{
2840 struct InternalStartContext *internal_context = cls;
2841 internal_context->peer->pg->starting--;
2842 internal_context->hostkey_callback(internal_context->hostkey_cls, id, d, emsg);
2843 GNUNET_free(internal_context);
2844}
2845
2846static void
2847internal_start (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
2848{
2849 struct InternalStartContext *internal_context = cls;
2850
2851 if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN)
2852 {
2853 GNUNET_free(internal_context);
2854 return;
2855 }
2856
2857 if (internal_context->peer->pg->starting < MAX_CONCURRENT_HOSTKEYS)
2858 {
2859 internal_context->peer->pg->starting++;
2860 internal_context->peer->daemon = GNUNET_TESTING_daemon_start (internal_context->sched,
2861 internal_context->pcfg,
2862 internal_context->timeout,
2863 internal_context->hostname,
2864 &internal_hostkey_callback,
2865 internal_context,
2866 internal_context->cb,
2867 internal_context->cb_cls);
2868 }
2869 else
2870 {
2871 GNUNET_SCHEDULER_add_delayed(internal_context->sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100), &internal_start, internal_context);
2872 }
2873}
2874
2801/** 2875/**
2802 * Start count gnunetd processes with the same set of transports and 2876 * Start count gnunetd processes with the same set of transports and
2803 * applications. The port numbers (any option called "PORT") will be 2877 * applications. The port numbers (any option called "PORT") will be
@@ -2842,6 +2916,7 @@ GNUNET_TESTING_daemons_start (struct GNUNET_SCHEDULER_Handle *sched,
2842 char *baseservicehome; 2916 char *baseservicehome;
2843 char *newservicehome; 2917 char *newservicehome;
2844 char *tmpdir; 2918 char *tmpdir;
2919 struct InternalStartContext *internal_context;
2845 struct GNUNET_CONFIGURATION_Handle *pcfg; 2920 struct GNUNET_CONFIGURATION_Handle *pcfg;
2846 unsigned int off; 2921 unsigned int off;
2847 unsigned int hostcnt; 2922 unsigned int hostcnt;
@@ -2968,6 +3043,20 @@ GNUNET_TESTING_daemons_start (struct GNUNET_SCHEDULER_Handle *sched,
2968 pg->peers[off].connect_peers = GNUNET_CONTAINER_multihashmap_create(total); 3043 pg->peers[off].connect_peers = GNUNET_CONTAINER_multihashmap_create(total);
2969 pg->peers[off].blacklisted_peers = GNUNET_CONTAINER_multihashmap_create(total); 3044 pg->peers[off].blacklisted_peers = GNUNET_CONTAINER_multihashmap_create(total);
2970 pg->peers[off].pg = pg; 3045 pg->peers[off].pg = pg;
3046 internal_context = GNUNET_malloc(sizeof(struct InternalStartContext));
3047 internal_context->sched = sched;
3048 internal_context->peer = &pg->peers[off];
3049 internal_context->pcfg = pcfg;
3050 internal_context->timeout = timeout;
3051 internal_context->hostname = hostname;
3052 internal_context->hostkey_callback = hostkey_callback;
3053 internal_context->hostkey_cls = hostkey_cls;
3054 internal_context->cb = cb;
3055 internal_context->cb_cls = cb_cls;
3056
3057 GNUNET_SCHEDULER_add_now (sched, &internal_start, internal_context);
3058
3059 /*
2971 pg->peers[off].daemon = GNUNET_TESTING_daemon_start (sched, 3060 pg->peers[off].daemon = GNUNET_TESTING_daemon_start (sched,
2972 pcfg, 3061 pcfg,
2973 timeout, 3062 timeout,
@@ -2978,6 +3067,7 @@ GNUNET_TESTING_daemons_start (struct GNUNET_SCHEDULER_Handle *sched,
2978 if (NULL == pg->peers[off].daemon) 3067 if (NULL == pg->peers[off].daemon)
2979 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 3068 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
2980 _("Could not start peer number %u!\n"), off); 3069 _("Could not start peer number %u!\n"), off);
3070 */
2981 3071
2982 } 3072 }
2983 return pg; 3073 return pg;