gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r18010 - gnunet/src/testing


From: gnunet
Subject: [GNUnet-SVN] r18010 - gnunet/src/testing
Date: Sat, 5 Nov 2011 02:56:35 +0100

Author: bartpolot
Date: 2011-11-05 02:56:35 +0100 (Sat, 05 Nov 2011)
New Revision: 18010

Added:
   gnunet/src/testing/test_testing_2dtorus.c
   gnunet/src/testing/test_testing_2dtorus.conf
Modified:
   gnunet/src/testing/
   gnunet/src/testing/Makefile.am
Log:
Added testcase for 2dtorus scenario from dht and mesh



Property changes on: gnunet/src/testing
___________________________________________________________________
Modified: svn:ignore
   - test_testing_peergroup
test_testing_reconnect
final_topology.dot
test_testing_topology_stability
topology_clique.dot
test_testing_topology_none
test_testing_topology_small_world_torus
test_testing_topology_small_world_ring
test_testing_topology_scale_free
test_testing_topology_ring
test_testing_topology_line
test_testing_topology_internat
test_testing_topology_erdos_renyi
test_testing_topology_clique_random
test_testing_topology_clique_minimum
test_testing_topology_clique_dfs
test_testing_topology_churn
test_testing_topology_blacklist
test_testing_topology_2d_torus
test_testing_group_remote
topology.dot
test_testing_topology_clique
test_testing_group.gcno
test_testing_group.gcda
test_testing_connect.gcno
test_testing_connect.gcda
test_testing_group
test_testing_connect
testing_testbed.gcno
testing_testbed.gcda
testing_group.gcno
testing_group.gcda
testing.gcno
testing.gcda
test_testing.gcno
test_testing.gcda
test_testing
Makefile.in
Makefile
.deps

   + test_testing_peergroup
test_testing_reconnect
final_topology.dot
test_testing_topology_stability
topology_clique.do
test_testing_2dtorus
test_testing_topology_none
test_testing_topology_small_world_torus
test_testing_topology_small_world_ring
test_testing_topology_scale_free
test_testing_topology_ring
test_testing_topology_line
test_testing_topology_internat
test_testing_topology_erdos_renyi
test_testing_topology_clique_random
test_testing_topology_clique_minimum
test_testing_topology_clique_dfs
test_testing_topology_churn
test_testing_topology_blacklist
test_testing_topology_2d_torus
test_testing_group_remote
topology.dot
test_testing_topology_clique
test_testing_group.gcno
test_testing_group.gcda
test_testing_connect.gcno
test_testing_connect.gcda
test_testing_group
test_testing_connect
testing_testbed.gcno
testing_testbed.gcda
testing_group.gcno
testing_group.gcda
testing.gcno
testing.gcda
test_testing.gcno
test_testing.gcda
test_testing
Makefile.in
Makefile
.deps


Modified: gnunet/src/testing/Makefile.am
===================================================================
--- gnunet/src/testing/Makefile.am      2011-11-05 01:52:19 UTC (rev 18009)
+++ gnunet/src/testing/Makefile.am      2011-11-05 01:56:35 UTC (rev 18010)
@@ -62,6 +62,7 @@
  test_testing_topology_line \
  test_testing_topology_blacklist \
  test_testing_group_remote \
+ test_testing_2dtorus \
  test_testing_topology_ring \
  test_testing_topology_2d_torus \
  test_testing_topology_small_world_ring \
@@ -78,7 +79,8 @@
  test_testing_reconnect \
  test_testing_group \
  test_testing_peergroup \
- test_testing_topology_clique
+ test_testing_topology_clique \
+ test_testing_2dtorus
 endif
 
 test_testing_SOURCES = \
@@ -172,6 +174,12 @@
  $(top_builddir)/src/testing/libgnunettesting.la \
  $(top_builddir)/src/util/libgnunetutil.la  
 
+test_testing_2dtorus_SOURCES = \
+  test_testing_2dtorus.c
+test_testing_2dtorus_LDADD = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
+ $(top_builddir)/src/util/libgnunetutil.la 
+
 test_testing_topology_ring_SOURCES = \
  test_testing_topology.c
 test_testing_topology_ring_LDADD = \
@@ -234,6 +242,7 @@
  test_testing_data.conf \
  test_testing_connect_peer1.conf \
  test_testing_connect_peer2.conf \
