adding test for content migration
authorChristian Grothoff <christian@grothoff.org>
Wed, 26 May 2010 20:46:25 +0000 (20:46 +0000)
committerChristian Grothoff <christian@grothoff.org>
Wed, 26 May 2010 20:46:25 +0000 (20:46 +0000)
TODO
src/fs/Makefile.am
src/fs/fs_test_lib.c
src/fs/fs_test_lib.h
src/fs/test_fs_test_lib.c
src/fs/test_gnunet_service_fs_migration.c
src/fs/test_gnunet_service_fs_migration_data.conf [new file with mode: 0644]
src/fs/test_gnunet_service_fs_p2p.c

diff --git a/TODO b/TODO
index cdbf4efd3187d5e981b6aa0a7af6e4347ea66afb..fc91c6200a46bdb0f3f6a79fabc7133bfa224616 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,7 +1,5 @@
 0.9.0pre1:
 * FS: [CG]
-  - test indexing
-  - test migration
   - TTL/priority calculations
   - hot-path routing, load considerations
   - statistics
index 463ba287500e305156d5e97002ee0e33ed685bcb..9cee55753104e488d0b9b846b428f34f8c29aae1 100644 (file)
@@ -324,6 +324,7 @@ EXTRA_DIST = \
   test_fs_search_data.conf \
   test_fs_unindex_data.conf \
   test_fs_uri_data.conf \
+  test_gnunet_service_fs_migration_data.conf \
   test_gnunet_fs_idx_data.conf \
   test_gnunet_fs_ns_data.conf \
   test_gnunet_fs_psd_data.conf \
