diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2013-03-15 09:37:18 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2013-03-15 09:37:18 +0000 |
commit | b92fefc699df523441c3b24d6d59cdc016af6bac (patch) | |
tree | 6710e2c32918af8d0f780f655acd5a1727f1fffa | |
parent | fef4792abec19870be63c7922ada0ebd4397a7c1 (diff) | |
download | gnunet-b92fefc699df523441c3b24d6d59cdc016af6bac.tar.gz gnunet-b92fefc699df523441c3b24d6d59cdc016af6bac.zip |
Call TestMaster callback upon timeout set through configuration
fixes #2833
-rw-r--r-- | src/include/gnunet_testbed_service.h | 19 | ||||
-rw-r--r-- | src/testbed/Makefile.am | 9 | ||||
-rw-r--r-- | src/testbed/test_testbed_api_test_timeout.c | 115 | ||||
-rw-r--r-- | src/testbed/test_testbed_api_test_timeout.conf | 92 | ||||
-rw-r--r-- | src/testbed/testbed.conf.in | 32 | ||||
-rw-r--r-- | src/testbed/testbed_api_testbed.c | 72 |
6 files changed, 317 insertions, 22 deletions
diff --git a/src/include/gnunet_testbed_service.h b/src/include/gnunet_testbed_service.h index 8ede5ee44..e41901ff1 100644 --- a/src/include/gnunet_testbed_service.h +++ b/src/include/gnunet_testbed_service.h | |||
@@ -1389,7 +1389,8 @@ GNUNET_TESTBED_get_statistics (unsigned int num_peers, | |||
1389 | * | 1389 | * |
1390 | * @param cls closure | 1390 | * @param cls closure |
1391 | * @param num_peers number of peers in 'peers' | 1391 | * @param num_peers number of peers in 'peers' |
1392 | * @param peers handle to peers run in the testbed | 1392 | * @param peers handle to peers run in the testbed. NULL upon timeout (see |
1393 | * GNUNET_TESTBED_test_run()). | ||
1393 | */ | 1394 | */ |
1394 | typedef void (*GNUNET_TESTBED_TestMaster)(void *cls, | 1395 | typedef void (*GNUNET_TESTBED_TestMaster)(void *cls, |
1395 | unsigned int num_peers, | 1396 | unsigned int num_peers, |
@@ -1404,6 +1405,10 @@ typedef void (*GNUNET_TESTBED_TestMaster)(void *cls, | |||
1404 | * (with possible options given in "UNDERLAY_XXX" and/or | 1405 | * (with possible options given in "UNDERLAY_XXX" and/or |
1405 | * "OVERLAY_XXX"). | 1406 | * "OVERLAY_XXX"). |
1406 | * | 1407 | * |
1408 | * The test_master callback will be called once the testbed setup is finished or | ||
1409 | * upon a timeout. This timeout is given through the configuration file by | ||
1410 | * setting the option "SETUP_TIMEOUT" in "[TESTBED]" section. | ||
1411 | * | ||
1407 | * The testbed is to be terminated using a call to | 1412 | * The testbed is to be terminated using a call to |
1408 | * "GNUNET_SCHEDULER_shutdown". | 1413 | * "GNUNET_SCHEDULER_shutdown". |
1409 | * | 1414 | * |
@@ -1421,7 +1426,8 @@ typedef void (*GNUNET_TESTBED_TestMaster)(void *cls, | |||
1421 | * set in the event_mask as this is the only way get access to the | 1426 | * set in the event_mask as this is the only way get access to the |
1422 | * handle of each peer | 1427 | * handle of each peer |
1423 | * @param cc_cls closure for cc | 1428 | * @param cc_cls closure for cc |
1424 | * @param test_master this callback will be called once the test is ready | 1429 | * @param test_master this callback will be called once the test is ready or |
1430 | * upon timeout | ||
1425 | * @param test_master_cls closure for 'test_master'. | 1431 | * @param test_master_cls closure for 'test_master'. |
1426 | */ | 1432 | */ |
1427 | void | 1433 | void |
@@ -1439,9 +1445,13 @@ GNUNET_TESTBED_run (const char *host_filename, | |||
1439 | * Convenience method for running a "simple" test on the local system | 1445 | * Convenience method for running a "simple" test on the local system |
1440 | * with a single call from 'main'. Underlay and overlay topology are | 1446 | * with a single call from 'main'. Underlay and overlay topology are |
1441 | * configured using the "UNDERLAY" and "OVERLAY" options in the | 1447 | * configured using the "UNDERLAY" and "OVERLAY" options in the |
1442 | * "[testbed]" section of the configuration (with possible options | 1448 | * "[TESTBED]" section of the configuration (with possible options |
1443 | * given in "UNDERLAY_XXX" and/or "OVERLAY_XXX"). | 1449 | * given in "UNDERLAY_XXX" and/or "OVERLAY_XXX"). |
1444 | * | 1450 | * |
1451 | * The test_master callback will be called once the testbed setup is finished or | ||
1452 | * upon a timeout. This timeout is given through the configuration file by | ||
1453 | * setting the option "SETUP_TIMEOUT" in "[TESTBED]" section. | ||
1454 | * | ||
1445 | * The test is to be terminated using a call to | 1455 | * The test is to be terminated using a call to |
1446 | * "GNUNET_SCHEDULER_shutdown". If starting the test fails, | 1456 | * "GNUNET_SCHEDULER_shutdown". If starting the test fails, |
1447 | * the program is stopped without 'master' ever being run. | 1457 | * the program is stopped without 'master' ever being run. |
@@ -1464,7 +1474,8 @@ GNUNET_TESTBED_run (const char *host_filename, | |||
1464 | * set in the event_mask as this is the only way get access to the | 1474 | * set in the event_mask as this is the only way get access to the |
1465 | * handle of each peer | 1475 | * handle of each peer |
1466 | * @param cc_cls closure for cc | 1476 | * @param cc_cls closure for cc |
1467 | * @param test_master this callback will be called once the test is ready | 1477 | * @param test_master this callback will be called once the test is ready or |
1478 | * upon timeout | ||
1468 | * @param test_master_cls closure for 'test_master'. | 1479 | * @param test_master_cls closure for 'test_master'. |
1469 | * @return GNUNET_SYSERR on error, GNUNET_OK on success | 1480 | * @return GNUNET_SYSERR on error, GNUNET_OK on success |
1470 | */ | 1481 | */ |
diff --git a/src/testbed/Makefile.am b/src/testbed/Makefile.am index bc703ebcb..8b5cfbd9f 100644 --- a/src/testbed/Makefile.am +++ b/src/testbed/Makefile.am | |||
@@ -109,6 +109,7 @@ check_PROGRAMS = \ | |||
109 | test_testbed_api_operations \ | 109 | test_testbed_api_operations \ |
110 | test_testbed_api_testbed_run \ | 110 | test_testbed_api_testbed_run \ |
111 | test_testbed_api_test \ | 111 | test_testbed_api_test \ |
112 | test_testbed_api_test_timeout \ | ||
112 | test_gnunet_helper_testbed \ | 113 | test_gnunet_helper_testbed \ |
113 | test_testbed_api_topology \ | 114 | test_testbed_api_topology \ |
114 | test_testbed_api_topology_clique \ | 115 | test_testbed_api_topology_clique \ |
@@ -135,6 +136,7 @@ if ENABLE_TEST_RUN | |||
135 | test_testbed_api_3peers_3controllers \ | 136 | test_testbed_api_3peers_3controllers \ |
136 | test_testbed_api_testbed_run \ | 137 | test_testbed_api_testbed_run \ |
137 | test_testbed_api_test \ | 138 | test_testbed_api_test \ |
139 | test_testbed_api_test_timeout \ | ||
138 | test_testbed_api_statistics \ | 140 | test_testbed_api_statistics \ |
139 | test_testbed_api_topology \ | 141 | test_testbed_api_topology \ |
140 | test_testbed_api_topology_clique \ | 142 | test_testbed_api_topology_clique \ |
@@ -207,6 +209,12 @@ test_testbed_api_test_LDADD = \ | |||
207 | $(top_builddir)/src/util/libgnunetutil.la \ | 209 | $(top_builddir)/src/util/libgnunetutil.la \ |
208 | libgnunettestbed.la | 210 | libgnunettestbed.la |
209 | 211 | ||
212 | test_testbed_api_test_timeout_SOURCES = \ | ||
213 | test_testbed_api_test_timeout.c | ||
214 | test_testbed_api_test_timeout_LDADD = \ | ||
215 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
216 | libgnunettestbed.la | ||
217 | |||
210 | test_testbed_api_topology_SOURCES = \ | 218 | test_testbed_api_topology_SOURCES = \ |
211 | test_testbed_api_topology.c | 219 | test_testbed_api_topology.c |
212 | test_testbed_api_topology_LDADD = \ | 220 | test_testbed_api_topology_LDADD = \ |
@@ -288,6 +296,7 @@ test_testbed_api_statistics_LDADD = \ | |||
288 | 296 | ||
289 | EXTRA_DIST = \ | 297 | EXTRA_DIST = \ |
290 | test_testbed_api.conf \ | 298 | test_testbed_api.conf \ |
299 | test_testbed_api_test_timeout.conf \ | ||
291 | test_testbed_api_testbed_run_topologyring.conf \ | 300 | test_testbed_api_testbed_run_topologyring.conf \ |
292 | test_testbed_api_testbed_run_topologyclique.conf \ | 301 | test_testbed_api_testbed_run_topologyclique.conf \ |
293 | test_testbed_api_testbed_run_topologyline.conf \ | 302 | test_testbed_api_testbed_run_topologyline.conf \ |
diff --git a/src/testbed/test_testbed_api_test_timeout.c b/src/testbed/test_testbed_api_test_timeout.c new file mode 100644 index 000000000..537837536 --- /dev/null +++ b/src/testbed/test_testbed_api_test_timeout.c | |||
@@ -0,0 +1,115 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | (C) 2008--2012 Christian Grothoff (and other contributing authors) | ||
4 | |||
5 | GNUnet is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 3, or (at your | ||
8 | option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file src/testbed/test_testbed_api_test.c | ||
23 | * @brief testing cases for testing notications via test master callback upon | ||
24 | * timeout while setting up testbed using functions | ||
25 | * GNUNET_TESTBED_test_run() | ||
26 | * @author Sree Harsha Totakura <sreeharsha@totakura.in> | ||
27 | */ | ||
28 | |||
29 | #include "platform.h" | ||
30 | #include "gnunet_common.h" | ||
31 | #include "gnunet_testbed_service.h" | ||
32 | |||
33 | |||
34 | /** | ||
35 | * Generic logging shortcut | ||
36 | */ | ||
37 | #define LOG(kind,...) \ | ||
38 | GNUNET_log (kind, __VA_ARGS__) | ||
39 | |||
40 | /** | ||
41 | * Number of peers we want to start | ||
42 | */ | ||
43 | #define NUM_PEERS 25 | ||
44 | |||
45 | /** | ||
46 | * Testing result | ||
47 | */ | ||
48 | static int result; | ||
49 | |||
50 | |||
51 | /** | ||
52 | * shortcut to exit during failure | ||
53 | */ | ||
54 | #define FAIL_TEST(cond) do { \ | ||
55 | if (!(cond)) { \ | ||
56 | GNUNET_break(0); \ | ||
57 | GNUNET_SCHEDULER_shutdown (); \ | ||
58 | return; \ | ||
59 | } \ | ||
60 | } while (0) | ||
61 | |||
62 | |||
63 | /** | ||
64 | * Controller event callback | ||
65 | * | ||
66 | * @param cls NULL | ||
67 | * @param event the controller event | ||
68 | */ | ||
69 | static void | ||
70 | controller_event_cb (void *cls, | ||
71 | const struct GNUNET_TESTBED_EventInformation *event) | ||
72 | { | ||
73 | FAIL_TEST (0); | ||
74 | } | ||
75 | |||
76 | |||
77 | /** | ||
78 | * Signature of a main function for a testcase. | ||
79 | * | ||
80 | * @param cls closure | ||
81 | * @param num_peers number of peers in 'peers' | ||
82 | * @param peers handle to peers run in the testbed | ||
83 | */ | ||
84 | static void | ||
85 | test_master (void *cls, unsigned int num_peers, | ||
86 | struct GNUNET_TESTBED_Peer **peers_) | ||
87 | { | ||
88 | FAIL_TEST (NULL == cls); | ||
89 | FAIL_TEST (0 == num_peers); | ||
90 | FAIL_TEST (NULL == peers_); | ||
91 | result = GNUNET_OK; | ||
92 | GNUNET_SCHEDULER_shutdown (); | ||
93 | } | ||
94 | |||
95 | |||
96 | /** | ||
97 | * Main function | ||
98 | */ | ||
99 | int | ||
100 | main (int argc, char **argv) | ||
101 | { | ||
102 | uint64_t event_mask; | ||
103 | |||
104 | result = GNUNET_SYSERR; | ||
105 | event_mask = 0; | ||
106 | (void) GNUNET_TESTBED_test_run ("test_testbed_api_test", | ||
107 | "test_testbed_api_test_timeout.conf", NUM_PEERS, | ||
108 | event_mask, &controller_event_cb, NULL, | ||
109 | &test_master, NULL); | ||
110 | if (GNUNET_OK != result) | ||
111 | return 1; | ||
112 | return 0; | ||
113 | } | ||
114 | |||
115 | /* end of test_testbed_api_test.c */ | ||
diff --git a/src/testbed/test_testbed_api_test_timeout.conf b/src/testbed/test_testbed_api_test_timeout.conf new file mode 100644 index 000000000..074de3d83 --- /dev/null +++ b/src/testbed/test_testbed_api_test_timeout.conf | |||
@@ -0,0 +1,92 @@ | |||
1 | [testbed] | ||
2 | AUTOSTART = NO | ||
3 | PORT = 12113 | ||
4 | ACCEPT_FROM = 127.0.0.1; | ||
5 | HOSTNAME = localhost | ||
6 | OVERLAY_TOPOLOGY = CLIQUE | ||
7 | SETUP_TIMEOUT = 2 s | ||
8 | #PREFIX = xterm -geometry 100x85 -T peer1 -e libtool --mode=execute gdb --args | ||
9 | |||
10 | [fs] | ||
11 | AUTOSTART = NO | ||
12 | |||
13 | [resolver] | ||
14 | AUTOSTART = NO | ||
15 | |||
16 | [mesh] | ||
17 | AUTOSTART = NO | ||
18 | |||
19 | [dht] | ||
20 | AUTOSTART = NO | ||
21 | |||
22 | [block] | ||
23 | plugins = dht test | ||
24 | |||
25 | [dhtcache] | ||
26 | QUOTA = 1 MB | ||
27 | DATABASE = sqlite | ||
28 | |||
29 | [transport] | ||
30 | PLUGINS = tcp | ||
31 | ACCEPT_FROM6 = ::1; | ||
32 | ACCEPT_FROM = 127.0.0.1; | ||
33 | NEIGHBOUR_LIMIT = 50 | ||
34 | PORT = 12365 | ||
35 | |||
36 | [ats] | ||
37 | WAN_QUOTA_OUT = 3932160 | ||
38 | WAN_QUOTA_IN = 3932160 | ||
39 | |||
40 | [core] | ||
41 | PORT = 12092 | ||
42 | AUTOSTART = YES | ||
43 | USE_EPHEMERAL_KEYS = NO | ||
44 | |||
45 | [arm] | ||
46 | DEFAULTSERVICES = core transport | ||
47 | PORT = 12366 | ||
48 | |||
49 | [transport-tcp] | ||
50 | TIMEOUT = 300 s | ||
51 | PORT = 12368 | ||
52 | |||
53 | [TESTING] | ||
54 | NUM_PEERS = 5 | ||
55 | WEAKRANDOM = YES | ||
56 | HOSTKEYSFILE = ../../contrib/testing_hostkeys.dat | ||
57 | MAX_CONCURRENT_SSH = 10 | ||
58 | USE_PROGRESSBARS = YES | ||
59 | PEERGROUP_TIMEOUT = 2400 s | ||
60 | |||
61 | [gnunetd] | ||
62 | HOSTKEY = $SERVICEHOME/.hostkey | ||
63 | |||
64 | [PATHS] | ||
65 | SERVICEHOME = /tmp/test-testbed/ | ||
66 | |||
67 | [dns] | ||
68 | AUTOSTART = NO | ||
69 | |||
70 | [nse] | ||
71 | AUTOSTART = NO | ||
72 | |||
73 | [vpn] | ||
74 | AUTOSTART = NO | ||
75 | |||
76 | [nat] | ||
77 | RETURN_LOCAL_ADDRESSES = YES | ||
78 | |||
79 | [gns-helper-service-w32] | ||
80 | AUTOSTART = NO | ||
81 | |||
82 | [consensus] | ||
83 | AUTOSTART = NO | ||
84 | |||
85 | [gns] | ||
86 | AUTOSTART = NO | ||
87 | |||
88 | [statistics] | ||
89 | AUTOSTART = NO | ||
90 | |||
91 | [peerinfo] | ||
92 | NO_IO = YES | ||
diff --git a/src/testbed/testbed.conf.in b/src/testbed/testbed.conf.in index 379cd22d1..5f91958ba 100644 --- a/src/testbed/testbed.conf.in +++ b/src/testbed/testbed.conf.in | |||
@@ -4,16 +4,44 @@ AUTOSTART = NO | |||
4 | HOSTNAME = localhost | 4 | HOSTNAME = localhost |
5 | HOME = $SERVICEHOME | 5 | HOME = $SERVICEHOME |
6 | BINARY = gnunet-service-testbed | 6 | BINARY = gnunet-service-testbed |
7 | |||
8 | # How long should operations wait? | ||
7 | OPERATION_TIMEOUT = 30 s | 9 | OPERATION_TIMEOUT = 30 s |
8 | # Set this to the path where the testbed helper is installed | 10 | |
11 | # Set this to the path where the testbed helper is installed. By default the | ||
12 | # helper binary is searched in @prefix@/lib/gnunet/libexec/ | ||
9 | # HELPER_BINARY_PATH = @prefix@/lib/gnunet/libexec/gnunet-helper-testbed | 13 | # HELPER_BINARY_PATH = @prefix@/lib/gnunet/libexec/gnunet-helper-testbed |
14 | |||
15 | # Add your local network address here. For example, if you want to running | ||
16 | # testbed on a group of hosts connected to network 192.168.1.0/24, then set | ||
17 | # ACCEPT_FROM = 127.0.0.1; 192.168.1.0/24; | ||
18 | # Multiple network addresses can be given. They should be separated by `;' | ||
10 | ACCEPT_FROM = 127.0.0.1; | 19 | ACCEPT_FROM = 127.0.0.1; |
11 | ACCEPT_FROM6 = ::1; | 20 | ACCEPT_FROM6 = ::1; |
21 | |||
12 | UNIXPATH = /tmp/gnunet-service-testbed.sock | 22 | UNIXPATH = /tmp/gnunet-service-testbed.sock |
13 | UNIX_MATCH_UID = YES | 23 | UNIX_MATCH_UID = YES |
14 | UNIX_MATCH_GID = YES | 24 | UNIX_MATCH_GID = YES |
25 | |||
26 | # How many maximum number of operations can be run in parallel. This number | ||
27 | # should be decreased if the system is getting overloaded and to keep reduce the | ||
28 | # load of testbed. | ||
15 | MAX_PARALLEL_OPERATIONS = 1000 | 29 | MAX_PARALLEL_OPERATIONS = 1000 |
16 | MAX_PARALLEL_SERVICE_CONNECTIONS = 256 | ||
17 | MAX_PARALLEL_TOPOLOGY_CONFIG_OPERATIONS = 1 | 30 | MAX_PARALLEL_TOPOLOGY_CONFIG_OPERATIONS = 1 |
31 | |||
32 | # How many maximum number of handles to peers' services should be kept open at | ||
33 | # any time. This number also keeps a check on the number of open descriptors as | ||
34 | # opening a service connection results in opening a file descriptor. | ||
35 | MAX_PARALLEL_SERVICE_CONNECTIONS = 256 | ||
36 | |||
37 | # Size of the internal testbed cache. It is used to cache handles to peers | ||
38 | # while trying to connect them. | ||
18 | CACHE_SIZE = 30 | 39 | CACHE_SIZE = 30 |
40 | |||
41 | # Maximum number of file descriptors a testbed controller is permitted to keep | ||
42 | # open. | ||
19 | MAX_OPEN_FDS = 512 | 43 | MAX_OPEN_FDS = 512 |
44 | |||
45 | # How long should we wait for testbed to setup while using helper functions | ||
46 | # GNUNET_TESTBED_test_run() and GNUNET_TESTBED_run() | ||
47 | SETUP_TIMEOUT = 5 m \ No newline at end of file | ||
diff --git a/src/testbed/testbed_api_testbed.c b/src/testbed/testbed_api_testbed.c index 3bd6f1db8..96be90e83 100644 --- a/src/testbed/testbed_api_testbed.c +++ b/src/testbed/testbed_api_testbed.c | |||
@@ -45,6 +45,11 @@ | |||
45 | LOG (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__) | 45 | LOG (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__) |
46 | 46 | ||
47 | /** | 47 | /** |
48 | * The default setup timeout in seconds | ||
49 | */ | ||
50 | #define DEFAULT_SETUP_TIMEOUT 300 | ||
51 | |||
52 | /** | ||
48 | * DLL of operations | 53 | * DLL of operations |
49 | */ | 54 | */ |
50 | struct DLLOperation | 55 | struct DLLOperation |
@@ -229,6 +234,11 @@ struct RunContext | |||
229 | GNUNET_SCHEDULER_TaskIdentifier shutdown_run_task; | 234 | GNUNET_SCHEDULER_TaskIdentifier shutdown_run_task; |
230 | 235 | ||
231 | /** | 236 | /** |
237 | * Task to be run of a timeout | ||
238 | */ | ||
239 | GNUNET_SCHEDULER_TaskIdentifier timeout_task; | ||
240 | |||
241 | /** | ||
232 | * The event mask for the controller | 242 | * The event mask for the controller |
233 | */ | 243 | */ |
234 | uint64_t event_mask; | 244 | uint64_t event_mask; |
@@ -457,6 +467,11 @@ shutdown_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
457 | GNUNET_SCHEDULER_cancel (rc->register_hosts_task); | 467 | GNUNET_SCHEDULER_cancel (rc->register_hosts_task); |
458 | rc->register_hosts_task = GNUNET_SCHEDULER_NO_TASK; | 468 | rc->register_hosts_task = GNUNET_SCHEDULER_NO_TASK; |
459 | } | 469 | } |
470 | if (GNUNET_SCHEDULER_NO_TASK != rc->timeout_task) | ||
471 | { | ||
472 | GNUNET_SCHEDULER_cancel (rc->timeout_task); | ||
473 | rc->timeout_task = GNUNET_SCHEDULER_NO_TASK; | ||
474 | } | ||
460 | if (NULL != rc->reg_handle) | 475 | if (NULL != rc->reg_handle) |
461 | { | 476 | { |
462 | GNUNET_TESTBED_cancel_registration (rc->reg_handle); | 477 | GNUNET_TESTBED_cancel_registration (rc->reg_handle); |
@@ -499,22 +514,16 @@ shutdown_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
499 | 514 | ||
500 | 515 | ||
501 | /** | 516 | /** |
502 | * Task to call master task | 517 | * call test master callback |
503 | * | 518 | * |
504 | * @param cls the run context | 519 | * @param cls the run context |
505 | * @param tc the task context | 520 | * @param tc the task context |
506 | */ | 521 | */ |
507 | static void | 522 | static void |
508 | call_master (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 523 | call_master (struct RunContext *rc) |
509 | { | 524 | { |
510 | struct RunContext *rc = cls; | 525 | GNUNET_SCHEDULER_cancel (rc->timeout_task); |
511 | 526 | rc->timeout_task = GNUNET_SCHEDULER_NO_TASK; | |
512 | if (NULL != rc->topology_operation) | ||
513 | { | ||
514 | DEBUG ("Overlay topology generated in %s\n", prof_time (rc)); | ||
515 | GNUNET_TESTBED_operation_done (rc->topology_operation); | ||
516 | rc->topology_operation = NULL; | ||
517 | } | ||
518 | if (NULL != rc->test_master) | 527 | if (NULL != rc->test_master) |
519 | rc->test_master (rc->test_master_cls, rc->num_peers, rc->peers); | 528 | rc->test_master (rc->test_master_cls, rc->num_peers, rc->peers); |
520 | } | 529 | } |
@@ -535,9 +544,11 @@ topology_completion_callback (void *cls, unsigned int nsuccess, | |||
535 | { | 544 | { |
536 | struct RunContext *rc = cls; | 545 | struct RunContext *rc = cls; |
537 | 546 | ||
547 | DEBUG ("Overlay topology generated in %s\n", prof_time (rc)); | ||
548 | GNUNET_TESTBED_operation_done (rc->topology_operation); | ||
549 | rc->topology_operation = NULL; | ||
538 | rc->state = RC_READY; | 550 | rc->state = RC_READY; |
539 | GNUNET_SCHEDULER_add_continuation (&call_master, rc, | 551 | call_master (rc); |
540 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); | ||
541 | } | 552 | } |
542 | 553 | ||
543 | 554 | ||
@@ -706,8 +717,7 @@ call_cc: | |||
706 | } | 717 | } |
707 | } | 718 | } |
708 | rc->state = RC_READY; | 719 | rc->state = RC_READY; |
709 | GNUNET_SCHEDULER_add_continuation (&call_master, rc, | 720 | call_master (rc); |
710 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); | ||
711 | } | 721 | } |
712 | 722 | ||
713 | 723 | ||
@@ -800,8 +810,8 @@ controller_status_cb (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
800 | 810 | ||
801 | if (status != GNUNET_OK) | 811 | if (status != GNUNET_OK) |
802 | { | 812 | { |
803 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 813 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
804 | "Controller crash detected. Shutting down.\n"); | 814 | _("Controller crash detected. Shutting down.\n")); |
805 | rc->cproc = NULL; | 815 | rc->cproc = NULL; |
806 | if (NULL != rc->peers) | 816 | if (NULL != rc->peers) |
807 | { | 817 | { |
@@ -949,6 +959,26 @@ host_habitable_cb (void *cls, const struct GNUNET_TESTBED_Host *host, | |||
949 | 959 | ||
950 | 960 | ||
951 | /** | 961 | /** |
962 | * Task run upon timeout while setting up the testbed | ||
963 | * | ||
964 | * @param cls the RunContext | ||
965 | * @param tc the task context | ||
966 | */ | ||
967 | static void | ||
968 | timeout_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
969 | { | ||
970 | struct RunContext *rc = cls; | ||
971 | |||
972 | rc->timeout_task = GNUNET_SCHEDULER_NO_TASK; | ||
973 | LOG (GNUNET_ERROR_TYPE_ERROR, _("Shutting down testbed due to timeout while setup.\n")); | ||
974 | shutdown_now (rc); | ||
975 | if (NULL != rc->test_master) | ||
976 | rc->test_master (rc->test_master_cls, 0, NULL); | ||
977 | rc->test_master = NULL; | ||
978 | } | ||
979 | |||
980 | |||
981 | /** | ||
952 | * Convenience method for running a testbed with | 982 | * Convenience method for running a testbed with |
953 | * a single call. Underlay and overlay topology | 983 | * a single call. Underlay and overlay topology |
954 | * are configured using the "UNDERLAY" and "OVERLAY" | 984 | * are configured using the "UNDERLAY" and "OVERLAY" |
@@ -985,6 +1015,7 @@ GNUNET_TESTBED_run (const char *host_filename, | |||
985 | { | 1015 | { |
986 | struct RunContext *rc; | 1016 | struct RunContext *rc; |
987 | char *topology; | 1017 | char *topology; |
1018 | struct GNUNET_TIME_Relative timeout; | ||
988 | unsigned long long random_links; | 1019 | unsigned long long random_links; |
989 | unsigned int hid; | 1020 | unsigned int hid; |
990 | unsigned int nhost; | 1021 | unsigned int nhost; |
@@ -1106,6 +1137,15 @@ GNUNET_TESTBED_run (const char *host_filename, | |||
1106 | rc->cproc = | 1137 | rc->cproc = |
1107 | GNUNET_TESTBED_controller_start ("127.0.0.1", rc->h, rc->cfg, | 1138 | GNUNET_TESTBED_controller_start ("127.0.0.1", rc->h, rc->cfg, |
1108 | &controller_status_cb, rc); | 1139 | &controller_status_cb, rc); |
1140 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_time (cfg, "TESTBED", | ||
1141 | "SETUP_TIMEOUT", | ||
1142 | &timeout)) | ||
1143 | { | ||
1144 | timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, | ||
1145 | DEFAULT_SETUP_TIMEOUT); | ||
1146 | } | ||
1147 | rc->timeout_task = | ||
1148 | GNUNET_SCHEDULER_add_delayed (timeout, &timeout_task, rc); | ||
1109 | rc->shutdown_run_task = | 1149 | rc->shutdown_run_task = |
1110 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_run, | 1150 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_run, |
1111 | rc); | 1151 | rc); |