gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r14897 - gnunet/src/testing
Date: Wed, 6 Apr 2011 11:40:36 +0200

Author: nevans
Date: 2011-04-06 11:40:36 +0200 (Wed, 06 Apr 2011)
New Revision: 14897

Added:
   gnunet/src/testing/test_testing_peergroup_data.conf
Modified:
   gnunet/src/testing/Makefile.am
   gnunet/src/testing/test_testing_data_remote.conf
   gnunet/src/testing/testing_group.c
   gnunet/src/testing/testing_peergroup.c
Log:
peergroup initial version with test case

Modified: gnunet/src/testing/Makefile.am
===================================================================
--- gnunet/src/testing/Makefile.am      2011-04-06 09:38:51 UTC (rev 14896)
+++ gnunet/src/testing/Makefile.am      2011-04-06 09:40:36 UTC (rev 14897)
@@ -27,6 +27,7 @@
  test_testing_connect \
  test_testing_reconnect \
  test_testing_group \
+ test_testing_peergroup \
  test_testing_topology_stability \
  test_testing_topology_clique \
  test_testing_topology_clique_random \
@@ -51,6 +52,7 @@
  test_testing_connect \
  test_testing_reconnect \
  test_testing_group \
+ test_testing_peergroup \
  test_testing_topology_clique
 # test_testing_topology_stability \
 # test_testing_topology_clique_random \
@@ -92,6 +94,12 @@
 test_testing_group_LDADD = \
  $(top_builddir)/src/testing/libgnunettesting.la \
  $(top_builddir)/src/util/libgnunetutil.la  
+ 
+test_testing_peergroup_SOURCES = \
+ test_testing_peergroup.c
+test_testing_peergroup_LDADD = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
+ $(top_builddir)/src/util/libgnunetutil.la 
 
 test_testing_topology_clique_SOURCES = \
  test_testing_topology.c

Modified: gnunet/src/testing/test_testing_data_remote.conf
===================================================================
--- gnunet/src/testing/test_testing_data_remote.conf    2011-04-06 09:38:51 UTC 
(rev 14896)
+++ gnunet/src/testing/test_testing_data_remote.conf    2011-04-06 09:40:36 UTC 
(rev 14897)
@@ -32,8 +32,9 @@
 CONTROL_HOST = 131.159.20.42
 HOSTFILE = remote_hosts.txt
 WEAKRANDOM = YES
-NUM_PEERS = 2
+NUM_PEERS = 5
 HOSTKEYSFILE = ../../contrib/testing_hostkeys.dat
+MAX_OUTSTANDING_SSH = 5
 
 [dht]
 AUTOSTART = NO

Added: gnunet/src/testing/test_testing_peergroup_data.conf
===================================================================
--- gnunet/src/testing/test_testing_peergroup_data.conf                         
(rev 0)
+++ gnunet/src/testing/test_testing_peergroup_data.conf 2011-04-06 09:40:36 UTC 
(rev 14897)
@@ -0,0 +1,57 @@
+[PATHS]
+SERVICEHOME = /tmp/test-gnunet-testing/
+DEFAULTCONFIG = test_testing_peergroup_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 = core
+
+[statistics]
+PORT = 2567
+
+[transport-tcp]
+PORT = 2568
+
+[peerinfo]
+PORT = 2569
+
+[core]
+PORT = 2570
+
+[testing]
+WEAKRANDOM = YES
+HOSTKEYSFILE = ../../contrib/testing_hostkeys.dat
+#The following options are REQUIRED for peergroup convenience usage!
+MAX_OUTSTANDING_CONNECTIONS = 20
+MAX_CONCURRENT_SSH = 1
+CONNECT_ATTEMPTS = 2
+PEERGROUP_TIMEOUT = 300
+TOPOLOGY = CLIQUE
+PERCENTAGE = 0.5
+PROBABILITY = 0.5
+CONNECT_TOPOLOGY = CLIQUE
+CONNECT_TOPOLOGY_OPTION = CONNECT_NONE
+CONNECT_TOPOLOGY_OPTION_MODIFIER = 0.0
+BLACKLIST_TOPOLOGY = NONE
+BLACKLIST_TRANSPORTS = tcp udp
+
+
+[fs]
+AUTOSTART = NO
+
+[datastore]
+AUTOSTART = NO
+
+[dht]
+AUTOSTART = NO
+
+

