aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan S. Evans <evans@in.tum.de>2011-02-05 14:19:42 +0000
committerNathan S. Evans <evans@in.tum.de>2011-02-05 14:19:42 +0000
commit5d67c7671b669eec8d63d3af345217bcf10768fd (patch)
treee1abf089630ba9d540f97b2d67fda0073744e247
parent59b233b7e3b3d70006fc8b40bd566e67bc487231 (diff)
downloadgnunet-5d67c7671b669eec8d63d3af345217bcf10768fd.tar.gz
gnunet-5d67c7671b669eec8d63d3af345217bcf10768fd.zip
configurable connect options
-rw-r--r--src/dht/gnunet-dht-driver.c56
-rw-r--r--src/fs/fs_test_lib.c1
-rw-r--r--src/include/gnunet_testing_lib.h26
-rw-r--r--src/testing/Makefile.am108
-rw-r--r--src/testing/test_testing_group.c1
-rw-r--r--src/testing/test_testing_group_remote.c1
-rw-r--r--src/testing/test_testing_large_topology.c27
-rw-r--r--src/testing/test_testing_topology.c27
-rw-r--r--src/testing/test_testing_topology_blacklist.c30
-rw-r--r--src/testing/test_testing_topology_churn.c1
-rw-r--r--src/testing/testing_group.c109
-rw-r--r--src/topology/test_gnunet_daemon_topology.c1
12 files changed, 306 insertions, 82 deletions
diff --git a/src/dht/gnunet-dht-driver.c b/src/dht/gnunet-dht-driver.c
index 97c8ed660..af8812d48 100644
--- a/src/dht/gnunet-dht-driver.c
+++ b/src/dht/gnunet-dht-driver.c
@@ -67,7 +67,7 @@
67#define FIND_PEER_THRESHOLD 1 67#define FIND_PEER_THRESHOLD 1
68 68
69/* If more than this many peers are added, slow down sending */ 69/* If more than this many peers are added, slow down sending */
70#define MAX_FIND_PEER_CUTOFF 4000 70#define MAX_FIND_PEER_CUTOFF 2000
71 71
72/* If less than this many peers are added, speed up sending */ 72/* If less than this many peers are added, speed up sending */
73#define MIN_FIND_PEER_CUTOFF 500 73#define MIN_FIND_PEER_CUTOFF 500
@@ -77,7 +77,7 @@
77 77
78#define DEFAULT_MAX_OUTSTANDING_PUTS 10 78#define DEFAULT_MAX_OUTSTANDING_PUTS 10
79 79
80#define DEFAULT_MAX_OUTSTANDING_FIND_PEERS 196 80#define DEFAULT_MAX_OUTSTANDING_FIND_PEERS 128
81 81
82#define DEFAULT_FIND_PEER_OFFSET GNUNET_TIME_relative_divide (DEFAULT_FIND_PEER_DELAY, DEFAULT_MAX_OUTSTANDING_FIND_PEERS) 82#define DEFAULT_FIND_PEER_OFFSET GNUNET_TIME_relative_divide (DEFAULT_FIND_PEER_DELAY, DEFAULT_MAX_OUTSTANDING_FIND_PEERS)
83 83
@@ -372,6 +372,16 @@ enum DHT_ROUND_TYPES
372/* Globals */ 372/* Globals */
373 373
374/** 374/**
375 * How long to try to connect two peers.
376 */
377struct GNUNET_TIME_Relative connect_timeout;
378
379/**
380 * How many times to re-attempt connecting two peers.
381 */
382static unsigned long long connect_attempts;
383
384/**
375 * Timeout to let all GET requests happen. 385 * Timeout to let all GET requests happen.
376 */ 386 */
377static struct GNUNET_TIME_Relative all_get_timeout; 387static struct GNUNET_TIME_Relative all_get_timeout;
@@ -436,6 +446,11 @@ static unsigned int in_dht_replication;
436static unsigned long long test_data_size = DEFAULT_TEST_DATA_SIZE; 446static unsigned long long test_data_size = DEFAULT_TEST_DATA_SIZE;
437 447
438/** 448/**
449 * Maximum number of concurrent connections to peers.
450 */
451static unsigned long long max_outstanding_connections;
452
453/**
439 * Maximum number of concurrent PUT requests. 454 * Maximum number of concurrent PUT requests.
440 */ 455 */
441static unsigned long long max_outstanding_puts = DEFAULT_MAX_OUTSTANDING_PUTS; 456static unsigned long long max_outstanding_puts = DEFAULT_MAX_OUTSTANDING_PUTS;
@@ -2533,7 +2548,7 @@ topology_callback (void *cls,
2533 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Conns/sec in last %d seconds: %f, Conns/sec for entire duration: %f\n", CONN_UPDATE_DURATION, (float)new_connections / duration, (float)total_connections / total_duration); 2548 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Conns/sec in last %d seconds: %f, Conns/sec for entire duration: %f\n", CONN_UPDATE_DURATION, (float)new_connections / duration, (float)total_connections / total_duration);
2534 connect_last_time = GNUNET_TIME_absolute_get(); 2549 connect_last_time = GNUNET_TIME_absolute_get();
2535 previous_connections = total_connections; 2550 previous_connections = total_connections;
2536 2551 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "have %u total_connections\n", total_connections);
2537 } 2552 }
2538 if (emsg == NULL) 2553 if (emsg == NULL)
2539 { 2554 {
@@ -2631,7 +2646,11 @@ peers_started_callback (void *cls,
2631 if ((pg != NULL) && (peers_left == 0)) 2646 if ((pg != NULL) && (peers_left == 0))
2632 { 2647 {
2633 connect_start_time = GNUNET_TIME_absolute_get(); 2648 connect_start_time = GNUNET_TIME_absolute_get();
2634 expected_connections = GNUNET_TESTING_connect_topology (pg, connect_topology, connect_topology_option, connect_topology_option_modifier, NULL, NULL); 2649 expected_connections = GNUNET_TESTING_connect_topology(pg,
2650 connect_topology, connect_topology_option,
2651 connect_topology_option_modifier,
2652 connect_timeout, connect_attempts,
2653 NULL, NULL);
2635 2654
2636 peer_connect_meter = create_meter(expected_connections, "Peer connection ", GNUNET_YES); 2655 peer_connect_meter = create_meter(expected_connections, "Peer connection ", GNUNET_YES);
2637 fprintf(stderr, "Have %d expected connections\n", expected_connections); 2656 fprintf(stderr, "Have %d expected connections\n", expected_connections);
@@ -2767,6 +2786,34 @@ run (void *cls,
2767 } 2786 }
2768 GNUNET_assert(num_peers > 0 && num_peers < ULONG_MAX); 2787 GNUNET_assert(num_peers > 0 && num_peers < ULONG_MAX);
2769 2788
2789 if (GNUNET_OK ==
2790 GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "connect_timeout",
2791 &temp_config_number))
2792 connect_timeout =
2793 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, temp_config_number);
2794 else
2795 {
2796 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", "testing", "connect_timeout");
2797 return;
2798 }
2799
2800
2801 if (GNUNET_OK !=
2802 GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "connect_attempts",
2803 &connect_attempts))
2804 {
2805 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", "testing", "connect_attempts");
2806 return;
2807 }
2808
2809 if (GNUNET_OK !=
2810 GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "max_outstanding_connections",
2811 &max_outstanding_connections))
2812 {
2813 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", "testing", "max_outstanding_connections");
2814 return;
2815 }
2816
2770 /** 2817 /**
2771 * Get DHT specific testing options. 2818 * Get DHT specific testing options.
2772 */ 2819 */
@@ -3314,6 +3361,7 @@ run (void *cls,
3314 get_meter = create_meter(num_gets, "Gets completed ", GNUNET_YES); 3361 get_meter = create_meter(num_gets, "Gets completed ", GNUNET_YES);
3315 pg = GNUNET_TESTING_daemons_start (cfg, 3362 pg = GNUNET_TESTING_daemons_start (cfg,
3316 peers_left, 3363 peers_left,
3364 max_outstanding_connections,
3317 GNUNET_TIME_relative_multiply(seconds_per_peer_start, num_peers), 3365 GNUNET_TIME_relative_multiply(seconds_per_peer_start, num_peers),
3318 &hostkey_callback, NULL, 3366 &hostkey_callback, NULL,
3319 &peers_started_callback, NULL, 3367 &peers_started_callback, NULL,
diff --git a/src/fs/fs_test_lib.c b/src/fs/fs_test_lib.c
index fd600951c..287c0eb1c 100644
--- a/src/fs/fs_test_lib.c
+++ b/src/fs/fs_test_lib.c
@@ -394,6 +394,7 @@ GNUNET_FS_TEST_daemons_start (const char *template_cfg_file,
394 daemons[i] = GNUNET_malloc (sizeof (struct GNUNET_FS_TestDaemon)); 394 daemons[i] = GNUNET_malloc (sizeof (struct GNUNET_FS_TestDaemon));
395 sctx->group = GNUNET_TESTING_daemons_start (sctx->cfg, 395 sctx->group = GNUNET_TESTING_daemons_start (sctx->cfg,
396 total, 396 total,
397 total, /* Outstanding connections */
397 timeout, 398 timeout,
398 NULL, 399 NULL,
399 NULL, 400 NULL,
diff --git a/src/include/gnunet_testing_lib.h b/src/include/gnunet_testing_lib.h
index 7830ac226..b0c43c44b 100644
--- a/src/include/gnunet_testing_lib.h
+++ b/src/include/gnunet_testing_lib.h
@@ -559,13 +559,15 @@ void GNUNET_TESTING_daemons_connect (struct GNUNET_TESTING_Daemon *d1,
559 559
560 560
561/** 561/**
562 * Start count gnunetd processes with the same set of transports and 562 * Start count gnunet instances with the same set of transports and
563 * applications. The port numbers (any option called "PORT") will be 563 * applications. The port numbers (any option called "PORT") will be
564 * adjusted to ensure that no two peers running on the same system 564 * adjusted to ensure that no two peers running on the same system
565 * have the same port(s) in their respective configurations. 565 * have the same port(s) in their respective configurations.
566 * 566 *
567 * @param cfg configuration template to use 567 * @param cfg configuration template to use
568 * @param total number of daemons to start 568 * @param total number of daemons to start
569 * @param max_concurrent_connections for testing, how many peers can
570 * we connect to simultaneously
569 * @param timeout total time allowed for peers to start 571 * @param timeout total time allowed for peers to start
570 * @param hostkey_callback function to call on each peers hostkey generation 572 * @param hostkey_callback function to call on each peers hostkey generation
571 * if NULL, peers will be started by this call, if non-null, 573 * if NULL, peers will be started by this call, if non-null,
@@ -576,16 +578,18 @@ void GNUNET_TESTING_daemons_connect (struct GNUNET_TESTING_Daemon *d1,
576 * @param cb_cls closure for cb 578 * @param cb_cls closure for cb
577 * @param connect_callback function to call each time two hosts are connected 579 * @param connect_callback function to call each time two hosts are connected
578 * @param connect_callback_cls closure for connect_callback 580 * @param connect_callback_cls closure for connect_callback
579 * @param hostnames linked list of hosts to use to start peers on (NULL to run on localhost only) 581 * @param hostnames linked list of host structs to use to start peers on
582 * (NULL to run on localhost only)
580 * 583 *
581 * @return NULL on error, otherwise handle to control peer group 584 * @return NULL on error, otherwise handle to control peer group
582 */ 585 */
583struct GNUNET_TESTING_PeerGroup * 586struct GNUNET_TESTING_PeerGroup *
584GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg, 587GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
585 unsigned int total, 588 unsigned int total,
589 unsigned int max_concurrent_connections,
586 struct GNUNET_TIME_Relative timeout, 590 struct GNUNET_TIME_Relative timeout,
587 GNUNET_TESTING_NotifyHostkeyCreated hostkey_callback, 591 GNUNET_TESTING_NotifyHostkeyCreated
588 void *hostkey_cls, 592 hostkey_callback, void *hostkey_cls,
589 GNUNET_TESTING_NotifyDaemonRunning cb, 593 GNUNET_TESTING_NotifyDaemonRunning cb,
590 void *cb_cls, 594 void *cb_cls,
591 GNUNET_TESTING_NotifyConnection 595 GNUNET_TESTING_NotifyConnection
@@ -894,20 +898,24 @@ GNUNET_TESTING_get_topology (struct GNUNET_TESTING_PeerGroup *pg,
894 * @param topology which topology to connect the peers in 898 * @param topology which topology to connect the peers in
895 * @param options options for connecting the topology 899 * @param options options for connecting the topology
896 * @param option_modifier modifier for options that take a parameter 900 * @param option_modifier modifier for options that take a parameter
901 * @param connect_timeout how long to wait before giving up on connecting
902 * two peers
903 * @param connect_attempts how many times to attempt to connect two peers
904 * over the connect_timeout duration
897 * @param notify_callback notification to be called once all connections completed 905 * @param notify_callback notification to be called once all connections completed
898 * @param notify_cls closure for notification callback 906 * @param notify_cls closure for notification callback
899 * 907 *
900 * @return the number of connections that will be attempted (multiple of two, 908 * @return the number of connections that will be attempted, GNUNET_SYSERR on error
901 * each bidirectional connection counts twice!), GNUNET_SYSERR on error
902 *
903 */ 909 */
904int 910int
905GNUNET_TESTING_connect_topology (struct GNUNET_TESTING_PeerGroup *pg, 911GNUNET_TESTING_connect_topology (struct GNUNET_TESTING_PeerGroup *pg,
906 enum GNUNET_TESTING_Topology topology, 912 enum GNUNET_TESTING_Topology topology,
907 enum GNUNET_TESTING_TopologyOption options, 913 enum GNUNET_TESTING_TopologyOption options,
908 double option_modifier, 914 double option_modifier,
909 GNUNET_TESTING_NotifyCompletion notify_callback, 915 struct GNUNET_TIME_Relative connect_timeout,
910 void *notify_cls); 916 unsigned int connect_attempts,
917 GNUNET_TESTING_NotifyCompletion
918 notify_callback, void *notify_cls);
911 919
912/** 920/**
913 * Start or stop an individual peer from the given group. 921 * Start or stop an individual peer from the given group.
diff --git a/src/testing/Makefile.am b/src/testing/Makefile.am
index 8084a9779..f6035ff2c 100644
--- a/src/testing/Makefile.am
+++ b/src/testing/Makefile.am
@@ -20,6 +20,8 @@ libgnunettesting_la_LIBADD = $(XLIB) \
20 $(top_builddir)/src/transport/libgnunettransport.la \ 20 $(top_builddir)/src/transport/libgnunettransport.la \
21 -lm \ 21 -lm \
22 $(top_builddir)/src/util/libgnunetutil.la 22 $(top_builddir)/src/util/libgnunetutil.la
23
24noinst_PROGRAMS = ${check_PROGRAMS}
23 25
24check_PROGRAMS = \ 26check_PROGRAMS = \
25 test_testing \ 27 test_testing \
@@ -27,6 +29,8 @@ check_PROGRAMS = \
27 test_testing_reconnect \ 29 test_testing_reconnect \
28 test_testing_group \ 30 test_testing_group \
29 test_testing_topology_stability \ 31 test_testing_topology_stability \
32 test_testing_large_topology_clique \
33 test_testing_topology_from_file \
30 test_testing_topology_clique \ 34 test_testing_topology_clique \
31 test_testing_topology_clique_random \ 35 test_testing_topology_clique_random \
32 test_testing_topology_clique_minimum \ 36 test_testing_topology_clique_minimum \
@@ -42,30 +46,35 @@ check_PROGRAMS = \
42 test_testing_topology_erdos_renyi \ 46 test_testing_topology_erdos_renyi \
43 test_testing_topology_internat \ 47 test_testing_topology_internat \
44 test_testing_topology_none \ 48 test_testing_topology_none \
45 test_testing_topology_scale_free 49 test_testing_topology_scale_free \
50 test_testing_topology_connect_only \
51 test_testing_topology_2d_torus_plus
46 52
53# test_testing_topology_stability
47if !DISABLE_TEST_RUN 54if !DISABLE_TEST_RUN
48TESTS = \ 55TESTS = \
49 test_testing \ 56 test_testing \
50 test_testing_connect \ 57 test_testing_connect \
51 test_testing_reconnect \ 58 test_testing_reconnect \
52 test_testing_group \ 59 test_testing_group \
53 test_testing_topology_clique 60 test_testing_topology_clique \
54# test_testing_topology_stability \ 61 test_testing_topology_from_file \
55# test_testing_topology_clique_random \ 62 test_testing_topology_clique_random \
56# test_testing_topology_clique_minimum \ 63 test_testing_topology_clique_minimum \
57# test_testing_topology_clique_dfs \ 64 test_testing_topology_clique_dfs \
58# test_testing_topology_churn \ 65 test_testing_topology_churn \
59# test_testing_topology_line 66 test_testing_topology_line \
60# test_testing_topology_blacklist \ 67 test_testing_topology_blacklist \
61# test_testing_group_remote \ 68 test_testing_group_remote \
62# test_testing_topology_ring \ 69 test_testing_topology_ring \
63# test_testing_topology_2d_torus \ 70 test_testing_topology_2d_torus \
64# test_testing_topology_small_world_ring \ 71 test_testing_topology_small_world_ring \
65# test_testing_topology_small_world_torus \ 72 test_testing_topology_small_world_torus \
66# test_testing_topology_erdos_renyi \ 73 test_testing_topology_erdos_renyi \
67# test_testing_topology_internat \ 74 test_testing_topology_internat \
68# test_testing_topology_scale_free 75 test_testing_topology_scale_free \
76 test_testing_topology_connect_only \
77 test_testing_topology_2d_torus_plus
69endif 78endif
70 79
71test_testing_SOURCES = \ 80test_testing_SOURCES = \
@@ -80,42 +89,54 @@ test_testing_connect_LDADD = \
80 $(top_builddir)/src/testing/libgnunettesting.la \ 89 $(top_builddir)/src/testing/libgnunettesting.la \
81 $(top_builddir)/src/util/libgnunetutil.la 90 $(top_builddir)/src/util/libgnunetutil.la
82 91
83test_testing_reconnect_SOURCES = \
84 test_testing_reconnect.c
85test_testing_reconnect_LDADD = \
86 $(top_builddir)/src/testing/libgnunettesting.la \
87 $(top_builddir)/src/util/libgnunetutil.la
88
89test_testing_group_SOURCES = \ 92test_testing_group_SOURCES = \
90 test_testing_group.c 93 test_testing_group.c
91test_testing_group_LDADD = \ 94test_testing_group_LDADD = \
92 $(top_builddir)/src/testing/libgnunettesting.la \ 95 $(top_builddir)/src/testing/libgnunettesting.la \
93 $(top_builddir)/src/util/libgnunetutil.la 96 $(top_builddir)/src/util/libgnunetutil.la
94 97
95test_testing_topology_clique_SOURCES = \ 98test_testing_topology_clique_SOURCES = \
96 test_testing_topology.c 99 test_testing_topology.c
97test_testing_topology_clique_LDADD = \ 100test_testing_topology_clique_LDADD = \
98 $(top_builddir)/src/testing/libgnunettesting.la \ 101 $(top_builddir)/src/testing/libgnunettesting.la \
99 $(top_builddir)/src/util/libgnunetutil.la 102 $(top_builddir)/src/util/libgnunetutil.la
100 103
104test_testing_topology_connect_only_SOURCES = \
105 test_testing_topology.c
106test_testing_topology_connect_only_LDADD = \
107 $(top_builddir)/src/testing/libgnunettesting.la \
108 $(top_builddir)/src/util/libgnunetutil.la
109
110test_testing_topology_from_file_SOURCES = \
111 test_testing_topology.c
112test_testing_topology_from_file_LDADD = \
113 $(top_builddir)/src/testing/libgnunettesting.la \
114 $(top_builddir)/src/util/libgnunetutil.la
115
116test_testing_large_topology_clique_SOURCES = \
117 test_testing_large_topology.c
118test_testing_large_topology_clique_LDADD = \
119 $(top_builddir)/src/testing/libgnunettesting.la \
120 $(top_builddir)/src/util/libgnunetutil.la
121
101test_testing_topology_stability_SOURCES = \ 122test_testing_topology_stability_SOURCES = \
102 test_testing_topology.c 123 test_testing_topology.c
103test_testing_topology_stability_LDADD = \ 124test_testing_topology_stability_LDADD = \
104 $(top_builddir)/src/testing/libgnunettesting.la \ 125 $(top_builddir)/src/testing/libgnunettesting.la \
105 $(top_builddir)/src/util/libgnunetutil.la 126 $(top_builddir)/src/util/libgnunetutil.la
106 127
107test_testing_topology_blacklist_SOURCES = \ 128test_testing_topology_blacklist_SOURCES = \
108 test_testing_topology_blacklist.c 129 test_testing_topology_blacklist.c
109test_testing_topology_blacklist_LDADD = \ 130test_testing_topology_blacklist_LDADD = \
110 $(top_builddir)/src/testing/libgnunettesting.la \ 131 $(top_builddir)/src/testing/libgnunettesting.la \
111 $(top_builddir)/src/util/libgnunetutil.la 132 $(top_builddir)/src/util/libgnunetutil.la
112 133
113test_testing_topology_churn_SOURCES = \ 134test_testing_topology_churn_SOURCES = \
114 test_testing_topology_churn.c 135 test_testing_topology_churn.c
115test_testing_topology_churn_LDADD = \ 136test_testing_topology_churn_LDADD = \
116 $(top_builddir)/src/testing/libgnunettesting.la \ 137 $(top_builddir)/src/testing/libgnunettesting.la \
117 $(top_builddir)/src/util/libgnunetutil.la 138 $(top_builddir)/src/util/libgnunetutil.la
118 139
119test_testing_topology_clique_random_SOURCES = \ 140test_testing_topology_clique_random_SOURCES = \
120 test_testing_topology.c 141 test_testing_topology.c
121test_testing_topology_clique_random_LDADD = \ 142test_testing_topology_clique_random_LDADD = \
@@ -127,7 +148,7 @@ test_testing_topology_clique_minimum_SOURCES = \
127test_testing_topology_clique_minimum_LDADD = \ 148test_testing_topology_clique_minimum_LDADD = \
128 $(top_builddir)/src/testing/libgnunettesting.la \ 149 $(top_builddir)/src/testing/libgnunettesting.la \
129 $(top_builddir)/src/util/libgnunetutil.la 150 $(top_builddir)/src/util/libgnunetutil.la
130 151
131test_testing_topology_clique_dfs_SOURCES = \ 152test_testing_topology_clique_dfs_SOURCES = \
132 test_testing_topology.c 153 test_testing_topology.c
133test_testing_topology_clique_dfs_LDADD = \ 154test_testing_topology_clique_dfs_LDADD = \
@@ -139,7 +160,12 @@ test_testing_topology_line_SOURCES = \
139test_testing_topology_line_LDADD = \ 160test_testing_topology_line_LDADD = \
140 $(top_builddir)/src/testing/libgnunettesting.la \ 161 $(top_builddir)/src/testing/libgnunettesting.la \
141 $(top_builddir)/src/util/libgnunetutil.la 162 $(top_builddir)/src/util/libgnunetutil.la
142 163
164test_testing_reconnect_SOURCES = \
165 test_testing_reconnect.c
166test_testing_reconnect_LDADD = \
167 $(top_builddir)/src/testing/libgnunettesting.la \
168 $(top_builddir)/src/util/libgnunetutil.la
143 169
144test_testing_group_remote_SOURCES = \ 170test_testing_group_remote_SOURCES = \
145 test_testing_group_remote.c 171 test_testing_group_remote.c
@@ -152,25 +178,31 @@ test_testing_topology_ring_SOURCES = \
152test_testing_topology_ring_LDADD = \ 178test_testing_topology_ring_LDADD = \
153 $(top_builddir)/src/testing/libgnunettesting.la \ 179 $(top_builddir)/src/testing/libgnunettesting.la \
154 $(top_builddir)/src/util/libgnunetutil.la 180 $(top_builddir)/src/util/libgnunetutil.la
155 181
156test_testing_topology_2d_torus_SOURCES = \ 182test_testing_topology_2d_torus_SOURCES = \
157 test_testing_topology.c 183 test_testing_topology.c
158test_testing_topology_2d_torus_LDADD = \ 184test_testing_topology_2d_torus_LDADD = \
159 $(top_builddir)/src/testing/libgnunettesting.la \ 185 $(top_builddir)/src/testing/libgnunettesting.la \
160 $(top_builddir)/src/util/libgnunetutil.la 186 $(top_builddir)/src/util/libgnunetutil.la
161 187
188test_testing_topology_2d_torus_plus_SOURCES = \
189 test_testing_topology.c
190test_testing_topology_2d_torus_plus_LDADD = \
191 $(top_builddir)/src/testing/libgnunettesting.la \
192 $(top_builddir)/src/util/libgnunetutil.la
193
162test_testing_topology_small_world_ring_SOURCES = \ 194test_testing_topology_small_world_ring_SOURCES = \
163 test_testing_topology.c 195 test_testing_topology.c
164test_testing_topology_small_world_ring_LDADD = \ 196test_testing_topology_small_world_ring_LDADD = \
165 $(top_builddir)/src/testing/libgnunettesting.la \ 197 $(top_builddir)/src/testing/libgnunettesting.la \
166 $(top_builddir)/src/util/libgnunetutil.la 198 $(top_builddir)/src/util/libgnunetutil.la
167 199
168test_testing_topology_small_world_torus_SOURCES = \ 200test_testing_topology_small_world_torus_SOURCES = \
169 test_testing_topology.c 201 test_testing_topology.c
170test_testing_topology_small_world_torus_LDADD = \ 202test_testing_topology_small_world_torus_LDADD = \
171 $(top_builddir)/src/testing/libgnunettesting.la \ 203 $(top_builddir)/src/testing/libgnunettesting.la \
172 $(top_builddir)/src/util/libgnunetutil.la 204 $(top_builddir)/src/util/libgnunetutil.la
173 205
174test_testing_topology_internat_SOURCES = \ 206test_testing_topology_internat_SOURCES = \
175 test_testing_topology.c 207 test_testing_topology.c
176test_testing_topology_internat_LDADD = \ 208test_testing_topology_internat_LDADD = \
@@ -182,7 +214,7 @@ test_testing_topology_erdos_renyi_SOURCES = \
182test_testing_topology_erdos_renyi_LDADD = \ 214test_testing_topology_erdos_renyi_LDADD = \
183 $(top_builddir)/src/testing/libgnunettesting.la \ 215 $(top_builddir)/src/testing/libgnunettesting.la \
184 $(top_builddir)/src/util/libgnunetutil.la 216 $(top_builddir)/src/util/libgnunetutil.la
185 217
186test_testing_topology_scale_free_SOURCES = \ 218test_testing_topology_scale_free_SOURCES = \
187 test_testing_topology.c 219 test_testing_topology.c
188test_testing_topology_scale_free_LDADD = \ 220test_testing_topology_scale_free_LDADD = \
@@ -194,8 +226,8 @@ test_testing_topology_none_SOURCES = \
194test_testing_topology_none_LDADD = \ 226test_testing_topology_none_LDADD = \
195 $(top_builddir)/src/testing/libgnunettesting.la \ 227 $(top_builddir)/src/testing/libgnunettesting.la \
196 $(top_builddir)/src/util/libgnunetutil.la 228 $(top_builddir)/src/util/libgnunetutil.la
197 229
198 230
199EXTRA_DIST = \ 231EXTRA_DIST = \
200 test_testing_data.conf \ 232 test_testing_data.conf \
201 test_testing_connect_peer1.conf \ 233 test_testing_connect_peer1.conf \
@@ -214,4 +246,4 @@ EXTRA_DIST = \
214 test_testing_data_topology_blacklist.conf \ 246 test_testing_data_topology_blacklist.conf \
215 test_testing_data_topology_churn.conf \ 247 test_testing_data_topology_churn.conf \
216 test_testing_data_topology_none.conf 248 test_testing_data_topology_none.conf
217 249
diff --git a/src/testing/test_testing_group.c b/src/testing/test_testing_group.c
index e3a3b2e63..1facaa63f 100644
--- a/src/testing/test_testing_group.c
+++ b/src/testing/test_testing_group.c
@@ -117,6 +117,7 @@ run (void *cls,
117 peers_left = NUM_PEERS; 117 peers_left = NUM_PEERS;
118 pg = GNUNET_TESTING_daemons_start (cfg, 118 pg = GNUNET_TESTING_daemons_start (cfg,
119 peers_left, 119 peers_left,
120 NUM_PEERS,
120 TIMEOUT, 121 TIMEOUT,
121 NULL, NULL, 122 NULL, NULL,
122 &my_cb, NULL, NULL, NULL, NULL); 123 &my_cb, NULL, NULL, NULL, NULL);
diff --git a/src/testing/test_testing_group_remote.c b/src/testing/test_testing_group_remote.c
index 5156007a6..02f76f826 100644
--- a/src/testing/test_testing_group_remote.c
+++ b/src/testing/test_testing_group_remote.c
@@ -203,6 +203,7 @@ run (void *cls,
203 peers_left = num_peers; 203 peers_left = num_peers;
204 pg = GNUNET_TESTING_daemons_start (cfg, 204 pg = GNUNET_TESTING_daemons_start (cfg,
205 peers_left, 205 peers_left,
206 peers_left,
206 TIMEOUT, 207 TIMEOUT,
207 NULL, 208 NULL,
208 NULL, &my_cb, NULL, NULL, NULL, hosts); 209 NULL, &my_cb, NULL, NULL, NULL, hosts);
diff --git a/src/testing/test_testing_large_topology.c b/src/testing/test_testing_large_topology.c
index d93f11168..46626618a 100644
--- a/src/testing/test_testing_large_topology.c
+++ b/src/testing/test_testing_large_topology.c
@@ -40,6 +40,10 @@ static float fail_percentage = 0.05;
40 40
41static int ok; 41static int ok;
42 42
43struct GNUNET_TIME_Relative connect_timeout;
44
45static unsigned long long connect_attempts;
46
43static unsigned long long num_peers; 47static unsigned long long num_peers;
44 48
45static unsigned int topology_connections; 49static unsigned int topology_connections;
@@ -775,6 +779,8 @@ connect_topology ()
775 GNUNET_TESTING_connect_topology (pg, connection_topology, 779 GNUNET_TESTING_connect_topology (pg, connection_topology,
776 connect_topology_option, 780 connect_topology_option,
777 connect_topology_option_modifier, 781 connect_topology_option_modifier,
782 connect_timeout,
783 connect_attempts,
778 &topology_creation_finished, NULL); 784 &topology_creation_finished, NULL);
779#if VERBOSE > 1 785#if VERBOSE > 1
780 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 786 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1076,6 +1082,26 @@ run (void *cls,
1076 &num_peers)) 1082 &num_peers))
1077 num_peers = DEFAULT_NUM_PEERS; 1083 num_peers = DEFAULT_NUM_PEERS;
1078 1084
1085 if (GNUNET_OK ==
1086 GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "connect_timeout",
1087 &temp_settle))
1088 connect_timeout =
1089 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, temp_settle);
1090 else
1091 {
1092 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", "testing", "connect_timeout");
1093 return;
1094 }
1095
1096
1097 if (GNUNET_OK !=
1098 GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "connect_attempts",
1099 &connect_attempts))
1100 {
1101 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", "testing", "connect_attempts");
1102 return;
1103 }
1104
1079 main_cfg = cfg; 1105 main_cfg = cfg;
1080 1106
1081 peers_left = num_peers; 1107 peers_left = num_peers;
@@ -1104,6 +1130,7 @@ run (void *cls,
1104 GNUNET_assert (num_peers > 0 && num_peers < (unsigned int) -1); 1130 GNUNET_assert (num_peers > 0 && num_peers < (unsigned int) -1);
1105 pg = GNUNET_TESTING_daemons_start (cfg, 1131 pg = GNUNET_TESTING_daemons_start (cfg,
1106 peers_left, 1132 peers_left,
1133 peers_left / 2,
1107 timeout, 1134 timeout,
1108 &hostkey_callback, NULL, 1135 &hostkey_callback, NULL,
1109 &peers_started_callback, NULL, 1136 &peers_started_callback, NULL,
diff --git a/src/testing/test_testing_topology.c b/src/testing/test_testing_topology.c
index 0e64f93aa..0461af89c 100644
--- a/src/testing/test_testing_topology.c
+++ b/src/testing/test_testing_topology.c
@@ -52,6 +52,10 @@ static int ok;
52 52
53static unsigned long long num_peers; 53static unsigned long long num_peers;
54 54
55struct GNUNET_TIME_Relative connect_timeout;
56
57static unsigned long long connect_attempts;
58
55static unsigned int topology_connections; 59static unsigned int topology_connections;
56 60
57static unsigned int total_connections; 61static unsigned int total_connections;
@@ -814,6 +818,8 @@ connect_topology ()
814 GNUNET_TESTING_connect_topology (pg, connection_topology, 818 GNUNET_TESTING_connect_topology (pg, connection_topology,
815 connect_topology_option, 819 connect_topology_option,
816 connect_topology_option_modifier, 820 connect_topology_option_modifier,
821 connect_timeout,
822 connect_attempts,
817 &topology_creation_finished, NULL); 823 &topology_creation_finished, NULL);
818#if VERBOSE 824#if VERBOSE
819 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 825 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1112,6 +1118,26 @@ run (void *cls,
1112 settle_time = 1118 settle_time =
1113 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, temp_settle); 1119 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, temp_settle);
1114 1120
1121 if (GNUNET_OK ==
1122 GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "connect_timeout",
1123 &temp_settle))
1124 connect_timeout =
1125 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, temp_settle);
1126 else
1127 {
1128 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", "testing", "connect_timeout");
1129 return;
1130 }
1131
1132
1133 if (GNUNET_OK !=
1134 GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "connect_attempts",
1135 &connect_attempts))
1136 {
1137 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", "testing", "connect_attempts");
1138 return;
1139 }
1140
1115 if (GNUNET_SYSERR == 1141 if (GNUNET_SYSERR ==
1116 GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "num_peers", 1142 GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "num_peers",
1117 &num_peers)) 1143 &num_peers))
@@ -1136,6 +1162,7 @@ run (void *cls,
1136 GNUNET_assert (num_peers > 0 && num_peers < (unsigned int) -1); 1162 GNUNET_assert (num_peers > 0 && num_peers < (unsigned int) -1);
1137 pg = GNUNET_TESTING_daemons_start (cfg, 1163 pg = GNUNET_TESTING_daemons_start (cfg,
1138 peers_left, 1164 peers_left,
1165 peers_left / 2,
1139 GNUNET_TIME_relative_multiply 1166 GNUNET_TIME_relative_multiply
1140 (GNUNET_TIME_UNIT_SECONDS, 1167 (GNUNET_TIME_UNIT_SECONDS,
1141 SECONDS_PER_PEER_START * num_peers), 1168 SECONDS_PER_PEER_START * num_peers),
diff --git a/src/testing/test_testing_topology_blacklist.c b/src/testing/test_testing_topology_blacklist.c
index aa4a9cac7..2c1a8b31c 100644
--- a/src/testing/test_testing_topology_blacklist.c
+++ b/src/testing/test_testing_topology_blacklist.c
@@ -43,6 +43,10 @@
43 43
44static int ok; 44static int ok;
45 45
46struct GNUNET_TIME_Relative connect_timeout;
47
48static unsigned long long connect_attempts;
49
46static unsigned long long num_peers; 50static unsigned long long num_peers;
47 51
48static unsigned int total_connections; 52static unsigned int total_connections;
@@ -256,6 +260,8 @@ connect_topology ()
256 GNUNET_TESTING_connect_topology (pg, connection_topology, 260 GNUNET_TESTING_connect_topology (pg, connection_topology,
257 connect_topology_option, 261 connect_topology_option,
258 connect_topology_option_modifier, 262 connect_topology_option_modifier,
263 connect_timeout,
264 connect_attempts,
259 NULL, NULL); 265 NULL, NULL);
260#if VERBOSE 266#if VERBOSE
261 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 267 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -393,6 +399,7 @@ run (void *cls,
393 unsigned long long connect_topology_num; 399 unsigned long long connect_topology_num;
394 unsigned long long blacklist_topology_num; 400 unsigned long long blacklist_topology_num;
395 unsigned long long connect_topology_option_num; 401 unsigned long long connect_topology_option_num;
402 unsigned long long temp_connect;
396 char *connect_topology_option_modifier_string; 403 char *connect_topology_option_modifier_string;
397 ok = 1; 404 ok = 1;
398 405
@@ -487,6 +494,26 @@ run (void *cls,
487 &num_peers)) 494 &num_peers))
488 num_peers = DEFAULT_NUM_PEERS; 495 num_peers = DEFAULT_NUM_PEERS;
489 496
497 if (GNUNET_OK ==
498 GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "connect_timeout",
499 &temp_connect))
500 connect_timeout =
501 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, temp_connect);
502 else
503 {
504 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", "testing", "connect_timeout");
505 return;
506 }
507
508
509 if (GNUNET_OK !=
510 GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "connect_attempts",
511 &connect_attempts))
512 {
513 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", "testing", "connect_attempts");
514 return;
515 }
516
490 main_cfg = cfg; 517 main_cfg = cfg;
491 518
492 GNUNET_assert (num_peers > 0 && num_peers < (unsigned int) -1); 519 GNUNET_assert (num_peers > 0 && num_peers < (unsigned int) -1);
@@ -508,7 +535,8 @@ run (void *cls,
508 "didn't start all daemons in reasonable amount of time!!!"); 535 "didn't start all daemons in reasonable amount of time!!!");
509 536
510 pg = GNUNET_TESTING_daemons_start (cfg, 537 pg = GNUNET_TESTING_daemons_start (cfg,
511 peers_left, TIMEOUT, &hostkey_callback, 538 peers_left, peers_left,
539 TIMEOUT, &hostkey_callback,
512 NULL, &peers_started_callback, NULL, 540 NULL, &peers_started_callback, NULL,
513 &topology_callback, NULL, NULL); 541 &topology_callback, NULL, NULL);
514 542
diff --git a/src/testing/test_testing_topology_churn.c b/src/testing/test_testing_topology_churn.c
index 8b2a12069..33f3a0737 100644
--- a/src/testing/test_testing_topology_churn.c
+++ b/src/testing/test_testing_topology_churn.c
@@ -280,6 +280,7 @@ run (void *cls,
280 "didn't start all daemons in reasonable amount of time!!!"); 280 "didn't start all daemons in reasonable amount of time!!!");
281 281
282 pg = GNUNET_TESTING_daemons_start (cfg, 282 pg = GNUNET_TESTING_daemons_start (cfg,
283 peers_left,
283 peers_left, TIMEOUT, NULL, NULL, 284 peers_left, TIMEOUT, NULL, NULL,
284 &peers_started_callback, NULL, NULL, 285 &peers_started_callback, NULL, NULL,
285 NULL, NULL); 286 NULL, NULL);
diff --git a/src/testing/testing_group.c b/src/testing/testing_group.c
index 24a98e612..929cc9128 100644
--- a/src/testing/testing_group.c
+++ b/src/testing/testing_group.c
@@ -53,21 +53,11 @@
53 */ 53 */
54#define HIGH_PORT 56000 54#define HIGH_PORT 56000
55 55
56#define MAX_OUTSTANDING_CONNECTIONS 200
57
58/* Maximum time to delay connect attempt */ 56/* Maximum time to delay connect attempt */
59#define MAX_CONNECT_DELAY 300 57#define MAX_CONNECT_DELAY 300
60 58
61#define MAX_CONCURRENT_HOSTKEYS 500 59#define MAX_CONCURRENT_HOSTKEYS 500
62 60
63#define MAX_CONCURRENT_STARTING 200
64
65#define MAX_CONCURRENT_SHUTDOWN 200
66
67#define CONNECT_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60)
68
69#define CONNECT_ATTEMPTS 12
70
71/** 61/**
72 * Which list of peers do we need to modify? 62 * Which list of peers do we need to modify?
73 */ 63 */
@@ -106,6 +96,11 @@ typedef unsigned int (*GNUNET_TESTING_ConnectionProcessor) (struct
106struct ChurnContext 96struct ChurnContext
107{ 97{
108 /** 98 /**
99 * The peergroup we are dealing with.
100 */
101 struct GNUNET_TESTING_PeerGroup *pg;
102
103 /**
109 * Callback used to notify of churning finished 104 * Callback used to notify of churning finished
110 */ 105 */
111 GNUNET_TESTING_NotifyCompletion cb; 106 GNUNET_TESTING_NotifyCompletion cb;
@@ -168,6 +163,7 @@ struct RestartContext
168 163
169struct ShutdownContext 164struct ShutdownContext
170{ 165{
166 struct GNUNET_TESTING_PeerGroup *pg;
171 /** 167 /**
172 * Total peers to wait for 168 * Total peers to wait for
173 */ 169 */
@@ -349,6 +345,11 @@ struct InternalStartContext
349struct ChurnRestartContext 345struct ChurnRestartContext
350{ 346{
351 /** 347 /**
348 * PeerGroup that we are working with.
349 */
350 struct GNUNET_TESTING_PeerGroup *pg;
351
352 /**
352 * Number of restarts currently in flight. 353 * Number of restarts currently in flight.
353 */ 354 */
354 unsigned int outstanding; 355 unsigned int outstanding;
@@ -494,6 +495,11 @@ struct HostData
494struct TopologyIterateContext 495struct TopologyIterateContext
495{ 496{
496 /** 497 /**
498 * The peergroup we are working with.
499 */
500 struct GNUNET_TESTING_PeerGroup *pg;
501
502 /**
497 * Callback for notifying of two connected peers. 503 * Callback for notifying of two connected peers.
498 */ 504 */
499 GNUNET_TESTING_NotifyTopology topology_cb; 505 GNUNET_TESTING_NotifyTopology topology_cb;
@@ -522,6 +528,11 @@ struct TopologyIterateContext
522struct StatsIterateContext 528struct StatsIterateContext
523{ 529{
524 /** 530 /**
531 * The peergroup that we are dealing with.
532 */
533 struct GNUNET_TESTING_PeerGroup *pg;
534
535 /**
525 * Continuation to call once all stats information has been retrieved. 536 * Continuation to call once all stats information has been retrieved.
526 */ 537 */
527 GNUNET_STATISTICS_Callback cont; 538 GNUNET_STATISTICS_Callback cont;
@@ -639,6 +650,18 @@ struct GNUNET_TESTING_PeerGroup
639 unsigned int started; 650 unsigned int started;
640 651
641 /** 652 /**
653 * Number of possible connections to peers
654 * at a time.
655 */
656 unsigned int max_outstanding_connections;
657
658 /**
659 * Number of connects we are waiting on, allows us to rate limit
660 * connect attempts.
661 */
662 unsigned int outstanding_connects;
663
664 /**
642 * Hostkeys loaded from a file. 665 * Hostkeys loaded from a file.
643 */ 666 */
644 char *hostkey_data; 667 char *hostkey_data;
@@ -701,6 +724,16 @@ struct ConnectContext
701 struct ConnectTopologyContext *ct_ctx; 724 struct ConnectTopologyContext *ct_ctx;
702 725
703 /** 726 /**
727 * How long to try this connection before timing out.
728 */
729 struct GNUNET_TIME_Relative connect_timeout;
730
731 /**
732 * How many times to retry connecting the two peers.
733 */
734 unsigned int connect_attempts;
735
736 /**
704 * Whether this connection has been accounted for in the schedule_connect call. 737 * Whether this connection has been accounted for in the schedule_connect call.
705 */ 738 */
706 int counted; 739 int counted;
@@ -837,12 +870,6 @@ uid_from_hash (const GNUNET_HashCode * hash, uint32_t * uid)
837#endif 870#endif
838 871
839/** 872/**
840 * Number of connects we are waiting on, allows us to rate limit
841 * connect attempts.
842 */
843static int outstanding_connects;
844
845/**
846 * Get a topology from a string input. 873 * Get a topology from a string input.
847 * 874 *
848 * @param topology where to write the retrieved topology 875 * @param topology where to write the retrieved topology
@@ -2806,7 +2833,7 @@ internal_connect_notify (void *cls,
2806{ 2833{
2807 struct ConnectTopologyContext *ct_ctx = cls; 2834 struct ConnectTopologyContext *ct_ctx = cls;
2808 struct GNUNET_TESTING_PeerGroup *pg = ct_ctx->pg; 2835 struct GNUNET_TESTING_PeerGroup *pg = ct_ctx->pg;
2809 outstanding_connects--; 2836 pg->outstanding_connects--;
2810 ct_ctx->remaining_connections--; 2837 ct_ctx->remaining_connections--;
2811 if (ct_ctx->remaining_connections == 0) 2838 if (ct_ctx->remaining_connections == 0)
2812 { 2839 {
@@ -2833,11 +2860,12 @@ static void
2833schedule_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 2860schedule_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
2834{ 2861{
2835 struct ConnectContext *connect_context = cls; 2862 struct ConnectContext *connect_context = cls;
2863 struct GNUNET_TESTING_PeerGroup *pg = connect_context->ct_ctx->pg;
2836 2864
2837 if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN) 2865 if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN)
2838 return; 2866 return;
2839 2867
2840 if (outstanding_connects > MAX_OUTSTANDING_CONNECTIONS) 2868 if (pg->outstanding_connects > pg->max_outstanding_connections)
2841 { 2869 {
2842#if VERBOSE_TESTING > 2 2870#if VERBOSE_TESTING > 2
2843 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2871 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -2855,11 +2883,11 @@ schedule_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
2855 _("Creating connection, outstanding_connections is %d\n"), 2883 _("Creating connection, outstanding_connections is %d\n"),
2856 outstanding_connects); 2884 outstanding_connects);
2857#endif 2885#endif
2858 outstanding_connects++; 2886 pg->outstanding_connects++;
2859 GNUNET_TESTING_daemons_connect (connect_context->first, 2887 GNUNET_TESTING_daemons_connect (connect_context->first,
2860 connect_context->second, 2888 connect_context->second,
2861 CONNECT_TIMEOUT, 2889 connect_context->connect_timeout,
2862 CONNECT_ATTEMPTS, 2890 connect_context->connect_attempts,
2863 &internal_connect_notify, 2891 &internal_connect_notify,
2864 connect_context->ct_ctx); 2892 connect_context->ct_ctx);
2865 GNUNET_free (connect_context); 2893 GNUNET_free (connect_context);
@@ -2970,6 +2998,8 @@ copy_allowed_topology (struct GNUNET_TESTING_PeerGroup *pg)
2970 * of each peer in the peer group 2998 * of each peer in the peer group
2971 * 2999 *
2972 * @param pg the peer group we are dealing with 3000 * @param pg the peer group we are dealing with
3001 * @param connect_timeout how long try connecting two peers
3002 * @param connect_attempts how many times (max) to attempt
2973 * @param notify_callback callback to notify when finished 3003 * @param notify_callback callback to notify when finished
2974 * @param notify_cls closure for notify callback 3004 * @param notify_cls closure for notify callback
2975 * 3005 *
@@ -2977,6 +3007,8 @@ copy_allowed_topology (struct GNUNET_TESTING_PeerGroup *pg)
2977 */ 3007 */
2978static int 3008static int
2979connect_topology (struct GNUNET_TESTING_PeerGroup *pg, 3009connect_topology (struct GNUNET_TESTING_PeerGroup *pg,
3010 struct GNUNET_TIME_Relative connect_timeout,
3011 unsigned int connect_attempts,
2980 GNUNET_TESTING_NotifyCompletion notify_callback, 3012 GNUNET_TESTING_NotifyCompletion notify_callback,
2981 void *notify_cls) 3013 void *notify_cls)
2982{ 3014{
@@ -3030,6 +3062,8 @@ connect_topology (struct GNUNET_TESTING_PeerGroup *pg,
3030 connect_context->first = pg->peers[pg_iter].daemon; 3062 connect_context->first = pg->peers[pg_iter].daemon;
3031 connect_context->second = pg->peers[connection_iter->index].daemon; 3063 connect_context->second = pg->peers[connection_iter->index].daemon;
3032 connect_context->ct_ctx = ct_ctx; 3064 connect_context->ct_ctx = ct_ctx;
3065 connect_context->connect_timeout = connect_timeout;
3066 connect_context->connect_attempts = connect_attempts;
3033 GNUNET_SCHEDULER_add_now (&schedule_connect, connect_context); 3067 GNUNET_SCHEDULER_add_now (&schedule_connect, connect_context);
3034 connection_iter = connection_iter->next; 3068 connection_iter = connection_iter->next;
3035 total++; 3069 total++;
@@ -4010,7 +4044,7 @@ schedule_get_topology (void *cls,
4010 if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN) 4044 if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN)
4011 return; 4045 return;
4012 4046
4013 if (topology_context->connected > MAX_OUTSTANDING_CONNECTIONS) 4047 if (topology_context->connected > topology_context->pg->max_outstanding_connections)
4014 { 4048 {
4015#if VERBOSE_TESTING > 2 4049#if VERBOSE_TESTING > 2
4016 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 4050 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -4058,6 +4092,7 @@ GNUNET_TESTING_get_topology (struct GNUNET_TESTING_PeerGroup *pg,
4058 topology_context = GNUNET_malloc (sizeof (struct TopologyIterateContext)); 4092 topology_context = GNUNET_malloc (sizeof (struct TopologyIterateContext));
4059 topology_context->topology_cb = cb; 4093 topology_context->topology_cb = cb;
4060 topology_context->cls = cls; 4094 topology_context->cls = cls;
4095 topology_context->pg = pg;
4061 total_count = 0; 4096 total_count = 0;
4062 for (i = 0; i < pg->total; i++) 4097 for (i = 0; i < pg->total; i++)
4063 { 4098 {
@@ -4152,7 +4187,7 @@ schedule_get_statistics (void *cls,
4152 if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN) 4187 if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN)
4153 return; 4188 return;
4154 4189
4155 if (stats_context->connected > MAX_OUTSTANDING_CONNECTIONS) 4190 if (stats_context->connected > stats_context->pg->max_outstanding_connections)
4156 { 4191 {
4157#if VERBOSE_TESTING > 2 4192#if VERBOSE_TESTING > 2
4158 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 4193 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -4290,6 +4325,7 @@ GNUNET_TESTING_get_statistics (struct GNUNET_TESTING_PeerGroup *pg,
4290 stats_context->cont = cont; 4325 stats_context->cont = cont;
4291 stats_context->proc = proc; 4326 stats_context->proc = proc;
4292 stats_context->cls = cls; 4327 stats_context->cls = cls;
4328 stats_context->pg = pg;
4293 total_count = 0; 4329 total_count = 0;
4294 4330
4295 for (i = 0; i < pg->total; i++) 4331 for (i = 0; i < pg->total; i++)
@@ -4338,6 +4374,10 @@ GNUNET_TESTING_get_statistics (struct GNUNET_TESTING_PeerGroup *pg,
4338 * @param topology which topology to connect the peers in 4374 * @param topology which topology to connect the peers in
4339 * @param options options for connecting the topology 4375 * @param options options for connecting the topology
4340 * @param option_modifier modifier for options that take a parameter 4376 * @param option_modifier modifier for options that take a parameter
4377 * @param connect_timeout how long to wait before giving up on connecting
4378 * two peers
4379 * @param connect_attempts how many times to attempt to connect two peers
4380 * over the connect_timeout duration
4341 * @param notify_callback notification to be called once all connections completed 4381 * @param notify_callback notification to be called once all connections completed
4342 * @param notify_cls closure for notification callback 4382 * @param notify_cls closure for notification callback
4343 * 4383 *
@@ -4348,6 +4388,8 @@ GNUNET_TESTING_connect_topology (struct GNUNET_TESTING_PeerGroup *pg,
4348 enum GNUNET_TESTING_Topology topology, 4388 enum GNUNET_TESTING_Topology topology,
4349 enum GNUNET_TESTING_TopologyOption options, 4389 enum GNUNET_TESTING_TopologyOption options,
4350 double option_modifier, 4390 double option_modifier,
4391 struct GNUNET_TIME_Relative connect_timeout,
4392 unsigned int connect_attempts,
4351 GNUNET_TESTING_NotifyCompletion 4393 GNUNET_TESTING_NotifyCompletion
4352 notify_callback, void *notify_cls) 4394 notify_callback, void *notify_cls)
4353{ 4395{
@@ -4480,7 +4522,7 @@ GNUNET_TESTING_connect_topology (struct GNUNET_TESTING_PeerGroup *pg,
4480 break; 4522 break;
4481 } 4523 }
4482 4524
4483 return connect_topology (pg, notify_callback, notify_cls); 4525 return connect_topology (pg, connect_timeout, connect_attempts, notify_callback, notify_cls);
4484} 4526}
4485 4527
4486/** 4528/**
@@ -4547,7 +4589,7 @@ internal_continue_startup (void *cls,
4547 return; 4589 return;
4548 } 4590 }
4549 4591
4550 if (internal_context->peer->pg->starting < MAX_CONCURRENT_STARTING) 4592 if (internal_context->peer->pg->starting < internal_context->peer->pg->max_outstanding_connections)
4551 { 4593 {
4552 internal_context->peer->pg->starting++; 4594 internal_context->peer->pg->starting++;
4553 GNUNET_TESTING_daemon_continue_startup (internal_context->peer->daemon); 4595 GNUNET_TESTING_daemon_continue_startup (internal_context->peer->daemon);
@@ -4630,7 +4672,7 @@ schedule_churn_restart (void *cls,
4630 struct ChurnRestartContext *startup_ctx = 4672 struct ChurnRestartContext *startup_ctx =
4631 peer_restart_ctx->churn_restart_ctx; 4673 peer_restart_ctx->churn_restart_ctx;
4632 4674
4633 if (startup_ctx->outstanding > MAX_CONCURRENT_STARTING) 4675 if (startup_ctx->outstanding > startup_ctx->pg->max_outstanding_connections)
4634 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 4676 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
4635 (GNUNET_TIME_UNIT_MILLISECONDS, 100), 4677 (GNUNET_TIME_UNIT_MILLISECONDS, 100),
4636 &schedule_churn_restart, peer_restart_ctx); 4678 &schedule_churn_restart, peer_restart_ctx);
@@ -4706,6 +4748,8 @@ GNUNET_TESTING_daemons_continue_startup (struct GNUNET_TESTING_PeerGroup *pg)
4706 * 4748 *
4707 * @param cfg configuration template to use 4749 * @param cfg configuration template to use
4708 * @param total number of daemons to start 4750 * @param total number of daemons to start
4751 * @param max_concurrent_connections for testing, how many peers can
4752 * we connect to simultaneously
4709 * @param timeout total time allowed for peers to start 4753 * @param timeout total time allowed for peers to start
4710 * @param hostkey_callback function to call on each peers hostkey generation 4754 * @param hostkey_callback function to call on each peers hostkey generation
4711 * if NULL, peers will be started by this call, if non-null, 4755 * if NULL, peers will be started by this call, if non-null,
@@ -4724,6 +4768,7 @@ GNUNET_TESTING_daemons_continue_startup (struct GNUNET_TESTING_PeerGroup *pg)
4724struct GNUNET_TESTING_PeerGroup * 4768struct GNUNET_TESTING_PeerGroup *
4725GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg, 4769GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
4726 unsigned int total, 4770 unsigned int total,
4771 unsigned int max_concurrent_connections,
4727 struct GNUNET_TIME_Relative timeout, 4772 struct GNUNET_TIME_Relative timeout,
4728 GNUNET_TESTING_NotifyHostkeyCreated 4773 GNUNET_TESTING_NotifyHostkeyCreated
4729 hostkey_callback, void *hostkey_cls, 4774 hostkey_callback, void *hostkey_cls,
@@ -4776,6 +4821,7 @@ GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
4776 pg->total = total; 4821 pg->total = total;
4777 pg->max_timeout = GNUNET_TIME_relative_to_absolute (timeout); 4822 pg->max_timeout = GNUNET_TIME_relative_to_absolute (timeout);
4778 pg->peers = GNUNET_malloc (total * sizeof (struct PeerData)); 4823 pg->peers = GNUNET_malloc (total * sizeof (struct PeerData));
4824 pg->max_outstanding_connections = max_concurrent_connections;
4779 if (NULL != hostnames) 4825 if (NULL != hostnames)
4780 { 4826 {
4781 off = 0; 4827 off = 0;
@@ -5176,12 +5222,12 @@ schedule_churn_shutdown_task (void *cls,
5176{ 5222{
5177 struct PeerShutdownContext *peer_shutdown_ctx = cls; 5223 struct PeerShutdownContext *peer_shutdown_ctx = cls;
5178 struct ShutdownContext *shutdown_ctx; 5224 struct ShutdownContext *shutdown_ctx;
5179 5225 struct ChurnContext *churn_ctx;
5180 GNUNET_assert (peer_shutdown_ctx != NULL); 5226 GNUNET_assert (peer_shutdown_ctx != NULL);
5181 shutdown_ctx = peer_shutdown_ctx->shutdown_ctx; 5227 shutdown_ctx = peer_shutdown_ctx->shutdown_ctx;
5182 GNUNET_assert (shutdown_ctx != NULL); 5228 GNUNET_assert (shutdown_ctx != NULL);
5183 5229 churn_ctx = (struct ChurnContext *)shutdown_ctx->cb_cls;
5184 if (shutdown_ctx->outstanding > MAX_CONCURRENT_SHUTDOWN) 5230 if (shutdown_ctx->outstanding > churn_ctx->pg->max_outstanding_connections)
5185 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 5231 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
5186 (GNUNET_TIME_UNIT_MILLISECONDS, 100), 5232 (GNUNET_TIME_UNIT_MILLISECONDS, 100),
5187 &schedule_churn_shutdown_task, 5233 &schedule_churn_shutdown_task,
@@ -5308,6 +5354,7 @@ GNUNET_TESTING_daemons_churn (struct GNUNET_TESTING_PeerGroup *pg,
5308 churn_ctx->num_to_stop = voff; 5354 churn_ctx->num_to_stop = voff;
5309 churn_ctx->cb = cb; 5355 churn_ctx->cb = cb;
5310 churn_ctx->cb_cls = cb_cls; 5356 churn_ctx->cb_cls = cb_cls;
5357 churn_ctx->pg = pg;
5311 5358
5312 for (i = 0; i < pg->total; i++) 5359 for (i = 0; i < pg->total; i++)
5313 { 5360 {
@@ -5362,6 +5409,7 @@ GNUNET_TESTING_daemons_churn (struct GNUNET_TESTING_PeerGroup *pg,
5362 churn_startup_ctx = GNUNET_malloc (sizeof (struct ChurnRestartContext)); 5409 churn_startup_ctx = GNUNET_malloc (sizeof (struct ChurnRestartContext));
5363 churn_startup_ctx->churn_ctx = churn_ctx; 5410 churn_startup_ctx->churn_ctx = churn_ctx;
5364 churn_startup_ctx->timeout = timeout; 5411 churn_startup_ctx->timeout = timeout;
5412 churn_startup_ctx->pg = pg;
5365 } 5413 }
5366 for (i = 0; i < von; i++) 5414 for (i = 0; i < von; i++)
5367 { 5415 {
@@ -5529,7 +5577,7 @@ schedule_shutdown_task (void *cls,
5529 shutdown_ctx = peer_shutdown_ctx->shutdown_ctx; 5577 shutdown_ctx = peer_shutdown_ctx->shutdown_ctx;
5530 GNUNET_assert (shutdown_ctx != NULL); 5578 GNUNET_assert (shutdown_ctx != NULL);
5531 5579
5532 if (shutdown_ctx->outstanding > MAX_CONCURRENT_SHUTDOWN) 5580 if (shutdown_ctx->outstanding > shutdown_ctx->pg->max_outstanding_connections)
5533 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 5581 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
5534 (GNUNET_TIME_UNIT_MILLISECONDS, 100), 5582 (GNUNET_TIME_UNIT_MILLISECONDS, 100),
5535 &schedule_shutdown_task, peer_shutdown_ctx); 5583 &schedule_shutdown_task, peer_shutdown_ctx);
@@ -5572,6 +5620,7 @@ GNUNET_TESTING_daemons_stop (struct GNUNET_TESTING_PeerGroup *pg,
5572 shutdown_ctx->cb_cls = cb_cls; 5620 shutdown_ctx->cb_cls = cb_cls;
5573 shutdown_ctx->total_peers = pg->total; 5621 shutdown_ctx->total_peers = pg->total;
5574 shutdown_ctx->timeout = timeout; 5622 shutdown_ctx->timeout = timeout;
5623 shutdown_ctx->pg = pg;
5575 /* shtudown_ctx->outstanding = 0; */ 5624 /* shtudown_ctx->outstanding = 0; */
5576 5625
5577 for (off = 0; off < pg->total; off++) 5626 for (off = 0; off < pg->total; off++)
diff --git a/src/topology/test_gnunet_daemon_topology.c b/src/topology/test_gnunet_daemon_topology.c
index 529496f11..ae96b071c 100644
--- a/src/topology/test_gnunet_daemon_topology.c
+++ b/src/topology/test_gnunet_daemon_topology.c
@@ -154,6 +154,7 @@ run (void *cls,
154 peers_left = NUM_PEERS; 154 peers_left = NUM_PEERS;
155 pg = GNUNET_TESTING_daemons_start (cfg, 155 pg = GNUNET_TESTING_daemons_start (cfg,
156 peers_left, 156 peers_left,
157 peers_left,
157 TIMEOUT, 158 TIMEOUT,
158 NULL, NULL, 159 NULL, NULL,
159 &my_cb, NULL, NULL, NULL, NULL); 160 &my_cb, NULL, NULL, NULL, NULL);