From a4bdb0feb4bd31c7dcbef939e1d80949ee5b0515 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Wed, 26 May 2010 20:46:25 +0000 Subject: [PATCH] adding test for content migration --- TODO | 2 - src/fs/Makefile.am | 1 + src/fs/fs_test_lib.c | 4 +- src/fs/fs_test_lib.h | 2 + src/fs/test_fs_test_lib.c | 1 + src/fs/test_gnunet_service_fs_migration.c | 64 ++++++++++++------- ...test_gnunet_service_fs_migration_data.conf | 58 +++++++++++++++++ src/fs/test_gnunet_service_fs_p2p.c | 1 + 8 files changed, 106 insertions(+), 27 deletions(-) create mode 100644 src/fs/test_gnunet_service_fs_migration_data.conf diff --git a/TODO b/TODO index cdbf4efd3..fc91c6200 100644 --- 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 diff --git a/src/fs/Makefile.am b/src/fs/Makefile.am index 463ba2875..9cee55753 100644 --- a/src/fs/Makefile.am +++ b/src/fs/Makefile.am @@ -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 \ diff --git a/src/fs/fs_test_lib.c b/src/fs/fs_test_lib.c index a8db67c8c..766bb121b 100644 --- a/src/fs/fs_test_lib.c +++ b/src/fs/fs_test_lib.c @@ -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); diff --git a/src/fs/fs_test_lib.h b/src/fs/fs_test_lib.h index 524c1f3cc..a13de9874 100644 --- a/src/fs/fs_test_lib.h +++ b/src/fs/fs_test_lib.h @@ -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, diff --git a/src/fs/test_fs_test_lib.c b/src/fs/test_fs_test_lib.c index da00e6e5e..ecb849627 100644 --- a/src/fs/test_fs_test_lib.c +++ b/src/fs/test_fs_test_lib.c @@ -152,6 +152,7 @@ run (void *cls, { sched = s; GNUNET_FS_TEST_daemons_start (sched, + "fs_test_lib_data.conf", TIMEOUT, NUM_DAEMONS, daemons, diff --git a/src/fs/test_gnunet_service_fs_migration.c b/src/fs/test_gnunet_service_fs_migration.c index 8227895ba..78cd3813a 100644 --- a/src/fs/test_gnunet_service_fs_migration.c +++ b/src/fs/test_gnunet_service_fs_migration.c @@ -22,12 +22,6 @@ * @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" @@ -37,18 +31,21 @@ /** * 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 index 000000000..f13ddad72 --- /dev/null +++ b/src/fs/test_gnunet_service_fs_migration_data.conf @@ -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 diff --git a/src/fs/test_gnunet_service_fs_p2p.c b/src/fs/test_gnunet_service_fs_p2p.c index 7e3e02c76..80d1017f1 100644 --- a/src/fs/test_gnunet_service_fs_p2p.c +++ b/src/fs/test_gnunet_service_fs_p2p.c @@ -161,6 +161,7 @@ run (void *cls, { sched = s; GNUNET_FS_TEST_daemons_start (sched, + "fs_test_lib_data.conf", TIMEOUT, NUM_DAEMONS, daemons, -- 2.25.1