Modified: gnunet/src/testing/testing_group.c
===================================================================
--- gnunet/src/testing/testing_group.c  2011-04-06 09:38:51 UTC (rev 14896)
+++ gnunet/src/testing/testing_group.c  2011-04-06 09:40:36 UTC (rev 14897)
@@ -2361,7 +2361,7 @@
   connect_attempts = 0;
 
   conn_meter = create_meter ((((pg->total * pg->total) + pg->total) / 2)
-      - pg->total, "Create Clique ", GNUNET_YES);
+      - pg->total, "Create Clique ", GNUNET_NO);
   for (outer_count = 0; outer_count < pg->total - 1; outer_count++)
     {
       for (inner_count = outer_count + 1; inner_count < pg->total; 
inner_count++)
@@ -2375,8 +2375,6 @@
           update_meter (conn_meter);
         }
     }
-  GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Meter has %d left\n",
-              conn_meter->total - conn_meter->completed);
   reset_meter (conn_meter);
   free_meter (conn_meter);
   return connect_attempts;
@@ -5922,7 +5920,7 @@
           else
             {
               total_hostkeys = fs / HOSTKEYFILESIZE;
-              GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+              GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                           "Will read %llu hostkeys from file\n", 
total_hostkeys);
               pg->hostkey_data = GNUNET_malloc_large (fs);
               GNUNET_assert (fs == GNUNET_DISK_file_read (fd, 
pg->hostkey_data, fs));

Modified: gnunet/src/testing/testing_peergroup.c
===================================================================
--- gnunet/src/testing/testing_peergroup.c      2011-04-06 09:38:51 UTC (rev 
14896)
+++ gnunet/src/testing/testing_peergroup.c      2011-04-06 09:40:36 UTC (rev 
14897)
@@ -44,8 +44,9 @@
   const struct GNUNET_CONFIGURATION_Handle *cfg;
   unsigned int total;
   unsigned int peers_left;
-  unsigned int max_concurrent_connections;
-  unsigned int max_concurrent_ssh;
+  unsigned long long max_concurrent_connections;
+  unsigned long long connect_attempts;
+  unsigned long long max_concurrent_ssh;
   struct GNUNET_TIME_Absolute timeout;
   GNUNET_TESTING_NotifyConnection connect_cb;
   void *connect_cb_cls;
@@ -53,8 +54,13 @@
   void *peergroup_cb_cls;
   const struct GNUNET_TESTING_Host *hostnames;
   enum GNUNET_TESTING_Topology topology;
+
+  float topology_percentage;
+
+  float topology_probability;
+
   enum GNUNET_TESTING_Topology restrict_topology;
-  const char *restrict_transports;
+  char *restrict_transports;
   enum GNUNET_TESTING_Topology connect_topology;
   enum GNUNET_TESTING_TopologyOption connect_topology_option;
   double connect_topology_option_modifier;
@@ -401,6 +407,8 @@
       GNUNET_SCHEDULER_cancel (pg_start_ctx->die_task);
 
       /* Call final callback, signifying that the peer group has been started 
and connected */
+      if (pg_start_ctx->peergroup_cb != NULL)
+        pg_start_ctx->peergroup_cb(pg_start_ctx->peergroup_cb_cls, NULL);
     }
 }
 
@@ -446,7 +454,7 @@
                                                  
pg_start_ctx->connect_topology_option,
                                                  
pg_start_ctx->connect_topology_option_modifier,
                                                  DEFAULT_CONNECT_TIMEOUT,
-                                                 DEFAULT_CONNECT_ATTEMPTS,
+                                                 
pg_start_ctx->connect_attempts,
                                                  NULL, NULL);
 
           pg_start_ctx->connect_meter
@@ -506,9 +514,6 @@
   pg_start_ctx->peers_left--;
   if (GNUNET_YES == update_meter (pg_start_ctx->hostkey_meter))
     {
-      GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                  "All %d hostkeys created, now creating topology!\n",
-                  pg_start_ctx->total);
       GNUNET_SCHEDULER_cancel (pg_start_ctx->die_task);
       /* Set up task in case topology creation doesn't finish
        * within a reasonable amount of time */
@@ -549,10 +554,6 @@
  *
  * @param cfg configuration template to use
  * @param total number of daemons to start
- * @param max_concurrent_connections for testing, how many peers can
-*                                   we connect to simultaneously
- * @param max_concurrent_ssh when starting with ssh, how many ssh
- *        connections will we allow at once (based on remote hosts allowed!)
  * @param timeout total time allowed for peers to start
  * @param connect_cb function to call each time two daemons are connected
  * @param connect_cb_cls closure for connect_callback
@@ -560,58 +561,188 @@
  * @param peergroup_cb_cls closure for peergroup_cb
  * @param hostnames linked list of host structs to use to start peers on
  *                  (NULL to run on localhost only)
