2 This file is part of GNUnet
3 (C) 2008, 2009 Christian Grothoff (and other contributing authors)
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 2, or (at your
8 option) any later version.
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.
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.
22 * @file testing/testing_testbed.c
23 * @brief convenience API for writing testcases for GNUnet
24 * Many testcases need to start and stop gnunetd,
25 * and this library is supposed to make that easier
26 * for TESTCASES. Normal programs should always
27 * use functions from gnunet_{util,arm}_lib.h. This API is
28 * ONLY for writing testcases!
29 * @author Christian Grothoff
32 #include "gnunet_arm_service.h"
33 #include "gnunet_testing_lib.h"
37 * Handle to an entire testbed of GNUnet peers.
39 struct GNUNET_TESTING_Testbed
45 * Start count GNUnet daemons with a particular
48 * @param size number of peers the testbed should have
49 * @param topology desired topology (enforced via F2F)
50 * @param service_home_prefix path to use as the prefix for the home of the services
51 * @param transports which transports should all peers use
52 * @param applications which applications should be used?
53 * @param timeout how long is this allowed to take?
54 * @param cb function to call on each daemon that was started
55 * @param cb_cls closure for cb
56 * @param cte function to call at the end
57 * @param cte_cls closure for cbe
58 * @param hostname where to run the peers; can be NULL (to run
59 * everything on localhost). Additional
60 * hosts can be specified using a NULL-terminated list of
61 * varargs, hosts will then be used round-robin from that
65 GNUNET_TESTING_testbed_start (struct GNUNET_SCHEDULER_Handle *sched,
66 struct GNUNET_CONFIGURATION_Handle *cfg,
68 enum GNUNET_TESTING_Topology topology,
69 const char *service_home_prefix,
70 const char *transports,
71 const char *applications,
72 GNUNET_TESTING_NotifyDaemonRunning cb,
74 GNUNET_TESTING_NotifyTestbedRunning cte,
83 * Stop all of the daemons started with the start function.
85 * @param tb handle for the testbed
86 * @param cb function to call at the end
87 * @param cb_cls closure for cb
90 GNUNET_TESTING_testbed_stop (struct GNUNET_TESTING_Testbed *tb,
91 GNUNET_TESTING_NotifyCompletion cb,
98 * Simulate churn in the testbed by stopping some peers (and possibly
99 * re-starting others if churn is called multiple times). This
100 * function can only be used to create leave-join churn (peers "never"
101 * leave for good). First "voff" random peers that are currently
102 * online will be taken offline; then "von" random peers that are then
103 * offline will be put back online. No notifications will be
104 * generated for any of these operations except for the callback upon
105 * completion. Note that the implementation is at liberty to keep
106 * the ARM service itself (but none of the other services or daemons)
107 * running even though the "peer" is being varied offline.
109 * @param tb handle for the testbed
110 * @param voff number of peers that should go offline
111 * @param von number of peers that should come back online;
112 * must be zero on first call (since "testbed_start"
113 * always starts all of the peers)
114 * @param cb function to call at the end
115 * @param cb_cls closure for cb
118 GNUNET_TESTING_testbed_churn (struct GNUNET_TESTING_Testbed *tb,
121 GNUNET_TESTING_NotifyCompletion cb,