diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2012-10-04 12:28:03 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2012-10-04 12:28:03 +0000 |
commit | e8a76652365d6c1bd6bd4903b2b4ba72447c961b (patch) | |
tree | 80875e75c967e86d88fbe4e15126239652f74dfc /src/testbed/test_testbed_api_3peers_3controllers.c | |
parent | d368600afb96d024105aa9d0ea8523b597a9099a (diff) | |
download | gnunet-e8a76652365d6c1bd6bd4903b2b4ba72447c961b.tar.gz gnunet-e8a76652365d6c1bd6bd4903b2b4ba72447c961b.zip |
test case for overlay connect via lateral links
Diffstat (limited to 'src/testbed/test_testbed_api_3peers_3controllers.c')
-rw-r--r-- | src/testbed/test_testbed_api_3peers_3controllers.c | 112 |
1 files changed, 80 insertions, 32 deletions
diff --git a/src/testbed/test_testbed_api_3peers_3controllers.c b/src/testbed/test_testbed_api_3peers_3controllers.c index 2c04529b2..fd64d987b 100644 --- a/src/testbed/test_testbed_api_3peers_3controllers.c +++ b/src/testbed/test_testbed_api_3peers_3controllers.c | |||
@@ -28,12 +28,18 @@ | |||
28 | 28 | ||
29 | /** | 29 | /** |
30 | * The testing architecture is: | 30 | * The testing architecture is: |
31 | * C1 | 31 | * A |
32 | * / \ | 32 | * / \ |
33 | * / \ | 33 | * / \ |
34 | * C2 == C3 | 34 | * B === C |
35 | * C1 is the master controller and C2, C3 are slave controllers. C2 links to C3 | 35 | * A is the master controller and B, C are slave controllers. B links to C |
36 | * laterally | 36 | * laterally. |
37 | * Peers are mapped to controllers in the following relations: | ||
38 | * Peer Controller | ||
39 | * 1 A | ||
40 | * 2 B | ||
41 | * 3 C | ||
42 | * | ||
37 | */ | 43 | */ |
38 | 44 | ||
39 | #include "platform.h" | 45 | #include "platform.h" |
@@ -107,11 +113,6 @@ static struct GNUNET_TESTBED_HostRegistrationHandle *reg_handle; | |||
107 | static struct GNUNET_TESTBED_Controller *controller1; | 113 | static struct GNUNET_TESTBED_Controller *controller1; |
108 | 114 | ||
109 | /** | 115 | /** |
110 | * The controller handle of another controller | ||
111 | */ | ||
112 | static struct GNUNET_TESTBED_Controller *controller2; | ||
113 | |||
114 | /** | ||
115 | * peer 1 | 116 | * peer 1 |
116 | */ | 117 | */ |
117 | static struct PeerContext peer1; | 118 | static struct PeerContext peer1; |
@@ -132,8 +133,8 @@ static struct PeerContext peer3; | |||
132 | static struct GNUNET_CONFIGURATION_Handle *cfg; | 133 | static struct GNUNET_CONFIGURATION_Handle *cfg; |
133 | 134 | ||
134 | /** | 135 | /** |
135 | * Handle to controller2 configuration, used to establish lateral link from | 136 | * Handle to slave controller C's configuration, used to establish lateral link from |
136 | * controller 1 | 137 | * master controller |
137 | */ | 138 | */ |
138 | static struct GNUNET_CONFIGURATION_Handle *cfg2; | 139 | static struct GNUNET_CONFIGURATION_Handle *cfg2; |
139 | 140 | ||
@@ -209,9 +210,24 @@ enum Stage | |||
209 | PEER3_STARTED, | 210 | PEER3_STARTED, |
210 | 211 | ||
211 | /** | 212 | /** |
212 | * peers are connected | 213 | * peer1 and peer2 are connected |
214 | */ | ||
215 | PEERS_1_2_CONNECTED, | ||
216 | |||
217 | /** | ||
218 | * Configuration of C has been acquired | ||
219 | */ | ||
220 | CONTROLLER_CFG_ACQUIRED, | ||
221 | |||
222 | /** | ||
223 | * Linking controller B to C laterally | ||
213 | */ | 224 | */ |
214 | PEERS_CONNECTED, | 225 | CONTROLLERS_LATERALLY_LINKED, |
226 | |||
227 | /** | ||
228 | * peer2 and peer3 are connected | ||
229 | */ | ||
230 | PEERS_2_3_CONNECTED, | ||
215 | 231 | ||
216 | /** | 232 | /** |
217 | * Peers are connected once again (this should not fail as they are already connected) | 233 | * Peers are connected once again (this should not fail as they are already connected) |
@@ -250,8 +266,6 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
250 | GNUNET_TESTBED_cancel_registration (reg_handle); | 266 | GNUNET_TESTBED_cancel_registration (reg_handle); |
251 | if (NULL != controller1) | 267 | if (NULL != controller1) |
252 | GNUNET_TESTBED_controller_disconnect (controller1); | 268 | GNUNET_TESTBED_controller_disconnect (controller1); |
253 | if (NULL != controller2) | ||
254 | GNUNET_TESTBED_controller_disconnect (controller2); | ||
255 | GNUNET_CONFIGURATION_destroy (cfg); | 269 | GNUNET_CONFIGURATION_destroy (cfg); |
256 | if (NULL != cfg2) | 270 | if (NULL != cfg2) |
257 | GNUNET_CONFIGURATION_destroy (cfg2); | 271 | GNUNET_CONFIGURATION_destroy (cfg2); |
@@ -330,13 +344,12 @@ op_comp_cb (void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg) | |||
330 | GNUNET_assert (NULL != common_operation); | 344 | GNUNET_assert (NULL != common_operation); |
331 | GNUNET_TESTBED_operation_done (common_operation); | 345 | GNUNET_TESTBED_operation_done (common_operation); |
332 | common_operation = NULL; | 346 | common_operation = NULL; |
333 | result = PEERS_CONNECTED; | 347 | result = PEERS_1_2_CONNECTED; |
334 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Peers connected\n"); | 348 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Peers connected\n"); |
335 | delayed_connect_task = | 349 | common_operation = |
336 | GNUNET_SCHEDULER_add_delayed (TIME_REL_SECS (3), | 350 | GNUNET_TESTBED_get_slave_config (NULL, controller1, neighbour2); |
337 | &do_delayed_connect, NULL); | ||
338 | break; | 351 | break; |
339 | case PEERS_CONNECTED: | 352 | case PEERS_2_3_CONNECTED: |
340 | GNUNET_assert (NULL == peer1.operation); | 353 | GNUNET_assert (NULL == peer1.operation); |
341 | GNUNET_assert (NULL == peer2.operation); | 354 | GNUNET_assert (NULL == peer2.operation); |
342 | GNUNET_assert (NULL != common_operation); | 355 | GNUNET_assert (NULL != common_operation); |
@@ -348,6 +361,14 @@ op_comp_cb (void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg) | |||
348 | peer2.operation = GNUNET_TESTBED_peer_stop (peer2.peer, NULL, NULL); | 361 | peer2.operation = GNUNET_TESTBED_peer_stop (peer2.peer, NULL, NULL); |
349 | peer3.operation = GNUNET_TESTBED_peer_stop (peer3.peer, NULL, NULL); | 362 | peer3.operation = GNUNET_TESTBED_peer_stop (peer3.peer, NULL, NULL); |
350 | break; | 363 | break; |
364 | case CONTROLLERS_LATERALLY_LINKED: | ||
365 | GNUNET_TESTBED_operation_done (common_operation); | ||
366 | common_operation = NULL; | ||
367 | result = PEERS_2_3_CONNECTED; | ||
368 | delayed_connect_task = | ||
369 | GNUNET_SCHEDULER_add_delayed (TIME_REL_SECS (3), | ||
370 | &do_delayed_connect, NULL); | ||
371 | break; | ||
351 | default: | 372 | default: |
352 | GNUNET_assert (0); | 373 | GNUNET_assert (0); |
353 | } | 374 | } |
@@ -429,10 +450,10 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event) | |||
429 | case GNUNET_TESTBED_ET_OPERATION_FINISHED: | 450 | case GNUNET_TESTBED_ET_OPERATION_FINISHED: |
430 | GNUNET_assert (NULL == event->details.operation_finished.op_cls); | 451 | GNUNET_assert (NULL == event->details.operation_finished.op_cls); |
431 | GNUNET_assert (NULL == event->details.operation_finished.emsg); | 452 | GNUNET_assert (NULL == event->details.operation_finished.emsg); |
432 | GNUNET_assert (NULL == event->details.operation_finished.generic); | ||
433 | switch (result) | 453 | switch (result) |
434 | { | 454 | { |
435 | case PEERS_STOPPED: | 455 | case PEERS_STOPPED: |
456 | GNUNET_assert (NULL == event->details.operation_finished.generic); | ||
436 | if (event->details.operation_finished.operation == peer1.operation) | 457 | if (event->details.operation_finished.operation == peer1.operation) |
437 | { | 458 | { |
438 | GNUNET_TESTBED_operation_done (peer1.operation); | 459 | GNUNET_TESTBED_operation_done (peer1.operation); |
@@ -460,6 +481,7 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event) | |||
460 | } | 481 | } |
461 | break; | 482 | break; |
462 | case PEER1_STARTED: | 483 | case PEER1_STARTED: |
484 | GNUNET_assert (NULL == event->details.operation_finished.generic); | ||
463 | GNUNET_assert (NULL != common_operation); | 485 | GNUNET_assert (NULL != common_operation); |
464 | GNUNET_TESTBED_operation_done (common_operation); | 486 | GNUNET_TESTBED_operation_done (common_operation); |
465 | common_operation = NULL; | 487 | common_operation = NULL; |
@@ -470,6 +492,7 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event) | |||
470 | GNUNET_assert (NULL != peer2.operation); | 492 | GNUNET_assert (NULL != peer2.operation); |
471 | break; | 493 | break; |
472 | case PEER2_STARTED: | 494 | case PEER2_STARTED: |
495 | GNUNET_assert (NULL == event->details.operation_finished.generic); | ||
473 | GNUNET_assert (NULL != common_operation); | 496 | GNUNET_assert (NULL != common_operation); |
474 | GNUNET_TESTBED_operation_done (common_operation); | 497 | GNUNET_TESTBED_operation_done (common_operation); |
475 | common_operation = NULL; | 498 | common_operation = NULL; |
@@ -479,6 +502,24 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event) | |||
479 | &peer_create_cb, NULL); | 502 | &peer_create_cb, NULL); |
480 | GNUNET_assert (NULL != peer3.operation); | 503 | GNUNET_assert (NULL != peer3.operation); |
481 | break; | 504 | break; |
505 | case PEERS_1_2_CONNECTED: | ||
506 | GNUNET_assert (NULL != event->details.operation_finished.generic); | ||
507 | cfg2 = | ||
508 | GNUNET_CONFIGURATION_dup (event->details.operation_finished.generic); | ||
509 | GNUNET_TESTBED_operation_done (common_operation); | ||
510 | result = CONTROLLER_CFG_ACQUIRED; | ||
511 | common_operation = | ||
512 | GNUNET_TESTBED_controller_link (controller1, neighbour2, neighbour1, | ||
513 | cfg2, GNUNET_NO); | ||
514 | break; | ||
515 | case CONTROLLER_CFG_ACQUIRED: | ||
516 | GNUNET_assert (NULL == event->details.operation_finished.generic); | ||
517 | GNUNET_TESTBED_operation_done (common_operation); | ||
518 | result = CONTROLLERS_LATERALLY_LINKED; | ||
519 | common_operation = | ||
520 | GNUNET_TESTBED_overlay_connect (NULL, &op_comp_cb, NULL, peer2.peer, | ||
521 | peer3.peer); | ||
522 | break; | ||
482 | default: | 523 | default: |
483 | GNUNET_assert (0); | 524 | GNUNET_assert (0); |
484 | } | 525 | } |
@@ -552,16 +593,25 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event) | |||
552 | } | 593 | } |
553 | break; | 594 | break; |
554 | case GNUNET_TESTBED_ET_CONNECT: | 595 | case GNUNET_TESTBED_ET_CONNECT: |
596 | GNUNET_assert (NULL == peer1.operation); | ||
597 | GNUNET_assert (NULL == peer2.operation); | ||
598 | GNUNET_assert (NULL == peer3.operation); | ||
555 | switch (result) | 599 | switch (result) |
556 | { | 600 | { |
557 | case PEER3_STARTED: | 601 | case PEER3_STARTED: |
558 | case PEERS_CONNECTED: | ||
559 | GNUNET_assert (NULL == peer1.operation); | ||
560 | GNUNET_assert (NULL == peer2.operation); | ||
561 | GNUNET_assert (NULL == peer3.operation); | ||
562 | GNUNET_assert (NULL != common_operation); | 602 | GNUNET_assert (NULL != common_operation); |
563 | /* GNUNET_assert ((event->details.peer_connect.peer1 == peer1.peer) && */ | 603 | GNUNET_assert ((event->details.peer_connect.peer1 == peer1.peer) && |
564 | /* (event->details.peer_connect.peer2 == peer2.peer)); */ | 604 | (event->details.peer_connect.peer2 == peer2.peer)); |
605 | break; | ||
606 | case PEERS_2_3_CONNECTED: | ||
607 | GNUNET_assert (NULL != common_operation); | ||
608 | GNUNET_assert ((event->details.peer_connect.peer1 == peer1.peer) && | ||
609 | (event->details.peer_connect.peer2 == peer2.peer)); | ||
610 | break; | ||
611 | case CONTROLLERS_LATERALLY_LINKED: | ||
612 | GNUNET_assert (NULL != common_operation); | ||
613 | GNUNET_assert ((event->details.peer_connect.peer1 == peer2.peer) && | ||
614 | (event->details.peer_connect.peer2 == peer3.peer)); | ||
565 | break; | 615 | break; |
566 | default: | 616 | default: |
567 | GNUNET_assert (0); | 617 | GNUNET_assert (0); |
@@ -718,8 +768,6 @@ main (int argc, char **argv) | |||
718 | }; | 768 | }; |
719 | int ret; | 769 | int ret; |
720 | 770 | ||
721 | //GNUNET_OS_network_interfaces_list (&interface_processor, NULL); | ||
722 | |||
723 | if (GNUNET_YES != check_ssh ("127.0.0.1")) | 771 | if (GNUNET_YES != check_ssh ("127.0.0.1")) |
724 | goto error_exit; | 772 | goto error_exit; |
725 | result = INIT; | 773 | result = INIT; |