diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-09-29 14:00:07 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-09-29 14:00:07 +0000 |
commit | 74072524b5e04db6377feec4f13becc7b312722a (patch) | |
tree | 00a68b26921a64033c5bd187b74ab94f10612e77 /src/dht/test_dht_multipeer.c | |
parent | 71468d051813e299453588e5856d720bc7726d5a (diff) | |
download | gnunet-74072524b5e04db6377feec4f13becc7b312722a.tar.gz gnunet-74072524b5e04db6377feec4f13becc7b312722a.zip |
use ring 10, test all-to-all GET/PUT
Diffstat (limited to 'src/dht/test_dht_multipeer.c')
-rw-r--r-- | src/dht/test_dht_multipeer.c | 74 |
1 files changed, 22 insertions, 52 deletions
diff --git a/src/dht/test_dht_multipeer.c b/src/dht/test_dht_multipeer.c index 0ac11c4fa..96fc8ed86 100644 --- a/src/dht/test_dht_multipeer.c +++ b/src/dht/test_dht_multipeer.c | |||
@@ -45,7 +45,7 @@ | |||
45 | #define SECONDS_PER_PEER_START 45 | 45 | #define SECONDS_PER_PEER_START 45 |
46 | 46 | ||
47 | /* If number of peers not in config file, use this number */ | 47 | /* If number of peers not in config file, use this number */ |
48 | #define DEFAULT_NUM_PEERS 5 | 48 | #define DEFAULT_NUM_PEERS 10 |
49 | 49 | ||
50 | #define TEST_DATA_SIZE 8 | 50 | #define TEST_DATA_SIZE 8 |
51 | 51 | ||
@@ -160,16 +160,6 @@ static struct GNUNET_TESTING_PeerGroup *pg; | |||
160 | static unsigned long long num_peers; | 160 | static unsigned long long num_peers; |
161 | 161 | ||
162 | /** | 162 | /** |
163 | * Total number of items to insert. | ||
164 | */ | ||
165 | static unsigned long long num_puts; | ||
166 | |||
167 | /** | ||
168 | * Total number of items to attempt to get. | ||
169 | */ | ||
170 | static unsigned long long num_gets; | ||
171 | |||
172 | /** | ||
173 | * How many puts do we currently have in flight? | 163 | * How many puts do we currently have in flight? |
174 | */ | 164 | */ |
175 | static unsigned long long outstanding_puts; | 165 | static unsigned long long outstanding_puts; |
@@ -365,7 +355,7 @@ get_stop_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
365 | fprintf (stderr, | 355 | fprintf (stderr, |
366 | "%llu gets succeeded, %llu gets failed!\n", | 356 | "%llu gets succeeded, %llu gets failed!\n", |
367 | gets_completed, gets_failed); | 357 | gets_completed, gets_failed); |
368 | if ((gets_completed + gets_failed == num_gets) && (outstanding_gets == 0)) /* Had some failures */ | 358 | if ((gets_failed > 0) && (outstanding_gets == 0)) /* Had some failures */ |
369 | { | 359 | { |
370 | GNUNET_SCHEDULER_cancel (die_task); | 360 | GNUNET_SCHEDULER_cancel (die_task); |
371 | die_task = | 361 | die_task = |
@@ -373,7 +363,8 @@ get_stop_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
373 | return; | 363 | return; |
374 | } | 364 | } |
375 | 365 | ||
376 | if ( (gets_completed == num_gets) && (outstanding_gets == 0) ) /* All gets successful */ | 366 | if ( (gets_completed == num_peers * num_peers) && |
367 | (outstanding_gets == 0) ) /* All gets successful */ | ||
377 | { | 368 | { |
378 | GNUNET_SCHEDULER_cancel (die_task); | 369 | GNUNET_SCHEDULER_cancel (die_task); |
379 | //GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 5), &get_topology, NULL); | 370 | //GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 5), &get_topology, NULL); |
@@ -501,7 +492,7 @@ put_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
501 | GNUNET_SCHEDULER_cancel (test_put->disconnect_task); | 492 | GNUNET_SCHEDULER_cancel (test_put->disconnect_task); |
502 | test_put->disconnect_task = | 493 | test_put->disconnect_task = |
503 | GNUNET_SCHEDULER_add_now (&put_disconnect_task, test_put); | 494 | GNUNET_SCHEDULER_add_now (&put_disconnect_task, test_put); |
504 | if (puts_completed == num_puts) | 495 | if (puts_completed == num_peers) |
505 | { | 496 | { |
506 | GNUNET_assert (outstanding_puts == 0); | 497 | GNUNET_assert (outstanding_puts == 0); |
507 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 498 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
@@ -572,10 +563,10 @@ topology_callback (void *cls, const struct GNUNET_PeerIdentity *first, | |||
572 | const char *emsg) | 563 | const char *emsg) |
573 | { | 564 | { |
574 | unsigned long long i; | 565 | unsigned long long i; |
566 | unsigned long long j; | ||
575 | uint32_t temp_daemon; | 567 | uint32_t temp_daemon; |
576 | struct TestPutContext *test_put; | 568 | struct TestPutContext *test_put; |
577 | struct TestGetContext *test_get; | 569 | struct TestGetContext *test_get; |
578 | int remember[num_puts][num_peers]; | ||
579 | 570 | ||
580 | if (emsg == NULL) | 571 | if (emsg == NULL) |
581 | { | 572 | { |
@@ -608,42 +599,31 @@ topology_callback (void *cls, const struct GNUNET_PeerIdentity *first, | |||
608 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, | 599 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, |
609 | "from setup puts/gets"); | 600 | "from setup puts/gets"); |
610 | fprintf (stderr, | 601 | fprintf (stderr, |
611 | "Issuing %llu PUTs at random locations\n", | 602 | "Issuing %llu PUTs (one per peer)\n", |
612 | num_puts); | 603 | num_peers); |
613 | for (i = 0; i < num_puts; i++) | 604 | for (i = 0; i < num_peers; i++) |
614 | { | 605 | { |
615 | test_put = GNUNET_malloc (sizeof (struct TestPutContext)); | 606 | test_put = GNUNET_malloc (sizeof (struct TestPutContext)); |
616 | test_put->uid = i; | 607 | test_put->uid = i; |
617 | temp_daemon = | 608 | test_put->daemon = GNUNET_TESTING_daemon_get (pg, i); |
618 | GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, num_peers); | ||
619 | test_put->daemon = GNUNET_TESTING_daemon_get (pg, temp_daemon); | ||
620 | |||
621 | test_put->next = all_puts; | 609 | test_put->next = all_puts; |
622 | all_puts = test_put; | 610 | all_puts = test_put; |
623 | } | 611 | } |
624 | GNUNET_SCHEDULER_add_now (&do_put, all_puts); | 612 | GNUNET_SCHEDULER_add_now (&do_put, all_puts); |
625 | 613 | ||
626 | fprintf (stderr, | 614 | fprintf (stderr, |
627 | "Issuing %llu GETs at random locations for random PUT data\n", | 615 | "Issuing %llu GETs\n", |
628 | num_gets); | 616 | num_peers * num_peers); |
629 | memset (remember, 0, sizeof (remember)); | 617 | for (i = 0; i < num_peers; i++) |
630 | for (i = 0; i < num_gets; i++) | 618 | for (j = 0; j < num_peers; j++) |
631 | { | 619 | { |
632 | test_get = GNUNET_malloc (sizeof (struct TestGetContext)); | 620 | test_get = GNUNET_malloc (sizeof (struct TestGetContext)); |
633 | test_get->uid = | 621 | test_get->uid = i; |
634 | GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, num_puts); | 622 | temp_daemon = j; |
635 | temp_daemon = | 623 | test_get->daemon = GNUNET_TESTING_daemon_get (pg, temp_daemon); |
636 | GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, num_peers); | 624 | test_get->next = all_gets; |
637 | while (remember[test_get->uid][temp_daemon] == 1) | 625 | all_gets = test_get; |
638 | temp_daemon = | 626 | } |
639 | GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, num_peers); | ||
640 | test_get->daemon = GNUNET_TESTING_daemon_get (pg, temp_daemon); | ||
641 | remember[test_get->uid][temp_daemon] = 1; | ||
642 | test_get->next = all_gets; | ||
643 | all_gets = test_get; | ||
644 | } | ||
645 | |||
646 | |||
647 | } | 627 | } |
648 | 628 | ||
649 | 629 | ||
@@ -879,16 +859,6 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
879 | &num_peers)) | 859 | &num_peers)) |
880 | num_peers = DEFAULT_NUM_PEERS; | 860 | num_peers = DEFAULT_NUM_PEERS; |
881 | 861 | ||
882 | if (GNUNET_SYSERR == | ||
883 | GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", "num_puts", | ||
884 | &num_puts)) | ||
885 | num_puts = DEFAULT_NUM_PEERS; | ||
886 | |||
887 | if (GNUNET_SYSERR == | ||
888 | GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", "num_gets", | ||
889 | &num_gets)) | ||
890 | num_gets = DEFAULT_NUM_PEERS; | ||
891 | |||
892 | /* Set peers_left so we know when all peers started */ | 862 | /* Set peers_left so we know when all peers started */ |
893 | peers_left = num_peers; | 863 | peers_left = num_peers; |
894 | 864 | ||