diff options
author | Bart Polot <bart@net.in.tum.de> | 2012-02-17 11:57:14 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2012-02-17 11:57:14 +0000 |
commit | 0a1efe8023d418c4a221522a29ad13ae47f72be2 (patch) | |
tree | 9e6f4074055fbfa4e99bf9ea50866fb404534433 /src/dht | |
parent | f99467164edfb1d0b30843b60e320a3cb8991698 (diff) | |
download | gnunet-0a1efe8023d418c4a221522a29ad13ae47f72be2.tar.gz gnunet-0a1efe8023d418c4a221522a29ad13ae47f72be2.zip |
- Adjusted the monitor test to new topology
Diffstat (limited to 'src/dht')
-rw-r--r-- | src/dht/test_dht_monitor.c | 45 |
1 files changed, 13 insertions, 32 deletions
diff --git a/src/dht/test_dht_monitor.c b/src/dht/test_dht_monitor.c index e456ede87..06489ff15 100644 --- a/src/dht/test_dht_monitor.c +++ b/src/dht/test_dht_monitor.c | |||
@@ -20,7 +20,7 @@ | |||
20 | /** | 20 | /** |
21 | * @file dht/test_dht_monitor.c | 21 | * @file dht/test_dht_monitor.c |
22 | * | 22 | * |
23 | * @brief Test for the dht service: store, retrieve and monitor in a 2d_torus. | 23 | * @brief Test for the dht service: store, retrieve and monitor in a line. |
24 | * TODO: update this description | 24 | * TODO: update this description |
25 | * Each peer stores it own ID in the DHT and then a different peer tries to | 25 | * Each peer stores it own ID in the DHT and then a different peer tries to |
26 | * retrieve that key from it. The GET starts after a first round of PUTS has | 26 | * retrieve that key from it. The GET starts after a first round of PUTS has |
@@ -120,7 +120,7 @@ struct GNUNET_DHT_MonitorHandle **mhs; | |||
120 | struct GNUNET_DHT_GetHandle *get_h_far; | 120 | struct GNUNET_DHT_GetHandle *get_h_far; |
121 | 121 | ||
122 | const char *id_origin = "FC74"; | 122 | const char *id_origin = "FC74"; |
123 | const char *id_far = "KPST"; | 123 | const char *id_far = "2UVH"; |
124 | 124 | ||
125 | unsigned int i_origin; | 125 | unsigned int i_origin; |
126 | unsigned int i_far; | 126 | unsigned int i_far; |
@@ -152,6 +152,7 @@ shutdown_callback (void *cls, const char *emsg) | |||
152 | "test: All peers successfully shut down!\n"); | 152 | "test: All peers successfully shut down!\n"); |
153 | #endif | 153 | #endif |
154 | } | 154 | } |
155 | GNUNET_CONFIGURATION_destroy (testing_cfg); | ||
155 | } | 156 | } |
156 | 157 | ||
157 | 158 | ||
@@ -171,7 +172,6 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
171 | if (data_file != NULL) | 172 | if (data_file != NULL) |
172 | GNUNET_DISK_file_close (data_file); | 173 | GNUNET_DISK_file_close (data_file); |
173 | GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); | 174 | GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); |
174 | GNUNET_CONFIGURATION_destroy (testing_cfg); | ||
175 | } | 175 | } |
176 | 176 | ||
177 | 177 | ||
@@ -267,10 +267,10 @@ put_id (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
267 | { | 267 | { |
268 | struct GNUNET_TESTING_Daemon *d; | 268 | struct GNUNET_TESTING_Daemon *d; |
269 | 269 | ||
270 | d = GNUNET_TESTING_daemon_get (pg, i_far); | 270 | d = GNUNET_TESTING_daemon_get (pg, 4); |
271 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: putting into DHT: %s\n", | 271 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: putting into DHT: %s\n", |
272 | GNUNET_h2s_full (&d->id.hashPubKey)); | 272 | GNUNET_h2s_full (&d->id.hashPubKey)); |
273 | GNUNET_DHT_put (hs[i_far], &d->id.hashPubKey, 10U, | 273 | GNUNET_DHT_put (hs[4], &d->id.hashPubKey, 10U, |
274 | GNUNET_DHT_RO_RECORD_ROUTE | | 274 | GNUNET_DHT_RO_RECORD_ROUTE | |
275 | GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, | 275 | GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, |
276 | GNUNET_BLOCK_TYPE_TEST, sizeof (struct GNUNET_PeerIdentity), | 276 | GNUNET_BLOCK_TYPE_TEST, sizeof (struct GNUNET_PeerIdentity), |
@@ -333,11 +333,8 @@ monitor_dht_cb (void *cls, | |||
333 | static void | 333 | static void |
334 | peergroup_ready (void *cls, const char *emsg) | 334 | peergroup_ready (void *cls, const char *emsg) |
335 | { | 335 | { |
336 | struct GNUNET_TESTING_Daemon *d; | ||
337 | char *buf; | 336 | char *buf; |
338 | const char *id_aux; | ||
339 | int buf_len; | 337 | int buf_len; |
340 | unsigned int i; | ||
341 | 338 | ||
342 | if (emsg != NULL) | 339 | if (emsg != NULL) |
343 | { | 340 | { |
@@ -372,29 +369,13 @@ peergroup_ready (void *cls, const char *emsg) | |||
372 | hs = GNUNET_malloc (num_peers * sizeof (struct GNUNET_DHT_Handle *)); | 369 | hs = GNUNET_malloc (num_peers * sizeof (struct GNUNET_DHT_Handle *)); |
373 | mhs = GNUNET_malloc (num_peers * sizeof (struct GNUNET_DHT_MonitorHandle *)); | 370 | mhs = GNUNET_malloc (num_peers * sizeof (struct GNUNET_DHT_MonitorHandle *)); |
374 | d_far = o = NULL; | 371 | d_far = o = NULL; |
375 | for (i = 0; i < num_peers; i++) | 372 | o = GNUNET_TESTING_daemon_get (pg, 0); |
376 | { | 373 | d_far = GNUNET_TESTING_daemon_get (pg, 4); |
377 | d = GNUNET_TESTING_daemon_get (pg, i); | ||
378 | hs[i] = GNUNET_DHT_connect (d->cfg, 32); | ||
379 | mhs[i] = GNUNET_DHT_monitor_start(hs[i], GNUNET_BLOCK_TYPE_ANY, NULL, | ||
380 | &monitor_dht_cb, (void *)(long)i); | ||
381 | id_aux = GNUNET_i2s (&d->id); | ||
382 | if (strcmp (id_aux, id_origin) == 0) | ||
383 | { | ||
384 | o = d; | ||
385 | i_origin = i; | ||
386 | } | ||
387 | if (strcmp (id_aux, id_far) == 0) | ||
388 | { | ||
389 | i_far = i; | ||
390 | d_far = d; | ||
391 | } | ||
392 | } | ||
393 | 374 | ||
394 | if ((NULL == o) || (NULL == d_far)) | 375 | if ((NULL == o) || (NULL == d_far)) |
395 | { | 376 | { |
396 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 377 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
397 | "test: Peers not found (hostkey file changed?)\n"); | 378 | "test: Error getting daemons from pg\n"); |
398 | GNUNET_SCHEDULER_cancel (disconnect_task); | 379 | GNUNET_SCHEDULER_cancel (disconnect_task); |
399 | disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_peers, NULL); | 380 | disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_peers, NULL); |
400 | return; | 381 | return; |
@@ -496,12 +477,12 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
496 | &topology_file)) | 477 | &topology_file)) |
497 | { | 478 | { |
498 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 479 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
499 | "Option test_dht_2d:topology_output_file is required!\n"); | 480 | "Option test_dht_monitor:topology_output_file is required!\n"); |
500 | return; | 481 | return; |
501 | } | 482 | } |
502 | 483 | ||
503 | if (GNUNET_OK == | 484 | if (GNUNET_OK == |
504 | GNUNET_CONFIGURATION_get_value_string (testing_cfg, "test_dht_2dtorus", | 485 | GNUNET_CONFIGURATION_get_value_string (testing_cfg, "test_dht_topo", |
505 | "data_output_file", | 486 | "data_output_file", |
506 | &data_filename)) | 487 | &data_filename)) |
507 | { | 488 | { |
@@ -520,7 +501,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
520 | } | 501 | } |
521 | 502 | ||
522 | if (GNUNET_YES == | 503 | if (GNUNET_YES == |
523 | GNUNET_CONFIGURATION_get_value_string (cfg, "test_dht_2dtorus", | 504 | GNUNET_CONFIGURATION_get_value_string (cfg, "test_dht_topo", |
524 | "output_file", &temp_str)) | 505 | "output_file", &temp_str)) |
525 | { | 506 | { |
526 | output_file = | 507 | output_file = |
@@ -567,7 +548,7 @@ main (int xargc, char *xargv[]) | |||
567 | { | 548 | { |
568 | char *const argv[] = { "test-dht-monitor", | 549 | char *const argv[] = { "test-dht-monitor", |
569 | "-c", | 550 | "-c", |
570 | "test_dht_2dtorus.conf", // reuse 2dtorus conf file | 551 | "test_dht_line.conf", |
571 | #if VERBOSE | 552 | #if VERBOSE |
572 | "-L", "DEBUG", | 553 | "-L", "DEBUG", |
573 | #endif | 554 | #endif |
@@ -577,7 +558,7 @@ main (int xargc, char *xargv[]) | |||
577 | in_test = GNUNET_NO; | 558 | in_test = GNUNET_NO; |
578 | GNUNET_PROGRAM_run (sizeof (argv) / sizeof (char *) - 1, argv, | 559 | GNUNET_PROGRAM_run (sizeof (argv) / sizeof (char *) - 1, argv, |
579 | "test_dht_monitor", | 560 | "test_dht_monitor", |
580 | gettext_noop ("Test dht monitoring in a small 2D torus."), | 561 | gettext_noop ("Test dht monitoring in a line."), |
581 | options, &run, NULL); | 562 | options, &run, NULL); |
582 | #if REMOVE_DIR | 563 | #if REMOVE_DIR |
583 | GNUNET_DISK_directory_remove ("/tmp/test_dht_monitor"); | 564 | GNUNET_DISK_directory_remove ("/tmp/test_dht_monitor"); |