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/fs/test_gnunet_service_fs_migration.c | |
parent | 43677cdd03d9a1219b9a1211f27c04f69732dfbc (diff) | |
download | gnunet-a4bdb0feb4bd31c7dcbef939e1d80949ee5b0515.tar.gz gnunet-a4bdb0feb4bd31c7dcbef939e1d80949ee5b0515.zip |
adding test for content migration
Diffstat (limited to 'src/fs/test_gnunet_service_fs_migration.c')
-rw-r--r-- | src/fs/test_gnunet_service_fs_migration.c | 64 |
1 files changed, 40 insertions, 24 deletions
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); |