diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2010-04-20 15:15:39 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2010-04-20 15:15:39 +0000 |
commit | f38edaf6e06e6786da37aa48e0818dce898a05d3 (patch) | |
tree | 7a83762f70cbf6d22f66f559cd8d908125f359ec /src | |
parent | a61f7e5a34d22fbaca6473e323a8f57500c8ca92 (diff) | |
download | gnunet-f38edaf6e06e6786da37aa48e0818dce898a05d3.tar.gz gnunet-f38edaf6e06e6786da37aa48e0818dce898a05d3.zip |
Diffstat (limited to 'src')
-rw-r--r-- | src/hostlist/Makefile.am | 1 | ||||
-rw-r--r-- | src/hostlist/hostlist-client.c | 6 | ||||
-rw-r--r-- | src/hostlist/test_gnunet_daemon_hostlist_learning.c | 61 | ||||
-rw-r--r-- | src/hostlist/test_learning_adv_peer.conf | 2 | ||||
-rw-r--r-- | src/hostlist/test_learning_learn_peer.conf | 2 |
5 files changed, 61 insertions, 11 deletions
diff --git a/src/hostlist/Makefile.am b/src/hostlist/Makefile.am index c4cc55f41..7bc9ffd3a 100644 --- a/src/hostlist/Makefile.am +++ b/src/hostlist/Makefile.am | |||
@@ -48,6 +48,7 @@ test_gnunet_daemon_hostlist_learning_LDADD = \ | |||
48 | $(top_builddir)/src/transport/libgnunettransport.la \ | 48 | $(top_builddir)/src/transport/libgnunettransport.la \ |
49 | $(top_builddir)/src/arm/libgnunetarm.la \ | 49 | $(top_builddir)/src/arm/libgnunetarm.la \ |
50 | $(top_builddir)/src/core/libgnunetcore.la \ | 50 | $(top_builddir)/src/core/libgnunetcore.la \ |
51 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | ||
51 | $(top_builddir)/src/util/libgnunetutil.la | 52 | $(top_builddir)/src/util/libgnunetutil.la |
52 | 53 | ||
53 | EXTRA_DIST = \ | 54 | EXTRA_DIST = \ |
diff --git a/src/hostlist/hostlist-client.c b/src/hostlist/hostlist-client.c index 1dc74ad50..de8366ced 100644 --- a/src/hostlist/hostlist-client.c +++ b/src/hostlist/hostlist-client.c | |||
@@ -497,6 +497,10 @@ static void update_hostlist ( ) | |||
497 | { | 497 | { |
498 | current_hostlist->times_used++; | 498 | current_hostlist->times_used++; |
499 | current_hostlist->quality = checked_add ( current_hostlist->quality, HOSTLIST_SUCCESSFUL_DOWNLOAD); | 499 | current_hostlist->quality = checked_add ( current_hostlist->quality, HOSTLIST_SUCCESSFUL_DOWNLOAD); |
500 | GNUNET_STATISTICS_update ( stats, | ||
501 | gettext_noop("Learned URI downloaded"), | ||
502 | 1, | ||
503 | GNUNET_YES); | ||
500 | } | 504 | } |
501 | else | 505 | else |
502 | current_hostlist->quality = checked_sub ( current_hostlist->quality, HOSTLIST_FAILED_DOWNLOAD ); | 506 | current_hostlist->quality = checked_sub ( current_hostlist->quality, HOSTLIST_FAILED_DOWNLOAD ); |
@@ -1192,7 +1196,7 @@ load_hostlist_file () | |||
1192 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1196 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
1193 | _("%u hostlist URIs loaded from file\n"), counter); | 1197 | _("%u hostlist URIs loaded from file\n"), counter); |
1194 | GNUNET_STATISTICS_set (stats, | 1198 | GNUNET_STATISTICS_set (stats, |
1195 | gettext_noop("# hostlis URIs read from file"), | 1199 | gettext_noop("# hostlist URIs read from file"), |
1196 | counter, | 1200 | counter, |
1197 | GNUNET_YES); | 1201 | GNUNET_YES); |
1198 | 1202 | ||
diff --git a/src/hostlist/test_gnunet_daemon_hostlist_learning.c b/src/hostlist/test_gnunet_daemon_hostlist_learning.c index fb9446bc4..346ab6808 100644 --- a/src/hostlist/test_gnunet_daemon_hostlist_learning.c +++ b/src/hostlist/test_gnunet_daemon_hostlist_learning.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include "gnunet_core_service.h" | 28 | #include "gnunet_core_service.h" |
29 | #include "gnunet_transport_service.h" | 29 | #include "gnunet_transport_service.h" |
30 | #include "gnunet_resolver_service.h" | 30 | #include "gnunet_resolver_service.h" |
31 | #include "gnunet_statistics_service.h" | ||
31 | 32 | ||
32 | #define VERBOSE GNUNET_YES | 33 | #define VERBOSE GNUNET_YES |
33 | 34 | ||
@@ -42,6 +43,7 @@ | |||
42 | 43 | ||
43 | static int timeout; | 44 | static int timeout; |
44 | static int adv_arrived; | 45 | static int adv_arrived; |
46 | static int learned_hostlist_downloaded; | ||
45 | 47 | ||
46 | static struct GNUNET_SCHEDULER_Handle *sched; | 48 | static struct GNUNET_SCHEDULER_Handle *sched; |
47 | 49 | ||
@@ -55,6 +57,7 @@ struct PeerContext | |||
55 | struct GNUNET_MessageHeader *hello; | 57 | struct GNUNET_MessageHeader *hello; |
56 | struct GNUNET_ARM_Handle *arm; | 58 | struct GNUNET_ARM_Handle *arm; |
57 | struct GNUNET_CORE_Handle *core; | 59 | struct GNUNET_CORE_Handle *core; |
60 | struct GNUNET_STATISTICS_Handle *stats; | ||
58 | #if START_ARM | 61 | #if START_ARM |
59 | pid_t arm_pid; | 62 | pid_t arm_pid; |
60 | #endif | 63 | #endif |
@@ -121,14 +124,38 @@ timeout_error (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
121 | clean_up (NULL, tc); | 124 | clean_up (NULL, tc); |
122 | } | 125 | } |
123 | 126 | ||
127 | static int | ||
128 | process_stat (void *cls, | ||
129 | const char *subsystem, | ||
130 | const char *name, | ||
131 | uint64_t value, | ||
132 | int is_persistent) | ||
133 | { | ||
134 | |||
135 | if ( GNUNET_YES == GNUNET_YES) | ||
136 | { | ||
137 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
138 | _("Client has successfully downloaded advertised URI \n")); | ||
139 | learned_hostlist_downloaded = GNUNET_YES; | ||
140 | } | ||
141 | if ( GNUNET_NO != learned_hostlist_downloaded ) | ||
142 | shutdown_testcase(); | ||
143 | return GNUNET_OK; | ||
144 | } | ||
145 | |||
124 | /** | 146 | /** |
125 | * Check the server statistics regularly | 147 | * Check the server statistics regularly |
126 | */ | 148 | */ |
127 | static void | 149 | static void |
128 | check_statistics (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 150 | check_statistics (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
129 | { | 151 | { |
130 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 152 | GNUNET_STATISTICS_get (learn_peer.stats, |
131 | "Checking server stats...\n"); | 153 | "hostlist", |
154 | gettext_noop("Learned URI downloaded"), | ||
155 | GNUNET_TIME_UNIT_MINUTES, | ||
156 | NULL, | ||
157 | &process_stat, | ||
158 | NULL); | ||
132 | check_task = GNUNET_SCHEDULER_add_delayed (sched, | 159 | check_task = GNUNET_SCHEDULER_add_delayed (sched, |
133 | CHECK_INTERVALL, | 160 | CHECK_INTERVALL, |
134 | &check_statistics, | 161 | &check_statistics, |
@@ -191,7 +218,6 @@ static int ad_arrive_handler (void *cls, | |||
191 | "Expected URI `%s' and recieved URI `%s' differ\n", expected_uri, recv_uri); | 218 | "Expected URI `%s' and recieved URI `%s' differ\n", expected_uri, recv_uri); |
192 | GNUNET_free ( expected_uri ); | 219 | GNUNET_free ( expected_uri ); |
193 | GNUNET_free ( hostname ); | 220 | GNUNET_free ( hostname ); |
194 | shutdown_testcase(); | ||
195 | return GNUNET_OK; | 221 | return GNUNET_OK; |
196 | } | 222 | } |
197 | 223 | ||
@@ -228,10 +254,11 @@ setup_learn_peer (struct PeerContext *p, const char *cfgname) | |||
228 | result = remove (filename); | 254 | result = remove (filename); |
229 | if (result == 0) | 255 | if (result == 0) |
230 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 256 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
231 | _("Hostlist hostlist file `%s' was removed\n"),filename); | 257 | _("Hostlist file `%s' was removed\n"),filename); |
232 | } | 258 | } |
233 | } | 259 | } |
234 | GNUNET_free ( filename ); | 260 | if ( NULL != filename) GNUNET_free ( filename ); |
261 | |||
235 | GNUNET_ARM_start_services (p->cfg, sched, "core", NULL); | 262 | GNUNET_ARM_start_services (p->cfg, sched, "core", NULL); |
236 | 263 | ||
237 | p->core = GNUNET_CORE_connect (sched, p->cfg, | 264 | p->core = GNUNET_CORE_connect (sched, p->cfg, |
@@ -243,6 +270,8 @@ setup_learn_peer (struct PeerContext *p, const char *cfgname) | |||
243 | NULL, GNUNET_NO, | 270 | NULL, GNUNET_NO, |
244 | learn_handlers ); | 271 | learn_handlers ); |
245 | GNUNET_assert ( NULL != p->core ); | 272 | GNUNET_assert ( NULL != p->core ); |
273 | p->stats = GNUNET_STATISTICS_create (sched, "hostlist", p->cfg); | ||
274 | GNUNET_assert ( NULL != p->stats ); | ||
246 | } | 275 | } |
247 | 276 | ||
248 | 277 | ||
@@ -334,6 +363,7 @@ run (void *cls, | |||
334 | { | 363 | { |
335 | timeout = GNUNET_NO; | 364 | timeout = GNUNET_NO; |
336 | adv_arrived = GNUNET_NO; | 365 | adv_arrived = GNUNET_NO; |
366 | learned_hostlist_downloaded = GNUNET_NO; | ||
337 | sched = s; | 367 | sched = s; |
338 | timeout_task = GNUNET_SCHEDULER_add_delayed (sched, | 368 | timeout_task = GNUNET_SCHEDULER_add_delayed (sched, |
339 | TIMEOUT, | 369 | TIMEOUT, |
@@ -370,10 +400,25 @@ check () | |||
370 | argv, "test-gnunet-daemon-hostlist", | 400 | argv, "test-gnunet-daemon-hostlist", |
371 | "nohelp", options, &run, NULL); | 401 | "nohelp", options, &run, NULL); |
372 | 402 | ||
373 | if ( (timeout == GNUNET_YES) || (adv_arrived == GNUNET_NO)) | 403 | if (timeout == GNUNET_YES) |
404 | { | ||
405 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
406 | "Testcase could not set up two communicating peers, timeout\n"); | ||
374 | return GNUNET_YES; | 407 | return GNUNET_YES; |
375 | else | 408 | } |
376 | return GNUNET_NO; | 409 | if (adv_arrived == GNUNET_NO) |
410 | { | ||
411 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
412 | "Learning peer did not recieve advertisement from server\n"); | ||
413 | return GNUNET_YES; | ||
414 | } | ||
415 | if (learned_hostlist_downloaded == GNUNET_NO) | ||
416 | { | ||
417 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
418 | "Advertisement hostlist could not be downloaded from server\n"); | ||
419 | return GNUNET_YES; | ||
420 | } | ||
421 | return GNUNET_NO; | ||
377 | } | 422 | } |
378 | 423 | ||
379 | int | 424 | int |
diff --git a/src/hostlist/test_learning_adv_peer.conf b/src/hostlist/test_learning_adv_peer.conf index d77c43ced..9af51e8f2 100644 --- a/src/hostlist/test_learning_adv_peer.conf +++ b/src/hostlist/test_learning_adv_peer.conf | |||
@@ -37,7 +37,7 @@ WEAKRANDOM = YES | |||
37 | HTTPPORT = 12981s | 37 | HTTPPORT = 12981s |
38 | SERVERS = http://localhost:12980/ | 38 | SERVERS = http://localhost:12980/ |
39 | OPTIONS = -b -p -a | 39 | OPTIONS = -b -p -a |
40 | DEBUG = YES | 40 | DEBUG = NO |
41 | HOSTLISTFILE = hostlists_adv_peer.file | 41 | HOSTLISTFILE = hostlists_adv_peer.file |
42 | #BINARY = /home/grothoff/bin/gnunet-daemon-hostlist | 42 | #BINARY = /home/grothoff/bin/gnunet-daemon-hostlist |
43 | 43 | ||
diff --git a/src/hostlist/test_learning_learn_peer.conf b/src/hostlist/test_learning_learn_peer.conf index 09fbc37a4..4bdb039e7 100644 --- a/src/hostlist/test_learning_learn_peer.conf +++ b/src/hostlist/test_learning_learn_peer.conf | |||
@@ -36,7 +36,7 @@ WEAKRANDOM = YES | |||
36 | HTTPPORT = 12980 | 36 | HTTPPORT = 12980 |
37 | SERVERS = http://localhost:12981/ | 37 | SERVERS = http://localhost:12981/ |
38 | OPTIONS = -b -p -e | 38 | OPTIONS = -b -p -e |
39 | DEBUG = YES | 39 | #DEBUG = YES |
40 | HOSTLISTFILE = hostlists_learn_peer.file | 40 | HOSTLISTFILE = hostlists_learn_peer.file |
41 | #BINARY = /home/grothoff/bin/gnunet-daemon-hostlist | 41 | #BINARY = /home/grothoff/bin/gnunet-daemon-hostlist |
42 | 42 | ||