aboutsummaryrefslogtreecommitdiff
path: root/src/testbed
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2013-03-15 09:37:18 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2013-03-15 09:37:18 +0000
commitb92fefc699df523441c3b24d6d59cdc016af6bac (patch)
tree6710e2c32918af8d0f780f655acd5a1727f1fffa /src/testbed
parentfef4792abec19870be63c7922ada0ebd4397a7c1 (diff)
downloadgnunet-b92fefc699df523441c3b24d6d59cdc016af6bac.tar.gz
gnunet-b92fefc699df523441c3b24d6d59cdc016af6bac.zip
Call TestMaster callback upon timeout set through configuration
fixes #2833
Diffstat (limited to 'src/testbed')
-rw-r--r--src/testbed/Makefile.am9
-rw-r--r--src/testbed/test_testbed_api_test_timeout.c115
-rw-r--r--src/testbed/test_testbed_api_test_timeout.conf92
-rw-r--r--src/testbed/testbed.conf.in32
-rw-r--r--src/testbed/testbed_api_testbed.c72
5 files changed, 302 insertions, 18 deletions
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
212test_testbed_api_test_timeout_SOURCES = \
213 test_testbed_api_test_timeout.c
214test_testbed_api_test_timeout_LDADD = \
215 $(top_builddir)/src/util/libgnunetutil.la \
216 libgnunettestbed.la
217
210test_testbed_api_topology_SOURCES = \ 218test_testbed_api_topology_SOURCES = \
211 test_testbed_api_topology.c 219 test_testbed_api_topology.c
212test_testbed_api_topology_LDADD = \ 220test_testbed_api_topology_LDADD = \
@@ -288,6 +296,7 @@ test_testbed_api_statistics_LDADD = \
288 296
289EXTRA_DIST = \ 297EXTRA_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 */
48static 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 */
69static void
70controller_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 */
84static void
85test_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 */
99int
100main (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]
2AUTOSTART = NO
3PORT = 12113
4ACCEPT_FROM = 127.0.0.1;
5HOSTNAME = localhost
6OVERLAY_TOPOLOGY = CLIQUE
7SETUP_TIMEOUT = 2 s
8#PREFIX = xterm -geometry 100x85 -T peer1 -e libtool --mode=execute gdb --args
9
10[fs]
11AUTOSTART = NO
12
13[resolver]
14AUTOSTART = NO
15
16[mesh]
17AUTOSTART = NO
18
19[dht]
20AUTOSTART = NO
21
22[block]
23plugins = dht test
24
25[dhtcache]
26QUOTA = 1 MB
27DATABASE = sqlite
28
29[transport]
30PLUGINS = tcp
31ACCEPT_FROM6 = ::1;
32ACCEPT_FROM = 127.0.0.1;
33NEIGHBOUR_LIMIT = 50
34PORT = 12365
35
36[ats]
37WAN_QUOTA_OUT = 3932160
38WAN_QUOTA_IN = 3932160
39
40[core]
41PORT = 12092
42AUTOSTART = YES
43USE_EPHEMERAL_KEYS = NO
44
45[arm]
46DEFAULTSERVICES = core transport
47PORT = 12366
48
49[transport-tcp]
50TIMEOUT = 300 s
51PORT = 12368
52
53[TESTING]
54NUM_PEERS = 5
55WEAKRANDOM = YES
56HOSTKEYSFILE = ../../contrib/testing_hostkeys.dat
57MAX_CONCURRENT_SSH = 10
58USE_PROGRESSBARS = YES
59PEERGROUP_TIMEOUT = 2400 s
60
61[gnunetd]
62HOSTKEY = $SERVICEHOME/.hostkey
63
64[PATHS]
65SERVICEHOME = /tmp/test-testbed/
66
67[dns]
68AUTOSTART = NO
69
70[nse]
71AUTOSTART = NO
72
73[vpn]
74AUTOSTART = NO
75
76[nat]
77RETURN_LOCAL_ADDRESSES = YES
78
79[gns-helper-service-w32]
80AUTOSTART = NO
81
82[consensus]
83AUTOSTART = NO
84
85[gns]
86AUTOSTART = NO
87
88[statistics]
89AUTOSTART = NO
90
91[peerinfo]
92NO_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
4HOSTNAME = localhost 4HOSTNAME = localhost
5HOME = $SERVICEHOME 5HOME = $SERVICEHOME
6BINARY = gnunet-service-testbed 6BINARY = gnunet-service-testbed
7
8# How long should operations wait?
7OPERATION_TIMEOUT = 30 s 9OPERATION_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 `;'
10ACCEPT_FROM = 127.0.0.1; 19ACCEPT_FROM = 127.0.0.1;
11ACCEPT_FROM6 = ::1; 20ACCEPT_FROM6 = ::1;
21
12UNIXPATH = /tmp/gnunet-service-testbed.sock 22UNIXPATH = /tmp/gnunet-service-testbed.sock
13UNIX_MATCH_UID = YES 23UNIX_MATCH_UID = YES
14UNIX_MATCH_GID = YES 24UNIX_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.
15MAX_PARALLEL_OPERATIONS = 1000 29MAX_PARALLEL_OPERATIONS = 1000
16MAX_PARALLEL_SERVICE_CONNECTIONS = 256
17MAX_PARALLEL_TOPOLOGY_CONFIG_OPERATIONS = 1 30MAX_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.
35MAX_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.
18CACHE_SIZE = 30 39CACHE_SIZE = 30
40
41# Maximum number of file descriptors a testbed controller is permitted to keep
42# open.
19MAX_OPEN_FDS = 512 43MAX_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()
47SETUP_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 */
50struct DLLOperation 55struct 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 */
507static void 522static void
508call_master (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 523call_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 */
967static void
968timeout_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);