aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2012-09-30 08:25:05 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2012-09-30 08:25:05 +0000
commitdc7a13e69dce4d346ca958c89b09da05ef1dee03 (patch)
tree417dd347756db5ce9befb4383dc779a1630cc92f
parent1f2907c29a80941b0d5c026fbf11b9bc9a59921c (diff)
downloadgnunet-dc7a13e69dce4d346ca958c89b09da05ef1dee03.tar.gz
gnunet-dc7a13e69dce4d346ca958c89b09da05ef1dee03.zip
rename
-rw-r--r--src/testbed/Makefile.am10
-rw-r--r--src/testbed/test_testbed_api_3peers_3controllers.c (renamed from src/testbed/test_testbed_api_2peers_2controllers.c)133
2 files changed, 76 insertions, 67 deletions
diff --git a/src/testbed/Makefile.am b/src/testbed/Makefile.am
index 7889346f2..0432e8bf7 100644
--- a/src/testbed/Makefile.am
+++ b/src/testbed/Makefile.am
@@ -72,7 +72,7 @@ check_PROGRAMS = \
72 test_testbed_api_hosts \ 72 test_testbed_api_hosts \
73 test_testbed_api_controllerlink \ 73 test_testbed_api_controllerlink \
74 test_testbed_api_2peers_1controller \ 74 test_testbed_api_2peers_1controller \
75 test_testbed_api_2peers_2controllers \ 75 test_testbed_api_3peers_3controllers \
76 test_testbed_api \ 76 test_testbed_api \
77 test_testbed_api_operations \ 77 test_testbed_api_operations \
78 test_testbed_api_testbed_run \ 78 test_testbed_api_testbed_run \
@@ -85,7 +85,7 @@ if ENABLE_TEST_RUN
85 test_testbed_api \ 85 test_testbed_api \
86 test_testbed_api_hosts \ 86 test_testbed_api_hosts \
87 test_testbed_api_2peers_1controller \ 87 test_testbed_api_2peers_1controller \
88 test_testbed_api_2peers_2controllers \ 88 test_testbed_api_3peers_3controllers \
89 test_testbed_api_operations \ 89 test_testbed_api_operations \
90 test_gnunet_helper_testbed \ 90 test_gnunet_helper_testbed \
91 test_testbed_api_controllerlink \ 91 test_testbed_api_controllerlink \
@@ -115,9 +115,9 @@ test_testbed_api_2peers_1controller_LDADD = \
115 $(top_builddir)/src/testing/libgnunettesting.la \ 115 $(top_builddir)/src/testing/libgnunettesting.la \
116 libgnunettestbed.la 116 libgnunettestbed.la
117 117
118test_testbed_api_2peers_2controllers_SOURCES = \ 118test_testbed_api_3peers_3controllers_SOURCES = \
119 test_testbed_api_2peers_2controllers.c 119 test_testbed_api_3peers_3controllers.c
120test_testbed_api_2peers_2controllers_LDADD = \ 120test_testbed_api_3peers_3controllers_LDADD = \
121 $(top_builddir)/src/util/libgnunetutil.la \ 121 $(top_builddir)/src/util/libgnunetutil.la \
122 $(top_builddir)/src/testing/libgnunettesting.la \ 122 $(top_builddir)/src/testing/libgnunettesting.la \
123 libgnunettestbed.la 123 libgnunettestbed.la
diff --git a/src/testbed/test_testbed_api_2peers_2controllers.c b/src/testbed/test_testbed_api_3peers_3controllers.c
index 6ebf97356..37b402104 100644
--- a/src/testbed/test_testbed_api_2peers_2controllers.c
+++ b/src/testbed/test_testbed_api_3peers_3controllers.c
@@ -19,12 +19,23 @@
19 */ 19 */
20 20
21/** 21/**
22 * @file testbed/test_testbed_api_2peers_2controllers.c 22 * @file testbed/test_testbed_api_3peers_3controllers.c
23 * @brief testcases for the testbed api: 2 peers are configured, started and 23 * @brief testcases for the testbed api: 3 peers are configured, started and
24 * connected together. Each peer resides on its own controller 24 * connected together. Each peer resides on its own controller.
25 * @author Sree Harsha Totakura 25 * @author Sree Harsha Totakura
26 */ 26 */
27 27
28
29/**
30 * The testing architecture is:
31 * C1
32 * / \
33 * / \
34 * C2 == C3
35 * C1 is the master controller and C2, C3 are slave controllers. C2 links to C3
36 * laterally
37 */
38
28#include "platform.h" 39#include "platform.h"
29#include "gnunet_util_lib.h" 40#include "gnunet_util_lib.h"
30#include "gnunet_testing_lib-new.h" 41#include "gnunet_testing_lib-new.h"
@@ -224,12 +235,6 @@ enum Stage
224static enum Stage result; 235static enum Stage result;
225 236
226/** 237/**
227 * Can we do testing with 3 controllers?
228 */
229static int ok_3c;
230
231
232/**
233 * Shutdown nicely 238 * Shutdown nicely
234 * 239 *
235 * @param cls NULL 240 * @param cls NULL
@@ -246,15 +251,17 @@ do_shutdown (void *cls, const const struct GNUNET_SCHEDULER_TaskContext *tc)
246 if (NULL != controller1) 251 if (NULL != controller1)
247 GNUNET_TESTBED_controller_disconnect (controller1); 252 GNUNET_TESTBED_controller_disconnect (controller1);
248 if (NULL != controller2) 253 if (NULL != controller2)
249 GNUNET_TESTBED_controller_disconnect (controller2); 254 GNUNET_TESTBED_controller_disconnect (controller2);
250 GNUNET_CONFIGURATION_destroy (cfg); 255 GNUNET_CONFIGURATION_destroy (cfg);
251 if (NULL != cfg2) 256 if (NULL != cfg2)
252 GNUNET_CONFIGURATION_destroy (cfg2); 257 GNUNET_CONFIGURATION_destroy (cfg2);
253 if (NULL != cp1) 258 if (NULL != cp1)
254 GNUNET_TESTBED_controller_stop (cp1); 259 GNUNET_TESTBED_controller_stop (cp1);
255 GNUNET_TESTBED_host_destroy (host); 260 if (NULL != host)
256 GNUNET_TESTBED_host_destroy (neighbour1); 261 GNUNET_TESTBED_host_destroy (host);
257 if (GNUNET_YES == ok_3c) 262 if (NULL != neighbour1)
263 GNUNET_TESTBED_host_destroy (neighbour1);
264 if (NULL != neighbour2)
258 GNUNET_TESTBED_host_destroy (neighbour2); 265 GNUNET_TESTBED_host_destroy (neighbour2);
259} 266}
260 267
@@ -317,7 +324,7 @@ op_comp_cb (void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg)
317 GNUNET_assert (common_operation == op); 324 GNUNET_assert (common_operation == op);
318 switch(result) 325 switch(result)
319 { 326 {
320 case PEER2_STARTED: 327 case PEER3_STARTED:
321 GNUNET_assert (NULL == peer1.operation); 328 GNUNET_assert (NULL == peer1.operation);
322 GNUNET_assert (NULL == peer2.operation); 329 GNUNET_assert (NULL == peer2.operation);
323 GNUNET_assert (NULL != common_operation); 330 GNUNET_assert (NULL != common_operation);
@@ -339,6 +346,7 @@ op_comp_cb (void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg)
339 LOG (GNUNET_ERROR_TYPE_DEBUG, "Peers connected again\n"); 346 LOG (GNUNET_ERROR_TYPE_DEBUG, "Peers connected again\n");
340 peer1.operation = GNUNET_TESTBED_peer_stop (peer1.peer, NULL, NULL); 347 peer1.operation = GNUNET_TESTBED_peer_stop (peer1.peer, NULL, NULL);
341 peer2.operation = GNUNET_TESTBED_peer_stop (peer2.peer, NULL, NULL); 348 peer2.operation = GNUNET_TESTBED_peer_stop (peer2.peer, NULL, NULL);
349 peer3.operation = GNUNET_TESTBED_peer_stop (peer3.peer, NULL, NULL);
342 break; 350 break;
343 default: 351 default:
344 GNUNET_assert (0); 352 GNUNET_assert (0);
@@ -379,7 +387,6 @@ peer_create_cb (void *cls, struct GNUNET_TESTBED_Peer *peer, const char *emsg)
379 peer2.operation = GNUNET_TESTBED_peer_start (peer, NULL, NULL); 387 peer2.operation = GNUNET_TESTBED_peer_start (peer, NULL, NULL);
380 break; 388 break;
381 case CONTROLLER3_UP: 389 case CONTROLLER3_UP:
382 GNUNET_assert (GNUNET_YES == ok_3c);
383 GNUNET_assert (NULL != peer3.operation); 390 GNUNET_assert (NULL != peer3.operation);
384 GNUNET_assert (NULL != peer); 391 GNUNET_assert (NULL != peer);
385 GNUNET_assert (NULL == peer3.peer); 392 GNUNET_assert (NULL == peer3.peer);
@@ -464,7 +471,6 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
464 break; 471 break;
465 case PEER2_STARTED: 472 case PEER2_STARTED:
466 GNUNET_assert (NULL != common_operation); 473 GNUNET_assert (NULL != common_operation);
467 GNUNET_assert (GNUNET_YES == ok_3c);
468 GNUNET_TESTBED_operation_done (common_operation); 474 GNUNET_TESTBED_operation_done (common_operation);
469 common_operation = NULL; 475 common_operation = NULL;
470 result = CONTROLLER3_UP; 476 result = CONTROLLER3_UP;
@@ -497,22 +503,17 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
497 peer2.operation = NULL; 503 peer2.operation = NULL;
498 result = PEER2_STARTED; 504 result = PEER2_STARTED;
499 GNUNET_assert (NULL == common_operation); 505 GNUNET_assert (NULL == common_operation);
500 if (GNUNET_YES == ok_3c) 506 common_operation =
501 common_operation = 507 GNUNET_TESTBED_controller_link (controller1, neighbour2, NULL, cfg,
502 GNUNET_TESTBED_controller_link (controller1, neighbour2, NULL, cfg, 508 GNUNET_YES);
503 GNUNET_YES);
504 else
505 common_operation =
506 GNUNET_TESTBED_overlay_connect (NULL, &op_comp_cb, NULL, peer1.peer,
507 peer2.peer);
508 GNUNET_assert (NULL != common_operation); 509 GNUNET_assert (NULL != common_operation);
509 break; 510 break;
510 case PEER3_CREATED: 511 case PEER3_CREATED:
511 GNUNET_assert (event->details.peer_start.host == neighbour1); 512 GNUNET_assert (event->details.peer_start.host == neighbour2);
512 GNUNET_assert (GNUNET_YES == ok_3c);
513 peer3.is_running = GNUNET_YES; 513 peer3.is_running = GNUNET_YES;
514 GNUNET_TESTBED_operation_done (peer3.operation); 514 GNUNET_TESTBED_operation_done (peer3.operation);
515 peer3.operation = NULL; 515 peer3.operation = NULL;
516 result = PEER3_STARTED;
516 common_operation = 517 common_operation =
517 GNUNET_TESTBED_overlay_connect (NULL, &op_comp_cb, NULL, peer1.peer, 518 GNUNET_TESTBED_overlay_connect (NULL, &op_comp_cb, NULL, peer1.peer,
518 peer2.peer); 519 peer2.peer);
@@ -547,20 +548,20 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
547 result = PEERS_STOPPED; 548 result = PEERS_STOPPED;
548 peer1.operation = GNUNET_TESTBED_peer_destroy (peer1.peer); 549 peer1.operation = GNUNET_TESTBED_peer_destroy (peer1.peer);
549 peer2.operation = GNUNET_TESTBED_peer_destroy (peer2.peer); 550 peer2.operation = GNUNET_TESTBED_peer_destroy (peer2.peer);
550 if (GNUNET_YES == ok_3c) 551 peer3.operation = GNUNET_TESTBED_peer_destroy (peer3.peer);
551 peer3.operation = GNUNET_TESTBED_peer_destroy (peer3.peer);
552 } 552 }
553 break; 553 break;
554 case GNUNET_TESTBED_ET_CONNECT: 554 case GNUNET_TESTBED_ET_CONNECT:
555 switch (result) 555 switch (result)
556 { 556 {
557 case PEER2_STARTED: 557 case PEER3_STARTED:
558 case PEERS_CONNECTED: 558 case PEERS_CONNECTED:
559 GNUNET_assert (NULL == peer1.operation); 559 GNUNET_assert (NULL == peer1.operation);
560 GNUNET_assert (NULL == peer2.operation); 560 GNUNET_assert (NULL == peer2.operation);
561 GNUNET_assert (NULL == peer3.operation);
561 GNUNET_assert (NULL != common_operation); 562 GNUNET_assert (NULL != common_operation);
562 GNUNET_assert ((event->details.peer_connect.peer1 == peer1.peer) && 563 /* GNUNET_assert ((event->details.peer_connect.peer1 == peer1.peer) && */
563 (event->details.peer_connect.peer2 == peer2.peer)); 564 /* (event->details.peer_connect.peer2 == peer2.peer)); */
564 break; 565 break;
565 default: 566 default:
566 GNUNET_assert (0); 567 GNUNET_assert (0);
@@ -581,22 +582,18 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
581static void 582static void
582registration_comp (void *cls, const char *emsg) 583registration_comp (void *cls, const char *emsg)
583{ 584{
585 reg_handle = NULL;
584 if (cls == neighbour1) 586 if (cls == neighbour1)
585 { 587 {
586 reg_handle = NULL;
587 if (GNUNET_YES != ok_3c)
588 goto create_peer;
589 neighbour2 = GNUNET_TESTBED_host_create ("127.0.0.1", NULL, 0); 588 neighbour2 = GNUNET_TESTBED_host_create ("127.0.0.1", NULL, 0);
590 GNUNET_assert (NULL != neighbour2); 589 GNUNET_assert (NULL != neighbour2);
591 reg_handle = 590 reg_handle =
592 GNUNET_TESTBED_register_host (controller1, neighbour1, &registration_comp, 591 GNUNET_TESTBED_register_host (controller1, neighbour2, &registration_comp,
593 neighbour2); 592 neighbour2);
594 GNUNET_assert (NULL != reg_handle); 593 GNUNET_assert (NULL != reg_handle);
595 return; 594 return;
596 } 595 }
597 GNUNET_assert (cls == neighbour2); 596 GNUNET_assert (cls == neighbour2);
598
599 create_peer:
600 peer1.operation = 597 peer1.operation =
601 GNUNET_TESTBED_peer_create (controller1, host, cfg, &peer_create_cb, 598 GNUNET_TESTBED_peer_create (controller1, host, cfg, &peer_create_cb,
602 &peer1); 599 &peer1);
@@ -646,7 +643,6 @@ status_cb (void *cls, const struct GNUNET_CONFIGURATION_Handle *config, int stat
646} 643}
647 644
648 645
649
650/** 646/**
651 * Main run function. 647 * Main run function.
652 * 648 *
@@ -672,26 +668,23 @@ run (void *cls, char *const *args, const char *cfgfile,
672 668
673 669
674/** 670/**
675 * Main function 671 * Function to check if password-less SSH logins to given ip work
672 *
673 * @param host_str numeric representation of the host's ip
674 * @return GNUNET_YES if password-less SSH login to the given host works;
675 * GNUNET_NO if not
676 */ 676 */
677int 677static int
678main (int argc, char **argv) 678check_ssh (char *host_str)
679{ 679{
680 int ret;
681
682 char *const argv2[] = { "test_testbed_api_2peers_2controllers",
683 "-c", "test_testbed_api.conf",
684 NULL
685 };
686 struct GNUNET_GETOPT_CommandLineOption options[] = {
687 GNUNET_GETOPT_OPTION_END
688 };
689 char *const remote_args[] = { 680 char *const remote_args[] = {
690 "ssh", "-o", "BatchMode=yes", "127.0.0.1", "echo", "SSH", "works", NULL 681 "ssh", "-o", "BatchMode=yes", "-o", "CheckHostIP=no", "-q",
682 host_str, "echo", "SSH", "works", NULL
691 }; 683 };
692 struct GNUNET_OS_Process *auxp; 684 struct GNUNET_OS_Process *auxp;
693 enum GNUNET_OS_ProcessStatusType type; 685 enum GNUNET_OS_ProcessStatusType type;
694 unsigned long code; 686 unsigned long code;
687 int ret;
695 688
696 auxp = 689 auxp =
697 GNUNET_OS_start_process_vap (GNUNET_NO, GNUNET_OS_INHERIT_STD_ALL, NULL, 690 GNUNET_OS_start_process_vap (GNUNET_NO, GNUNET_OS_INHERIT_STD_ALL, NULL,
@@ -706,27 +699,43 @@ main (int argc, char **argv)
706 while (GNUNET_NO == ret); 699 while (GNUNET_NO == ret);
707 (void) GNUNET_OS_process_wait (auxp); 700 (void) GNUNET_OS_process_wait (auxp);
708 GNUNET_OS_process_destroy (auxp); 701 GNUNET_OS_process_destroy (auxp);
709 if (0 != code) 702 return (0 != code) ? GNUNET_NO : GNUNET_YES;
710 goto error_exit; 703}
711 704
712 ok_3c = GNUNET_NO; 705
713 /* FIXME: use GNUNET_OS_network_interface_list() to get the list of interfaces 706/**
714 */ 707 * Main function
715 708 */
709int
710main (int argc, char **argv)
711{
712 char *const argv2[] = { "test_testbed_api_3peers_3controllers",
713 "-c", "test_testbed_api.conf",
714 NULL
715 };
716 struct GNUNET_GETOPT_CommandLineOption options[] = {
717 GNUNET_GETOPT_OPTION_END
718 };
719 int ret;
720
721 //GNUNET_OS_network_interfaces_list (&interface_processor, NULL);
722
723 if (GNUNET_YES != check_ssh ("127.0.0.1"))
724 goto error_exit;
716 result = INIT; 725 result = INIT;
717 ret = 726 ret =
718 GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2, 727 GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2,
719 "test_testbed_api_2peers_2controllers", "nohelp", 728 "test_testbed_api_3peers_3controllers", "nohelp",
720 options, &run, NULL); 729 options, &run, NULL);
721 if ((GNUNET_OK != ret) || (SUCCESS != result)) 730 if ((GNUNET_OK != ret) || (SUCCESS != result))
722 return 1; 731 return 1;
723 return 0; 732 return 0;
724 733
725 error_exit: 734 error_exit:
726 (void) printf ("Unable to run the test as this system is not configured " 735 (void) PRINTF ("Unable to run the test as this system is not configured "
727 "to use password less SSH logins to localhost.\n" 736 "to use password less SSH logins to localhost.\n"
728 "Marking test as successful\n"); 737 "Marking test as successful\n");
729 return 0; 738 return 0;
730} 739}
731 740
732/* end of test_testbed_api_2peers_2controllers.c */ 741/* end of test_testbed_api_3peers_3controllers.c */