index a8db67c8c24b6534dc2501f59844039e4735343b..766bb121b620808aa5a33adbc124beb60925607d 100644 (file)
@@ -316,6 +316,7 @@ start_timeout (void *cls,
  * Start daemons for testing.
  *
  * @param sched scheduler to use
+ * @param template_cfg_file configuration template to use
  * @param timeout if this operation cannot be completed within the
  *                given period, call the continuation with an error code
  * @param total number of daemons to start
@@ -326,6 +327,7 @@ start_timeout (void *cls,
  */
 void
 GNUNET_FS_TEST_daemons_start (struct GNUNET_SCHEDULER_Handle *sched,
+                             const char *template_cfg_file,
                              struct GNUNET_TIME_Relative timeout,
                              unsigned int total,
                              struct GNUNET_FS_TestDaemon **daemons,
@@ -345,7 +347,7 @@ GNUNET_FS_TEST_daemons_start (struct GNUNET_SCHEDULER_Handle *sched,
   sctx->cfg = GNUNET_CONFIGURATION_create ();
   if (GNUNET_OK !=
       GNUNET_CONFIGURATION_load (sctx->cfg,
-                                "fs_test_lib_data.conf"))
+                                template_cfg_file))
     {
       GNUNET_break (0);
       GNUNET_CONFIGURATION_destroy (sctx->cfg);
index 524c1f3cc39a09652295110f6f7944d879b626bf..a13de98740585ab2e4c741f31328a5be61705613 100644 (file)
@@ -42,6 +42,7 @@ struct GNUNET_FS_TestDaemon;
  * Start daemons for testing.
  *
  * @param sched scheduler to use
+ * @param template_cfg_file configuration template to use
  * @param timeout if this operation cannot be completed within the
  *                given period, call the continuation with an error code
  * @param total number of daemons to start
@@ -52,6 +53,7 @@ struct GNUNET_FS_TestDaemon;
  */
 void
 GNUNET_FS_TEST_daemons_start (struct GNUNET_SCHEDULER_Handle *sched,
+                             const char *template_cfg_file,
                              struct GNUNET_TIME_Relative timeout,
                              unsigned int total,
                              struct GNUNET_FS_TestDaemon **daemons,
index da00e6e5e2b3c0ab464ebf0bf12bf2c948943469..ecb849627fc33285b969f50878587f1d99a2ffcc 100644 (file)
@@ -152,6 +152,7 @@ run (void *cls,
 {
   sched = s;
   GNUNET_FS_TEST_daemons_start (sched,
+                               "fs_test_lib_data.conf",
                                TIMEOUT,
                                NUM_DAEMONS,
                                daemons,
index 8227895ba5fbc103e69e53a8a2cc0e5a30c06094..78cd3813a19fc8bc6364dcc81c029f67d2370549 100644 (file)
  * @file fs/test_gnunet_service_fs_migration.c
  * @brief test content migration between two peers
  * @author Christian Grothoff
- *
- * TODO:
- * - change configuration to enable migration
- * - shutdown source peer during download
- * - wait long enough to allow for migration between
- *   publish and download
  */
 #include "platform.h"
 #include "fs_test_lib.h"
 /**
  * File-size we use for testing.
  */
-#define FILESIZE (1024 * 1024 * 2)
+#define FILESIZE (2 * 32 * 1024)
 
 /**
  * How long until we give up on transmitting the message?
  */
 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 600)
 
-#define NUM_DAEMONS 2
+/**
+ * How long do we give the peers for content migration?
+ */
+#define MIGRATION_DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60)
 
 #define SEED 42
 
-static struct GNUNET_FS_TestDaemon *daemons[NUM_DAEMONS];
+static struct GNUNET_FS_TestDaemon *daemons[2];
 
 static struct GNUNET_SCHEDULER_Handle *sched;
 
@@ -64,7 +61,7 @@ do_stop (void *cls,
   char *fancy;
 
   GNUNET_FS_TEST_daemons_stop (sched,
-                              NUM_DAEMONS,
+                              1,
                               daemons);
   if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE))
     {
@@ -91,18 +88,11 @@ do_stop (void *cls,
 
 static void
 do_download (void *cls,
-            const struct GNUNET_FS_Uri *uri)
+            const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
-  if (NULL == uri)
-    {
-      GNUNET_FS_TEST_daemons_stop (sched,
-                                  NUM_DAEMONS,
-                                  daemons);
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                 "Timeout during upload attempt, shutting down with error\n");
-      ok = 1;
-      return;
-    }
+  struct GNUNET_FS_Uri *uri = cls;
+
+  GNUNET_FS_TEST_daemons_stop (sched, 1, &daemons[1]);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Downloading %llu bytes\n",
              (unsigned long long) FILESIZE);
@@ -116,6 +106,31 @@ do_download (void *cls,
 }
 
 
+static void
+do_wait (void *cls,
+        const struct GNUNET_FS_Uri *uri)
+{
+  struct GNUNET_FS_Uri *d;
+
+  if (NULL == uri)
+    {
+      GNUNET_FS_TEST_daemons_stop (sched,
+                                  2,
+                                  daemons);
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                 "Timeout during upload attempt, shutting down with error\n");
+      ok = 1;
+      return;
+    }
+  d = GNUNET_FS_uri_dup (uri);
+  GNUNET_SCHEDULER_add_delayed (sched,
+                               MIGRATION_DELAY,
+                               &do_download,
+                               d);
+}
+
+
+
 static void
 do_publish (void *cls,
            const struct GNUNET_SCHEDULER_TaskContext *tc)
@@ -123,7 +138,7 @@ do_publish (void *cls,
   if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE))
     {
       GNUNET_FS_TEST_daemons_stop (sched,
-                                  NUM_DAEMONS,
+                                  2,
                                   daemons);
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                  "Timeout during connect attempt, shutting down with error\n");
@@ -138,7 +153,7 @@ do_publish (void *cls,
                          TIMEOUT,
                          1, GNUNET_NO, FILESIZE, SEED, 
                          VERBOSE, 
-                         &do_download, NULL);
+                         &do_wait, NULL);
 }
 
 
@@ -167,8 +182,9 @@ run (void *cls,
 {
   sched = s;
   GNUNET_FS_TEST_daemons_start (sched,
+                               "test_gnunet_service_fs_migration_data.conf",
                                TIMEOUT,
-                               NUM_DAEMONS,
+                               2,
                                daemons,
                                &do_connect,
                                NULL);
diff --git a/src/fs/test_gnunet_service_fs_migration_data.conf b/src/fs/test_gnunet_service_fs_migration_data.conf
new file mode 100644 (file)
index 0000000..f13ddad
--- /dev/null
@@ -0,0 +1,58 @@
+[PATHS]
+SERVICEHOME = /tmp/test-gnunet-service-fs-migration/
+DEFAULTCONFIG = test_gnunet_service_fs_migration_data.conf
+
+[gnunetd]
+HOSTKEY = $SERVICEHOME/.hostkey
+
+[resolver]
+PORT = 43464
+HOSTNAME = localhost
+
+[transport]
+PORT = 43465
+PLUGINS = tcp
+#DEBUG = YES
+
+[arm]
+PORT = 43466
+HOSTNAME = localhost
+DEFAULTSERVICES = fs
+
+[datastore]
+#DEBUG = YES
+#PREFIX = valgrind --tool=memcheck --leak-check=yes
+
+[statistics]
+PORT = 43467
+HOSTNAME = localhost
+
+[transport-tcp]
+TIMEOUT = 300000
+PORT = 43468
+
+[peerinfo]
+PORT = 43469
+HOSTNAME = localhost
+
+[core]
+PORT = 43470
+HOSTNAME = localhost
+#TOTAL_QUOTA_IN = 9321
+#TOTAL_QUOTA_OUT = 9321
+TOTAL_QUOTA_IN = 3932160
+TOTAL_QUOTA_OUT = 3932160
+#DEBUG = YES
+#PREFIX = valgrind --tool=memcheck --leak-check=yes
+
+[fs]
+PORT = 43471
+HOSTNAME = localhost
+#OPTIONS = -L DEBUG
+ACTIVEMIGRATION = YES
+#DEBUG = YES
+#PREFIX = valgrind --tool=memcheck --leak-check=yes 
+#PREFIX = xterm -e gdb -x cmd --args 
+
+[testing]
+WEAKRANDOM = YES
index 7e3e02c7626a9b1c4a020a6f41f7e98c5787e8bc..80d1017f12ba334140a70d8602043051f7394f65 100644 (file)
@@ -161,6 +161,7 @@ run (void *cls,
 {
   sched = s;
   GNUNET_FS_TEST_daemons_start (sched,
+                               "fs_test_lib_data.conf",
                                TIMEOUT,
                                NUM_DAEMONS,
                                daemons,