#define FIND_PEER_THRESHOLD 1
/* If more than this many peers are added, slow down sending */
-#define MAX_FIND_PEER_CUTOFF 4000
+#define MAX_FIND_PEER_CUTOFF 2000
/* If less than this many peers are added, speed up sending */
#define MIN_FIND_PEER_CUTOFF 500
#define DEFAULT_MAX_OUTSTANDING_PUTS 10
-#define DEFAULT_MAX_OUTSTANDING_FIND_PEERS 196
+#define DEFAULT_MAX_OUTSTANDING_FIND_PEERS 128
#define DEFAULT_FIND_PEER_OFFSET GNUNET_TIME_relative_divide (DEFAULT_FIND_PEER_DELAY, DEFAULT_MAX_OUTSTANDING_FIND_PEERS)
/* Globals */
+/**
+ * How long to try to connect two peers.
+ */
+struct GNUNET_TIME_Relative connect_timeout;
+
+/**
+ * How many times to re-attempt connecting two peers.
+ */
+static unsigned long long connect_attempts;
+
/**
* Timeout to let all GET requests happen.
*/
*/
static unsigned long long test_data_size = DEFAULT_TEST_DATA_SIZE;
+/**
+ * Maximum number of concurrent connections to peers.
+ */
+static unsigned long long max_outstanding_connections;
+
/**
* Maximum number of concurrent PUT requests.
*/
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);
connect_last_time = GNUNET_TIME_absolute_get();
previous_connections = total_connections;
-
+ GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "have %u total_connections\n", total_connections);
}
if (emsg == NULL)
{
if ((pg != NULL) && (peers_left == 0))
{
connect_start_time = GNUNET_TIME_absolute_get();
- expected_connections = GNUNET_TESTING_connect_topology (pg, connect_topology, connect_topology_option, connect_topology_option_modifier, NULL, NULL);
+ expected_connections = GNUNET_TESTING_connect_topology(pg,
+ connect_topology, connect_topology_option,
+ connect_topology_option_modifier,
+ connect_timeout, connect_attempts,
+ NULL, NULL);
peer_connect_meter = create_meter(expected_connections, "Peer connection ", GNUNET_YES);
fprintf(stderr, "Have %d expected connections\n", expected_connections);
}
GNUNET_assert(num_peers > 0 && num_peers < ULONG_MAX);
+ if (GNUNET_OK ==
+ GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "connect_timeout",
+ &temp_config_number))
+ connect_timeout =
+ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, temp_config_number);
+ else
+ {
+ GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", "testing", "connect_timeout");
+ return;
+ }
+
+
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "connect_attempts",
+ &connect_attempts))
+ {
+ GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", "testing", "connect_attempts");
+ return;
+ }
+
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "max_outstanding_connections",
+ &max_outstanding_connections))
+ {
+ GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", "testing", "max_outstanding_connections");
+ return;
+ }
+
/**
* Get DHT specific testing options.
*/
get_meter = create_meter(num_gets, "Gets completed ", GNUNET_YES);
pg = GNUNET_TESTING_daemons_start (cfg,
peers_left,
+ max_outstanding_connections,
GNUNET_TIME_relative_multiply(seconds_per_peer_start, num_peers),
&hostkey_callback, NULL,
&peers_started_callback, NULL,
daemons[i] = GNUNET_malloc (sizeof (struct GNUNET_FS_TestDaemon));
sctx->group = GNUNET_TESTING_daemons_start (sctx->cfg,
total,
+ total, /* Outstanding connections */
timeout,
NULL,
NULL,
/**
- * Start count gnunetd processes with the same set of transports and
+ * Start count gnunet instances with the same set of transports and
* applications. The port numbers (any option called "PORT") will be
* adjusted to ensure that no two peers running on the same system
* have the same port(s) in their respective configurations.
*
* @param cfg configuration template to use
* @param total number of daemons to start
+ * @param max_concurrent_connections for testing, how many peers can
+ * we connect to simultaneously
* @param timeout total time allowed for peers to start
* @param hostkey_callback function to call on each peers hostkey generation
* if NULL, peers will be started by this call, if non-null,
* @param cb_cls closure for cb
* @param connect_callback function to call each time two hosts are connected
* @param connect_callback_cls closure for connect_callback
- * @param hostnames linked list of hosts to use to start peers on (NULL to run on localhost only)
+ * @param hostnames linked list of host structs to use to start peers on
+ * (NULL to run on localhost only)
*
* @return NULL on error, otherwise handle to control peer group
*/
struct GNUNET_TESTING_PeerGroup *
GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
unsigned int total,
+ unsigned int max_concurrent_connections,
struct GNUNET_TIME_Relative timeout,
- GNUNET_TESTING_NotifyHostkeyCreated hostkey_callback,
- void *hostkey_cls,
+ GNUNET_TESTING_NotifyHostkeyCreated
+ hostkey_callback, void *hostkey_cls,
GNUNET_TESTING_NotifyDaemonRunning cb,
void *cb_cls,
GNUNET_TESTING_NotifyConnection
* @param topology which topology to connect the peers in
* @param options options for connecting the topology
* @param option_modifier modifier for options that take a parameter
+ * @param connect_timeout how long to wait before giving up on connecting
+ * two peers
+ * @param connect_attempts how many times to attempt to connect two peers
+ * over the connect_timeout duration
* @param notify_callback notification to be called once all connections completed
* @param notify_cls closure for notification callback
*
- * @return the number of connections that will be attempted (multiple of two,
- * each bidirectional connection counts twice!), GNUNET_SYSERR on error
- *
+ * @return the number of connections that will be attempted, GNUNET_SYSERR on error
*/
int
GNUNET_TESTING_connect_topology (struct GNUNET_TESTING_PeerGroup *pg,
enum GNUNET_TESTING_Topology topology,
enum GNUNET_TESTING_TopologyOption options,
double option_modifier,
- GNUNET_TESTING_NotifyCompletion notify_callback,
- void *notify_cls);
+ struct GNUNET_TIME_Relative connect_timeout,
+ unsigned int connect_attempts,
+ GNUNET_TESTING_NotifyCompletion
+ notify_callback, void *notify_cls);
/**
* Start or stop an individual peer from the given group.
$(top_builddir)/src/transport/libgnunettransport.la \
-lm \
$(top_builddir)/src/util/libgnunetutil.la
+
+noinst_PROGRAMS = ${check_PROGRAMS}
check_PROGRAMS = \
test_testing \
test_testing_reconnect \
test_testing_group \
test_testing_topology_stability \
+ test_testing_large_topology_clique \
+ test_testing_topology_from_file \
test_testing_topology_clique \
test_testing_topology_clique_random \
test_testing_topology_clique_minimum \
test_testing_topology_erdos_renyi \
test_testing_topology_internat \
test_testing_topology_none \
- test_testing_topology_scale_free
+ test_testing_topology_scale_free \
+ test_testing_topology_connect_only \
+ test_testing_topology_2d_torus_plus
+# test_testing_topology_stability
if !DISABLE_TEST_RUN
TESTS = \
test_testing \
test_testing_connect \
test_testing_reconnect \
test_testing_group \
- test_testing_topology_clique
-# test_testing_topology_stability \
-# test_testing_topology_clique_random \
-# test_testing_topology_clique_minimum \
-# test_testing_topology_clique_dfs \
-# test_testing_topology_churn \
-# test_testing_topology_line
-# test_testing_topology_blacklist \
-# test_testing_group_remote \
-# test_testing_topology_ring \
-# test_testing_topology_2d_torus \
-# test_testing_topology_small_world_ring \
-# test_testing_topology_small_world_torus \
-# test_testing_topology_erdos_renyi \
-# test_testing_topology_internat \
-# test_testing_topology_scale_free
+ test_testing_topology_clique \
+ test_testing_topology_from_file \
+ test_testing_topology_clique_random \
+ test_testing_topology_clique_minimum \
+ test_testing_topology_clique_dfs \
+ test_testing_topology_churn \
+ test_testing_topology_line \
+ test_testing_topology_blacklist \
+ test_testing_group_remote \
+ test_testing_topology_ring \
+ test_testing_topology_2d_torus \
+ test_testing_topology_small_world_ring \
+ test_testing_topology_small_world_torus \
+ test_testing_topology_erdos_renyi \
+ test_testing_topology_internat \
+ test_testing_topology_scale_free \
+ test_testing_topology_connect_only \
+ test_testing_topology_2d_torus_plus
endif
test_testing_SOURCES = \
$(top_builddir)/src/testing/libgnunettesting.la \
$(top_builddir)/src/util/libgnunetutil.la
-test_testing_reconnect_SOURCES = \
- test_testing_reconnect.c
-test_testing_reconnect_LDADD = \
- $(top_builddir)/src/testing/libgnunettesting.la \
- $(top_builddir)/src/util/libgnunetutil.la
-
test_testing_group_SOURCES = \
test_testing_group.c
test_testing_group_LDADD = \
$(top_builddir)/src/testing/libgnunettesting.la \
$(top_builddir)/src/util/libgnunetutil.la
-
+
test_testing_topology_clique_SOURCES = \
test_testing_topology.c
test_testing_topology_clique_LDADD = \
$(top_builddir)/src/testing/libgnunettesting.la \
$(top_builddir)/src/util/libgnunetutil.la
-
+
+test_testing_topology_connect_only_SOURCES = \
+ test_testing_topology.c
+test_testing_topology_connect_only_LDADD = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
+ $(top_builddir)/src/util/libgnunetutil.la
+
+test_testing_topology_from_file_SOURCES = \
+ test_testing_topology.c
+test_testing_topology_from_file_LDADD = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
+ $(top_builddir)/src/util/libgnunetutil.la
+
+test_testing_large_topology_clique_SOURCES = \
+ test_testing_large_topology.c
+test_testing_large_topology_clique_LDADD = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
+ $(top_builddir)/src/util/libgnunetutil.la
+
test_testing_topology_stability_SOURCES = \
test_testing_topology.c
test_testing_topology_stability_LDADD = \
$(top_builddir)/src/testing/libgnunettesting.la \
$(top_builddir)/src/util/libgnunetutil.la
-
+
test_testing_topology_blacklist_SOURCES = \
test_testing_topology_blacklist.c
test_testing_topology_blacklist_LDADD = \
$(top_builddir)/src/testing/libgnunettesting.la \
$(top_builddir)/src/util/libgnunetutil.la
-
+
test_testing_topology_churn_SOURCES = \
test_testing_topology_churn.c
test_testing_topology_churn_LDADD = \
$(top_builddir)/src/testing/libgnunettesting.la \
$(top_builddir)/src/util/libgnunetutil.la
-
+
test_testing_topology_clique_random_SOURCES = \
test_testing_topology.c
test_testing_topology_clique_random_LDADD = \
test_testing_topology_clique_minimum_LDADD = \
$(top_builddir)/src/testing/libgnunettesting.la \
$(top_builddir)/src/util/libgnunetutil.la
-
+
test_testing_topology_clique_dfs_SOURCES = \
test_testing_topology.c
test_testing_topology_clique_dfs_LDADD = \
test_testing_topology_line_LDADD = \
$(top_builddir)/src/testing/libgnunettesting.la \
$(top_builddir)/src/util/libgnunetutil.la
-
+
+test_testing_reconnect_SOURCES = \
+ test_testing_reconnect.c
+test_testing_reconnect_LDADD = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
+ $(top_builddir)/src/util/libgnunetutil.la
test_testing_group_remote_SOURCES = \
test_testing_group_remote.c
test_testing_topology_ring_LDADD = \
$(top_builddir)/src/testing/libgnunettesting.la \
$(top_builddir)/src/util/libgnunetutil.la
-
+
test_testing_topology_2d_torus_SOURCES = \
test_testing_topology.c
test_testing_topology_2d_torus_LDADD = \
$(top_builddir)/src/testing/libgnunettesting.la \
$(top_builddir)/src/util/libgnunetutil.la
-
+
+test_testing_topology_2d_torus_plus_SOURCES = \
+ test_testing_topology.c
+test_testing_topology_2d_torus_plus_LDADD = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
+ $(top_builddir)/src/util/libgnunetutil.la
+
test_testing_topology_small_world_ring_SOURCES = \
test_testing_topology.c
test_testing_topology_small_world_ring_LDADD = \
$(top_builddir)/src/testing/libgnunettesting.la \
$(top_builddir)/src/util/libgnunetutil.la
-
+
test_testing_topology_small_world_torus_SOURCES = \
test_testing_topology.c
test_testing_topology_small_world_torus_LDADD = \
$(top_builddir)/src/testing/libgnunettesting.la \
$(top_builddir)/src/util/libgnunetutil.la
-
+
test_testing_topology_internat_SOURCES = \
test_testing_topology.c
test_testing_topology_internat_LDADD = \
test_testing_topology_erdos_renyi_LDADD = \
$(top_builddir)/src/testing/libgnunettesting.la \
$(top_builddir)/src/util/libgnunetutil.la
-
+
test_testing_topology_scale_free_SOURCES = \
test_testing_topology.c
test_testing_topology_scale_free_LDADD = \
test_testing_topology_none_LDADD = \
$(top_builddir)/src/testing/libgnunettesting.la \
$(top_builddir)/src/util/libgnunetutil.la
-
-
+
+
EXTRA_DIST = \
test_testing_data.conf \
test_testing_connect_peer1.conf \
test_testing_data_topology_blacklist.conf \
test_testing_data_topology_churn.conf \
test_testing_data_topology_none.conf
-
+
peers_left = NUM_PEERS;
pg = GNUNET_TESTING_daemons_start (cfg,
peers_left,
+ NUM_PEERS,
TIMEOUT,
NULL, NULL,
&my_cb, NULL, NULL, NULL, NULL);
peers_left = num_peers;
pg = GNUNET_TESTING_daemons_start (cfg,
+ peers_left,
peers_left,
TIMEOUT,
NULL,
static int ok;
+struct GNUNET_TIME_Relative connect_timeout;
+
+static unsigned long long connect_attempts;
+
static unsigned long long num_peers;
static unsigned int topology_connections;
GNUNET_TESTING_connect_topology (pg, connection_topology,
connect_topology_option,
connect_topology_option_modifier,
+ connect_timeout,
+ connect_attempts,
&topology_creation_finished, NULL);
#if VERBOSE > 1
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
&num_peers))
num_peers = DEFAULT_NUM_PEERS;
+ if (GNUNET_OK ==
+ GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "connect_timeout",
+ &temp_settle))
+ connect_timeout =
+ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, temp_settle);
+ else
+ {
+ GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", "testing", "connect_timeout");
+ return;
+ }
+
+
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "connect_attempts",
+ &connect_attempts))
+ {
+ GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", "testing", "connect_attempts");
+ return;
+ }
+
main_cfg = cfg;
peers_left = num_peers;
GNUNET_assert (num_peers > 0 && num_peers < (unsigned int) -1);
pg = GNUNET_TESTING_daemons_start (cfg,
peers_left,
+ peers_left / 2,
timeout,
&hostkey_callback, NULL,
&peers_started_callback, NULL,
static unsigned long long num_peers;
+struct GNUNET_TIME_Relative connect_timeout;
+
+static unsigned long long connect_attempts;
+
static unsigned int topology_connections;
static unsigned int total_connections;
GNUNET_TESTING_connect_topology (pg, connection_topology,
connect_topology_option,
connect_topology_option_modifier,
+ connect_timeout,
+ connect_attempts,
&topology_creation_finished, NULL);
#if VERBOSE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
settle_time =
GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, temp_settle);
+ if (GNUNET_OK ==
+ GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "connect_timeout",
+ &temp_settle))
+ connect_timeout =
+ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, temp_settle);
+ else
+ {
+ GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", "testing", "connect_timeout");
+ return;
+ }
+
+
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "connect_attempts",
+ &connect_attempts))
+ {
+ GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", "testing", "connect_attempts");
+ return;
+ }
+
if (GNUNET_SYSERR ==
GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "num_peers",
&num_peers))
GNUNET_assert (num_peers > 0 && num_peers < (unsigned int) -1);
pg = GNUNET_TESTING_daemons_start (cfg,
peers_left,
+ peers_left / 2,
GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_SECONDS,
SECONDS_PER_PEER_START * num_peers),
static int ok;
+struct GNUNET_TIME_Relative connect_timeout;
+
+static unsigned long long connect_attempts;
+
static unsigned long long num_peers;
static unsigned int total_connections;
GNUNET_TESTING_connect_topology (pg, connection_topology,
connect_topology_option,
connect_topology_option_modifier,
+ connect_timeout,
+ connect_attempts,
NULL, NULL);
#if VERBOSE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
unsigned long long connect_topology_num;
unsigned long long blacklist_topology_num;
unsigned long long connect_topology_option_num;
+ unsigned long long temp_connect;
char *connect_topology_option_modifier_string;
ok = 1;
&num_peers))
num_peers = DEFAULT_NUM_PEERS;
+ if (GNUNET_OK ==
+ GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "connect_timeout",
+ &temp_connect))
+ connect_timeout =
+ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, temp_connect);
+ else
+ {
+ GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", "testing", "connect_timeout");
+ return;
+ }
+
+
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "connect_attempts",
+ &connect_attempts))
+ {
+ GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", "testing", "connect_attempts");
+ return;
+ }
+
main_cfg = cfg;
GNUNET_assert (num_peers > 0 && num_peers < (unsigned int) -1);
"didn't start all daemons in reasonable amount of time!!!");
pg = GNUNET_TESTING_daemons_start (cfg,
- peers_left, TIMEOUT, &hostkey_callback,
+ peers_left, peers_left,
+ TIMEOUT, &hostkey_callback,
NULL, &peers_started_callback, NULL,
&topology_callback, NULL, NULL);
"didn't start all daemons in reasonable amount of time!!!");
pg = GNUNET_TESTING_daemons_start (cfg,
+ peers_left,
peers_left, TIMEOUT, NULL, NULL,
&peers_started_callback, NULL, NULL,
NULL, NULL);
*/
#define HIGH_PORT 56000
-#define MAX_OUTSTANDING_CONNECTIONS 200
-
/* Maximum time to delay connect attempt */
#define MAX_CONNECT_DELAY 300
#define MAX_CONCURRENT_HOSTKEYS 500
-#define MAX_CONCURRENT_STARTING 200
-
-#define MAX_CONCURRENT_SHUTDOWN 200
-
-#define CONNECT_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60)
-
-#define CONNECT_ATTEMPTS 12
-
/**
* Which list of peers do we need to modify?
*/
*/
struct ChurnContext
{
+ /**
+ * The peergroup we are dealing with.
+ */
+ struct GNUNET_TESTING_PeerGroup *pg;
+
/**
* Callback used to notify of churning finished
*/
struct ShutdownContext
{
+ struct GNUNET_TESTING_PeerGroup *pg;
/**
* Total peers to wait for
*/
struct ChurnRestartContext
{
+ /**
+ * PeerGroup that we are working with.
+ */
+ struct GNUNET_TESTING_PeerGroup *pg;
+
/**
* Number of restarts currently in flight.
*/
struct TopologyIterateContext
{
+ /**
+ * The peergroup we are working with.
+ */
+ struct GNUNET_TESTING_PeerGroup *pg;
+
/**
* Callback for notifying of two connected peers.
*/
struct StatsIterateContext
{
+ /**
+ * The peergroup that we are dealing with.
+ */
+ struct GNUNET_TESTING_PeerGroup *pg;
+
/**
* Continuation to call once all stats information has been retrieved.
*/
*/
unsigned int started;
+ /**
+ * Number of possible connections to peers
+ * at a time.
+ */
+ unsigned int max_outstanding_connections;
+
+ /**
+ * Number of connects we are waiting on, allows us to rate limit
+ * connect attempts.
+ */
+ unsigned int outstanding_connects;
+
/**
* Hostkeys loaded from a file.
*/
*/
struct ConnectTopologyContext *ct_ctx;
+ /**
+ * How long to try this connection before timing out.
+ */
+ struct GNUNET_TIME_Relative connect_timeout;
+
+ /**
+ * How many times to retry connecting the two peers.
+ */
+ unsigned int connect_attempts;
+
/**
* Whether this connection has been accounted for in the schedule_connect call.
*/
}
#endif
-/**
- * Number of connects we are waiting on, allows us to rate limit
- * connect attempts.
- */
-static int outstanding_connects;
-
/**
* Get a topology from a string input.
*
{
struct ConnectTopologyContext *ct_ctx = cls;
struct GNUNET_TESTING_PeerGroup *pg = ct_ctx->pg;
- outstanding_connects--;
+ pg->outstanding_connects--;
ct_ctx->remaining_connections--;
if (ct_ctx->remaining_connections == 0)
{
schedule_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct ConnectContext *connect_context = cls;
+ struct GNUNET_TESTING_PeerGroup *pg = connect_context->ct_ctx->pg;
if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN)
return;
- if (outstanding_connects > MAX_OUTSTANDING_CONNECTIONS)
+ if (pg->outstanding_connects > pg->max_outstanding_connections)
{
#if VERBOSE_TESTING > 2
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Creating connection, outstanding_connections is %d\n"),
outstanding_connects);
#endif
- outstanding_connects++;
+ pg->outstanding_connects++;
GNUNET_TESTING_daemons_connect (connect_context->first,
connect_context->second,
- CONNECT_TIMEOUT,
- CONNECT_ATTEMPTS,
+ connect_context->connect_timeout,
+ connect_context->connect_attempts,
&internal_connect_notify,
connect_context->ct_ctx);
GNUNET_free (connect_context);
* of each peer in the peer group
*
* @param pg the peer group we are dealing with
+ * @param connect_timeout how long try connecting two peers
+ * @param connect_attempts how many times (max) to attempt
* @param notify_callback callback to notify when finished
* @param notify_cls closure for notify callback
*
*/
static int
connect_topology (struct GNUNET_TESTING_PeerGroup *pg,
+ struct GNUNET_TIME_Relative connect_timeout,
+ unsigned int connect_attempts,
GNUNET_TESTING_NotifyCompletion notify_callback,
void *notify_cls)
{
connect_context->first = pg->peers[pg_iter].daemon;
connect_context->second = pg->peers[connection_iter->index].daemon;
connect_context->ct_ctx = ct_ctx;
+ connect_context->connect_timeout = connect_timeout;
+ connect_context->connect_attempts = connect_attempts;
GNUNET_SCHEDULER_add_now (&schedule_connect, connect_context);
connection_iter = connection_iter->next;
total++;
if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN)
return;
- if (topology_context->connected > MAX_OUTSTANDING_CONNECTIONS)
+ if (topology_context->connected > topology_context->pg->max_outstanding_connections)
{
#if VERBOSE_TESTING > 2
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
topology_context = GNUNET_malloc (sizeof (struct TopologyIterateContext));
topology_context->topology_cb = cb;
topology_context->cls = cls;
+ topology_context->pg = pg;
total_count = 0;
for (i = 0; i < pg->total; i++)
{
if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN)
return;
- if (stats_context->connected > MAX_OUTSTANDING_CONNECTIONS)
+ if (stats_context->connected > stats_context->pg->max_outstanding_connections)
{
#if VERBOSE_TESTING > 2
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
stats_context->cont = cont;
stats_context->proc = proc;
stats_context->cls = cls;
+ stats_context->pg = pg;
total_count = 0;
for (i = 0; i < pg->total; i++)
* @param topology which topology to connect the peers in
* @param options options for connecting the topology
* @param option_modifier modifier for options that take a parameter
+ * @param connect_timeout how long to wait before giving up on connecting
+ * two peers
+ * @param connect_attempts how many times to attempt to connect two peers
+ * over the connect_timeout duration
* @param notify_callback notification to be called once all connections completed
* @param notify_cls closure for notification callback
*
enum GNUNET_TESTING_Topology topology,
enum GNUNET_TESTING_TopologyOption options,
double option_modifier,
+ struct GNUNET_TIME_Relative connect_timeout,
+ unsigned int connect_attempts,
GNUNET_TESTING_NotifyCompletion
notify_callback, void *notify_cls)
{
break;
}
- return connect_topology (pg, notify_callback, notify_cls);
+ return connect_topology (pg, connect_timeout, connect_attempts, notify_callback, notify_cls);
}
/**
return;
}
- if (internal_context->peer->pg->starting < MAX_CONCURRENT_STARTING)
+ if (internal_context->peer->pg->starting < internal_context->peer->pg->max_outstanding_connections)
{
internal_context->peer->pg->starting++;
GNUNET_TESTING_daemon_continue_startup (internal_context->peer->daemon);
struct ChurnRestartContext *startup_ctx =
peer_restart_ctx->churn_restart_ctx;
- if (startup_ctx->outstanding > MAX_CONCURRENT_STARTING)
+ if (startup_ctx->outstanding > startup_ctx->pg->max_outstanding_connections)
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_MILLISECONDS, 100),
&schedule_churn_restart, peer_restart_ctx);
*
* @param cfg configuration template to use
* @param total number of daemons to start
+ * @param max_concurrent_connections for testing, how many peers can
+ * we connect to simultaneously
* @param timeout total time allowed for peers to start
* @param hostkey_callback function to call on each peers hostkey generation
* if NULL, peers will be started by this call, if non-null,
struct GNUNET_TESTING_PeerGroup *
GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
unsigned int total,
+ unsigned int max_concurrent_connections,
struct GNUNET_TIME_Relative timeout,
GNUNET_TESTING_NotifyHostkeyCreated
hostkey_callback, void *hostkey_cls,
pg->total = total;
pg->max_timeout = GNUNET_TIME_relative_to_absolute (timeout);
pg->peers = GNUNET_malloc (total * sizeof (struct PeerData));
+ pg->max_outstanding_connections = max_concurrent_connections;
if (NULL != hostnames)
{
off = 0;
{
struct PeerShutdownContext *peer_shutdown_ctx = cls;
struct ShutdownContext *shutdown_ctx;
-
+ struct ChurnContext *churn_ctx;
GNUNET_assert (peer_shutdown_ctx != NULL);
shutdown_ctx = peer_shutdown_ctx->shutdown_ctx;
GNUNET_assert (shutdown_ctx != NULL);
-
- if (shutdown_ctx->outstanding > MAX_CONCURRENT_SHUTDOWN)
+ churn_ctx = (struct ChurnContext *)shutdown_ctx->cb_cls;
+ if (shutdown_ctx->outstanding > churn_ctx->pg->max_outstanding_connections)
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_MILLISECONDS, 100),
&schedule_churn_shutdown_task,
churn_ctx->num_to_stop = voff;
churn_ctx->cb = cb;
churn_ctx->cb_cls = cb_cls;
+ churn_ctx->pg = pg;
for (i = 0; i < pg->total; i++)
{
churn_startup_ctx = GNUNET_malloc (sizeof (struct ChurnRestartContext));
churn_startup_ctx->churn_ctx = churn_ctx;
churn_startup_ctx->timeout = timeout;
+ churn_startup_ctx->pg = pg;
}
for (i = 0; i < von; i++)
{
shutdown_ctx = peer_shutdown_ctx->shutdown_ctx;
GNUNET_assert (shutdown_ctx != NULL);
- if (shutdown_ctx->outstanding > MAX_CONCURRENT_SHUTDOWN)
+ if (shutdown_ctx->outstanding > shutdown_ctx->pg->max_outstanding_connections)
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_MILLISECONDS, 100),
&schedule_shutdown_task, peer_shutdown_ctx);
shutdown_ctx->cb_cls = cb_cls;
shutdown_ctx->total_peers = pg->total;
shutdown_ctx->timeout = timeout;
+ shutdown_ctx->pg = pg;
/* shtudown_ctx->outstanding = 0; */
for (off = 0; off < pg->total; off++)
#endif
peers_left = NUM_PEERS;
pg = GNUNET_TESTING_daemons_start (cfg,
+ peers_left,
peers_left,
TIMEOUT,
NULL, NULL,