- * @param topology allowed overlay topology
- * @param restrict_topology blacklist connections to this topology
- * @param restrict_transports specific transports to blacklist
- * @param connect_topology topology to connect peers in (defaults to allowed
- *        topology)
- * @param connect_topology_options options for connect topology
- * @param connect_topology_option_modifier option modifier for connect topology
  * @param verbose GNUNET_YES to print progress bars, GNUNET_NO otherwise
  *
  * @return NULL on error, otherwise handle to control peer group
  */
 struct GNUNET_TESTING_PeerGroup *
-GNUNET_TESTING_PeerGroup_start(
+GNUNET_TESTING_peergroup_start(
                                const struct GNUNET_CONFIGURATION_Handle *cfg,
                                unsigned int total,
-                               unsigned int max_concurrent_connections,
-                               unsigned int max_concurrent_ssh,
                                struct GNUNET_TIME_Relative timeout,
                                GNUNET_TESTING_NotifyConnection connect_cb,
                                void *connect_cb_cls,
                                GNUNET_TESTING_NotifyCompletion peergroup_cb,
                                void *peergroup_cb_cls,
                                const struct GNUNET_TESTING_Host *hostnames,
-                               enum GNUNET_TESTING_Topology topology,
-                               enum GNUNET_TESTING_Topology restrict_topology,
-                               const char *restrict_transports,
-                               enum GNUNET_TESTING_Topology connect_topology,
-                               enum GNUNET_TESTING_TopologyOption 
connect_topology_options,
-                               double connect_topology_option_modifier, int 
verbose)
+                               int verbose)
 {
   struct PeerGroupStartupContext *pg_start_ctx;
-
+  unsigned long long temp_config_number;
+  char *temp_str;
   GNUNET_assert(total > 0);
   GNUNET_assert(cfg != NULL);
 
   pg_start_ctx = GNUNET_malloc(sizeof(struct PeerGroupStartupContext));
+
+  if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg, "testing",
+                                                          "connect_attempts",
+                                                          
&pg_start_ctx->connect_attempts))
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n",
+                  "testing", "connect_attempts");
+      GNUNET_free(pg_start_ctx);
+      return NULL;
+    }
+
+  if (GNUNET_OK
+      != GNUNET_CONFIGURATION_get_value_number (cfg, "testing",
+                                                "max_outstanding_connections",
+                                                
&pg_start_ctx->max_concurrent_connections))
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n",
+                  "testing", "max_outstanding_connections");
+      GNUNET_free(pg_start_ctx);
+      return NULL;
+    }
+
+  if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg, "testing",
+                                                          "max_concurrent_ssh",
+                                                          
&pg_start_ctx->max_concurrent_ssh))
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n",
+                  "testing", "max_concurrent_ssh");
+      GNUNET_free(pg_start_ctx);
+      return NULL;
+    }
+
+  if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cfg, "testing",
+                                                          "peergroup_timeout",
+                                                          &temp_config_number))
+    pg_start_ctx->timeout = 
GNUNET_TIME_relative_to_absolute(GNUNET_TIME_relative_multiply 
(GNUNET_TIME_UNIT_SECONDS,
+                                                     temp_config_number));
+  else
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n",
+                  "testing", "peergroup_timeout");
+      GNUNET_free(pg_start_ctx);
+      return NULL;
+    }
+
+
+  /* Read topology related options from the configuration file */
+  temp_str = NULL;
+  if ((GNUNET_YES == GNUNET_CONFIGURATION_get_value_string (cfg, "testing",
+                                                            "topology",
+                                                            &temp_str))
+      && (GNUNET_NO == GNUNET_TESTING_topology_get (&pg_start_ctx->topology, 
temp_str)))
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                  "Invalid topology `%s' given for section %s option %s\n",
+                  temp_str, "TESTING", "TOPOLOGY");
+      pg_start_ctx->topology = GNUNET_TESTING_TOPOLOGY_CLIQUE; /* Defaults to 
NONE, so set better default here */
+    }
+  GNUNET_free_non_null(temp_str);
+
+  if (GNUNET_OK
+      != GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "percentage",
+                                                &temp_str))
+    pg_start_ctx->topology_percentage = 0.5;
+  else
+    {
+      pg_start_ctx->topology_percentage = atof (temp_str);
+      GNUNET_free(temp_str);
+    }
+
+  if (GNUNET_OK
+      != GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "probability",
+                                                &temp_str))
+    pg_start_ctx->topology_probability = 0.5;
+  else
+    {
+      pg_start_ctx->topology_probability = atof (temp_str);
+      GNUNET_free(temp_str);
+    }
+
+  if ((GNUNET_YES
+      == GNUNET_CONFIGURATION_get_value_string (cfg, "testing",
+                                                "connect_topology",
+                                                &temp_str))
+      && (GNUNET_NO == GNUNET_TESTING_topology_get 
(&pg_start_ctx->connect_topology,
+                                                    temp_str)))
+    {
+      GNUNET_log (
+                  GNUNET_ERROR_TYPE_WARNING,
+                  "Invalid connect topology `%s' given for section %s option 
%s\n",
+                  temp_str, "TESTING", "CONNECT_TOPOLOGY");
+    }
+  GNUNET_free_non_null(temp_str);
+
+  if ((GNUNET_YES
+      == GNUNET_CONFIGURATION_get_value_string (cfg, "testing",
+                                                "connect_topology_option",
+                                                &temp_str))
+      && (GNUNET_NO
+          == GNUNET_TESTING_topology_option_get 
(&pg_start_ctx->connect_topology_option,
+                                                 temp_str)))
+    {
+      GNUNET_log (
+                  GNUNET_ERROR_TYPE_WARNING,
+                  "Invalid connect topology option `%s' given for section %s 
option %s\n",
+                  temp_str, "TESTING",
+                  "CONNECT_TOPOLOGY_OPTION");
+      pg_start_ctx->connect_topology_option = 
GNUNET_TESTING_TOPOLOGY_OPTION_ALL; /* Defaults to NONE, set to ALL */
+    }
+  GNUNET_free_non_null(temp_str);
+
+  if (GNUNET_YES
+      == GNUNET_CONFIGURATION_get_value_string (
+                                                cfg,
+                                                "testing",
+                                                
"connect_topology_option_modifier",
+                                                &temp_str))
+    {
+      if (sscanf (temp_str, "%lf",
+                  &pg_start_ctx->connect_topology_option_modifier) != 1)
+        {
+          GNUNET_log (
+                      GNUNET_ERROR_TYPE_WARNING,
+                      _("Invalid value `%s' for option `%s' in section `%s': 
expected float\n"),
+                          temp_str,
+                      "connect_topology_option_modifier", "TESTING");
+          GNUNET_free (temp_str);
+          GNUNET_free(pg_start_ctx);
+          return NULL;
+        }
+      GNUNET_free (temp_str);
+    }
+
+  if (GNUNET_YES
+      != GNUNET_CONFIGURATION_get_value_string (cfg, "testing",
+                                                "blacklist_transports",
+                                                
&pg_start_ctx->restrict_transports))
+    pg_start_ctx->restrict_transports = NULL;
+
+  if ((GNUNET_YES
+      == GNUNET_CONFIGURATION_get_value_string (cfg, "testing",
+                                                "blacklist_topology",
+                                                &temp_str))
+      && (GNUNET_NO == GNUNET_TESTING_topology_get 
(&pg_start_ctx->restrict_topology,
+                                                    temp_str)))
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                  "Invalid topology `%s' given for section %s option %s\n",
+                  temp_str, "TESTING", "BLACKLIST_TOPOLOGY");
+    }
+  GNUNET_free_non_null(temp_str);
+
   pg_start_ctx->cfg = cfg;
   pg_start_ctx->total = total;
   pg_start_ctx->peers_left = total;
