diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-05-26 20:46:25 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-05-26 20:46:25 +0000 |
commit | a4bdb0feb4bd31c7dcbef939e1d80949ee5b0515 (patch) | |
tree | 43543ada749760062a40df086ab94498180fea4f /src | |
parent | 43677cdd03d9a1219b9a1211f27c04f69732dfbc (diff) | |
download | gnunet-a4bdb0feb4bd31c7dcbef939e1d80949ee5b0515.tar.gz gnunet-a4bdb0feb4bd31c7dcbef939e1d80949ee5b0515.zip |
adding test for content migration
Diffstat (limited to 'src')
-rw-r--r-- | src/fs/Makefile.am | 1 | ||||
-rw-r--r-- | src/fs/fs_test_lib.c | 4 | ||||
-rw-r--r-- | src/fs/fs_test_lib.h | 2 | ||||
-rw-r--r-- | src/fs/test_fs_test_lib.c | 1 | ||||
-rw-r--r-- | src/fs/test_gnunet_service_fs_migration.c | 64 | ||||
-rw-r--r-- | src/fs/test_gnunet_service_fs_migration_data.conf | 58 | ||||
-rw-r--r-- | src/fs/test_gnunet_service_fs_p2p.c | 1 |
7 files changed, 106 insertions, 25 deletions
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 = \ | |||
324 | test_fs_search_data.conf \ | 324 | test_fs_search_data.conf \ |
325 | test_fs_unindex_data.conf \ | 325 | test_fs_unindex_data.conf \ |
326 | test_fs_uri_data.conf \ | 326 | test_fs_uri_data.conf \ |
327 | test_gnunet_service_fs_migration_data.conf \ | ||
327 | test_gnunet_fs_idx_data.conf \ | 328 | test_gnunet_fs_idx_data.conf \ |
328 | test_gnunet_fs_ns_data.conf \ | 329 | test_gnunet_fs_ns_data.conf \ |
329 | test_gnunet_fs_psd_data.conf \ | 330 | 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, | |||
316 | * Start daemons for testing. | 316 | * Start daemons for testing. |
317 | * | 317 | * |
318 | * @param sched scheduler to use | 318 | * @param sched scheduler to use |
319 | * @param template_cfg_file configuration template to use | ||
319 | * @param timeout if this operation cannot be completed within the | 320 | * @param timeout if this operation cannot be completed within the |
320 | * given period, call the continuation with an error code | 321 | * given period, call the continuation with an error code |
321 | * @param total number of daemons to start | 322 | * @param total number of daemons to start |
@@ -326,6 +327,7 @@ start_timeout (void *cls, | |||
326 | */ | 327 | */ |
327 | void | 328 | void |
328 | GNUNET_FS_TEST_daemons_start (struct GNUNET_SCHEDULER_Handle *sched, | 329 | GNUNET_FS_TEST_daemons_start (struct GNUNET_SCHEDULER_Handle *sched, |
330 | const char *template_cfg_file, | ||
329 | struct GNUNET_TIME_Relative timeout, | 331 | struct GNUNET_TIME_Relative timeout, |
330 | unsigned int total, | 332 | unsigned int total, |
331 | struct GNUNET_FS_TestDaemon **daemons, | 333 | struct GNUNET_FS_TestDaemon **daemons, |
@@ -345,7 +347,7 @@ GNUNET_FS_TEST_daemons_start (struct GNUNET_SCHEDULER_Handle *sched, | |||
345 | sctx->cfg = GNUNET_CONFIGURATION_create (); | 347 | sctx->cfg = GNUNET_CONFIGURATION_create (); |
346 | if (GNUNET_OK != | 348 | if (GNUNET_OK != |
347 | GNUNET_CONFIGURATION_load (sctx->cfg, | 349 | GNUNET_CONFIGURATION_load (sctx->cfg, |
348 | "fs_test_lib_data.conf")) | 350 | template_cfg_file)) |
349 | { | 351 | { |
350 | GNUNET_break (0); | 352 | GNUNET_break (0); |
351 | GNUNET_CONFIGURATION_destroy (sctx->cfg); | 353 | 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; | |||
42 | * Start daemons for testing. | 42 | * Start daemons for testing. |
43 | * | 43 | * |
44 | * @param sched scheduler to use | 44 | * @param sched scheduler to use |
45 | * @param template_cfg_file configuration template to use | ||
45 | * @param timeout if this operation cannot be completed within the | 46 | * @param timeout if this operation cannot be completed within the |
46 | * given period, call the continuation with an error code | 47 | * given period, call the continuation with an error code |
47 | * @param total number of daemons to start | 48 | * @param total number of daemons to start |
@@ -52,6 +53,7 @@ struct GNUNET_FS_TestDaemon; | |||
52 | */ | 53 | */ |
53 | void | 54 | void |
54 | GNUNET_FS_TEST_daemons_start (struct GNUNET_SCHEDULER_Handle *sched, | 55 | GNUNET_FS_TEST_daemons_start (struct GNUNET_SCHEDULER_Handle *sched, |
56 | const char *template_cfg_file, | ||
55 | struct GNUNET_TIME_Relative timeout, | 57 | struct GNUNET_TIME_Relative timeout, |
56 | unsigned int total, | 58 | unsigned int total, |
57 | struct GNUNET_FS_TestDaemon **daemons, | 59 | 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, | |||
152 | { | 152 | { |
153 | sched = s; | 153 | sched = s; |
154 | GNUNET_FS_TEST_daemons_start (sched, | 154 | GNUNET_FS_TEST_daemons_start (sched, |
155 | "fs_test_lib_data.conf", | ||
155 | TIMEOUT, | 156 | TIMEOUT, |
156 | NUM_DAEMONS, | 157 | NUM_DAEMONS, |
157 | daemons, | 158 | 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 @@ | |||
22 | * @file fs/test_gnunet_service_fs_migration.c | 22 | * @file fs/test_gnunet_service_fs_migration.c |
23 | * @brief test content migration between two peers | 23 | * @brief test content migration between two peers |
24 | * @author Christian Grothoff | 24 | * @author Christian Grothoff |
25 | * | ||
26 | * TODO: | ||
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 | ||
31 | */ | 25 | */ |
32 | #include "platform.h" | 26 | #include "platform.h" |
33 | #include "fs_test_lib.h" | 27 | #include "fs_test_lib.h" |
@@ -37,18 +31,21 @@ | |||
37 | /** | 31 | /** |
38 | * File-size we use for testing. | 32 | * File-size we use for testing. |
39 | */ | 33 | */ |
40 | #define FILESIZE (1024 * 1024 * 2) | 34 | #define FILESIZE (2 * 32 * 1024) |
41 | 35 | ||
42 | /** | 36 | /** |
43 | * How long until we give up on transmitting the message? | 37 | * How long until we give up on transmitting the message? |
44 | */ | 38 | */ |
45 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 600) | 39 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 600) |
46 | 40 | ||
47 | #define NUM_DAEMONS 2 | 41 | /** |
42 | * How long do we give the peers for content migration? | ||
43 | */ | ||
44 | #define MIGRATION_DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60) | ||
48 | 45 | ||
49 | #define SEED 42 | 46 | #define SEED 42 |
50 | 47 | ||
51 | static struct GNUNET_FS_TestDaemon *daemons[NUM_DAEMONS]; | 48 | static struct GNUNET_FS_TestDaemon *daemons[2]; |
52 | 49 | ||
53 | static struct GNUNET_SCHEDULER_Handle *sched; | 50 | static struct GNUNET_SCHEDULER_Handle *sched; |
54 | 51 | ||
@@ -64,7 +61,7 @@ do_stop (void *cls, | |||
64 | char *fancy; | 61 | char *fancy; |
65 | 62 | ||
66 | GNUNET_FS_TEST_daemons_stop (sched, | 63 | GNUNET_FS_TEST_daemons_stop (sched, |
67 | NUM_DAEMONS, | 64 | 1, |
68 | daemons); | 65 | daemons); |
69 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)) | 66 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)) |
70 | { | 67 | { |
@@ -91,18 +88,11 @@ do_stop (void *cls, | |||
91 | 88 | ||
92 | static void | 89 | static void |
93 | do_download (void *cls, | 90 | do_download (void *cls, |
94 | const struct GNUNET_FS_Uri *uri) | 91 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
95 | { | 92 | { |
96 | if (NULL == uri) | 93 | struct GNUNET_FS_Uri *uri = cls; |
97 | { | 94 | |
98 | GNUNET_FS_TEST_daemons_stop (sched, | 95 | GNUNET_FS_TEST_daemons_stop (sched, 1, &daemons[1]); |
99 | NUM_DAEMONS, | ||
100 | daemons); | ||
101 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
102 | "Timeout during upload attempt, shutting down with error\n"); | ||
103 | ok = 1; | ||
104 | return; | ||
105 | } | ||
106 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 96 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
107 | "Downloading %llu bytes\n", | 97 | "Downloading %llu bytes\n", |
108 | (unsigned long long) FILESIZE); | 98 | (unsigned long long) FILESIZE); |
@@ -117,13 +107,38 @@ do_download (void *cls, | |||
117 | 107 | ||
118 | 108 | ||
119 | static void | 109 | static void |
110 | do_wait (void *cls, | ||
111 | const struct GNUNET_FS_Uri *uri) | ||
112 | { | ||
113 | struct GNUNET_FS_Uri *d; | ||
114 | |||
115 | if (NULL == uri) | ||
116 | { | ||
117 | GNUNET_FS_TEST_daemons_stop (sched, | ||
118 | 2, | ||
119 | daemons); | ||
120 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
121 | "Timeout during upload attempt, shutting down with error\n"); | ||
122 | ok = 1; | ||
123 | return; | ||
124 | } | ||
125 | d = GNUNET_FS_uri_dup (uri); | ||
126 | GNUNET_SCHEDULER_add_delayed (sched, | ||
127 | MIGRATION_DELAY, | ||
128 | &do_download, | ||
129 | d); | ||
130 | } | ||
131 | |||
132 | |||
133 | |||
134 | static void | ||
120 | do_publish (void *cls, | 135 | do_publish (void *cls, |
121 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 136 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
122 | { | 137 | { |
123 | if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)) | 138 | if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)) |
124 | { | 139 | { |
125 | GNUNET_FS_TEST_daemons_stop (sched, | 140 | GNUNET_FS_TEST_daemons_stop (sched, |
126 | NUM_DAEMONS, | 141 | 2, |
127 | daemons); | 142 | daemons); |
128 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 143 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
129 | "Timeout during connect attempt, shutting down with error\n"); | 144 | "Timeout during connect attempt, shutting down with error\n"); |
@@ -138,7 +153,7 @@ do_publish (void *cls, | |||
138 | TIMEOUT, | 153 | TIMEOUT, |
139 | 1, GNUNET_NO, FILESIZE, SEED, | 154 | 1, GNUNET_NO, FILESIZE, SEED, |
140 | VERBOSE, | 155 | VERBOSE, |
141 | &do_download, NULL); | 156 | &do_wait, NULL); |
142 | } | 157 | } |
143 | 158 | ||
144 | 159 | ||
@@ -167,8 +182,9 @@ run (void *cls, | |||
167 | { | 182 | { |
168 | sched = s; | 183 | sched = s; |
169 | GNUNET_FS_TEST_daemons_start (sched, | 184 | GNUNET_FS_TEST_daemons_start (sched, |
185 | "test_gnunet_service_fs_migration_data.conf", | ||
170 | TIMEOUT, | 186 | TIMEOUT, |
171 | NUM_DAEMONS, | 187 | 2, |
172 | daemons, | 188 | daemons, |
173 | &do_connect, | 189 | &do_connect, |
174 | NULL); | 190 | 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 @@ | |||
1 | [PATHS] | ||
2 | SERVICEHOME = /tmp/test-gnunet-service-fs-migration/ | ||
3 | DEFAULTCONFIG = test_gnunet_service_fs_migration_data.conf | ||
4 | |||
5 | [gnunetd] | ||
6 | HOSTKEY = $SERVICEHOME/.hostkey | ||
7 | |||
8 | [resolver] | ||
9 | PORT = 43464 | ||
10 | HOSTNAME = localhost | ||
11 | |||
12 | [transport] | ||
13 | PORT = 43465 | ||
14 | PLUGINS = tcp | ||
15 | #DEBUG = YES | ||
16 | |||
17 | [arm] | ||
18 | PORT = 43466 | ||
19 | HOSTNAME = localhost | ||
20 | DEFAULTSERVICES = fs | ||
21 | |||
22 | [datastore] | ||
23 | #DEBUG = YES | ||
24 | #PREFIX = valgrind --tool=memcheck --leak-check=yes | ||
25 | |||
26 | [statistics] | ||
27 | PORT = 43467 | ||
28 | HOSTNAME = localhost | ||
29 | |||
30 | [transport-tcp] | ||
31 | TIMEOUT = 300000 | ||
32 | PORT = 43468 | ||
33 | |||
34 | [peerinfo] | ||
35 | PORT = 43469 | ||
36 | HOSTNAME = localhost | ||
37 | |||
38 | [core] | ||
39 | PORT = 43470 | ||
40 | HOSTNAME = localhost | ||
41 | #TOTAL_QUOTA_IN = 9321 | ||
42 | #TOTAL_QUOTA_OUT = 9321 | ||
43 | TOTAL_QUOTA_IN = 3932160 | ||
44 | TOTAL_QUOTA_OUT = 3932160 | ||
45 | #DEBUG = YES | ||
46 | #PREFIX = valgrind --tool=memcheck --leak-check=yes | ||
47 | |||
48 | [fs] | ||
49 | PORT = 43471 | ||
50 | HOSTNAME = localhost | ||
51 | #OPTIONS = -L DEBUG | ||
52 | ACTIVEMIGRATION = YES | ||
53 | #DEBUG = YES | ||
54 | #PREFIX = valgrind --tool=memcheck --leak-check=yes | ||
55 | #PREFIX = xterm -e gdb -x cmd --args | ||
56 | |||
57 | [testing] | ||
58 | 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, | |||
161 | { | 161 | { |
162 | sched = s; | 162 | sched = s; |
163 | GNUNET_FS_TEST_daemons_start (sched, | 163 | GNUNET_FS_TEST_daemons_start (sched, |
164 | "fs_test_lib_data.conf", | ||
164 | TIMEOUT, | 165 | TIMEOUT, |
165 | NUM_DAEMONS, | 166 | NUM_DAEMONS, |
166 | daemons, | 167 | daemons, |