* 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
*/
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,
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);
* 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
*/
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,
* @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;
char *fancy;
GNUNET_FS_TEST_daemons_stop (sched,
- NUM_DAEMONS,
+ 1,
daemons);
if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE))
{
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);
}
+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)
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");
TIMEOUT,
1, GNUNET_NO, FILESIZE, SEED,
VERBOSE,
- &do_download, NULL);
+ &do_wait, NULL);
}
{
sched = s;
GNUNET_FS_TEST_daemons_start (sched,
+ "test_gnunet_service_fs_migration_data.conf",
TIMEOUT,
- NUM_DAEMONS,
+ 2,
daemons,
&do_connect,
NULL);