aboutsummaryrefslogtreecommitdiff
path: root/src/testing/testing_group.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing/testing_group.c')
-rw-r--r--src/testing/testing_group.c62
1 files changed, 61 insertions, 1 deletions
diff --git a/src/testing/testing_group.c b/src/testing/testing_group.c
index 622afcd63..1c9f1c4bb 100644
--- a/src/testing/testing_group.c
+++ b/src/testing/testing_group.c
@@ -242,6 +242,18 @@ struct InternalStartContext
242 * Hostname, where to start the peer 242 * Hostname, where to start the peer
243 */ 243 */
244 const char *hostname; 244 const char *hostname;
245
246 /**
247 * Username to use when connecting to the
248 * host via ssh.
249 */
250 const char *username;
251
252 /**
253 * Port to use for ssh.
254 */
255 uint16_t sshport;
256
245}; 257};
246 258
247/** 259/**
@@ -312,6 +324,16 @@ struct HostData
312 char *hostname; 324 char *hostname;
313 325
314 /** 326 /**
327 * SSH username to use when connecting to this host.
328 */
329 char *username;
330
331 /**
332 * SSH port to use when connecting to this host.
333 */
334 uint16_t sshport;
335
336 /**
315 * Lowest port that we have not yet used 337 * Lowest port that we have not yet used
316 * for GNUnet. 338 * for GNUnet.
317 */ 339 */
@@ -729,6 +751,7 @@ update_config (void *cls,
729 value = uval; 751 value = uval;
730 } 752 }
731 GNUNET_free(single_variable); 753 GNUNET_free(single_variable);
754 GNUNET_free(per_host_variable);
732 755
733 } 756 }
734 757
@@ -816,6 +839,7 @@ make_config (const struct GNUNET_CONFIGURATION_Handle *cfg,
816 GNUNET_CONFIGURATION_set_value_string(uc.ret, "transport-udp", "BINDTO", "127.0.0.1"); 839 GNUNET_CONFIGURATION_set_value_string(uc.ret, "transport-udp", "BINDTO", "127.0.0.1");
817 } 840 }
818 841
842
819 *port = (uint16_t) uc.nport; 843 *port = (uint16_t) uc.nport;
820 *upnum = uc.upnum; 844 *upnum = uc.upnum;
821 uc.fdnum++; 845 uc.fdnum++;
@@ -3312,6 +3336,8 @@ internal_start (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
3312 internal_context->peer->cfg, 3336 internal_context->peer->cfg,
3313 internal_context->timeout, 3337 internal_context->timeout,
3314 internal_context->hostname, 3338 internal_context->hostname,
3339 internal_context->username,
3340 internal_context->sshport,
3315 &internal_hostkey_callback, 3341 &internal_hostkey_callback,
3316 internal_context, 3342 internal_context,
3317 &internal_startup_callback, 3343 &internal_startup_callback,
@@ -3387,6 +3413,7 @@ GNUNET_TESTING_daemons_start (struct GNUNET_SCHEDULER_Handle *sched,
3387 char *start; 3413 char *start;
3388#endif 3414#endif
3389 const char *hostname; 3415 const char *hostname;
3416 const char *username;
3390 char *baseservicehome; 3417 char *baseservicehome;
3391 char *newservicehome; 3418 char *newservicehome;
3392 char *tmpdir; 3419 char *tmpdir;
@@ -3394,6 +3421,7 @@ GNUNET_TESTING_daemons_start (struct GNUNET_SCHEDULER_Handle *sched,
3394 unsigned int off; 3421 unsigned int off;
3395 unsigned int hostcnt; 3422 unsigned int hostcnt;
3396 uint16_t minport; 3423 uint16_t minport;
3424 uint16_t sshport;
3397 uint32_t upnum; 3425 uint32_t upnum;
3398 uint32_t fdnum; 3426 uint32_t fdnum;
3399 3427
@@ -3428,7 +3456,11 @@ GNUNET_TESTING_daemons_start (struct GNUNET_SCHEDULER_Handle *sched,
3428 while (hostpos != NULL) 3456 while (hostpos != NULL)
3429 { 3457 {
3430 pg->hosts[off].minport = LOW_PORT; 3458 pg->hosts[off].minport = LOW_PORT;
3431 pg->hosts[off++].hostname = GNUNET_strdup(hostpos->hostname); 3459 off++;
3460 pg->hosts[off].hostname = GNUNET_strdup(hostpos->hostname);
3461 if (hostpos->username != NULL)
3462 pg->hosts[off].username = GNUNET_strdup(hostpos->username);
3463 pg->hosts[off].sshport = hostpos->port;
3432 hostpos = hostpos->next; 3464 hostpos = hostpos->next;
3433 } 3465 }
3434 3466
@@ -3495,6 +3527,8 @@ GNUNET_TESTING_daemons_start (struct GNUNET_SCHEDULER_Handle *sched,
3495 if (hostcnt > 0) 3527 if (hostcnt > 0)
3496 { 3528 {
3497 hostname = pg->hosts[off % hostcnt].hostname; 3529 hostname = pg->hosts[off % hostcnt].hostname;
3530 username = pg->hosts[off % hostcnt].username;
3531 sshport = pg->hosts[off % hostcnt].sshport;
3498 pcfg = make_config (cfg, 3532 pcfg = make_config (cfg,
3499 &pg->hosts[off % hostcnt].minport, 3533 &pg->hosts[off % hostcnt].minport,
3500 &upnum, 3534 &upnum,
@@ -3503,6 +3537,8 @@ GNUNET_TESTING_daemons_start (struct GNUNET_SCHEDULER_Handle *sched,
3503 else 3537 else
3504 { 3538 {
3505 hostname = NULL; 3539 hostname = NULL;
3540 username = NULL;
3541 sshport = 0;
3506 pcfg = make_config (cfg, 3542 pcfg = make_config (cfg,
3507 &minport, 3543 &minport,
3508 &upnum, 3544 &upnum,
@@ -3548,6 +3584,8 @@ GNUNET_TESTING_daemons_start (struct GNUNET_SCHEDULER_Handle *sched,
3548 pg->peers[off].internal_context.peer = &pg->peers[off]; 3584 pg->peers[off].internal_context.peer = &pg->peers[off];
3549 pg->peers[off].internal_context.timeout = timeout; 3585 pg->peers[off].internal_context.timeout = timeout;
3550 pg->peers[off].internal_context.hostname = hostname; 3586 pg->peers[off].internal_context.hostname = hostname;
3587 pg->peers[off].internal_context.username = username;
3588 pg->peers[off].internal_context.sshport = sshport;
3551 pg->peers[off].internal_context.hostkey_callback = hostkey_callback; 3589 pg->peers[off].internal_context.hostkey_callback = hostkey_callback;
3552 pg->peers[off].internal_context.hostkey_cls = hostkey_cls; 3590 pg->peers[off].internal_context.hostkey_cls = hostkey_cls;
3553 pg->peers[off].internal_context.start_cb = cb; 3591 pg->peers[off].internal_context.start_cb = cb;
@@ -3740,6 +3778,28 @@ churn_start_callback (void *cls,
3740 } 3778 }
3741} 3779}
3742 3780
3781/**
3782 * Count the number of running peers.
3783 *
3784 * @param pg handle for the peer group
3785 *
3786 * @return the number of currently running peers in the peer group
3787 */
3788unsigned int
3789GNUNET_TESTING_daemons_running (struct GNUNET_TESTING_PeerGroup *pg)
3790{
3791 unsigned int i;
3792 unsigned int running = 0;
3793 for (i = 0; i < pg->total; i++)
3794 {
3795 if (pg->peers[i].daemon->running == GNUNET_YES)
3796 {
3797 GNUNET_assert(running != -1);
3798 running++;
3799 }
3800 }
3801 return running;
3802}
3743 3803
3744/** 3804/**
3745 * Simulate churn by stopping some peers (and possibly 3805 * Simulate churn by stopping some peers (and possibly