+ test_testing_2dtorus.conf \
  test_testing_data_topology_clique.conf \
  test_testing_data_topology_clique_random.conf \
  test_testing_data_topology_clique_minimum.conf \

Added: gnunet/src/testing/test_testing_2dtorus.c
===================================================================
--- gnunet/src/testing/test_testing_2dtorus.c                           (rev 0)
+++ gnunet/src/testing/test_testing_2dtorus.c   2011-11-05 01:56:35 UTC (rev 
18010)
@@ -0,0 +1,389 @@
+/*
+     This file is part of GNUnet.
+     (C) 2011 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 3, 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_2dtorus.c
+ *
+ * @brief Test for creating a 2dtorus.
+ */
+#include "platform.h"
+#include "gnunet_testing_lib.h"
+
+#define VERBOSE GNUNET_YES
+#define REMOVE_DIR GNUNET_YES
+
+/**
+ * How long until we give up on connecting the peers?
+ */
+#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1500)
+
+/**
+ * Time to wait for stuff that should be rather fast
+ */
+#define SHORT_TIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30)
+
+
+/**
+ * How many events have happened
+ */
+static int ok;
+
+/**
+ * Be verbose
+ */
+static int verbose;
+
+/**
+ * Total number of peers in the test.
+ */
+static unsigned long long num_peers;
+
+/**
+ * Global configuration file
+ */
+static struct GNUNET_CONFIGURATION_Handle *testing_cfg;
+
+/**
+ * Total number of currently running peers.
+ */
+static unsigned long long peers_running;
+
+/**
+ * Total number of successful connections in the whole network.
+ */
+static unsigned int total_connections;
+
+/**
+ * Total number of counted topo connections
+ */
+static unsigned int topo_connections;
+
+/**
+ * Total number of failed connections in the whole network.
+ */
+static unsigned int failed_connections;
+
+/**
+ * The currently running peer group.
+ */
+static struct GNUNET_TESTING_PeerGroup *pg;
+
+/**
+ * Task called to disconnect peers
+ */
+static GNUNET_SCHEDULER_TaskIdentifier disconnect_task;
+
+/**
+ * Task called to shutdown test.
+ */
+static GNUNET_SCHEDULER_TaskIdentifier shutdown_handle;
+
+
+/**
+ * Check whether peers successfully shut down.
+ */
+static void
+shutdown_callback (void *cls, const char *emsg)
+{
+  if (emsg != NULL)
+  {
+#if VERBOSE
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "test: Shutdown of peers failed!\n");
+#endif
+    ok--;
+  }
+  else
+  {
+#if VERBOSE
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "test: All peers successfully shut down!\n");
+#endif
+  }
+}
+
+
+static void
+shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+#if VERBOSE
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "test: Ending test.\n");
+#endif
+
+  GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
+  GNUNET_CONFIGURATION_destroy (testing_cfg);
+}
+
+
+static void
+disconnect_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "test: disconnecting peers\n");
+
+  if (GNUNET_SCHEDULER_NO_TASK != shutdown_handle)
+  {
+    GNUNET_SCHEDULER_cancel (shutdown_handle);
+    shutdown_handle = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
+  }
+}
+
+
+/**
+ * Prototype of a callback function indicating that two peers
+ * are currently connected.
+ *
+ * @param cls closure
+ * @param first peer id for first daemon
+ * @param second peer id for the second daemon
+ * @param distance distance between the connected peers
+ * @param emsg error message (NULL on success)
+ */
+void
+topo_cb (void *cls, const struct GNUNET_PeerIdentity *first,
+         const struct GNUNET_PeerIdentity *second, const char *emsg)
+{
+  topo_connections++;
+  if (NULL != emsg)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                "test: Error by topo %u: %s\n",
+                topo_connections, emsg);
+  }
+  else
+  {
+    if (first == NULL || second == NULL)
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  "test: Connection %u NULL\n",
+                  topo_connections);
+      if (disconnect_task != GNUNET_SCHEDULER_NO_TASK)
+      {
+        GNUNET_SCHEDULER_cancel (disconnect_task);
+        GNUNET_SCHEDULER_add_now(&disconnect_peers, NULL);
+      }
+      return;
+    }
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "test: Connection %u ok\n",
+                topo_connections);
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "test:   %s\n",
+                GNUNET_i2s (first));
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "test:   %s\n",
+                GNUNET_i2s (second));
+  }
+}
+
+
+/**
+ * peergroup_ready: start test when all peers are connected
+ * @param cls closure
+ * @param emsg error message
+ */
+static void
+peergroup_ready (void *cls, const char *emsg)
+{
+  if (emsg != NULL)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "test: Peergroup callback called with error, aborting 
test!\n");
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "test: Error from testing: `%s'\n", emsg);
+    ok--;
+    GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
+    return;
+  }
+#if VERBOSE
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              
"************************************************************\n");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "test: Peer Group started successfully!\n");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "test: Have %u connections\n",
+              total_connections);
+#endif
+
+  peers_running = GNUNET_TESTING_daemons_running (pg);
+  if (0 < failed_connections)
+  {
+    ok = GNUNET_SYSERR;
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "test: %u connections have FAILED!\n",
+                failed_connections);
+    disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_peers, NULL);
+
+  }
+  else
+  {
+    GNUNET_TESTING_get_topology (pg, &topo_cb, NULL);
+    disconnect_task =
+        GNUNET_SCHEDULER_add_delayed (SHORT_TIME, &disconnect_peers, NULL);
+    ok = GNUNET_OK;
+  }
+
+}
+
+
+/**
+ * Function that will be called whenever two daemons are connected by
+ * the testing library.
+ *
+ * @param cls closure
+ * @param first peer id for first daemon
+ * @param second peer id for the second daemon
+ * @param distance distance between the connected peers
+ * @param first_cfg config for the first daemon
+ * @param second_cfg config for the second daemon
+ * @param first_daemon handle for the first daemon
+ * @param second_daemon handle for the second daemon
+ * @param emsg error message (NULL on success)
+ */
+static void
+connect_cb (void *cls, const struct GNUNET_PeerIdentity *first,
+            const struct GNUNET_PeerIdentity *second, uint32_t distance,
+            const struct GNUNET_CONFIGURATION_Handle *first_cfg,
+            const struct GNUNET_CONFIGURATION_Handle *second_cfg,
+            struct GNUNET_TESTING_Daemon *first_daemon,
+            struct GNUNET_TESTING_Daemon *second_daemon, const char *emsg)
+{
+  if (emsg == NULL)
+  {
+    total_connections++;
+  }
+  else
+  {
+    failed_connections++;
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "test: Problem with new connection (%s)\n",
+                emsg);
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test:   (%s)\n",
+                GNUNET_i2s (first));
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test:   (%s)\n",
+                GNUNET_i2s (second));
+  }
+
+}
+
+
+/**
+ * run: load configuration options and schedule test to run (start peergroup)
+ * @param cls closure
+ * @param args argv
+ * @param cfgfile configuration file name (can be NULL)
+ * @param cfg configuration handle
+ */
+static void
+run (void *cls, char *const *args, const char *cfgfile,
+     const struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+  struct GNUNET_TESTING_Host *hosts;
+
+  ok = GNUNET_NO;
+  total_connections = 0;
+  failed_connections = 0;
+  testing_cfg = GNUNET_CONFIGURATION_dup (cfg);
+
+  GNUNET_log_setup ("test_testing_2dtorus",
+#if VERBOSE
+                    "DEBUG",
+#else
+                    "WARNING",
+#endif
+                    NULL);
+
+#if VERBOSE
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "test: Starting daemons.\n");
+  GNUNET_CONFIGURATION_set_value_string (testing_cfg, "testing",
+                                         "use_progressbars", "YES");
+#endif
+
+  if (GNUNET_OK !=
+      GNUNET_CONFIGURATION_get_value_number (testing_cfg, "testing",
+                                             "num_peers", &num_peers))
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "Option TESTING:NUM_PEERS is required!\n");
+    return;
+  }
+
+  hosts = GNUNET_TESTING_hosts_load (testing_cfg);
+
+  pg = GNUNET_TESTING_peergroup_start (testing_cfg, num_peers, TIMEOUT,
+                                       &connect_cb, &peergroup_ready, NULL,
+                                       hosts);
+  GNUNET_assert (pg != NULL);
+  shutdown_handle =
+      GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_get_forever (),
+                                    &shutdown_task, NULL);
+}
+
+
+/**
+ * test_testing_2dtorus command line options
+ */
+static struct GNUNET_GETOPT_CommandLineOption options[] = {
+  {'V', "verbose", NULL,
+   gettext_noop ("be verbose (print progress information)"),
+   0, &GNUNET_GETOPT_set_one, &verbose},
+  GNUNET_GETOPT_OPTION_END
+};
+
+
+/**
+ * Main: start test
+ */
+int
+main (int argc, char *argv[])
+{
+  char *const argv2[] = {
+    argv[0],
+    "-c",
+    "test_testing_2dtorus.conf",
+#if VERBOSE
+    "-L",
+    "DEBUG",
+#endif
+    NULL
+  };
+
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: Start\n");
+
+
+  GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2,
+                      "test_testing_2dtorus",
+                      gettext_noop ("Test testing 2d torus."), options,
+                      &run, NULL);
+#if REMOVE_DIR
+  GNUNET_DISK_directory_remove ("/tmp/test_testing_2dtorus");
+#endif
+  if (GNUNET_OK != ok)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                "test: FAILED!\n");
+    return 1;
+  }
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: success\n");
+  return 0;
+}
+
+/* end of test_testing_2dtorus.c */

