test_testing \
test_testing_connect \
test_testing_group \
- test_testing_topology_clique
-# test_testing_group_remote
+ test_testing_topology_clique
+# test_testing_group_remote \
# test_testing_topology_ring \
# test_testing_topology_2d_torus \
# test_testing_topology_small_world_ring \
# test_testing_topology_small_world_torus \
# test_testing_topology_erdos_renyi \
-# test_testing_topology_internat
+# test_testing_topology_internat \
+# test_testing_topology_scale_free
TESTS = \
test_testing \
test_testing_connect \
test_testing_group \
- test_testing_topology_clique
-# test_testing_group_remote
+ test_testing_topology_clique
+# test_testing_group_remote \
# test_testing_topology_ring \
# test_testing_topology_2d_torus \
# test_testing_topology_small_world_ring \
# test_testing_topology_small_world_torus \
# test_testing_topology_erdos_renyi \
-# test_testing_topology_internat
-#$(check_PROGRAMS)
+# test_testing_topology_internat \
+# test_testing_topology_scale_free
test_testing_SOURCES = \
test_testing.c
# $(top_builddir)/src/testing/libgnunettesting.la \
# $(top_builddir)/src/util/libgnunetutil.la
+#test_testing_topology_scale_free_SOURCES = \
+# test_testing_topology.c
+#test_testing_topology_scale_free_LDADD = \
+# $(top_builddir)/src/testing/libgnunettesting.la \
+# $(top_builddir)/src/util/libgnunetutil.la
+
EXTRA_DIST = \
test_testing_data.conf \
test_testing_data_topology_small_world_ring.conf \
test_testing_data_topology_small_world_torus.conf \
test_testing_data_topology_erdos_renyi.conf \
- test_testing_data_topology_internat.conf
+ test_testing_data_topology_internat.conf \
+ test_testing_data_topology_scale_free.conf
--- /dev/null
+[PATHS]
+SERVICEHOME = /tmp/test-gnunet-testing/
+DEFAULTCONFIG = test_testing_data.conf
+
+[resolver]
+PORT = 2564
+
+[transport]
+PORT = 2565
+PLUGINS = tcp
+#PREFIX = xterm -e xterm -T transport -e gdb -x cmd --args
+#PREFIX = valgrind --tool=memcheck --log-file=logs%p
+
+[arm]
+PORT = 2566
+DEFAULTSERVICES = peerinfo transport core
+
+[statistics]
+PORT = 2567
+
+[transport-tcp]
+PORT = 2568
+
+[peerinfo]
+PORT = 2569
+
+[core]
+PORT = 2570
+
+[testing]
+CONTROL_HOST = 131.159.20.42
+HOSTS = 127.0.0.1
+WEAKRANDOM = YES
#DEBUG = YES
[testing]
-NUM_PEERS = 5
+NUM_PEERS = 25
WEAKRANDOM = YES
TOPOLOGY = 2
F2F = YES
#include "platform.h"
#include "gnunet_testing_lib.h"
-#define VERBOSE GNUNET_YES
+#define VERBOSE GNUNET_NO
#define NUM_PEERS 4
--- /dev/null
+/*
+ This file is part of GNUnet.
+ (C) 2009 Christian Grothoff (and other contributing authors)
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 2, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+/**
+ * @file testing/test_testing_group_remote.c
+ * @brief testcase for testing remote and local starting and connecting
+ * of hosts from the testing library. The test_testing_data_remote.conf
+ * file should be modified if this testcase is intended to be used.
+ */
+#include "platform.h"
+#include "gnunet_testing_lib.h"
+
+#define VERBOSE GNUNET_YES
+
+
+/**
+ * How long until we give up on connecting the peers?
+ */
+#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60)
+
+#define DEFAULT_NUM_PEERS 8;
+
+static int ok;
+
+static int peers_left;
+
+static struct GNUNET_TESTING_PeerGroup *pg;
+
+static struct GNUNET_SCHEDULER_Handle *sched;
+
+static unsigned long long num_peers;
+
+static char *hostnames;
+
+
+static void
+my_cb (void *cls,
+ const struct GNUNET_PeerIdentity *id,
+ const struct GNUNET_CONFIGURATION_Handle *cfg,
+ struct GNUNET_TESTING_Daemon *d, const char *emsg)
+{
+ GNUNET_assert (id != NULL);
+ peers_left--;
+ if (peers_left == 0)
+ {
+ GNUNET_TESTING_daemons_stop (pg);
+ ok = 0;
+ }
+}
+
+
+static void
+run (void *cls,
+ struct GNUNET_SCHEDULER_Handle *s,
+ char *const *args,
+ const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+ sched = s;
+ ok = 1;
+#if VERBOSE
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting daemons.\n");
+#endif
+
+ if (GNUNET_SYSERR ==
+ GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "num_peers",
+ &num_peers))
+ num_peers = DEFAULT_NUM_PEERS;
+
+ GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "hosts",
+ &hostnames);
+
+ peers_left = num_peers;
+ pg = GNUNET_TESTING_daemons_start (sched, cfg,
+ peers_left,
+ &my_cb, NULL, NULL, NULL, hostnames);
+ GNUNET_assert (pg != NULL);
+}
+
+static int
+check ()
+{
+ char *const argv[] = { "test-testing",
+ "-c",
+ "test_testing_data_remote.conf",
+#if VERBOSE
+ "-L", "DEBUG",
+#endif
+ NULL
+ };
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+ GNUNET_GETOPT_OPTION_END
+ };
+ GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1,
+ argv, "test-testing-group", "nohelp",
+ options, &run, &ok);
+ return ok;
+}
+
+int
+main (int argc, char *argv[])
+{
+ int ret;
+
+ GNUNET_log_setup ("test-testing-group",
+#if VERBOSE
+ "DEBUG",
+#else
+ "WARNING",
+#endif
+ NULL);
+ ret = check ();
+ /**
+ * Still need to remove the base testing directory here,
+ * because group starts will create subdirectories under this
+ * main dir. However, we no longer need to sleep, as the
+ * shutdown sequence won't return until everything is cleaned
+ * up.
+ */
+ GNUNET_DISK_directory_remove ("/tmp/test-gnunet-testing");
+ return ret;
+}
+
+/* end of test_testing_group.c */
#include "gnunet_testing_lib.h"
#include "gnunet_core_service.h"
-#define VERBOSE GNUNET_YES
+#define VERBOSE GNUNET_NO
/**
* How long until we fail the whole testcase?
static int transmit_ready_called;
+static enum GNUNET_TESTING_Topology topology;
+
#define MTYPE 12345
struct GNUNET_TestMessage
maybe this way is best so that the client can know both
when peers are started, and when they are connected.
*/
- expected_connections = GNUNET_TESTING_create_topology (pg);
+ expected_connections = GNUNET_TESTING_create_topology (pg, topology);
#if VERBOSE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Have %d expected connections\n", expected_connections);
char *const *args,
const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
{
+ unsigned long long topology_num;
sched = s;
ok = 1;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Starting daemons based on config file %s\n", cfgfile);
#endif
+
+ if (GNUNET_YES ==
+ GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "topology",
+ &topology_num))
+ topology = topology_num;
+
if (GNUNET_SYSERR ==
GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "num_peers",
&num_peers))
#include "gnunet_arm_service.h"
#include "gnunet_testing_lib.h"
-#define VERBOSE_TESTING GNUNET_NO
+#define VERBOSE_TESTING GNUNET_YES
/**
* Lowest port used for GNUnet testing. Should be high enough to not
return added;
}
+/**
+ * Scale free network construction as described in:
+ *
+ * "Emergence of Scaling in Random Networks." Science 286, 509-512, 1999.
+ *
+ * Start with a network of "one" peer, then progressively add
+ * peers up to the total number. At each step, iterate over
+ * all possible peers and connect new peer based on number of
+ * existing connections of the target peer.
+ *
+ * @param pg the peer group we are dealing with
+ *
+ * @return the number of connections created
+ */
static int
create_scale_free (struct GNUNET_TESTING_PeerGroup *pg)
{
- int total_connections;
- int outer_count;
- int i;
- int previous_total_connections;
+ unsigned int total_connections;
+ unsigned int outer_count;
+ unsigned int i;
+ unsigned int previous_total_connections;
double random;
double probability;
/* Add a connection between the first two nodes */
total_connections = add_connections(pg, 0, 1);
- for (outer_count = 1; outer_count < pg->total - 1; outer_count++)
+ for (outer_count = 1; outer_count < pg->total; outer_count++)
{
previous_total_connections = total_connections;
for (i = 0; i < outer_count; i++)
{
- probability = pg->peers[i].num_connections / previous_total_connections;
+ probability = pg->peers[i].num_connections / (double)previous_total_connections;
random = ((double) GNUNET_CRYPTO_random_u64(GNUNET_CRYPTO_QUALITY_WEAK,
(uint64_t)-1LL)) / ( (double) (uint64_t) -1LL);
+#if VERBOSE_TESTING
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Considering connecting peer %d to peer %d\n",
+ outer_count, i);
+#endif
if (random < probability)
{
#if VERBOSE_TESTING
* the connection actually happened.
*
* @param pg the peer group struct representing the running peers
+ * @param topology which topology to connect the peers in
*
* @return the number of connections should be created by the topology, so the
* caller knows how many to wait for (if it so chooses)
*
*/
int
-GNUNET_TESTING_create_topology (struct GNUNET_TESTING_PeerGroup *pg)
+GNUNET_TESTING_create_topology (struct GNUNET_TESTING_PeerGroup *pg, enum GNUNET_TESTING_Topology topology)
{
- unsigned long long topology_num;
int ret;
int num_connections;
GNUNET_assert (pg->notify_connection != NULL);
ret = GNUNET_OK;
- if (GNUNET_YES ==
- GNUNET_CONFIGURATION_get_value_number (pg->cfg, "testing", "topology",
- &topology_num))
+
+ switch (topology)
{
- switch (topology_num)
- {
- case GNUNET_TESTING_TOPOLOGY_CLIQUE:
+ case GNUNET_TESTING_TOPOLOGY_CLIQUE:
#if VERBOSE_TESTING
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- _("Creating clique topology\n"));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ _("Creating clique topology\n"));
#endif
- num_connections = create_clique (pg);
- break;
- case GNUNET_TESTING_TOPOLOGY_SMALL_WORLD_RING:
+ num_connections = create_clique (pg);
+ break;
+ case GNUNET_TESTING_TOPOLOGY_SMALL_WORLD_RING:
#if VERBOSE_TESTING
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- _("Creating small world (ring) topology\n"));
-#endif
- num_connections = create_small_world_ring (pg);
- break;
- case GNUNET_TESTING_TOPOLOGY_SMALL_WORLD:
-#if VERBOSE_TESTING
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- _("Creating small world (2d-torus) topology\n"));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ _("Creating small world (ring) topology\n"));
#endif
- num_connections = create_small_world (pg);
- break;
- case GNUNET_TESTING_TOPOLOGY_RING:
+ num_connections = create_small_world_ring (pg);
+ break;
+ case GNUNET_TESTING_TOPOLOGY_SMALL_WORLD:
#if VERBOSE_TESTING
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- _("Creating ring topology\n"));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ _("Creating small world (2d-torus) topology\n"));
#endif
- num_connections = create_ring (pg);
- break;
- case GNUNET_TESTING_TOPOLOGY_2D_TORUS:
+ num_connections = create_small_world (pg);
+ break;
+ case GNUNET_TESTING_TOPOLOGY_RING:
#if VERBOSE_TESTING
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- _("Creating 2d torus topology\n"));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ _("Creating ring topology\n"));
#endif
- num_connections = create_2d_torus (pg);
- break;
- case GNUNET_TESTING_TOPOLOGY_ERDOS_RENYI:
+ num_connections = create_ring (pg);
+ break;
+ case GNUNET_TESTING_TOPOLOGY_2D_TORUS:
#if VERBOSE_TESTING
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- _("Creating Erdos-Renyi topology\n"));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ _("Creating 2d torus topology\n"));
#endif
- num_connections = create_erdos_renyi (pg);
- break;
- case GNUNET_TESTING_TOPOLOGY_INTERNAT:
+ num_connections = create_2d_torus (pg);
+ break;
+ case GNUNET_TESTING_TOPOLOGY_ERDOS_RENYI:
#if VERBOSE_TESTING
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- _("Creating InterNAT topology\n"));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ _("Creating Erdos-Renyi topology\n"));
#endif
- num_connections = create_nated_internet (pg);
- break;
- case GNUNET_TESTING_TOPOLOGY_SCALE_FREE:
+ num_connections = create_erdos_renyi (pg);
+ break;
+ case GNUNET_TESTING_TOPOLOGY_INTERNAT:
#if VERBOSE_TESTING
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- _("Creating Scale Free topology\n"));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ _("Creating InterNAT topology\n"));
#endif
- num_connections = create_scale_free (pg);
- break;
- case GNUNET_TESTING_TOPOLOGY_NONE:
- num_connections = 0;
- break;
- default:
- num_connections = 0;
- break;
- }
- if (num_connections < 1)
- return GNUNET_SYSERR;
-
- if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno (pg->cfg, "TESTING", "F2F"))
- ret = create_and_copy_friend_files(pg);
- if (ret == GNUNET_OK)
- connect_topology(pg);
- else
- {
+ num_connections = create_nated_internet (pg);
+ break;
+ case GNUNET_TESTING_TOPOLOGY_SCALE_FREE:
#if VERBOSE_TESTING
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- _("Failed during friend file copying!\n"));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ _("Creating Scale Free topology\n"));
#endif
- return GNUNET_SYSERR;
- }
+ num_connections = create_scale_free (pg);
+ break;
+ case GNUNET_TESTING_TOPOLOGY_NONE:
+ num_connections = 0;
+ break;
+ default:
+ num_connections = 0;
+ break;
}
+ if (num_connections < 1)
+ return GNUNET_SYSERR;
+
+ if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno (pg->cfg, "TESTING", "F2F"))
+ ret = create_and_copy_friend_files(pg);
+ if (ret == GNUNET_OK)
+ connect_topology(pg);
else
{
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- _("No topology specified, was one intended?\n"));
+#if VERBOSE_TESTING
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ _("Failed during friend file copying!\n"));
+#endif
return GNUNET_SYSERR;
}