2 This file is part of GNUnet.
3 (C) 2010 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 2, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file fs/test_gnunet_service_fs_migration.c
23 * @brief test content migration between two peers
24 * @author Christian Grothoff
27 * - change configuration to enable migration
28 * - shutdown source peer during download
29 * - wait long enough to allow for migration between
30 * publish and download
33 #include "fs_test_lib.h"
35 #define VERBOSE GNUNET_NO
38 * File-size we use for testing.
40 #define FILESIZE (1024 * 1024 * 2)
43 * How long until we give up on transmitting the message?
45 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 600)
51 static struct GNUNET_FS_TestDaemon *daemons[NUM_DAEMONS];
53 static struct GNUNET_SCHEDULER_Handle *sched;
57 static struct GNUNET_TIME_Absolute start_time;
61 const struct GNUNET_SCHEDULER_TaskContext *tc)
63 struct GNUNET_TIME_Relative del;
66 GNUNET_FS_TEST_daemons_stop (sched,
69 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE))
71 del = GNUNET_TIME_absolute_get_duration (start_time);
74 fancy = GNUNET_STRINGS_byte_size_fancy (((unsigned long long)FILESIZE) * 1000LL / del.value);
76 "Download speed was %s/s\n",
79 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
80 "Finished download, shutting down\n",
81 (unsigned long long) FILESIZE);
85 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
86 "Timeout during download, shutting down with error\n");
93 do_download (void *cls,
94 const struct GNUNET_FS_Uri *uri)
98 GNUNET_FS_TEST_daemons_stop (sched,
101 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
102 "Timeout during upload attempt, shutting down with error\n");
106 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
107 "Downloading %llu bytes\n",
108 (unsigned long long) FILESIZE);
109 start_time = GNUNET_TIME_absolute_get ();
110 GNUNET_FS_TEST_download (sched,
120 do_publish (void *cls,
121 const struct GNUNET_SCHEDULER_TaskContext *tc)
123 if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE))
125 GNUNET_FS_TEST_daemons_stop (sched,
128 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
129 "Timeout during connect attempt, shutting down with error\n");
133 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
134 "Publishing %llu bytes\n",
135 (unsigned long long) FILESIZE);
136 GNUNET_FS_TEST_publish (sched,
139 1, GNUNET_NO, FILESIZE, SEED,
146 do_connect (void *cls,
147 const struct GNUNET_SCHEDULER_TaskContext *tc)
149 GNUNET_assert (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE));
150 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
151 "Daemons started, will now try to connect them\n");
152 GNUNET_FS_TEST_daemons_connect (sched,
163 struct GNUNET_SCHEDULER_Handle *s,
166 const struct GNUNET_CONFIGURATION_Handle *cfg)
169 GNUNET_FS_TEST_daemons_start (sched,
179 main (int argc, char *argv[])
181 char *const argvx[] = {
182 "test-gnunet-service-fs-migration",
184 "fs_test_lib_data.conf",
190 struct GNUNET_GETOPT_CommandLineOption options[] = {
191 GNUNET_GETOPT_OPTION_END
194 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-lib/");
195 GNUNET_log_setup ("test_gnunet_service_fs_migration",
202 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1,
203 argvx, "test-gnunet-service-fs-migration",
204 "nohelp", options, &run, NULL);
205 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-lib/");
209 /* end of test_gnunet_service_fs_migration.c */