Added: gnunet/src/testing/test_testing_2dtorus.conf
===================================================================
--- gnunet/src/testing/test_testing_2dtorus.conf                                
(rev 0)
+++ gnunet/src/testing/test_testing_2dtorus.conf        2011-11-05 01:56:35 UTC 
(rev 18010)
@@ -0,0 +1,77 @@
+[PATHS]
+SERVICEHOME = /tmp/test_testing_small/
+DEFAULTCONFIG = test_testing_small.conf
+
+[arm]
+PORT = 10010
+DEFAULTSERVICES = core dht
+#DEBUG = YES
+
+[statistics]
+AUTOSTART = YES
+PORT = 10000
+
+[dht]
+DEBUG = NO
+AUTOSTART = YES
+ACCEPT_FROM6 = ::1;
+ACCEPT_FROM = 127.0.0.1;
+HOSTNAME = localhost
+PORT = 10001
+
+[nse]
+WORKBITS = 0
+
+[dns]
+AUTOSTART = NO
+PORT = 10011
+
+[transport]
+PORT = 10002
+AUTOSTART = YES
+
+[nat]
+DISABLEV6 = YES 
+BINDTO = 127.0.0.1
+ENABLE_UPNP = NO
+BEHIND_NAT = NO
+ALLOW_NAT = NO
+INTERNAL_ADDRESS = 127.0.0.1
+EXTERNAL_ADDRESS = 127.0.0.1
+
+[core]
+TOTAL_QUOTA_IN = 999111999
+TOTAL_QUOTA_OUT = 999111999
+AUTOSTART = YES
+PORT = 10003
+
+[peerinfo]
+AUTOSTART = YES
+PORT = 10004
+
+[testing]
+NUM_PEERS = 16
+WEAKRANDOM = YES
+TOPOLOGY = 2D_TORUS
+CONNECT_TOPOLOGY = 2D_TORUS
+#TOPOLOGY_FILE = small.dat
+CONNECT_TOPOLOGY = 2D_TORUS
+#CONNECT_TOPOLOGY_OPTION = CONNECT_MINIMUM
+#CONNECT_TOPOLOGY_OPTION_MODIFIER = 25
+#PERCENTAGE = 3
+#PROBABILITY = .1
+F2F = NO
+CONNECT_TIMEOUT = 60
+CONNECT_ATTEMPTS = 3
+DEBUG = YES
+HOSTKEYSFILE = ../../contrib/testing_hostkeys.dat
+MAX_CONCURRENT_SSH = 10
+USE_PROGRESSBARS = YES
+PEERGROUP_TIMEOUT = 2400
+TOPOLOGY_OUTPUT_FILE = testing_topo_initial
+MAX_OUTSTANDING_CONNECTIONS = 75
+#SINGLE_PEERINFO_PER_HOST = YES
+#NUM_PEERINFO_PER_HOST = 10
+#SINGLE_STATISTICS_PER_HOST = YES
+#NUM_STATISTICS_PER_HOST = 10
+DELETE_FILES = YES




reply via email to

[Prev in Thread] Current Thread [Next in Thread]