aboutsummaryrefslogtreecommitdiff
path: root/src/testing/testing_group.c
diff options
context:
space:
mode:
authorNathan S. Evans <evans@in.tum.de>2011-07-25 14:27:33 +0000
committerNathan S. Evans <evans@in.tum.de>2011-07-25 14:27:33 +0000
commit08f1114108442793fb00dc443ed6b94b81c3b443 (patch)
treeec282bc9ef6963f2a9d6ff21e5b9f3db395bbd8a /src/testing/testing_group.c
parent91d1bc4750c36d7f3e996f483fe4bee7c242eb45 (diff)
downloadgnunet-08f1114108442793fb00dc443ed6b94b81c3b443.tar.gz
gnunet-08f1114108442793fb00dc443ed6b94b81c3b443.zip
churn a service
Diffstat (limited to 'src/testing/testing_group.c')
-rw-r--r--src/testing/testing_group.c116
1 files changed, 89 insertions, 27 deletions
diff --git a/src/testing/testing_group.c b/src/testing/testing_group.c
index e7be22a8a..b9ccf69f2 100644
--- a/src/testing/testing_group.c
+++ b/src/testing/testing_group.c
@@ -103,6 +103,12 @@ struct ChurnContext
103 struct GNUNET_TESTING_PeerGroup *pg; 103 struct GNUNET_TESTING_PeerGroup *pg;
104 104
105 /** 105 /**
106 * Name of the service to churn on/off, NULL
107 * to churn entire peer.
108 */
109 char *service;
110
111 /**
106 * Callback used to notify of churning finished 112 * Callback used to notify of churning finished
107 */ 113 */
108 GNUNET_TESTING_NotifyCompletion cb; 114 GNUNET_TESTING_NotifyCompletion cb;
@@ -5576,9 +5582,15 @@ schedule_churn_restart(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
5576 &schedule_churn_restart, peer_restart_ctx); 5582 &schedule_churn_restart, peer_restart_ctx);
5577 else 5583 else
5578 { 5584 {
5579 GNUNET_TESTING_daemon_start_stopped (peer_restart_ctx->daemon, 5585 if (startup_ctx->churn_ctx->service != NULL)
5580 startup_ctx->timeout, 5586 GNUNET_TESTING_daemon_start_stopped_service (peer_restart_ctx->daemon,
5581 &churn_start_callback, startup_ctx); 5587 startup_ctx->churn_ctx->service,
5588 startup_ctx->timeout,
5589 &churn_start_callback, startup_ctx);
5590 else
5591 GNUNET_TESTING_daemon_start_stopped (peer_restart_ctx->daemon,
5592 startup_ctx->timeout,
5593 &churn_start_callback, startup_ctx);
5582 GNUNET_free (peer_restart_ctx); 5594 GNUNET_free (peer_restart_ctx);
5583 } 5595 }
5584} 5596}
@@ -6336,9 +6348,15 @@ schedule_churn_shutdown_task(void *cls,
6336 else 6348 else
6337 { 6349 {
6338 shutdown_ctx->outstanding++; 6350 shutdown_ctx->outstanding++;
6339 GNUNET_TESTING_daemon_stop (peer_shutdown_ctx->daemon, 6351 if (churn_ctx->service != NULL)
6340 shutdown_ctx->timeout, shutdown_ctx->cb, 6352 GNUNET_TESTING_daemon_stop_service (peer_shutdown_ctx->daemon,
6341 shutdown_ctx, GNUNET_NO, GNUNET_YES); 6353 churn_ctx->service,
6354 shutdown_ctx->timeout, shutdown_ctx->cb,
6355 shutdown_ctx);
6356 else
6357 GNUNET_TESTING_daemon_stop (peer_shutdown_ctx->daemon,
6358 shutdown_ctx->timeout, shutdown_ctx->cb,
6359 shutdown_ctx, GNUNET_NO, GNUNET_YES);
6342 GNUNET_free (peer_shutdown_ctx); 6360 GNUNET_free (peer_shutdown_ctx);
6343 } 6361 }
6344} 6362}
@@ -6355,6 +6373,7 @@ schedule_churn_shutdown_task(void *cls,
6355 * completion. 6373 * completion.
6356 * 6374 *
6357 * @param pg handle for the peer group 6375 * @param pg handle for the peer group
6376 * @param service the service to churn off/on, NULL to churn peer
6358 * @param voff number of peers that should go offline 6377 * @param voff number of peers that should go offline
6359 * @param von number of peers that should come back online; 6378 * @param von number of peers that should come back online;
6360 * must be zero on first call (since "testbed_start" 6379 * must be zero on first call (since "testbed_start"
@@ -6366,6 +6385,7 @@ schedule_churn_shutdown_task(void *cls,
6366 */ 6385 */
6367void 6386void
6368GNUNET_TESTING_daemons_churn(struct GNUNET_TESTING_PeerGroup *pg, 6387GNUNET_TESTING_daemons_churn(struct GNUNET_TESTING_PeerGroup *pg,
6388 char *service,
6369 unsigned int voff, unsigned int von, 6389 unsigned int voff, unsigned int von,
6370 struct GNUNET_TIME_Relative timeout, 6390 struct GNUNET_TIME_Relative timeout,
6371 GNUNET_TESTING_NotifyCompletion cb, void *cb_cls) 6391 GNUNET_TESTING_NotifyCompletion cb, void *cb_cls)
@@ -6385,6 +6405,7 @@ GNUNET_TESTING_daemons_churn(struct GNUNET_TESTING_PeerGroup *pg,
6385 unsigned int *stopped_arr; 6405 unsigned int *stopped_arr;
6386 unsigned int *running_permute; 6406 unsigned int *running_permute;
6387 unsigned int *stopped_permute; 6407 unsigned int *stopped_permute;
6408 char *pos;
6388 6409
6389 shutdown_ctx = NULL; 6410 shutdown_ctx = NULL;
6390 peer_shutdown_ctx = NULL; 6411 peer_shutdown_ctx = NULL;
@@ -6402,15 +6423,39 @@ GNUNET_TESTING_daemons_churn(struct GNUNET_TESTING_PeerGroup *pg,
6402 6423
6403 for (i = 0; i < pg->total; i++) 6424 for (i = 0; i < pg->total; i++)
6404 { 6425 {
6405 if (pg->peers[i].daemon->running == GNUNET_YES) 6426 if (service == NULL)
6406 { 6427 {
6407 GNUNET_assert (running != -1); 6428 if (pg->peers[i].daemon->running == GNUNET_YES)
6408 running++; 6429 {
6430 GNUNET_assert (running != -1);
6431 running++;
6432 }
6433 else
6434 {
6435 GNUNET_assert (stopped != -1);
6436 stopped++;
6437 }
6409 } 6438 }
6410 else 6439 else
6411 { 6440 {
6412 GNUNET_assert (stopped != -1); 6441 /* FIXME: make churned services a list! */
6413 stopped++; 6442 pos = pg->peers[i].daemon->churned_services;
6443 /* FIXME: while (pos != NULL) */
6444 if (pos != NULL)
6445 {
6446 if (0 == strcasecmp(pos, service))
6447 {
6448 GNUNET_assert (stopped != -1);
6449 stopped++;
6450 break;
6451 }
6452 /* FIXME: pos = pos->next; */
6453 }
6454 if (pos == NULL)
6455 {
6456 GNUNET_assert (running != -1);
6457 running++;
6458 }
6414 } 6459 }
6415 } 6460 }
6416 6461
@@ -6463,17 +6508,43 @@ GNUNET_TESTING_daemons_churn(struct GNUNET_TESTING_PeerGroup *pg,
6463 6508
6464 for (i = 0; i < pg->total; i++) 6509 for (i = 0; i < pg->total; i++)
6465 { 6510 {
6466 if (pg->peers[i].daemon->running == GNUNET_YES) 6511 if (service == NULL)
6467 { 6512 {
6468 GNUNET_assert ((running_arr != NULL) && (total_running > running)); 6513 if (pg->peers[i].daemon->running == GNUNET_YES)
6469 running_arr[running] = i; 6514 {
6470 running++; 6515 GNUNET_assert ((running_arr != NULL) && (total_running > running));
6516 running_arr[running] = i;
6517 running++;
6518 }
6519 else
6520 {
6521 GNUNET_assert ((stopped_arr != NULL) && (total_stopped > stopped));
6522 stopped_arr[stopped] = i;
6523 stopped++;
6524 }
6471 } 6525 }
6472 else 6526 else
6473 { 6527 {
6474 GNUNET_assert ((stopped_arr != NULL) && (total_stopped > stopped)); 6528 /* FIXME: make churned services a list! */
6475 stopped_arr[stopped] = i; 6529 pos = pg->peers[i].daemon->churned_services;
6476 stopped++; 6530 /* FIXME: while (pos != NULL) */
6531 if (pos != NULL)
6532 {
6533 if (0 == strcasecmp(pos, service))
6534 {
6535 GNUNET_assert ((stopped_arr != NULL) && (total_stopped > stopped));
6536 stopped_arr[stopped] = i;
6537 stopped++;
6538 break;
6539 }
6540 /* FIXME: pos = pos->next; */
6541 }
6542 if (pos == NULL)
6543 {
6544 GNUNET_assert ((running_arr != NULL) && (total_running > running));
6545 running_arr[running] = i;
6546 running++;
6547 }
6477 } 6548 }
6478 } 6549 }
6479 6550
@@ -6500,12 +6571,6 @@ GNUNET_TESTING_daemons_churn(struct GNUNET_TESTING_PeerGroup *pg,
6500 peer_shutdown_ctx->shutdown_ctx = shutdown_ctx; 6571 peer_shutdown_ctx->shutdown_ctx = shutdown_ctx;
6501 GNUNET_SCHEDULER_add_now (&schedule_churn_shutdown_task, 6572 GNUNET_SCHEDULER_add_now (&schedule_churn_shutdown_task,
6502 peer_shutdown_ctx); 6573 peer_shutdown_ctx);
6503
6504 /*
6505 GNUNET_TESTING_daemon_stop (pg->peers[running_arr[running_permute[i]]].daemon,
6506 timeout,
6507 &churn_stop_callback, churn_ctx,
6508 GNUNET_NO, GNUNET_YES); */
6509 } 6574 }
6510 6575
6511 GNUNET_assert (stopped >= von); 6576 GNUNET_assert (stopped >= von);
@@ -6528,9 +6593,6 @@ GNUNET_TESTING_daemons_churn(struct GNUNET_TESTING_PeerGroup *pg,
6528 peer_restart_ctx->daemon 6593 peer_restart_ctx->daemon
6529 = pg->peers[stopped_arr[stopped_permute[i]]].daemon; 6594 = pg->peers[stopped_arr[stopped_permute[i]]].daemon;
6530 GNUNET_SCHEDULER_add_now (&schedule_churn_restart, peer_restart_ctx); 6595 GNUNET_SCHEDULER_add_now (&schedule_churn_restart, peer_restart_ctx);
6531 /*
6532 GNUNET_TESTING_daemon_start_stopped(pg->peers[stopped_arr[stopped_permute[i]]].daemon,
6533 timeout, &churn_start_callback, churn_ctx); */
6534 } 6596 }
6535 6597
6536 GNUNET_free_non_null (running_arr); 6598 GNUNET_free_non_null (running_arr);