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 3, 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 include/gnunet_testing_lib.h
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 #ifndef GNUNET_TESTING_LIB_H
33 #define GNUNET_TESTING_LIB_H
35 #include "gnunet_util_lib.h"
36 #include "gnunet_statistics_service.h"
41 #if 0 /* keep Emacsens' auto-indent happy */
46 #define HOSTKEYFILESIZE 914
49 * Handle for a GNUnet daemon (technically a set of
50 * daemons; the handle is really for the master ARM
51 * daemon) started by the testing library.
53 struct GNUNET_TESTING_Daemon;
56 * Linked list of hostnames and ports to use for starting daemons.
58 struct GNUNET_TESTING_Host
61 * Pointer to next item in the list.
63 struct GNUNET_TESTING_Host *next;
66 * Hostname to connect to.
71 * Username to use when connecting (may be null).
76 * Port to use for SSH connection (used for ssh
77 * connection forwarding, 0 to let ssh decide)
83 * Prototype of a function that will be called whenever
84 * a daemon was started by the testing library.
87 * @param id identifier for the daemon, NULL on error
88 * @param d handle for the daemon
89 * @param emsg error message (NULL on success)
91 typedef void (*GNUNET_TESTING_NotifyHostkeyCreated)(void *cls,
92 const struct GNUNET_PeerIdentity *id,
93 struct GNUNET_TESTING_Daemon *d,
97 * Prototype of a function that will be called whenever
98 * a daemon was started by the testing library.
101 * @param id identifier for the daemon, NULL on error
102 * @param cfg configuration used by this daemon
103 * @param d handle for the daemon
104 * @param emsg error message (NULL on success)
106 typedef void (*GNUNET_TESTING_NotifyDaemonRunning)(void *cls,
107 const struct GNUNET_PeerIdentity *id,
108 const struct GNUNET_CONFIGURATION_Handle *cfg,
109 struct GNUNET_TESTING_Daemon *d,
114 * Handle to an entire testbed of GNUnet peers.
116 struct GNUNET_TESTING_Testbed;
119 * Phases of starting GNUnet on a system.
121 enum GNUNET_TESTING_StartPhase
124 * Copy the configuration file to the target system.
129 * Configuration file has been copied, generate hostkey.
134 * Create the hostkey for the peer.
139 * Hostkey generated, wait for topology to be finished.
144 * Topology has been created, now start ARM.
149 * ARM has been started, check that it has properly daemonized and
150 * then try to connect to the CORE service (which should be
151 * auto-started by ARM).
156 * We're waiting for CORE to start.
161 * CORE is up, now make sure we get the HELLO for this peer.
166 * Core has notified us that we've established a connection to the service.
167 * The main FSM halts here and waits to be moved to UPDATE or CLEANUP.
172 * We've been asked to terminate the instance and are now waiting for
173 * the remote command to stop the gnunet-arm process and delete temporary
179 * We've received a configuration update and are currently waiting for
180 * the copy process for the update to complete. Once it is, we will
181 * return to "SP_START_DONE" (and rely on ARM to restart all affected
188 * Prototype of a function that will be called when a
189 * particular operation was completed the testing library.
192 * @param emsg NULL on success
194 typedef void (*GNUNET_TESTING_NotifyCompletion)(void *cls,
198 * Prototype of a function that will be called with the
199 * number of connections created for a particular topology.
202 * @param num_connections the number of connections created
204 typedef void (*GNUNET_TESTING_NotifyConnections)(void *cls,
205 unsigned int num_connections);
208 * Handle for a GNUnet daemon (technically a set of
209 * daemons; the handle is really for the master ARM
210 * daemon) started by the testing library.
212 struct GNUNET_TESTING_Daemon
217 struct GNUNET_CONFIGURATION_Handle *cfg;
220 * At what time to give up starting the peer
222 struct GNUNET_TIME_Absolute max_timeout;
225 * Host to run GNUnet on.
230 * Port to use for ssh, NULL to let system choose default.
235 * Result of GNUNET_i2s of this peer,
241 * Username we are using.
246 * Name of the configuration file
251 * Callback to inform initiator that the peer's
252 * hostkey has been created.
254 GNUNET_TESTING_NotifyHostkeyCreated hostkey_callback;
257 * Closure for hostkey creation callback.
262 * Function to call when the peer is running.
264 GNUNET_TESTING_NotifyDaemonRunning cb;
272 * Arguments from "daemon_stop" call.
274 GNUNET_TESTING_NotifyCompletion dead_cb;
277 * Closure for 'dead_cb'.
282 * Arguments from "daemon_stop" call.
284 GNUNET_TESTING_NotifyCompletion update_cb;
287 * Closure for 'update_cb'.
292 * Identity of this peer (once started).
294 struct GNUNET_PeerIdentity id;
297 * Flag to indicate that we've already been asked
298 * to terminate (but could not because some action
299 * was still pending).
304 * GNUNET_YES if the hostkey has been created
305 * for this peer, GNUNET_NO otherwise.
310 * PID of the process that we started last.
312 struct GNUNET_OS_Process *proc;
315 * In which phase are we during the start of
318 enum GNUNET_TESTING_StartPhase phase;
321 * ID of the current task.
323 GNUNET_SCHEDULER_TaskIdentifier task;
326 * Handle to the server.
328 struct GNUNET_CORE_Handle *server;
331 * Handle to the transport service of this peer
333 struct GNUNET_TRANSPORT_Handle *th;
336 * HELLO message for this peer
338 struct GNUNET_HELLO_Message *hello;
341 * Handle to a pipe for reading the hostkey.
343 struct GNUNET_DISK_PipeHandle *pipe_stdout;
346 * Output from gnunet-peerinfo is read into this buffer.
348 char hostkeybuf[105];
351 * Current position in 'hostkeybuf' (for reading from gnunet-peerinfo)
353 unsigned int hostkeybufpos;
356 * Set to GNUNET_YES once the peer is up.
361 * Used to tell shutdown not to remove configuration for the peer
362 * (if it's going to be restarted later)
369 * Handle to a group of GNUnet peers.
371 struct GNUNET_TESTING_PeerGroup;
375 * Prototype of a function that will be called whenever
376 * two daemons are connected by the testing library.
379 * @param first peer id for first daemon
380 * @param second peer id for the second daemon
381 * @param distance distance between the connected peers
382 * @param first_cfg config for the first daemon
383 * @param second_cfg config for the second daemon
384 * @param first_daemon handle for the first daemon
385 * @param second_daemon handle for the second daemon
386 * @param emsg error message (NULL on success)
388 typedef void (*GNUNET_TESTING_NotifyConnection)(void *cls,
389 const struct GNUNET_PeerIdentity *first,
390 const struct GNUNET_PeerIdentity *second,
392 const struct GNUNET_CONFIGURATION_Handle *first_cfg,
393 const struct GNUNET_CONFIGURATION_Handle *second_cfg,
394 struct GNUNET_TESTING_Daemon *first_daemon,
395 struct GNUNET_TESTING_Daemon *second_daemon,
399 * Prototype of a callback function indicating that two peers
400 * are currently connected.
403 * @param first peer id for first daemon
404 * @param second peer id for the second daemon
405 * @param distance distance between the connected peers
406 * @param emsg error message (NULL on success)
408 typedef void (*GNUNET_TESTING_NotifyTopology)(void *cls,
409 const struct GNUNET_PeerIdentity *first,
410 const struct GNUNET_PeerIdentity *second,
414 * Starts a GNUnet daemon. GNUnet must be installed on the target
415 * system and available in the PATH. The machine must furthermore be
416 * reachable via "ssh" (unless the hostname is "NULL") without the
417 * need to enter a password.
419 * @param cfg configuration to use
420 * @param timeout how long to wait starting up peers
421 * @param pretend GNUNET_YES to set up files but not start peer GNUNET_NO
422 * to really start the peer (default)
423 * @param hostname name of the machine where to run GNUnet
424 * (use NULL for localhost).
425 * @param ssh_username ssh username to use when connecting to hostname
426 * @param sshport port to pass to ssh process when connecting to hostname
427 * @param hostkey pointer to a hostkey to be written to disk (instead of being generated)
428 * @param hostkey_callback function to call once the hostkey has been
429 * generated for this peer, but it hasn't yet been started
430 * (NULL to start immediately, otherwise waits on GNUNET_TESTING_daemon_continue_start)
431 * @param hostkey_cls closure for hostkey callback
432 * @param cb function to call once peer is up, or failed to start
433 * @param cb_cls closure for cb
434 * @return handle to the daemon (actual start will be completed asynchronously)
436 struct GNUNET_TESTING_Daemon *
437 GNUNET_TESTING_daemon_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
438 struct GNUNET_TIME_Relative timeout,
440 const char *hostname,
441 const char *ssh_username,
444 GNUNET_TESTING_NotifyHostkeyCreated
445 hostkey_callback, void *hostkey_cls,
446 GNUNET_TESTING_NotifyDaemonRunning cb,
450 * Continues GNUnet daemon startup when user wanted to be notified
451 * once a hostkey was generated (for creating friends files, blacklists,
454 * @param daemon the daemon to finish starting
457 GNUNET_TESTING_daemon_continue_startup(struct GNUNET_TESTING_Daemon *daemon);
460 * Check whether the given daemon is running.
462 * @param daemon the daemon to check
464 * @return GNUNET_YES if the daemon is up, GNUNET_NO if the
465 * daemon is down, GNUNET_SYSERR on error.
468 GNUNET_TESTING_daemon_running (struct GNUNET_TESTING_Daemon *daemon);
471 * Restart (stop and start) a GNUnet daemon.
473 * @param d the daemon that should be restarted
474 * @param cb function called once the daemon is (re)started
475 * @param cb_cls closure for cb
478 GNUNET_TESTING_daemon_restart (struct GNUNET_TESTING_Daemon *d,
479 GNUNET_TESTING_NotifyDaemonRunning cb, void *cb_cls);
482 * Start a peer that has previously been stopped using the daemon_stop
483 * call (and files weren't deleted and the allow restart flag)
485 * @param daemon the daemon to start (has been previously stopped)
486 * @param timeout how long to wait for restart
487 * @param cb the callback for notification when the peer is running
488 * @param cb_cls closure for the callback
491 GNUNET_TESTING_daemon_start_stopped (struct GNUNET_TESTING_Daemon *daemon,
492 struct GNUNET_TIME_Relative timeout,
493 GNUNET_TESTING_NotifyDaemonRunning cb,
497 * Get a certain testing daemon handle.
499 * @param pg handle to the set of running peers
500 * @param position the number of the peer to return
502 struct GNUNET_TESTING_Daemon *
503 GNUNET_TESTING_daemon_get (struct GNUNET_TESTING_PeerGroup *pg,
504 unsigned int position);
507 * Get a daemon by peer identity, so callers can
508 * retrieve the daemon without knowing it's offset.
510 * @param pg the peer group to retrieve the daemon from
511 * @param peer_id the peer identity of the daemon to retrieve
513 * @return the daemon on success, or NULL if no such peer identity is found
515 struct GNUNET_TESTING_Daemon *
516 GNUNET_TESTING_daemon_get_by_id (struct GNUNET_TESTING_PeerGroup *pg,
517 struct GNUNET_PeerIdentity *peer_id);
520 * Stops a GNUnet daemon.
522 * @param d the daemon that should be stopped
523 * @param timeout how long to wait for process for shutdown to complete
524 * @param cb function called once the daemon was stopped
525 * @param cb_cls closure for cb
526 * @param delete_files GNUNET_YES to remove files, GNUNET_NO
527 * to leave them (i.e. for restarting at a later time,
528 * or logfile inspection once finished)
529 * @param allow_restart GNUNET_YES to restart peer later (using this API)
530 * GNUNET_NO to kill off and clean up for good
533 GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d,
534 struct GNUNET_TIME_Relative timeout,
535 GNUNET_TESTING_NotifyCompletion cb, void *cb_cls,
536 int delete_files, int allow_restart);
540 * Changes the configuration of a GNUnet daemon.
542 * @param d the daemon that should be modified
543 * @param cfg the new configuration for the daemon
544 * @param cb function called once the configuration was changed
545 * @param cb_cls closure for cb
547 void GNUNET_TESTING_daemon_reconfigure (struct GNUNET_TESTING_Daemon *d,
548 struct GNUNET_CONFIGURATION_Handle *cfg,
549 GNUNET_TESTING_NotifyCompletion cb,
554 * Establish a connection between two GNUnet daemons.
556 * @param d1 handle for the first daemon
557 * @param d2 handle for the second daemon
558 * @param timeout how long is the connection attempt
560 * @param max_connect_attempts how many times should we try to reconnect
562 * @param send_hello GNUNET_YES to send the HELLO, GNUNET_NO to assume
563 * the HELLO has already been exchanged
564 * @param cb function to call at the end
565 * @param cb_cls closure for cb
568 GNUNET_TESTING_daemons_connect (struct GNUNET_TESTING_Daemon *d1,
569 struct GNUNET_TESTING_Daemon *d2,
570 struct GNUNET_TIME_Relative timeout,
571 unsigned int max_connect_attempts,
573 GNUNET_TESTING_NotifyConnection cb,
580 * Start count gnunet instances with the same set of transports and
581 * applications. The port numbers (any option called "PORT") will be
582 * adjusted to ensure that no two peers running on the same system
583 * have the same port(s) in their respective configurations.
585 * @param cfg configuration template to use
586 * @param total number of daemons to start
587 * @param max_concurrent_connections for testing, how many peers can
588 * we connect to simultaneously
589 * @param max_concurrent_ssh when starting with ssh, how many ssh
590 * connections will we allow at once (based on remote hosts allowed!)
591 * @param timeout total time allowed for peers to start
592 * @param hostkey_callback function to call on each peers hostkey generation
593 * if NULL, peers will be started by this call, if non-null,
594 * GNUNET_TESTING_daemons_continue_startup must be called after
595 * successful hostkey generation
596 * @param hostkey_cls closure for hostkey callback
597 * @param cb function to call on each daemon that was started
598 * @param cb_cls closure for cb
599 * @param connect_callback function to call each time two hosts are connected
600 * @param connect_callback_cls closure for connect_callback
601 * @param hostnames linked list of host structs to use to start peers on
602 * (NULL to run on localhost only)
604 * @return NULL on error, otherwise handle to control peer group
606 struct GNUNET_TESTING_PeerGroup *
607 GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
609 unsigned int max_concurrent_connections,
610 unsigned int max_concurrent_ssh,
611 struct GNUNET_TIME_Relative timeout,
612 GNUNET_TESTING_NotifyHostkeyCreated
613 hostkey_callback, void *hostkey_cls,
614 GNUNET_TESTING_NotifyDaemonRunning cb,
616 GNUNET_TESTING_NotifyConnection
617 connect_callback, void *connect_callback_cls,
618 const struct GNUNET_TESTING_Host *hostnames);
621 * Function which continues a peer group starting up
622 * after successfully generating hostkeys for each peer.
624 * @param pg the peer group to continue starting
627 GNUNET_TESTING_daemons_continue_startup(struct GNUNET_TESTING_PeerGroup *pg);
630 * Restart all peers in the given group.
632 * @param pg the handle to the peer group
633 * @param callback function to call on completion (or failure)
634 * @param callback_cls closure for the callback function
637 GNUNET_TESTING_daemons_restart (struct GNUNET_TESTING_PeerGroup *pg,
638 GNUNET_TESTING_NotifyCompletion callback,
643 * Shutdown all peers started in the given group.
645 * @param pg handle to the peer group
646 * @param timeout how long to wait for shutdown
647 * @param cb callback to notify upon success or failure
648 * @param cb_cls closure for cb
651 GNUNET_TESTING_daemons_stop (struct GNUNET_TESTING_PeerGroup *pg,
652 struct GNUNET_TIME_Relative timeout,
653 GNUNET_TESTING_NotifyCompletion cb,
658 * Count the number of running peers.
660 * @param pg handle for the peer group
662 * @return the number of currently running peers in the peer group
665 GNUNET_TESTING_daemons_running (struct GNUNET_TESTING_PeerGroup *pg);
668 * Simulate churn by stopping some peers (and possibly
669 * re-starting others if churn is called multiple times). This
670 * function can only be used to create leave-join churn (peers "never"
671 * leave for good). First "voff" random peers that are currently
672 * online will be taken offline; then "von" random peers that are then
673 * offline will be put back online. No notifications will be
674 * generated for any of these operations except for the callback upon
675 * completion. Note that the implementation is at liberty to keep
676 * the ARM service itself (but none of the other services or daemons)
677 * running even though the "peer" is being varied offline.
679 * @param pg handle for the peer group
680 * @param voff number of peers that should go offline
681 * @param von number of peers that should come back online;
682 * must be zero on first call (since "testbed_start"
683 * always starts all of the peers)
684 * @param timeout how long to wait for operations to finish before
686 * @param cb function to call at the end
687 * @param cb_cls closure for cb
690 GNUNET_TESTING_daemons_churn (struct GNUNET_TESTING_PeerGroup *pg,
693 struct GNUNET_TIME_Relative timeout,
694 GNUNET_TESTING_NotifyCompletion cb,
698 * Callback function to process statistic values.
701 * @param peer the peer the statistics belong to
702 * @param subsystem name of subsystem that created the statistic
703 * @param name the name of the datum
704 * @param value the current value
705 * @param is_persistent GNUNET_YES if the value is persistent, GNUNET_NO if not
706 * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration
708 typedef int (*GNUNET_TESTING_STATISTICS_Iterator) (void *cls,
709 const struct GNUNET_PeerIdentity *peer,
710 const char *subsystem,
716 * Iterate over all (running) peers in the peer group, retrieve
717 * all statistics from each.
720 GNUNET_TESTING_get_statistics (struct GNUNET_TESTING_PeerGroup *pg,
721 GNUNET_STATISTICS_Callback cont,
722 GNUNET_TESTING_STATISTICS_Iterator proc, void *cls);
725 * Topologies supported for testbeds.
727 enum GNUNET_TESTING_Topology
730 * A clique (everyone connected to everyone else).
732 GNUNET_TESTING_TOPOLOGY_CLIQUE,
735 * Small-world network (2d torus plus random links).
737 GNUNET_TESTING_TOPOLOGY_SMALL_WORLD,
740 * Small-world network (ring plus random links).
742 GNUNET_TESTING_TOPOLOGY_SMALL_WORLD_RING,
747 GNUNET_TESTING_TOPOLOGY_RING,
752 GNUNET_TESTING_TOPOLOGY_2D_TORUS,
757 GNUNET_TESTING_TOPOLOGY_ERDOS_RENYI,
760 * Certain percentage of peers are unable to communicate directly
761 * replicating NAT conditions
763 GNUNET_TESTING_TOPOLOGY_INTERNAT,
766 * Scale free topology.
768 GNUNET_TESTING_TOPOLOGY_SCALE_FREE,
771 * Straight line topology.
773 GNUNET_TESTING_TOPOLOGY_LINE,
776 * All peers are disconnected.
778 GNUNET_TESTING_TOPOLOGY_NONE,
781 * Read a topology from a given file.
783 GNUNET_TESTING_TOPOLOGY_FROM_FILE
787 * Options for connecting a topology.
789 enum GNUNET_TESTING_TopologyOption
792 * Try to connect all peers specified in the topology.
794 GNUNET_TESTING_TOPOLOGY_OPTION_ALL,
797 * Choose a random subset of connections to create.
799 GNUNET_TESTING_TOPOLOGY_OPTION_RANDOM,
802 * Create at least X connections for each peer.
804 GNUNET_TESTING_TOPOLOGY_OPTION_MINIMUM,
807 * Using a depth first search, create one connection
808 * per peer. If any are missed (graph disconnected)
809 * start over at those peers until all have at least one
812 GNUNET_TESTING_TOPOLOGY_OPTION_DFS,
815 * Find the N closest peers to each allowed peer in the
816 * topology and make sure a connection to those peers
817 * exists in the connect topology.
819 GNUNET_TESTING_TOPOLOGY_OPTION_ADD_CLOSEST,
822 * No options specified.
824 GNUNET_TESTING_TOPOLOGY_OPTION_NONE
829 * Get a topology from a string input.
831 * @param topology where to write the retrieved topology
832 * @param topology_string The string to attempt to
833 * get a configuration value from
834 * @return GNUNET_YES if topology string matched a
835 * known topology, GNUNET_NO if not
838 GNUNET_TESTING_topology_get(enum GNUNET_TESTING_Topology *topology,
839 const char * topology_string);
842 * Get connect topology option from string input.
844 * @param topology_option where to write the retrieved topology
845 * @param topology_string The string to attempt to
846 * get a configuration value from
847 * @return GNUNET_YES if topology string matched a
848 * known topology, GNUNET_NO if not
851 GNUNET_TESTING_topology_option_get(enum GNUNET_TESTING_TopologyOption *topology_option,
852 const char * topology_string);
856 * Takes a peer group and creates a topology based on the
857 * one specified. Creates a topology means generates friend
858 * files for the peers so they can only connect to those allowed
859 * by the topology. This will only have an effect once peers
860 * are started if the FRIENDS_ONLY option is set in the base
863 * Also takes an optional restrict topology which
864 * disallows direct connections UNLESS they are specified in
865 * the restricted topology.
867 * A simple example; if the topology option is set to LINE
868 * peers can ONLY connect in a LINE. However, if the topology
869 * option is set to 2D-torus and the restrict option is set to
870 * line with restrict_transports equal to "tcp udp", then peers
871 * may connect in a 2D-torus, but will be restricted to tcp and
872 * udp connections only in a LINE. Generally it only makes
873 * sense to do this if restrict_topology is a subset of topology.
875 * For testing peer discovery, etc. it is generally better to
876 * leave restrict_topology as GNUNET_TESTING_TOPOLOGY_NONE and
877 * then use the connect_topology function to restrict the initial
880 * @param pg the peer group struct representing the running peers
881 * @param topology which topology to connect the peers in
882 * @param restrict_topology allow only direct connections in this topology,
883 * based on those listed in restrict_transports, set to
884 * GNUNET_TESTING_TOPOLOGY_NONE for no restrictions
885 * @param restrict_transports space delimited list of transports to blacklist
886 * to create restricted topology, NULL for none
888 * @return the maximum number of connections were all allowed peers
889 * connected to each other
892 GNUNET_TESTING_create_topology (struct GNUNET_TESTING_PeerGroup *pg,
893 enum GNUNET_TESTING_Topology topology,
894 enum GNUNET_TESTING_Topology restrict_topology,
895 const char *restrict_transports);
898 * Iterate over all (running) peers in the peer group, retrieve
899 * all connections that each currently has.
901 * @param pg the peer group we are concerned with
902 * @param cb callback for topology information
903 * @param cls closure for callback
906 GNUNET_TESTING_get_topology (struct GNUNET_TESTING_PeerGroup *pg,
907 GNUNET_TESTING_NotifyTopology cb, void *cls);
910 * Stop the connection process temporarily.
912 * @param pg the peer group to stop connecting
914 void GNUNET_TESTING_stop_connections(struct GNUNET_TESTING_PeerGroup *pg);
917 * Resume the connection process.
919 * @param pg the peer group to resume connecting
921 void GNUNET_TESTING_resume_connections(struct GNUNET_TESTING_PeerGroup *pg);
924 * There are many ways to connect peers that are supported by this function.
925 * To connect peers in the same topology that was created via the
926 * GNUNET_TESTING_create_topology, the topology variable must be set to
927 * GNUNET_TESTING_TOPOLOGY_NONE. If the topology variable is specified,
928 * a new instance of that topology will be generated and attempted to be
929 * connected. This could result in some connections being impossible,
930 * because some topologies are non-deterministic.
932 * @param pg the peer group struct representing the running peers
933 * @param topology which topology to connect the peers in
934 * @param options options for connecting the topology
935 * @param option_modifier modifier for options that take a parameter
936 * @param connect_timeout how long to wait before giving up on connecting
938 * @param connect_attempts how many times to attempt to connect two peers
939 * over the connect_timeout duration
940 * @param notify_callback notification to be called once all connections completed
941 * @param notify_cls closure for notification callback
943 * @return the number of connections that will be attempted, GNUNET_SYSERR on error
946 GNUNET_TESTING_connect_topology (struct GNUNET_TESTING_PeerGroup *pg,
947 enum GNUNET_TESTING_Topology topology,
948 enum GNUNET_TESTING_TopologyOption options,
949 double option_modifier,
950 struct GNUNET_TIME_Relative connect_timeout,
951 unsigned int connect_attempts,
952 GNUNET_TESTING_NotifyCompletion
953 notify_callback, void *notify_cls);
956 * Start or stop an individual peer from the given group.
958 * @param pg handle to the peer group
959 * @param offset which peer to start or stop
960 * @param desired_status GNUNET_YES to have it running, GNUNET_NO to stop it
961 * @param timeout how long to wait for shutdown
962 * @param cb function to call at the end
963 * @param cb_cls closure for cb
966 GNUNET_TESTING_daemons_vary (struct GNUNET_TESTING_PeerGroup *pg,
969 struct GNUNET_TIME_Relative timeout,
970 GNUNET_TESTING_NotifyCompletion cb,
974 * Start count gnunet instances with the same set of transports and
975 * applications. The port numbers (any option called "PORT") will be
976 * adjusted to ensure that no two peers running on the same system
977 * have the same port(s) in their respective configurations.
979 * @param cfg configuration template to use
980 * @param total number of daemons to start
981 * @param max_concurrent_connections for testing, how many peers can
982 * we connect to simultaneously
983 * @param max_concurrent_ssh when starting with ssh, how many ssh
984 * connections will we allow at once (based on remote hosts allowed!)
985 * @param timeout total time allowed for peers to start
986 * @param connect_cb function to call each time two daemons are connected
987 * @param connect_cb_cls closure for connect_callback
988 * @param peergroup_cb function to call once all peers are up and connected
989 * @param peergroup_cb_cls closure for peergroup_cb
990 * @param hostnames linked list of host structs to use to start peers on
991 * (NULL to run on localhost only)
992 * @param topology allowed overlay topology
993 * @param restrict_topology blacklist connections to this topology
994 * @param restrict_transports specific transports to blacklist
995 * @param connect_topology topology to connect peers in (defaults to allowed
997 * @param connect_topology_options options for connect topology
998 * @param connect_topology_option_modifier option modifier for connect topology
999 * @param verbose GNUNET_YES to print progress bars, GNUNET_NO otherwise
1001 * @return NULL on error, otherwise handle to control peer group
1003 struct GNUNET_TESTING_PeerGroup *
1004 GNUNET_TESTING_PeerGroup_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
1006 unsigned int max_concurrent_connections,
1007 unsigned int max_concurrent_ssh,
1008 struct GNUNET_TIME_Relative timeout,
1009 GNUNET_TESTING_NotifyConnection
1010 connect_cb, void *connect_cb_cls,
1011 GNUNET_TESTING_NotifyCompletion peergroup_cb,
1012 void *peergroup_cb_cls,
1013 const struct GNUNET_TESTING_Host *hostnames,
1014 enum GNUNET_TESTING_Topology topology,
1015 enum GNUNET_TESTING_Topology restrict_topology,
1016 const char *restrict_transports,
1017 enum GNUNET_TESTING_Topology connect_topology,
1018 enum GNUNET_TESTING_TopologyOption connect_topology_options,
1019 double connect_topology_option_modifier,
1023 #if 0 /* keep Emacsens' auto-indent happy */