From 66dd280cc10564606ebba1eb17b9e4c171ca83fb Mon Sep 17 00:00:00 2001 From: "Nathan S. Evans" Date: Tue, 15 Feb 2011 11:56:03 +0000 Subject: [PATCH] change to allow number of outstanding ssh connections to be set separately --- src/testing/test_testing_topology.c | 52 ++++++++++++++++++--------- src/testing/testing_group.c | 54 +++++++++++++++++++---------- 2 files changed, 71 insertions(+), 35 deletions(-) diff --git a/src/testing/test_testing_topology.c b/src/testing/test_testing_topology.c index 0461af89c..66540c078 100644 --- a/src/testing/test_testing_topology.c +++ b/src/testing/test_testing_topology.c @@ -26,7 +26,9 @@ #include "gnunet_core_service.h" #include "gnunet_os_lib.h" -#define VERBOSE GNUNET_YES +#define VERBOSE GNUNET_NO + +#define PROGRESS_BARS GNUNET_YES #define DELAY_FOR_LOGGING GNUNET_NO @@ -359,7 +361,7 @@ process_mtype (void *cls, if (pos->uid != ntohl (msg->uid)) return GNUNET_OK; -#if VERBOSE +#if PROGRESS_BARS if ((total_messages_received) % modnum == 0) { if (total_messages_received == 0) @@ -390,7 +392,7 @@ process_mtype (void *cls, if (total_messages_received == expected_messages) { -#if VERBOSE +#if PROGRESS_BARS fprintf (stdout, "100%%]\n"); #endif GNUNET_SCHEDULER_cancel (die_task); @@ -691,7 +693,7 @@ topology_callback (void *cls, struct TestMessageContext *temp_context; if (emsg == NULL) { -#if VERBOSE +#if PROGRESS_BARS if ((total_connections) % modnum == 0) { if (total_connections == 0) @@ -738,7 +740,7 @@ topology_callback (void *cls, if (total_connections == expected_connections) { -#if VERBOSE +#if PROGRESS_BARS fprintf (stdout, "100%%]\n"); #endif #if VERBOSE @@ -748,6 +750,10 @@ topology_callback (void *cls, #endif modnum = expected_messages / 4; dotnum = (expected_messages / 50) + 1; + if (modnum == 0) + modnum = 1; + if (dotnum == 0) + dotnum = 1; GNUNET_SCHEDULER_cancel (die_task); die_task = GNUNET_SCHEDULER_NO_TASK; #if DELAY_FOR_LOGGING @@ -764,7 +770,7 @@ topology_callback (void *cls, GNUNET_SCHEDULER_add_delayed (settle_time, &send_test_messages, test_messages); #endif -#if VERBOSE +#if PROGRESS_BARS fprintf (stdout, "Test message progress: ["); #endif @@ -821,8 +827,8 @@ connect_topology () connect_timeout, connect_attempts, &topology_creation_finished, NULL); -#if VERBOSE - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, +#if PROGRESS_BARS + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Have %d expected connections\n", expected_connections); #endif } @@ -836,12 +842,18 @@ connect_topology () return; } - die_task = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, + die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply + (GNUNET_TIME_UNIT_SECONDS, + SECONDS_PER_PEER_START * num_peers), &end_badly, "from connect topology (timeout)"); modnum = expected_connections / 4; dotnum = (expected_connections / 50) + 1; -#if VERBOSE + if (modnum == 0) + modnum = 1; + if (dotnum == 0) + dotnum = 1; +#if PROGRESS_BARS fprintf (stdout, "Peer connection progress: ["); #endif } @@ -854,7 +866,7 @@ create_topology () (pg, topology, blacklist_topology, blacklist_transports) != GNUNET_SYSERR) { -#if VERBOSE +#if PROGRESS_BARS GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Topology set up, now starting peers!\n"); fprintf (stdout, "Daemon start progress ["); @@ -869,7 +881,9 @@ create_topology () "from create topology (bad return)"); } GNUNET_SCHEDULER_cancel (die_task); - die_task = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, + die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply + (GNUNET_TIME_UNIT_SECONDS, + SECONDS_PER_PEER_START * num_peers), &end_badly, "from continue startup (timeout)"); } @@ -892,7 +906,7 @@ peers_started_callback (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Started daemon %llu out of %llu\n", (num_peers - peers_left) + 1, num_peers); #endif -#if VERBOSE +#if PROGRESS_BARS if ((num_peers - peers_left) % modnum == 0) { if (num_peers - peers_left == 0) @@ -912,7 +926,7 @@ peers_started_callback (void *cls, peers_left--; if (peers_left == 0) { -#if VERBOSE +#if PROGRESS_BARS fprintf (stdout, "100%%]\n"); #endif #if VERBOSE @@ -965,7 +979,7 @@ hostkey_callback (void *cls, num_peers - peers_left, num_peers, GNUNET_i2s (id)); #endif -#if VERBOSE +#if PROGRESS_BARS if ((num_peers - peers_left) % modnum == 0) { if (num_peers - peers_left == 0) @@ -985,7 +999,7 @@ hostkey_callback (void *cls, peers_left--; if (peers_left == 0) { -#if VERBOSE +#if PROGRESS_BARS fprintf (stdout, "100%%]\n"); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All %d hostkeys created, now creating topology!\n", @@ -1148,7 +1162,11 @@ run (void *cls, peers_left = num_peers; modnum = num_peers / 4; dotnum = (num_peers / 50) + 1; -#if VERBOSE + if (modnum == 0) + modnum = 1; + if (dotnum == 0) + dotnum = 1; +#if PROGRESS_BARS fprintf (stdout, "Hostkey generation progress: ["); #endif /* Set up a task to end testing if peer start fails */ diff --git a/src/testing/testing_group.c b/src/testing/testing_group.c index a35a63a75..b4420115d 100644 --- a/src/testing/testing_group.c +++ b/src/testing/testing_group.c @@ -56,8 +56,6 @@ /* Maximum time to delay connect attempt */ #define MAX_CONNECT_DELAY 300 -#define MAX_CONCURRENT_HOSTKEYS 500 - /** * Which list of peers do we need to modify? */ @@ -655,6 +653,11 @@ struct GNUNET_TESTING_PeerGroup */ unsigned int max_outstanding_connections; + /** + * Number of ssh connections to peers (max). + */ + unsigned int max_concurrent_ssh; + /** * Number of connects we are waiting on, allows us to rate limit * connect attempts. @@ -1125,6 +1128,7 @@ update_config (void *cls, * out of "*port" numbers, return NULL. * * @param cfg template configuration + * @param off the current peer offset * @param port port numbers to use, update to reflect * port numbers that were used * @param upnum number to make unix domain socket names unique @@ -1136,6 +1140,7 @@ update_config (void *cls, */ static struct GNUNET_CONFIGURATION_Handle * make_config (const struct GNUNET_CONFIGURATION_Handle *cfg, + uint32_t off, uint16_t * port, uint32_t * upnum, const char *hostname, uint32_t * fdnum) { @@ -1143,6 +1148,7 @@ make_config (const struct GNUNET_CONFIGURATION_Handle *cfg, uint16_t orig; char *control_host; char *allowed_hosts; + unsigned long long temp_port; orig = *port; uc.nport = *port; @@ -1171,20 +1177,28 @@ make_config (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_CONFIGURATION_set_value_string (uc.ret, "core", "ACCEPT_FROM", allowed_hosts); - GNUNET_CONFIGURATION_set_value_string (uc.ret, "core", "UNIXPATH", - ""); GNUNET_CONFIGURATION_set_value_string (uc.ret, "transport", "ACCEPT_FROM", allowed_hosts); - GNUNET_CONFIGURATION_set_value_string (uc.ret, "transport", "UNIXPATH", - ""); GNUNET_CONFIGURATION_set_value_string (uc.ret, "dht", "ACCEPT_FROM", allowed_hosts); - GNUNET_CONFIGURATION_set_value_string (uc.ret, "dht", "UNIXPATH", - ""); GNUNET_CONFIGURATION_set_value_string (uc.ret, "statistics", "ACCEPT_FROM", allowed_hosts); - GNUNET_CONFIGURATION_set_value_string (uc.ret, "statistics", "UNIXPATH", - ""); + + GNUNET_CONFIGURATION_set_value_string (uc.ret, "core", "UNIXPATH", ""); + GNUNET_CONFIGURATION_set_value_string (uc.ret, "transport", "UNIXPATH", ""); + GNUNET_CONFIGURATION_set_value_string (uc.ret, "dht", "UNIXPATH", ""); + GNUNET_CONFIGURATION_set_value_string (uc.ret, "statistics", "UNIXPATH", ""); + + + if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number(uc.orig, "statistics", "port", &temp_port) && + (temp_port != 0) && + (GNUNET_YES != + GNUNET_CONFIGURATION_get_value_yesno (uc.orig, "testing", + "single_statistics_per_host"))) + { + GNUNET_CONFIGURATION_set_value_number (uc.ret, "statistics", "port", temp_port + off); + } + GNUNET_free_non_null (control_host); GNUNET_free (allowed_hosts); } @@ -4614,7 +4628,7 @@ internal_continue_startup (void *cls, return; } - if (internal_context->peer->pg->starting < internal_context->peer->pg->max_outstanding_connections) + if (internal_context->peer->pg->starting < internal_context->peer->pg->max_concurrent_ssh) { internal_context->peer->pg->starting++; GNUNET_TESTING_daemon_continue_startup (internal_context->peer->daemon); @@ -4697,7 +4711,7 @@ schedule_churn_restart (void *cls, struct ChurnRestartContext *startup_ctx = peer_restart_ctx->churn_restart_ctx; - if (startup_ctx->outstanding > startup_ctx->pg->max_outstanding_connections) + if (startup_ctx->outstanding > startup_ctx->pg->max_concurrent_ssh) GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 100), &schedule_churn_restart, peer_restart_ctx); @@ -4721,7 +4735,7 @@ internal_start (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) return; } - if (internal_context->peer->pg->starting < MAX_CONCURRENT_HOSTKEYS) + if (internal_context->peer->pg->starting < internal_context->peer->pg->max_concurrent_ssh) { internal_context->peer->pg->starting++; internal_context->peer->daemon = @@ -4774,7 +4788,9 @@ GNUNET_TESTING_daemons_continue_startup (struct GNUNET_TESTING_PeerGroup *pg) * @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 +* we connect to simultaneously + * @param max_concurrent_ssh when starting with ssh, how many ssh + * connections will we allow at once (based on remote hosts allowed!) * @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, @@ -4794,6 +4810,7 @@ struct GNUNET_TESTING_PeerGroup * GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg, unsigned int total, unsigned int max_concurrent_connections, + unsigned int max_concurrent_ssh, struct GNUNET_TIME_Relative timeout, GNUNET_TESTING_NotifyHostkeyCreated hostkey_callback, void *hostkey_cls, @@ -4847,6 +4864,7 @@ GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg, pg->max_timeout = GNUNET_TIME_relative_to_absolute (timeout); pg->peers = GNUNET_malloc (total * sizeof (struct PeerData)); pg->max_outstanding_connections = max_concurrent_connections; + pg->max_concurrent_ssh = max_concurrent_ssh; if (NULL != hostnames) { off = 0; @@ -4935,7 +4953,6 @@ GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg, &baseservicehome)); for (i = 0; i < pg->num_hosts; i++) { - if (NULL != pg->hosts[i].username) GNUNET_asprintf (&arg, "%s@%s", pg->hosts[i].username, pg->hosts[i].hostname); else @@ -5003,6 +5020,7 @@ GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg, username = pg->hosts[off % hostcnt].username; sshport = pg->hosts[off % hostcnt].sshport; pcfg = make_config (cfg, + off, &pg->hosts[off % hostcnt].minport, &upnum, hostname, &fdnum); } @@ -5011,7 +5029,7 @@ GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg, hostname = NULL; username = NULL; sshport = 0; - pcfg = make_config (cfg, &minport, &upnum, hostname, &fdnum); + pcfg = make_config (cfg, off, &minport, &upnum, hostname, &fdnum); } if (NULL == pcfg) @@ -5252,7 +5270,7 @@ schedule_churn_shutdown_task (void *cls, shutdown_ctx = peer_shutdown_ctx->shutdown_ctx; GNUNET_assert (shutdown_ctx != NULL); churn_ctx = (struct ChurnContext *)shutdown_ctx->cb_cls; - if (shutdown_ctx->outstanding > churn_ctx->pg->max_outstanding_connections) + if (shutdown_ctx->outstanding > churn_ctx->pg->max_concurrent_ssh) GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 100), &schedule_churn_shutdown_task, @@ -5602,7 +5620,7 @@ schedule_shutdown_task (void *cls, shutdown_ctx = peer_shutdown_ctx->shutdown_ctx; GNUNET_assert (shutdown_ctx != NULL); - if (shutdown_ctx->outstanding > shutdown_ctx->pg->max_outstanding_connections) + if (shutdown_ctx->outstanding > shutdown_ctx->pg->max_concurrent_ssh) GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 100), &schedule_shutdown_task, peer_shutdown_ctx); -- 2.25.1