aboutsummaryrefslogtreecommitdiff
path: root/src/testbed
diff options
context:
space:
mode:
Diffstat (limited to 'src/testbed')
-rw-r--r--src/testbed/Makefile.am39
-rw-r--r--src/testbed/testbed.conf0
-rw-r--r--src/testbed/testbed.h535
-rw-r--r--src/testbed/testbed_api.c150
-rw-r--r--src/testbed/testbed_api_hosts.c200
-rw-r--r--src/testbed/testbed_api_hosts.h105
-rw-r--r--src/testbed/testbed_api_operations.c74
-rw-r--r--src/testbed/testbed_api_operations.h34
-rw-r--r--src/testbed/testbed_api_peers.c297
-rw-r--r--src/testbed/testbed_api_peers.h71
-rw-r--r--src/testbed/testbed_api_services.c61
-rw-r--r--src/testbed/testbed_api_test.c67
-rw-r--r--src/testbed/testbed_api_testbed.c153
-rw-r--r--src/testbed/testbed_api_topology.c127
14 files changed, 1913 insertions, 0 deletions
diff --git a/src/testbed/Makefile.am b/src/testbed/Makefile.am
new file mode 100644
index 000000000..b7b936004
--- /dev/null
+++ b/src/testbed/Makefile.am
@@ -0,0 +1,39 @@
1INCLUDES = -I$(top_srcdir)/src/include
2
3if MINGW
4 WINFLAGS = -Wl,--no-undefined -Wl,--export-all-symbols
5endif
6
7if USE_COVERAGE
8 AM_CFLAGS = --coverage -O0
9 XLIB = -lgcov
10endif
11
12pkgcfgdir= $(pkgdatadir)/config.d/
13
14dist_pkgcfg_DATA = \
15 testbed.conf
16
17lib_LTLIBRARIES = \
18 libgnunettestbed.la
19
20libgnunettestbed_la_SOURCES = \
21 testbed_api.c testbed.h \
22 testbed_api_hosts.c testbed_api_hosts.h \
23 testbed_api_operations.c testbed_api_operations.h \
24 testbed_api_peers.c testbed_api_peers.h \
25 testbed_api_services.c \
26 testbed_api_testbed.c \
27 testbed_api_test.c \
28 testbed_api_topology.c
29libgnunettestbed_la_LIBADD = $(XLIB) \
30 $(top_builddir)/src/core/libgnunetcore.la \
31 $(top_builddir)/src/statistics/libgnunetstatistics.la \
32 $(top_builddir)/src/transport/libgnunettransport.la \
33 $(top_builddir)/src/hello/libgnunethello.la \
34 -lm \
35 $(top_builddir)/src/util/libgnunetutil.la
36libgnunettestbed_la_LDFLAGS = \
37 $(GN_LIB_LDFLAGS) \
38 -version-info 0:0:0
39
diff --git a/src/testbed/testbed.conf b/src/testbed/testbed.conf
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/src/testbed/testbed.conf
diff --git a/src/testbed/testbed.h b/src/testbed/testbed.h
new file mode 100644
index 000000000..4e4e490f0
--- /dev/null
+++ b/src/testbed/testbed.h
@@ -0,0 +1,535 @@
1/*
2 This file is part of GNUnet
3 (C) 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 testing/new_testing.h
23 * @brief IPC messages between testing API and service ("controller")
24 * @author Christian Grothoff
25 */
26
27#ifndef NEW_TESTING_H
28#define NEW_TESTING_H
29
30#include "gnunet_util_lib.h"
31
32
33/**
34 * Initial message from a client to a testing control service.
35 */
36struct GNUNET_TESTBED_Message
37{
38
39 /**
40 * Type is
41 */
42 struct GNUNET_MessageHeader header;
43
44 /**
45 * Host ID that the controller is either given
46 * (if this is the dominating client communicating
47 * via stdin) or assumed to have (for peer-connections
48 * between controllers).
49 */
50 uint32_t host_id GNUNET_PACKED;
51
52 /**
53 * Event mask that specifies which events this client
54 * is interested in. In NBO.
55 */
56 uint64_t event_mask GNUNET_PACKED;
57
58};
59
60
61/**
62 * Notify the service about a host that we intend to use.
63 */
64struct GNUNET_TESTBED_AddHostMessage
65{
66
67 /**
68 * Type is
69 */
70 struct GNUNET_MessageHeader header;
71
72 /**
73 * Unique ID for the host (in NBO).
74 */
75 uint32_t host_id GNUNET_PACKED;
76
77 /**
78 * SSH port to use, 0 for default (in NBO).
79 */
80 uint16_t ssh_port GNUNET_PACKED;
81
82 /**
83 * Number of bytes in the user name that follows;
84 * 0 to use no user name; otherwise 'strlen (username)',
85 * excluding 0-termination!
86 */
87 uint16_t user_name_length GNUNET_PACKED;
88
89 /* followed by 0-terminated user name */
90
91 /* followed by 0-terminated host name */
92
93};
94
95
96/**
97 * Confirmation from the service that adding a host
98 * worked (or failed).
99 */
100struct GNUNET_TESTBED_HostConfirmedMessage
101{
102
103 /**
104 * Type is
105 */
106 struct GNUNET_MessageHeader header;
107
108 /**
109 * Unique ID for the host (in NBO).
110 */
111 uint32_t host_id GNUNET_PACKED;
112
113 /* followed by the 0-terminated error message (on failure)
114 (typical errors include failure to login and
115 host-id already in use) */
116
117};
118
119
120/**
121 * Message to testing service: configure service sharing
122 * at a host.
123 */
124struct GNUNET_TESTBED_ConfigureSharedServiceMessage
125{
126
127 /**
128 * Type is
129 */
130 struct GNUNET_MessageHeader header;
131
132 /**
133 * Host that is being configured.
134 */
135 uint32_t host_id GNUNET_PACKED;
136
137 /**
138 * Number of peers that should share a service instance;
139 * 1 for no sharing, 0 to forcefully disable the service.
140 */
141 uint32_t num_peers GNUNET_PACKED;
142
143 /* followed by 0-terminated name of the service */
144
145};
146
147
148/**
149 * Client notifies controller that it should delegate
150 * requests for a particular client to a particular
151 * sub-controller.
152 */
153struct GNUNET_TESTBED_ControllerLinkMessage
154{
155
156 /**
157 * Type is
158 */
159 struct GNUNET_MessageHeader header;
160
161 /**
162 * For which host should requests be delegated? NBO.
163 */
164 uint32_t delegated_host_id GNUNET_PACKED;
165
166 /**
167 * Which host is responsible for managing the delegation? NBO
168 */
169 uint32_t slave_host_id GNUNET_PACKED;
170
171 /**
172 * Is the receiving controller the master controller for
173 * the slave host (and thus responsible for starting it?). NBO.
174 */
175 int32_t is_subordinate GNUNET_PACKED;
176
177 /* followed by serialized slave configuration;
178 gzip'ed configuration file in INI format */
179
180};
181
182
183/**
184 * Message sent from client to testing service to
185 * create (configure, but not start) a peer.
186 */
187struct GNUNET_TESTBED_PeerCreateMessage
188{
189
190 /**
191 * Type is
192 */
193 struct GNUNET_MessageHeader header;
194
195 /**
196 * On which host should the peer be started?
197 */
198 uint32_t host_id GNUNET_PACKED;
199
200 /**
201 * Unique ID for the peer.
202 */
203 uint32_t peer_id GNUNET_PACKED;
204
205 /* followed by serialized peer configuration;
206 gzip'ed configuration file in INI format */
207
208};
209
210
211/**
212 * Message sent from client to testing service to
213 * reconfigure a (stopped) a peer.
214 */
215struct GNUNET_TESTBED_PeerReconfigureMessage
216{
217
218 /**
219 * Type is
220 */
221 struct GNUNET_MessageHeader header;
222
223 /**
224 * Unique ID for the peer.
225 */
226 uint32_t peer_id GNUNET_PACKED;
227
228 /**
229 * Operation ID that is used to identify this operation.
230 */
231 uint64_t operation_id GNUNET_PACKED;
232
233 /* followed by serialized peer configuration;
234 gzip'ed configuration file in INI format */
235
236};
237
238
239/**
240 * Message sent from client to testing service to
241 * start a peer.
242 */
243struct GNUNET_TESTBED_PeerStartMessage
244{
245
246 /**
247 * Type is
248 */
249 struct GNUNET_MessageHeader header;
250
251 /**
252 * Unique ID for the peer.
253 */
254 uint32_t peer_id GNUNET_PACKED;
255
256 /**
257 * Operation ID that is used to identify this operation.
258 */
259 uint64_t operation_id GNUNET_PACKED;
260
261};
262
263
264/**
265 * Message sent from client to testing service to
266 * stop a peer.
267 */
268struct GNUNET_TESTBED_PeerStopMessage
269{
270
271 /**
272 * Type is
273 */
274 struct GNUNET_MessageHeader header;
275
276 /**
277 * Unique ID for the peer.
278 */
279 uint32_t peer_id GNUNET_PACKED;
280
281 /**
282 * Operation ID that is used to identify this operation.
283 */
284 uint64_t operation_id GNUNET_PACKED;
285
286};
287
288
289/**
290 * Message sent from client to testing service to
291 * destroy a (stopped) peer.
292 */
293struct GNUNET_TESTBED_PeerDestroyMessage
294{
295
296 /**
297 * Type is
298 */
299 struct GNUNET_MessageHeader header;
300
301 /**
302 * Unique ID for the peer.
303 */
304 uint32_t peer_id GNUNET_PACKED;
305
306 /**
307 * Operation ID that is used to identify this operation.
308 */
309 uint64_t operation_id GNUNET_PACKED;
310
311};
312
313
314/**
315 * Message sent from client to testing service to
316 * (re)configure a "physical" link between two peers.
317 */
318struct GNUNET_TESTBED_ConfigureUnderlayLinkMessage
319{
320
321 /**
322 * Type is
323 */
324 struct GNUNET_MessageHeader header;
325
326 /**
327 * 'enum GNUNET_TESTBED_ConnectOption' of the option to change
328 */
329 int32_t connect_option GNUNET_PACKED;
330
331 /**
332 * Unique ID for the first peer.
333 */
334 uint32_t peer1 GNUNET_PACKED;
335
336 /**
337 * Unique ID for the second peer.
338 */
339 uint32_t peer2 GNUNET_PACKED;
340
341 /**
342 * Operation ID that is used to identify this operation.
343 */
344 uint64_t operation_id GNUNET_PACKED;
345
346 /* followed by option-dependent variable-size values */
347
348};
349
350
351/**
352 * Message sent from client to testing service to
353 * connect two peers.
354 */
355struct GNUNET_TESTBED_OverlayConnectMessage
356{
357
358 /**
359 * Type is
360 */
361 struct GNUNET_MessageHeader header;
362
363 /**
364 * Unique ID for the first peer.
365 */
366 uint32_t peer1 GNUNET_PACKED;
367
368 /**
369 * Operation ID that is used to identify this operation.
370 */
371 uint64_t operation_id GNUNET_PACKED;
372
373 /**
374 * Unique ID for the second peer.
375 */
376 uint32_t peer2 GNUNET_PACKED;
377
378};
379
380
381/**
382 * Event notification from a controller to a client.
383 */
384struct GNUNET_TESTBED_PeerEventMessage
385{
386
387 /**
388 * Type is
389 */
390 struct GNUNET_MessageHeader header;
391
392 /**
393 * 'enum GNUNET_TESTBED_EventType' (in NBO);
394 * either GNUNET_TESTBED_ET_PEER_START or GNUNET_TESTBED_ET_PEER_STOP.
395 */
396 int32_t event_type GNUNET_PACKED;
397
398 /**
399 * Host where the peer is running.
400 */
401 uint32_t host_id GNUNET_PACKED;
402
403 /**
404 * Peer that was started or stopped.
405 */
406 uint32_t peer_id GNUNET_PACKED;
407
408 /**
409 * Operation ID that is used to identify this operation.
410 */
411 uint64_t operation_id GNUNET_PACKED;
412
413};
414
415
416/**
417 * Event notification from a controller to a client.
418 */
419struct GNUNET_TESTBED_ConnectionEventMessage
420{
421
422 /**
423 * Type is
424 */
425 struct GNUNET_MessageHeader header;
426
427 /**
428 * 'enum GNUNET_TESTBED_EventType' (in NBO);
429 * either GNUNET_TESTBED_ET_PEER_CONNECT or GNUNET_TESTBED_ET_PEER_DISCONNECT.
430 */
431 int32_t event_type GNUNET_PACKED;
432
433 /**
434 * First peer.
435 */
436 uint32_t peer1 GNUNET_PACKED;
437
438 /**
439 * Second peer.
440 */
441 uint32_t peer2 GNUNET_PACKED;
442
443 /**
444 * Operation ID that is used to identify this operation.
445 */
446 uint64_t operation_id GNUNET_PACKED;
447
448};
449
450
451/**
452 * Event notification from a controller to a client.
453 */
454struct GNUNET_TESTBED_OperationFailureEventMessage
455{
456
457 /**
458 * Type is
459 */
460 struct GNUNET_MessageHeader header;
461
462 /**
463 * 'enum GNUNET_TESTBED_EventType' (in NBO);
464 * GNUNET_TESTBED_ET_OPERATION_FINISHED.
465 */
466 int32_t event_type GNUNET_PACKED;
467
468 /**
469 * Operation ID of the operation that created this event.
470 */
471 uint64_t operation_id GNUNET_PACKED;
472
473 /* followed by 0-terminated error message */
474
475};
476
477
478/**
479 * Event notification from a controller to a client.
480 */
481struct GNUNET_TESTBED_PeerCreateSuccessEventMessage
482{
483
484 /**
485 * Type is
486 */
487 struct GNUNET_MessageHeader header;
488
489 /**
490 * Peer identity of the peer that was created.
491 */
492 uint32_t peer_id GNUNET_PACKED;
493
494 /**
495 * Operation ID of the operation that created this event.
496 */
497 uint64_t operation_id GNUNET_PACKED;
498
499 /**
500 * Identity of the peer.
501 */
502 struct GNUNET_PeerIdentity peer_id;
503
504 /* followed by gzip-compressed configuration of the peer */
505
506};
507
508
509/**
510 * Event notification from a controller to a client for
511 * a generic operational success where the operation does
512 * not return any data.
513 */
514struct GNUNET_TESTBED_GenericOperationSuccessEventMessage
515{
516
517 /**
518 * Type is
519 */
520 struct GNUNET_MessageHeader header;
521
522 /**
523 * 'enum GNUNET_TESTBED_EventType' (in NBO);
524 * GNUNET_TESTBED_ET_OPERATION_FINISHED.
525 */
526 int32_t event_type GNUNET_PACKED;
527
528 /**
529 * Operation ID of the operation that created this event.
530 */
531 uint64_t operation_id GNUNET_PACKED;
532
533};
534
535#endif
diff --git a/src/testbed/testbed_api.c b/src/testbed/testbed_api.c
new file mode 100644
index 000000000..bffe8162f
--- /dev/null
+++ b/src/testbed/testbed_api.c
@@ -0,0 +1,150 @@
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 testing/new_testing_api.c
23 * @brief API for accessing the GNUnet testing service.
24 * This library is supposed to make it easier to write
25 * testcases and script large-scale benchmarks.
26 * @author Christian Grothoff
27 */
28#include "platform.h"
29#include "gnunet_testing_service.h"
30#include "gnunet_core_service.h"
31#include "gnunet_constants.h"
32#include "gnunet_transport_service.h"
33#include "gnunet_hello_lib.h"
34
35
36
37
38/**
39 * Start a controller process using the given configuration at the
40 * given host.
41 *
42 * @param cfg configuration to use
43 * @param host host to run the controller on, NULL for 'localhost'
44 * @param event_mask bit mask with set of events to call 'cc' for;
45 * or-ed values of "1LL" shifted by the
46 * respective 'enum GNUNET_TESTBED_EventType'
47 * (i.e. "(1LL << GNUNET_TESTBED_ET_CONNECT) | ...")
48 * @param cc controller callback to invoke on events
49 * @param cc_cls closure for cc
50 * @return handle to the controller
51 */
52struct GNUNET_TESTBED_Controller *
53GNUNET_TESTBED_controller_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
54 struct GNUNET_TESTBED_Host *host,
55 uint64_t event_mask,
56 GNUNET_TESTBED_ControllerCallback cc,
57 void *cc_cls)
58{
59 GNUNET_break (0);
60 return NULL;
61}
62
63
64/**
65 * Configure shared services at a controller. Using this function,
66 * you can specify that certain services (such as "resolver")
67 * should not be run for each peer but instead be shared
68 * across N peers on the specified host. This function
69 * must be called before any peers are created at the host.
70 *
71 * @param controller controller to configure
72 * @param service_name name of the service to share
73 * @param num_peers number of peers that should share one instance
74 * of the specified service (1 for no sharing is the default),
75 * use 0 to disable the service
76 */
77void
78GNUNET_TESTBED_controller_configure_sharing (struct GNUNET_TESTBED_Controller *controller,
79 const char *service_name,
80 uint32_t num_peers)
81{
82 GNUNET_break (0);
83}
84
85
86/**
87 * Stop the given controller (also will terminate all peers and
88 * controllers dependent on this controller). This function
89 * blocks until the testbed has been fully terminated (!).
90 *
91 * @param controller handle to controller to stop
92 */
93void
94GNUNET_TESTBED_controller_stop (struct GNUNET_TESTBED_Controller *controller)
95{
96 GNUNET_break (0);
97}
98
99
100/**
101 * Create a link from a 'master' controller to a slave controller.
102 * Whenever the master controller is asked to start a peer at the
103 * given 'delegated_host', it will delegate the request to the
104 * specified slave controller. Note that the slave controller runs at
105 * the 'slave_host', which may or may not be the same host as the
106 * 'delegated_host' (for hierarchical delegations). The configuration
107 * of the slave controller is given and to be used to either create
108 * the slave controller or to connect to an existing slave controller
109 * process. 'is_subordinate' specifies if the given slave controller
110 * should be started and managed by the master controller, or if the
111 * slave already has a master and this is just a secondary master that
112 * is also allowed to use the existing slave.
113 *
114 * @param master handle to the master controller who creates the association
115 * @param delegated_host requests to which host should be delegated
116 * @param slave_host which host is used to run the slave controller
117 * @param slave_cfg configuration to use for the slave controller
118 * @param is_subordinate GNUNET_YES if the slave should be started (and stopped)
119 * by the master controller; GNUNET_NO if we are just
120 * allowed to use the slave via TCP/IP
121 */
122void
123GNUNET_TESTBED_controller_link (struct GNUNET_TESTBED_Controller *master,
124 struct GNUNET_TESTBED_Host *delegated_host,
125 struct GNUNET_TESTBED_Host *slave_host,
126 const struct GNUNET_CONFIGURATION_Handle *slave_cfg,
127 int is_subordinate)
128{
129 GNUNET_break (0);
130}
131
132
133/**
134 * Ask the testbed controller to write the current overlay topology to
135 * a file. Naturally, the file will only contain a snapshot as the
136 * topology may evolve all the time.
137 *
138 * @param controller overlay controller to inspect
139 * @param filename name of the file the topology should
140 * be written to.
141 */
142void
143GNUNET_TESTBED_overlay_write_topology_to_file (struct GNUNET_TESTBED_Controller *controller,
144 const char *filename)
145{
146}
147
148
149
150/* end of new_testing_api.c */
diff --git a/src/testbed/testbed_api_hosts.c b/src/testbed/testbed_api_hosts.c
new file mode 100644
index 000000000..f9ddfdc07
--- /dev/null
+++ b/src/testbed/testbed_api_hosts.c
@@ -0,0 +1,200 @@
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 testing/new_testing_api_hosts.c
23 * @brief API for manipulating 'hosts' controlled by the GNUnet testing service;
24 * allows parsing hosts files, starting, stopping and communicating (via
25 * SSH/stdin/stdout) with the remote (or local) processes
26 * @author Christian Grothoff
27 */
28#include "platform.h"
29#include "gnunet_testing_service.h"
30#include "gnunet_core_service.h"
31#include "gnunet_constants.h"
32#include "gnunet_transport_service.h"
33#include "gnunet_hello_lib.h"
34
35
36
37/**
38 * Opaque handle to a host running experiments managed by the testing framework.
39 * The master process must be able to SSH to this host without password (via
40 * ssh-agent).
41 */
42struct GNUNET_TESTBED_Host
43{
44
45
46 const char *hostname;
47
48 const char *username;
49
50 /**
51 * Global ID we use to refer to a host on the network
52 */
53 uint32_t unique_id;
54
55 uint16_t port;
56};
57
58
59/**
60 * Lookup a host by ID.
61 *
62 * @param id global host ID assigned to the host; 0 is
63 * reserved to always mean 'localhost'
64 * @return handle to the host, NULL on error
65 */
66struct GNUNET_TESTBED_Host *
67GNUNET_TESTBED_host_lookup_by_id_ (uint32_t id)
68{
69 GNUNET_break (0);
70 return NULL;
71}
72
73
74/**
75 * Create a host by ID; given this host handle, we could not
76 * run peers at the host, but we can talk about the host
77 * internally.
78 *
79 * @param id global host ID assigned to the host; 0 is
80 * reserved to always mean 'localhost'
81 * @return handle to the host, NULL on error
82 */
83struct GNUNET_TESTBED_Host *
84GNUNET_TESTBED_host_create_by_id_ (uint32_t id)
85{
86 return NULL;
87}
88
89
90/**
91 * Obtain a host's unique global ID.
92 *
93 * @param host handle to the host, NULL means 'localhost'
94 * @return id global host ID assigned to the host (0 is
95 * 'localhost', but then obviously not globally unique)
96 */
97uint32_t
98GNUNET_TESTBED_host_get_id_ (struct GNUNET_TESTBED_Host *host)
99{
100 GNUNET_break (0);
101 return 0;
102}
103
104
105/**
106 * Create a host to run peers and controllers on.
107 *
108 * @param id global host ID assigned to the host; 0 is
109 * reserved to always mean 'localhost'
110 * @param hostname name of the host, use "NULL" for localhost
111 * @param username username to use for the login; may be NULL
112 * @param port port number to use for ssh; use 0 to let ssh decide
113 * @return handle to the host, NULL on error
114 */
115struct GNUNET_TESTBED_Host *
116GNUNET_TESTBED_host_create_with_id_ (uint32_t id,
117 const char *hostname,
118 const char *username,
119 uint16_t port)
120{
121 GNUNET_break (0);
122 return NULL;
123}
124
125
126/**
127 * Create a host to run peers and controllers on.
128 *
129 * @param hostname name of the host, use "NULL" for localhost
130 * @param username username to use for the login; may be NULL
131 * @param port port number to use for ssh; use 0 to let ssh decide
132 * @return handle to the host, NULL on error
133 */
134struct GNUNET_TESTBED_Host *
135GNUNET_TESTBED_host_create (const char *hostname,
136 const char *username,
137 uint16_t port)
138{
139 static uint32_t uid_generator;
140
141 return GNUNET_TESTBED_host_create_with_id_ (++uid_generator,
142 hostname, username,
143 port);
144}
145
146
147/**
148 * Load a set of hosts from a configuration file.
149 *
150 * @param filename file with the host specification
151 * @param hosts set to the hosts found in the file
152 * @return number of hosts returned in 'hosts', 0 on error
153 */
154unsigned int
155GNUNET_TESTBED_hosts_load_from_file (const char *filename,
156 struct GNUNET_TESTBED_Host **hosts)
157{
158 GNUNET_break (0);
159 return 0;
160}
161
162
163/**
164 * Destroy a host handle. Must only be called once everything
165 * running on that host has been stopped.
166 *
167 * @param host handle to destroy
168 */
169void
170GNUNET_TESTBED_host_destroy (struct GNUNET_TESTBED_Host *host)
171{
172 GNUNET_break (0);
173}
174
175
176/**
177 * Run a given helper process at the given host. Communication
178 * with the helper will be via GNUnet messages on stdin/stdout.
179 * Runs the process via 'ssh' at the specified host, or locally.
180 * Essentially an SSH-wrapper around the 'gnunet_helper_lib.h' API.
181 *
182 * @param host host to use, use "NULL" for localhost
183 * @param binary_argv binary name and command-line arguments to give to the binary
184 * @param cb function to call for messages received from the binary
185 * @param cb_cls closure for cb
186 * @return handle to terminate the command, NULL on error
187 */
188struct GNUNET_HELPER_Handle *
189GNUNET_TESTBED_host_run_ (struct GNUNET_TESTBED_Host *host,
190 char *const binary_argv[],
191 GNUNET_SERVER_MessageTokenizerCallback cb, void *cb_cls)
192{
193 /* FIXME: decide on the SSH command line, prepend it and
194 run GNUNET_HELPER_start with the modified binary_name and binary_argv! */
195 GNUNET_break (0);
196 return NULL;
197}
198
199
200/* end of new_testing_api_hosts.c */
diff --git a/src/testbed/testbed_api_hosts.h b/src/testbed/testbed_api_hosts.h
new file mode 100644
index 000000000..269b3f2af
--- /dev/null
+++ b/src/testbed/testbed_api_hosts.h
@@ -0,0 +1,105 @@
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 testing/new_testing_api_hosts.h
23 * @brief internal API to access the 'hosts' subsystem
24 * @author Christian Grothoff
25 */
26#ifndef NEW_TESTING_API_HOSTS_H
27#define NEW_TESTING_API_HOSTS_H
28
29#include "gnunet_testing_service.h"
30#include "gnunet_helper_lib.h"
31
32
33/**
34 * Lookup a host by ID.
35 *
36 * @param id global host ID assigned to the host; 0 is
37 * reserved to always mean 'localhost'
38 * @return handle to the host, NULL on error
39 */
40struct GNUNET_TESTBED_Host *
41GNUNET_TESTBED_host_lookup_by_id_ (uint32_t id);
42
43
44/**
45 * Create a host by ID; given this host handle, we could not
46 * run peers at the host, but we can talk about the host
47 * internally.
48 *
49 * @param id global host ID assigned to the host; 0 is
50 * reserved to always mean 'localhost'
51 * @return handle to the host, NULL on error
52 */
53struct GNUNET_TESTBED_Host *
54GNUNET_TESTBED_host_create_by_id_ (uint32_t id);
55
56
57/**
58 * Create a host to run peers and controllers on. This function is used
59 * if a peer learns about a host via IPC between controllers (and thus
60 * some higher-level controller has already determined the unique IDs).
61 *
62 * @param id global host ID assigned to the host; 0 is
63 * reserved to always mean 'localhost'
64 * @param hostname name of the host, use "NULL" for localhost
65 * @param username username to use for the login; may be NULL
66 * @param port port number to use for ssh; use 0 to let ssh decide
67 * @return handle to the host, NULL on error
68 */
69struct GNUNET_TESTBED_Host *
70GNUNET_TESTBED_host_create_with_id_ (uint32_t id,
71 const char *hostname,
72 const char *username,
73 uint16_t port);
74
75
76/**
77 * Obtain a host's unique global ID.
78 *
79 * @param host handle to the host, NULL means 'localhost'
80 * @return id global host ID assigned to the host (0 is
81 * 'localhost', but then obviously not globally unique)
82 */
83uint32_t
84GNUNET_TESTBED_host_get_id_ (struct GNUNET_TESTBED_Host *host);
85
86
87/**
88 * Run a given helper process at the given host. Communication
89 * with the helper will be via GNUnet messages on stdin/stdout.
90 * Runs the process via 'ssh' at the specified host, or locally.
91 * Essentially an SSH-wrapper around the 'gnunet_helper_lib.h' API.
92 *
93 * @param host host to use, use "NULL" for localhost
94 * @param binary_argv binary name and command-line arguments to give to the binary
95 * @param cb function to call for messages received from the binary
96 * @param cb_cls closure for cb
97 * @return handle to terminate the command, NULL on error
98 */
99struct GNUNET_HELPER_Handle *
100GNUNET_TESTBED_host_run_ (struct GNUNET_TESTBED_Host *host,
101 char *const binary_argv[],
102 GNUNET_SERVER_MessageTokenizerCallback cb, void *cb_cls);
103
104#endif
105/* end of new_testing_api_hosts.h */
diff --git a/src/testbed/testbed_api_operations.c b/src/testbed/testbed_api_operations.c
new file mode 100644
index 000000000..fa75cf435
--- /dev/null
+++ b/src/testbed/testbed_api_operations.c
@@ -0,0 +1,74 @@
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 testing/new_testing_api_operations.c
23 * @brief functions to manage operation queues
24 * @author Christian Grothoff
25 */
26#include "platform.h"
27#include "new_testing_api_operations.h"
28
29
30/**
31 * Opaque handle to an abstract operation to be executed by the testing framework.
32 */
33struct GNUNET_TESTBED_Operation
34{
35 // FIXME!
36};
37
38
39
40/**
41 * Cancel a pending operation. Releases all resources
42 * of the operation and will ensure that no event
43 * is generated for the operation. Does NOT guarantee
44 * that the operation will be fully undone (or that
45 * nothing ever happened).
46 *
47 * @param operation operation to cancel
48 */
49void
50GNUNET_TESTBED_operation_cancel (struct GNUNET_TESTBED_Operation *operation)
51{
52 GNUNET_break (0);
53
54}
55
56
57/**
58 * Signal that the information from an operation has been fully
59 * processed. This function MUST be called for each event
60 * of type 'operation_finished' to fully remove the operation
61 * from the operation queue. After calling this function, the
62 * 'op_result' becomes invalid (!).
63 *
64 * @param operation operation to signal completion for
65 */
66void
67GNUNET_TESTBED_operation_done (struct GNUNET_TESTBED_Operation *operation)
68{
69 GNUNET_break (0);
70}
71
72
73
74/* end of new_testing_api_operations.c */
diff --git a/src/testbed/testbed_api_operations.h b/src/testbed/testbed_api_operations.h
new file mode 100644
index 000000000..3636fa421
--- /dev/null
+++ b/src/testbed/testbed_api_operations.h
@@ -0,0 +1,34 @@
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 testing/new_testing_api_operations.h
23 * @brief internal API to access the 'operations' subsystem
24 * @author Christian Grothoff
25 */
26#ifndef NEW_TESTING_API_OPERATIONS_H
27#define NEW_TESTING_API_OPERATIONS_H
28
29#include "gnunet_testing_service.h"
30#include "gnunet_helper_lib.h"
31
32
33#endif
34/* end of new_testing_api_operations.h */
diff --git a/src/testbed/testbed_api_peers.c b/src/testbed/testbed_api_peers.c
new file mode 100644
index 000000000..c73a0958a
--- /dev/null
+++ b/src/testbed/testbed_api_peers.c
@@ -0,0 +1,297 @@
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 testing/new_testing_api_peers.c
23 * @brief management of the knowledge about peers in this library
24 * (we know the peer ID, its host, pending operations, etc.)
25 * @author Christian Grothoff
26 */
27#include "platform.h"
28#include "new_testing_api_peers.h"
29
30
31/**
32 * Details about a peer; kept in a separate struct to avoid bloating
33 * memory consumption everywhere...
34 */
35struct PeerDetails
36{
37 /**
38 * Configuration of the peer; NULL if we are not sure what the peer's correct
39 * configuration actually is; non-NULL if this peer is controlled by this
40 * process.
41 */
42 struct GNUNET_CONFIGURATION_Handle *cfg;
43
44 /**
45 * If this process has started this peer's ARM process, this is the handle
46 * to the 'gnunet-service-arm' process of the peer.
47 */
48 struct GNUNET_OS_Process *arm;
49
50 // ...
51
52};
53
54
55/**
56 * A peer controlled by the testing framework. A peer runs
57 * at a particular host.
58 */
59struct GNUNET_TESTBED_Peer
60{
61 /**
62 * Our controller context (not necessarily the controller
63 * that is responsible for starting/running the peer!).
64 */
65 struct GNUNET_TESTBED_Controller *controller;
66
67 /**
68 * Which host does this peer run on?
69 */
70 struct GNUENT_TESTING_Host *host;
71
72 /**
73 * Globally unique ID of the peer.
74 */
75 uint32_t unique_id;
76
77 /**
78 * Internals of the peer for the controlling process; NULL if
79 * this process is not controlling this peer.
80 */
81 struct PeerDetails *details;
82
83};
84
85
86/**
87 * Lookup a peer by ID.
88 *
89 * @param id global peer ID assigned to the peer
90 * @return handle to the host, NULL on error
91 */
92struct GNUNET_TESTBED_Peer *
93GNUNET_TESTBED_peer_lookup_by_id_ (uint32_t id)
94{
95 GNUNET_break (0);
96 return NULL;
97}
98
99
100/**
101 * Create the given peer at the specified host using the given
102 * controller. If the given controller is not running on the target
103 * host, it should find or create a controller at the target host and
104 * delegate creating the peer. Explicit delegation paths can be setup
105 * using 'GNUNET_TESTBED_controller_link'. If no explicit delegation
106 * path exists, a direct link with a subordinate controller is setup
107 * for the first delegated peer to a particular host; the subordinate
108 * controller is then destroyed once the last peer that was delegated
109 * to the remote host is stopped. This function is used in particular
110 * if some other controller has already assigned a unique ID to the
111 * peer.
112 *
113 * Creating the peer only creates the handle to manipulate and further
114 * configure the peer; use "GNUNET_TESTBED_peer_start" and
115 * "GNUNET_TESTBED_peer_stop" to actually start/stop the peer's
116 * processes.
117 *
118 * Note that the given configuration will be adjusted by the
119 * controller to avoid port/path conflicts with other peers.
120 * The "final" configuration can be obtained using
121 * 'GNUNET_TESTBED_peer_get_information'.
122 *
123 * @param unique_id unique ID for this peer
124 * @param controller controller process to use
125 * @param host host to run the peer on
126 * @param cfg configuration to use for the peer
127 * @return handle to the peer (actual startup will happen asynchronously)
128 */
129struct GNUNET_TESTBED_Peer *
130GNUNET_TESTBED_peer_create_with_id_ (uint32_t unique_id,
131 struct GNUNET_TESTBED_Controller *controller,
132 struct GNUNET_TESTBED_Host *host,
133 const struct GNUNET_CONFIGURATION_Handle *cfg)
134{
135 // FIXME: create locally or delegate...
136 GNUNET_break (0);
137 return NULL;
138}
139
140
141/**
142 * Create the given peer at the specified host using the given
143 * controller. If the given controller is not running on the target
144 * host, it should find or create a controller at the target host and
145 * delegate creating the peer. Explicit delegation paths can be setup
146 * using 'GNUNET_TESTBED_controller_link'. If no explicit delegation
147 * path exists, a direct link with a subordinate controller is setup
148 * for the first delegated peer to a particular host; the subordinate
149 * controller is then destroyed once the last peer that was delegated
150 * to the remote host is stopped.
151 *
152 * Creating the peer only creates the handle to manipulate and further
153 * configure the peer; use "GNUNET_TESTBED_peer_start" and
154 * "GNUNET_TESTBED_peer_stop" to actually start/stop the peer's
155 * processes.
156 *
157 * Note that the given configuration will be adjusted by the
158 * controller to avoid port/path conflicts with other peers.
159 * The "final" configuration can be obtained using
160 * 'GNUNET_TESTBED_peer_get_information'.
161 *
162 * @param controller controller process to use
163 * @param host host to run the peer on
164 * @param cfg configuration to use for the peer
165 * @return handle to the peer (actual startup will happen asynchronously)
166 */
167struct GNUNET_TESTBED_Peer *
168GNUNET_TESTBED_peer_create (struct GNUNET_TESTBED_Controller *controller,
169 struct GNUNET_TESTBED_Host *host,
170 const struct GNUNET_CONFIGURATION_Handle *cfg)
171{
172 static uint32_t id_gen;
173
174 return GNUNET_TESTBED_peer_create_with_id_ (++id_gen,
175 controller,
176 host,
177 cfg);
178}
179
180
181/**
182 * Start the given peer.
183 *
184 * @param peer peer to start
185 * @return handle to the operation
186 */
187struct GNUNET_TESTBED_Operation *
188GNUNET_TESTBED_peer_start (struct GNUNET_TESTBED_Peer *peer)
189{
190 // FIXME: start locally or delegate...
191 GNUNET_break (0);
192 return NULL;
193}
194
195
196/**
197 * Stop the given peer. The handle remains valid (use
198 * "GNUNET_TESTBED_peer_destroy" to fully clean up the
199 * state of the peer).
200 *
201 * @param peer peer to stop
202 * @return handle to the operation
203 */
204struct GNUNET_TESTBED_Operation *
205GNUNET_TESTBED_peer_stop (struct GNUNET_TESTBED_Peer *peer)
206{
207 // FIXME: stop locally or delegate...
208 GNUNET_break (0);
209 return NULL;
210}
211
212
213/**
214 * Request information about a peer.
215 *
216 * @param peer peer to request information about
217 * @param pit desired information
218 * @return handle to the operation
219 */
220struct GNUNET_TESTBED_Operation *
221GNUNET_TESTBED_peer_get_information (struct GNUNET_TESTBED_Peer *peer,
222 enum GNUNET_TESTBED_PeerInformationType pit)
223{
224 // FIXME: handle locally or delegate...
225 GNUNET_break (0);
226 return NULL;
227}
228
229
230/**
231 * Change peer configuration. Must only be called while the
232 * peer is stopped. Ports and paths cannot be changed this
233 * way.
234 *
235 * @param peer peer to change configuration for
236 * @param cfg new configuration (differences to existing
237 * configuration only)
238 * @return handle to the operation
239 */
240struct GNUNET_TESTBED_Operation *
241GNUNET_TESTBED_peer_update_configuration (struct GNUNET_TESTBED_Peer *peer,
242 const struct GNUNET_CONFIGURATION_Handle *cfg)
243{
244 // FIXME: handle locally or delegate...
245 GNUNET_break (0);
246 return NULL;
247}
248
249
250/**
251 * Manipulate the P2P underlay topology by configuring a link
252 * between two peers.
253 *
254 * @param op_cls closure argument to give with the operation event
255 * @param p1 first peer
256 * @param p2 second peer
257 * @param co option to change
258 * @param ... option-specific values
259 * @return handle to the operation, NULL if configuring the link at this
260 * time is not allowed
261 */
262struct GNUNET_TESTBED_Operation *
263GNUNET_TESTBED_underlay_configure_link (void *op_cls,
264 struct GNUNET_TESTBED_Peer *p1,
265 struct GNUNET_TESTBED_Peer *p2,
266 enum GNUNET_TESTBED_ConnectOption co, ...)
267{
268 GNUNET_break (0);
269 return NULL;
270}
271
272
273
274/**
275 * Both peers must have been started before calling this function.
276 * This function then obtains a HELLO from 'p1', gives it to 'p2'
277 * and asks 'p2' to connect to 'p1'.
278 *
279 * @param op_cls closure argument to give with the operation event
280 * @param p1 first peer
281 * @param p2 second peer
282 * @return handle to the operation, NULL if connecting these two
283 * peers is fundamentally not possible at this time (peers
284 * not running or underlay disallows)
285 */
286struct GNUNET_TESTBED_Operation *
287GNUNET_TESTBED_overlay_connect (void *op_cls,
288 struct GNUNET_TESTBED_Peer *p1,
289 struct GNUNET_TESTBED_Peer *p2)
290{
291 GNUNET_break (0);
292 return NULL;
293}
294
295
296
297/* end of new_testing_api_peers.c */
diff --git a/src/testbed/testbed_api_peers.h b/src/testbed/testbed_api_peers.h
new file mode 100644
index 000000000..6b2ed7c8b
--- /dev/null
+++ b/src/testbed/testbed_api_peers.h
@@ -0,0 +1,71 @@
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 testing/new_testing_api_peers.h
23 * @brief internal API to access the 'peers' subsystem
24 * @author Christian Grothoff
25 */
26#ifndef NEW_TESTING_API_PEERS_H
27#define NEW_TESTING_API_PEERS_H
28
29#include "gnunet_testing_service.h"
30#include "gnunet_helper_lib.h"
31
32
33/**
34 * Create the given peer at the specified host using the given
35 * controller. If the given controller is not running on the target
36 * host, it should find or create a controller at the target host and
37 * delegate creating the peer. Explicit delegation paths can be setup
38 * using 'GNUNET_TESTBED_controller_link'. If no explicit delegation
39 * path exists, a direct link with a subordinate controller is setup
40 * for the first delegated peer to a particular host; the subordinate
41 * controller is then destroyed once the last peer that was delegated
42 * to the remote host is stopped. This function is used in particular
43 * if some other controller has already assigned a unique ID to the
44 * peer.
45 *
46 * Creating the peer only creates the handle to manipulate and further
47 * configure the peer; use "GNUNET_TESTBED_peer_start" and
48 * "GNUNET_TESTBED_peer_stop" to actually start/stop the peer's
49 * processes.
50 *
51 * Note that the given configuration will be adjusted by the
52 * controller to avoid port/path conflicts with other peers.
53 * The "final" configuration can be obtained using
54 * 'GNUNET_TESTBED_peer_get_information'.
55 *
56 * @param unique_id unique ID for this peer
57 * @param controller controller process to use
58 * @param host host to run the peer on
59 * @param cfg configuration to use for the peer
60 * @return handle to the peer (actual startup will happen asynchronously)
61 */
62struct GNUNET_TESTBED_Peer *
63GNUNET_TESTBED_peer_create_with_id_ (uint32_t unique_id,
64 struct GNUNET_TESTBED_Controller *controller,
65 struct GNUNET_TESTBED_Host *host,
66 const struct GNUNET_CONFIGURATION_Handle *cfg);
67
68
69
70#endif
71/* end of new_testing_api_peers.h */
diff --git a/src/testbed/testbed_api_services.c b/src/testbed/testbed_api_services.c
new file mode 100644
index 000000000..524ec35e3
--- /dev/null
+++ b/src/testbed/testbed_api_services.c
@@ -0,0 +1,61 @@
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 testing/new_testing_api_services.c
23 * @brief convenience functions for accessing services
24 * @author Christian Grothoff
25 */
26#include "platform.h"
27#include "new_testing_api_peers.h"
28
29
30/**
31 * Connect to a service offered by the given peer. Will ensure that
32 * the request is queued to not overwhelm our ability to create and
33 * maintain connections with other systems. The actual service
34 * handle is then returned via the 'op_result' member in the event
35 * callback. The 'ca' callback is used to create the connection
36 * when the time is right; the 'da' callback will be used to
37 * destroy the connection (upon 'GNUNET_TESTBED_operation_done').
38 * 'GNUNET_TESTBED_operation_cancel' can be used to abort this
39 * operation until the event callback has been called.
40 *
41 * @param op_cls closure to pass in operation event
42 * @param peer peer that runs the service
43 * @param service_name name of the service to connect to
44 * @param ca helper function to establish the connection
45 * @param da helper function to close the connection
46 * @param cada_cls closure for ca and da
47 * @return handle for the operation
48 */
49struct GNUNET_TESTBED_Operation *
50GNUNET_TESTBED_service_connect (void *op_cls,
51 struct GNUNET_TESTBED_Peer *peer,
52 const char *service_name,
53 GNUNET_TESTBED_ConnectAdapter ca,
54 GNUNET_TESTBED_DisconnectAdapter da,
55 void *cada_cls)
56{
57 GNUNET_break (0);
58 return NULL;
59}
60
61/* end of new_testing_api_services.c */
diff --git a/src/testbed/testbed_api_test.c b/src/testbed/testbed_api_test.c
new file mode 100644
index 000000000..ed5e2e8e3
--- /dev/null
+++ b/src/testbed/testbed_api_test.c
@@ -0,0 +1,67 @@
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 testing/new_testing_api_test.c
23 * @brief high-level test function
24 * @author Christian Grothoff
25 */
26#include "platform.h"
27#include "gnunet_testing_service.h"
28
29
30
31
32/**
33 * Convenience method for running a "simple" test on the local system
34 * with a single call from 'main'. Underlay and overlay topology are
35 * configured using the "UNDERLAY" and "OVERLAY" options in the
36 * "[testbed]" section of the configuration (with possible options
37 * given in "UNDERLAY_XXX" and/or "OVERLAY_XXX").
38 *
39 * The test is to be terminated using a call to
40 * "GNUNET_SCHEDULER_shutdown". If starting the test fails,
41 * the program is stopped without 'master' ever being run.
42 *
43 * NOTE: this function should be called from 'main', NOT from
44 * within a GNUNET_SCHEDULER-loop. This function will initialze
45 * the scheduler loop, the testbed and then pass control to
46 * 'master'.
47 *
48 * @param testname name of the testcase (to configure logging, etc.)
49 * @param cfg_filename configuration filename to use
50 * (for testbed, controller and peers)
51 * @param num_peers number of peers to start
52 * @param test_master task to run once the test is ready
53 * @param test_master_cls closure for 'task'.
54 */
55void
56GNUNET_TESTBED_test_run (const char *testname,
57 const char *cfg_filename,
58 unsigned int num_peers,
59 GNUNET_TESTBED_TestMaster test_master,
60 void *test_master_cls)
61{
62 GNUNET_break (0);
63}
64
65
66
67/* end of new_testing_api_test.c */
diff --git a/src/testbed/testbed_api_testbed.c b/src/testbed/testbed_api_testbed.c
new file mode 100644
index 000000000..8c917db81
--- /dev/null
+++ b/src/testbed/testbed_api_testbed.c
@@ -0,0 +1,153 @@
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 testing/new_testing_api_testbed.c
23 * @brief high-level testbed management
24 * @author Christian Grothoff
25 */
26#include "platform.h"
27#include "gnunet_testing_service.h"
28
29
30/**
31 * Opaque handle to an abstract operation to be executed by the testing framework.
32 */
33struct GNUNET_TESTBED_Testbed
34{
35 // FIXME!
36};
37
38
39/**
40 * Configure and run a testbed using the given
41 * master controller on 'num_hosts' starting
42 * 'num_peers' using the given peer configuration.
43 *
44 * @param controller master controller for the testbed
45 * (must not be destroyed until after the
46 * testbed is destroyed).
47 * @param num_hosts number of hosts in 'hosts', 0 to only
48 * use 'localhost'
49 * @param hosts list of hosts to use for the testbed
50 * @param num_peers number of peers to start
51 * @param peer_cfg peer configuration template to use
52 * @param underlay_topology underlay topology to create
53 * @param va topology-specific options
54 * @return handle to the testbed
55 */
56struct GNUNET_TESTBED_Testbed *
57GNUNET_TESTBED_create_va (struct GNUNET_TESTBED_Controller *controller,
58 unsigned int num_hosts,
59 struct GNUNET_TESTBED_Host **hosts,
60 unsigned int num_peers,
61 const struct GNUNET_CONFIGURATION_Handle *peer_cfg,
62 enum GNUNET_TESTBED_TopologyOption underlay_topology,
63 va_list va)
64{
65 GNUNET_break (0);
66 return NULL;
67}
68
69
70/**
71 * Configure and run a testbed using the given
72 * master controller on 'num_hosts' starting
73 * 'num_peers' using the given peer configuration.
74 *
75 * @param controller master controller for the testbed
76 * (must not be destroyed until after the
77 * testbed is destroyed).
78 * @param num_hosts number of hosts in 'hosts', 0 to only
79 * use 'localhost'
80 * @param hosts list of hosts to use for the testbed
81 * @param num_peers number of peers to start
82 * @param peer_cfg peer configuration template to use
83 * @param underlay_topology underlay topology to create
84 * @param ... topology-specific options
85 */
86struct GNUNET_TESTBED_Testbed *
87GNUNET_TESTBED_create (struct GNUNET_TESTBED_Controller *controller,
88 unsigned int num_hosts,
89 struct GNUNET_TESTBED_Host **hosts,
90 unsigned int num_peers,
91 const struct GNUNET_CONFIGURATION_Handle *peer_cfg,
92 enum GNUNET_TESTBED_TopologyOption underlay_topology,
93 ...)
94{
95 GNUNET_break (0);
96 return NULL;
97}
98
99
100/**
101 * Destroy a testbed. Stops all running peers and then
102 * destroys all peers. Does NOT destroy the master controller.
103 *
104 * @param testbed testbed to destroy
105 */
106void
107GNUNET_TESTBED_destroy (struct GNUNET_TESTBED_Testbed *testbed)
108{
109 GNUNET_break (0);
110}
111
112
113
114/**
115 * Convenience method for running a testbed with
116 * a single call. Underlay and overlay topology
117 * are configured using the "UNDERLAY" and "OVERLAY"
118 * options in the "[testbed]" section of the configuration\
119 * (with possible options given in "UNDERLAY_XXX" and/or
120 * "OVERLAY_XXX").
121 *
122 * The testbed is to be terminated using a call to
123 * "GNUNET_SCHEDULER_shutdown".
124 *
125 * @param host_filename name of the file with the 'hosts', NULL
126 * to run everything on 'localhost'
127 * @param cfg configuration to use (for testbed, controller and peers)
128 * @param num_peers number of peers to start; FIXME: maybe put that ALSO into cfg?
129 * @param event_mask bit mask with set of events to call 'cc' for;
130 * or-ed values of "1LL" shifted by the
131 * respective 'enum GNUNET_TESTBED_EventType'
132 * (i.e. "(1LL << GNUNET_TESTBED_ET_CONNECT) || ...")
133 * @param cc controller callback to invoke on events
134 * @param cc_cls closure for cc
135 * @param master task to run once the testbed is ready
136 * @param master_cls closure for 'task'.
137 */
138void
139GNUNET_TESTBED_run (const char *host_filename,
140 const struct GNUNET_CONFIGURATION_Handle *cfg,
141 unsigned int num_peers,
142 uint64_t event_mask,
143 GNUNET_TESTBED_ControllerCallback cc,
144 void *cc_cls,
145 GNUNET_SCHEDULER_Task master,
146 void *master_cls)
147{
148 GNUNET_break (0);
149}
150
151
152
153/* end of new_testing_api_testbed.c */
diff --git a/src/testbed/testbed_api_topology.c b/src/testbed/testbed_api_topology.c
new file mode 100644
index 000000000..12def3a1f
--- /dev/null
+++ b/src/testbed/testbed_api_topology.c
@@ -0,0 +1,127 @@
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 testing/new_testing_api_topology.c
23 * @brief topology-generation functions
24 * @author Christian Grothoff
25 */
26#include "platform.h"
27#include "gnunet_testing_service.h"
28
29
30/**
31 * Configure overall network topology to have a particular shape.
32 *
33 * @param op_cls closure argument to give with the operation event
34 * @param num_peers number of peers in 'peers'
35 * @param peers array of 'num_peers' with the peers to configure
36 * @param topo desired underlay topology to use
37 * @param ap topology-specific options
38 * @return handle to the operation, NULL if configuring the topology
39 * is not allowed at this time
40 */
41struct GNUNET_TESTBED_Operation *
42GNUNET_TESTBED_underlay_configure_topology_va (void *op_cls,
43 unsigned int num_peers,
44 struct GNUNET_TESTBED_Peer **peers,
45 enum GNUNET_TESTBED_TopologyOption topo,
46 va_list ap)
47{
48 GNUNET_break (0);
49 return NULL;
50}
51
52
53/**
54 * Configure overall network topology to have a particular shape.
55 *
56 * @param op_cls closure argument to give with the operation event
57 * @param num_peers number of peers in 'peers'
58 * @param peers array of 'num_peers' with the peers to configure
59 * @param topo desired underlay topology to use
60 * @param ... topology-specific options
61 * @return handle to the operation, NULL if configuring the topology
62 * is not allowed at this time
63 */
64struct GNUNET_TESTBED_Operation *
65GNUNET_TESTBED_underlay_configure_topology (void *op_cls,
66 unsigned int num_peers,
67 struct GNUNET_TESTBED_Peer **peers,
68 enum GNUNET_TESTBED_TopologyOption topo,
69 ...)
70{
71 GNUNET_break (0);
72 return NULL;
73}
74
75
76/**
77 * All peers must have been started before calling this function.
78 * This function then connects the given peers in the P2P overlay
79 * using the given topology.
80 *
81 * @param op_cls closure argument to give with the operation event
82 * @param num_peers number of peers in 'peers'
83 * @param peers array of 'num_peers' with the peers to configure
84 * @param topo desired underlay topology to use
85 * @param va topology-specific options
86 * @return handle to the operation, NULL if connecting these
87 * peers is fundamentally not possible at this time (peers
88 * not running or underlay disallows)
89 */
90struct GNUNET_TESTBED_Operation *
91GNUNET_TESTBED_overlay_configure_topology_va (void *op_cls,
92 unsigned int num_peers,
93 struct GNUNET_TESTBED_Peer *peers,
94 enum GNUNET_TESTBED_TopologyOption topo,
95 va_list va)
96{
97 GNUNET_break (0);
98 return NULL;
99}
100
101
102/**
103 * All peers must have been started before calling this function.
104 * This function then connects the given peers in the P2P overlay
105 * using the given topology.
106 *
107 * @param op_cls closure argument to give with the operation event
108 * @param num_peers number of peers in 'peers'
109 * @param peers array of 'num_peers' with the peers to configure
110 * @param topo desired underlay topology to use
111 * @param ... topology-specific options
112 * @return handle to the operation, NULL if connecting these
113 * peers is fundamentally not possible at this time (peers
114 * not running or underlay disallows)
115 */
116struct GNUNET_TESTBED_Operation *
117GNUNET_TESTBED_overlay_configure_topology (void *op_cls,
118 unsigned int num_peers,
119 struct GNUNET_TESTBED_Peer *peers,
120 enum GNUNET_TESTBED_TopologyOption topo,
121 ...)
122{
123 GNUNET_break (0);
124 return NULL;
125}
126
127/* end of new_testing_api_topology.c */