-  pg_start_ctx->max_concurrent_connections = max_concurrent_connections;
-  pg_start_ctx->max_concurrent_ssh = max_concurrent_ssh;
-  pg_start_ctx->timeout = GNUNET_TIME_relative_to_absolute(timeout);
   pg_start_ctx->connect_cb = connect_cb_cls;
   pg_start_ctx->peergroup_cb = peergroup_cb;
   pg_start_ctx->peergroup_cb_cls = peergroup_cb_cls;
   pg_start_ctx->hostnames = hostnames;
-  pg_start_ctx->topology = topology;
-  pg_start_ctx->restrict_topology = restrict_topology;
-  pg_start_ctx->restrict_transports = restrict_transports;
-  pg_start_ctx->connect_topology = connect_topology;
-  pg_start_ctx->connect_topology_option = connect_topology_options;
-  pg_start_ctx->connect_topology_option_modifier = 
connect_topology_option_modifier;
   pg_start_ctx->verbose = verbose;
   pg_start_ctx->hostkey_meter = create_meter (pg_start_ctx->peers_left, 
"Hostkeys created ", pg_start_ctx->verbose);
   pg_start_ctx->peer_start_meter = create_meter (pg_start_ctx->peers_left, 
"Peers started ", pg_start_ctx->verbose);
@@ -640,5 +771,4 @@
   return pg_start_ctx->pg;
 }
 
-
 /* end of testing_peergroup.c */




reply via email to

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