gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r11098 - gnunet/src/testing
Date: Wed, 28 Apr 2010 15:59:11 +0200

Author: nevans
Date: 2010-04-28 15:59:11 +0200 (Wed, 28 Apr 2010)
New Revision: 11098

Added:
   gnunet/src/testing/test_testing_data_remote.conf
   gnunet/src/testing/test_testing_group_remote.c
Modified:
   gnunet/src/testing/Makefile.am
   gnunet/src/testing/test_testing_data_topology_small_world_ring.conf
   gnunet/src/testing/test_testing_group.c
   gnunet/src/testing/test_testing_topology.c
   gnunet/src/testing/testing_group.c
Log:
minor testing changes

Modified: gnunet/src/testing/Makefile.am
===================================================================
--- gnunet/src/testing/Makefile.am      2010-04-28 13:43:19 UTC (rev 11097)
+++ gnunet/src/testing/Makefile.am      2010-04-28 13:59:11 UTC (rev 11098)
@@ -25,28 +25,29 @@
  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
@@ -114,7 +115,13 @@
 # $(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_connect_peer1.conf \
@@ -125,5 +132,6 @@
  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
  

Added: gnunet/src/testing/test_testing_data_remote.conf
===================================================================
--- gnunet/src/testing/test_testing_data_remote.conf                            
(rev 0)
+++ gnunet/src/testing/test_testing_data_remote.conf    2010-04-28 13:59:11 UTC 
(rev 11098)
@@ -0,0 +1,33 @@
+[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

Modified: gnunet/src/testing/test_testing_data_topology_small_world_ring.conf
===================================================================
--- gnunet/src/testing/test_testing_data_topology_small_world_ring.conf 
2010-04-28 13:43:19 UTC (rev 11097)
+++ gnunet/src/testing/test_testing_data_topology_small_world_ring.conf 
2010-04-28 13:59:11 UTC (rev 11098)
@@ -30,7 +30,7 @@
 #DEBUG = YES
 
 [testing]
-NUM_PEERS = 5
+NUM_PEERS = 25
 WEAKRANDOM = YES
 TOPOLOGY = 2
 F2F = YES

Modified: gnunet/src/testing/test_testing_group.c
===================================================================
--- gnunet/src/testing/test_testing_group.c     2010-04-28 13:43:19 UTC (rev 
11097)
+++ gnunet/src/testing/test_testing_group.c     2010-04-28 13:59:11 UTC (rev 
11098)
@@ -24,7 +24,7 @@
 #include "platform.h"
 #include "gnunet_testing_lib.h"
 
-#define VERBOSE GNUNET_YES
+#define VERBOSE GNUNET_NO
 
 #define NUM_PEERS 4
 

Added: gnunet/src/testing/test_testing_group_remote.c
===================================================================
--- gnunet/src/testing/test_testing_group_remote.c                              
(rev 0)
+++ gnunet/src/testing/test_testing_group_remote.c      2010-04-28 13:59:11 UTC 
(rev 11098)
@@ -0,0 +1,139 @@
+/*
+     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 */

Modified: gnunet/src/testing/test_testing_topology.c
===================================================================
--- gnunet/src/testing/test_testing_topology.c  2010-04-28 13:43:19 UTC (rev 
11097)
+++ gnunet/src/testing/test_testing_topology.c  2010-04-28 13:59:11 UTC (rev 
11098)
@@ -25,7 +25,7 @@
 #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?
@@ -81,6 +81,8 @@
 
 static int transmit_ready_called;
 
+static enum GNUNET_TESTING_Topology topology;
+
 #define MTYPE 12345
 
 struct GNUNET_TestMessage
@@ -518,7 +520,7 @@
          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);
@@ -575,6 +577,7 @@
      char *const *args,
      const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
+  unsigned long long topology_num;
   sched = s;
   ok = 1;
 
@@ -588,6 +591,12 @@
   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))

Modified: gnunet/src/testing/testing_group.c
===================================================================
--- gnunet/src/testing/testing_group.c  2010-04-28 13:43:19 UTC (rev 11097)
+++ gnunet/src/testing/testing_group.c  2010-04-28 13:59:11 UTC (rev 11098)
@@ -27,7 +27,7 @@
 #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
@@ -354,14 +354,28 @@
   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;
 
@@ -370,14 +384,19 @@
   /* 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
@@ -1099,109 +1118,99 @@
  * 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"));
+      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:
+      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 (2d-torus) topology\n"));
 #endif
-          num_connections = create_small_world (pg);
-          break;
-        case GNUNET_TESTING_TOPOLOGY_RING:
+      num_connections = create_small_world (pg);
+      break;
+    case GNUNET_TESTING_TOPOLOGY_RING:
 #if VERBOSE_TESTING
-          GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                      _("Creating ring topology\n"));
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  _("Creating ring topology\n"));
 #endif
-          num_connections = create_ring (pg);
-          break;
-        case GNUNET_TESTING_TOPOLOGY_2D_TORUS:
+      num_connections = create_ring (pg);
+      break;
+    case GNUNET_TESTING_TOPOLOGY_2D_TORUS:
 #if VERBOSE_TESTING
-          GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                      _("Creating 2d torus topology\n"));
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  _("Creating 2d torus topology\n"));
 #endif
-          num_connections = create_2d_torus (pg);
-          break;
-        case GNUNET_TESTING_TOPOLOGY_ERDOS_RENYI:
+      num_connections = create_2d_torus (pg);
+      break;
+    case GNUNET_TESTING_TOPOLOGY_ERDOS_RENYI:
 #if VERBOSE_TESTING
-          GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                      _("Creating Erdos-Renyi topology\n"));
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  _("Creating Erdos-Renyi topology\n"));
 #endif
-          num_connections = create_erdos_renyi (pg);
-          break;
-        case GNUNET_TESTING_TOPOLOGY_INTERNAT:
+      num_connections = create_erdos_renyi (pg);
+      break;
+    case GNUNET_TESTING_TOPOLOGY_INTERNAT:
 #if VERBOSE_TESTING
-          GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                      _("Creating InterNAT topology\n"));
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  _("Creating InterNAT topology\n"));
 #endif
-          num_connections = create_nated_internet (pg);
-          break;
-        case GNUNET_TESTING_TOPOLOGY_SCALE_FREE:
+      num_connections = create_nated_internet (pg);
+      break;
+    case GNUNET_TESTING_TOPOLOGY_SCALE_FREE:
 #if VERBOSE_TESTING
-          GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                      _("Creating Scale Free topology\n"));
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  _("Creating Scale Free 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;
+      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
-        {
+  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
+    {
 #if VERBOSE_TESTING
-          GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                      _("Failed during friend file copying!\n"));
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  _("Failed during friend file copying!\n"));
 #endif
-          return GNUNET_SYSERR;
-        }
-    }
-  else
-    {
-      GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                  _("No topology specified, was one intended?\n"));
       return GNUNET_SYSERR;
     }
 





reply via email to

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