diff options
author | Nathan S. Evans <evans@in.tum.de> | 2010-11-05 18:21:50 +0000 |
---|---|---|
committer | Nathan S. Evans <evans@in.tum.de> | 2010-11-05 18:21:50 +0000 |
commit | 75a33a1499cf60ea4364c9aa673816629a6c1413 (patch) | |
tree | 0620da4312bb04de4d7b65074fdd3b0c3dd6cc0e /src/testing/test_testing_topology.c | |
parent | 7217c601ad30760872823193d62307e7a335d226 (diff) | |
download | gnunet-75a33a1499cf60ea4364c9aa673816629a6c1413.tar.gz gnunet-75a33a1499cf60ea4364c9aa673816629a6c1413.zip |
big scheduler refactoring, expect some issues
Diffstat (limited to 'src/testing/test_testing_topology.c')
-rw-r--r-- | src/testing/test_testing_topology.c | 86 |
1 files changed, 34 insertions, 52 deletions
diff --git a/src/testing/test_testing_topology.c b/src/testing/test_testing_topology.c index 7ca58faf1..adb5211fe 100644 --- a/src/testing/test_testing_topology.c +++ b/src/testing/test_testing_topology.c | |||
@@ -70,8 +70,6 @@ static unsigned long long peers_left; | |||
70 | 70 | ||
71 | static struct GNUNET_TESTING_PeerGroup *pg; | 71 | static struct GNUNET_TESTING_PeerGroup *pg; |
72 | 72 | ||
73 | static struct GNUNET_SCHEDULER_Handle *sched; | ||
74 | |||
75 | const struct GNUNET_CONFIGURATION_Handle *main_cfg; | 73 | const struct GNUNET_CONFIGURATION_Handle *main_cfg; |
76 | 74 | ||
77 | GNUNET_SCHEDULER_TaskIdentifier die_task; | 75 | GNUNET_SCHEDULER_TaskIdentifier die_task; |
@@ -219,7 +217,7 @@ finish_testing () | |||
219 | pos = pos->next; | 217 | pos = pos->next; |
220 | if (free_pos->disconnect_task != GNUNET_SCHEDULER_NO_TASK) | 218 | if (free_pos->disconnect_task != GNUNET_SCHEDULER_NO_TASK) |
221 | { | 219 | { |
222 | GNUNET_SCHEDULER_cancel(sched, free_pos->disconnect_task); | 220 | GNUNET_SCHEDULER_cancel(free_pos->disconnect_task); |
223 | } | 221 | } |
224 | GNUNET_free(free_pos); | 222 | GNUNET_free(free_pos); |
225 | } | 223 | } |
@@ -272,7 +270,7 @@ disconnect_cores (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | |||
272 | 270 | ||
273 | static void stats_finished (void *cls, int result) | 271 | static void stats_finished (void *cls, int result) |
274 | { | 272 | { |
275 | GNUNET_SCHEDULER_add_now (sched, &finish_testing, NULL); | 273 | GNUNET_SCHEDULER_add_now (&finish_testing, NULL); |
276 | } | 274 | } |
277 | 275 | ||
278 | /** | 276 | /** |
@@ -323,7 +321,7 @@ static void topology_cb (void *cls, | |||
323 | fprintf(outfile, "}\n"); | 321 | fprintf(outfile, "}\n"); |
324 | fclose(outfile); | 322 | fclose(outfile); |
325 | GNUNET_TESTING_get_statistics(pg, &stats_finished, &stats_print, NULL); | 323 | GNUNET_TESTING_get_statistics(pg, &stats_finished, &stats_print, NULL); |
326 | //GNUNET_SCHEDULER_add_now (sched, &finish_testing, NULL); | 324 | //GNUNET_SCHEDULER_add_now (&finish_testing, NULL); |
327 | } | 325 | } |
328 | } | 326 | } |
329 | } | 327 | } |
@@ -373,7 +371,7 @@ process_mtype (void *cls, | |||
373 | #if VERBOSE | 371 | #if VERBOSE |
374 | fprintf(stdout, "100%%]\n"); | 372 | fprintf(stdout, "100%%]\n"); |
375 | #endif | 373 | #endif |
376 | GNUNET_SCHEDULER_cancel (sched, die_task); | 374 | GNUNET_SCHEDULER_cancel (die_task); |
377 | GNUNET_asprintf(&dotOutFileNameFinished, "%s.dot", "final_topology"); | 375 | GNUNET_asprintf(&dotOutFileNameFinished, "%s.dot", "final_topology"); |
378 | dotOutFileFinished = fopen (dotOutFileNameFinished, "w"); | 376 | dotOutFileFinished = fopen (dotOutFileNameFinished, "w"); |
379 | GNUNET_free(dotOutFileNameFinished); | 377 | GNUNET_free(dotOutFileNameFinished); |
@@ -383,11 +381,11 @@ process_mtype (void *cls, | |||
383 | } | 381 | } |
384 | topology_connections = 0; | 382 | topology_connections = 0; |
385 | GNUNET_TESTING_get_topology (pg, &topology_cb, dotOutFileFinished); | 383 | GNUNET_TESTING_get_topology (pg, &topology_cb, dotOutFileFinished); |
386 | //GNUNET_SCHEDULER_add_now (sched, &finish_testing, NULL); | 384 | //GNUNET_SCHEDULER_add_now (&finish_testing, NULL); |
387 | } | 385 | } |
388 | else | 386 | else |
389 | { | 387 | { |
390 | pos->disconnect_task = GNUNET_SCHEDULER_add_now(sched, &disconnect_cores, pos); | 388 | pos->disconnect_task = GNUNET_SCHEDULER_add_now(&disconnect_cores, pos); |
391 | } | 389 | } |
392 | 390 | ||
393 | return GNUNET_OK; | 391 | return GNUNET_OK; |
@@ -523,8 +521,7 @@ init_notify_peer1 (void *cls, | |||
523 | /* | 521 | /* |
524 | * Connect to the receiving peer | 522 | * Connect to the receiving peer |
525 | */ | 523 | */ |
526 | pos->peer2handle = GNUNET_CORE_connect (sched, | 524 | pos->peer2handle = GNUNET_CORE_connect (pos->peer2->cfg, |
527 | pos->peer2->cfg, | ||
528 | TIMEOUT, | 525 | TIMEOUT, |
529 | pos, | 526 | pos, |
530 | &init_notify_peer2, | 527 | &init_notify_peer2, |
@@ -551,14 +548,13 @@ send_test_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | |||
551 | 548 | ||
552 | if (die_task == GNUNET_SCHEDULER_NO_TASK) | 549 | if (die_task == GNUNET_SCHEDULER_NO_TASK) |
553 | { | 550 | { |
554 | die_task = GNUNET_SCHEDULER_add_delayed (sched, | 551 | die_task = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, |
555 | TEST_TIMEOUT, | ||
556 | &end_badly, "from send test messages (timeout)"); | 552 | &end_badly, "from send test messages (timeout)"); |
557 | } | 553 | } |
558 | 554 | ||
559 | if (total_server_connections >= MAX_OUTSTANDING_CONNECTIONS) | 555 | if (total_server_connections >= MAX_OUTSTANDING_CONNECTIONS) |
560 | { | 556 | { |
561 | GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1), | 557 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1), |
562 | &send_test_messages, pos); | 558 | &send_test_messages, pos); |
563 | return; /* Otherwise we'll double schedule messages here! */ | 559 | return; /* Otherwise we'll double schedule messages here! */ |
564 | } | 560 | } |
@@ -566,8 +562,7 @@ send_test_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | |||
566 | /* | 562 | /* |
567 | * Connect to the sending peer | 563 | * Connect to the sending peer |
568 | */ | 564 | */ |
569 | pos->peer1handle = GNUNET_CORE_connect (sched, | 565 | pos->peer1handle = GNUNET_CORE_connect (pos->peer1->cfg, |
570 | pos->peer1->cfg, | ||
571 | TIMEOUT, | 566 | TIMEOUT, |
572 | pos, | 567 | pos, |
573 | &init_notify_peer1, | 568 | &init_notify_peer1, |
@@ -580,12 +575,11 @@ send_test_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | |||
580 | 575 | ||
581 | if (total_server_connections < MAX_OUTSTANDING_CONNECTIONS) | 576 | if (total_server_connections < MAX_OUTSTANDING_CONNECTIONS) |
582 | { | 577 | { |
583 | GNUNET_SCHEDULER_add_now (sched, | 578 | GNUNET_SCHEDULER_add_now (&send_test_messages, pos->next); |
584 | &send_test_messages, pos->next); | ||
585 | } | 579 | } |
586 | else | 580 | else |
587 | { | 581 | { |
588 | GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1), | 582 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1), |
589 | &send_test_messages, pos->next); | 583 | &send_test_messages, pos->next); |
590 | } | 584 | } |
591 | } | 585 | } |
@@ -662,12 +656,11 @@ topology_callback (void *cls, | |||
662 | #endif | 656 | #endif |
663 | modnum = expected_messages / 4; | 657 | modnum = expected_messages / 4; |
664 | dotnum = (expected_messages / 50) + 1; | 658 | dotnum = (expected_messages / 50) + 1; |
665 | GNUNET_SCHEDULER_cancel (sched, die_task); | 659 | GNUNET_SCHEDULER_cancel (die_task); |
666 | die_task = GNUNET_SCHEDULER_NO_TASK; | 660 | die_task = GNUNET_SCHEDULER_NO_TASK; |
667 | #if DELAY_FOR_LOGGING | 661 | #if DELAY_FOR_LOGGING |
668 | fprintf(stdout, "Sending test messages in 10 seconds.\n"); | 662 | fprintf(stdout, "Sending test messages in 10 seconds.\n"); |
669 | GNUNET_SCHEDULER_add_delayed (sched, | 663 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
670 | GNUNET_TIME_relative_multiply | ||
671 | (GNUNET_TIME_UNIT_SECONDS, 10), | 664 | (GNUNET_TIME_UNIT_SECONDS, 10), |
672 | &send_test_messages, test_messages); | 665 | &send_test_messages, test_messages); |
673 | gather_log_data(); | 666 | gather_log_data(); |
@@ -676,7 +669,7 @@ topology_callback (void *cls, | |||
676 | { | 669 | { |
677 | GNUNET_TESTING_get_topology (pg, &topology_cb, NULL); | 670 | GNUNET_TESTING_get_topology (pg, &topology_cb, NULL); |
678 | } | 671 | } |
679 | GNUNET_SCHEDULER_add_delayed (sched, settle_time, &send_test_messages, test_messages); | 672 | GNUNET_SCHEDULER_add_delayed (settle_time, &send_test_messages, test_messages); |
680 | #endif | 673 | #endif |
681 | #if VERBOSE | 674 | #if VERBOSE |
682 | fprintf(stdout, "Test message progress: ["); | 675 | fprintf(stdout, "Test message progress: ["); |
@@ -687,15 +680,14 @@ topology_callback (void *cls, | |||
687 | { | 680 | { |
688 | if (failed_connections < (unsigned int)(fail_percentage * total_connections)) | 681 | if (failed_connections < (unsigned int)(fail_percentage * total_connections)) |
689 | { | 682 | { |
690 | GNUNET_SCHEDULER_cancel (sched, die_task); | 683 | GNUNET_SCHEDULER_cancel (die_task); |
691 | die_task = GNUNET_SCHEDULER_NO_TASK; | 684 | die_task = GNUNET_SCHEDULER_NO_TASK; |
692 | GNUNET_SCHEDULER_add_now (sched, &send_test_messages, test_messages); | 685 | GNUNET_SCHEDULER_add_now (&send_test_messages, test_messages); |
693 | } | 686 | } |
694 | else | 687 | else |
695 | { | 688 | { |
696 | GNUNET_SCHEDULER_cancel (sched, die_task); | 689 | GNUNET_SCHEDULER_cancel (die_task); |
697 | die_task = GNUNET_SCHEDULER_add_now (sched, | 690 | die_task = GNUNET_SCHEDULER_add_now (&end_badly, "from topology_callback (too many failed connections)"); |
698 | &end_badly, "from topology_callback (too many failed connections)"); | ||
699 | } | 691 | } |
700 | } | 692 | } |
701 | else | 693 | else |
@@ -730,15 +722,13 @@ connect_topology () | |||
730 | #endif | 722 | #endif |
731 | } | 723 | } |
732 | 724 | ||
733 | GNUNET_SCHEDULER_cancel (sched, die_task); | 725 | GNUNET_SCHEDULER_cancel (die_task); |
734 | if (expected_connections == GNUNET_SYSERR) | 726 | if (expected_connections == GNUNET_SYSERR) |
735 | { | 727 | { |
736 | die_task = GNUNET_SCHEDULER_add_now (sched, | 728 | die_task = GNUNET_SCHEDULER_add_now (&end_badly, "from connect topology (bad return)"); |
737 | &end_badly, "from connect topology (bad return)"); | ||
738 | } | 729 | } |
739 | 730 | ||
740 | die_task = GNUNET_SCHEDULER_add_delayed (sched, | 731 | die_task = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, |
741 | TEST_TIMEOUT, | ||
742 | &end_badly, "from connect topology (timeout)"); | 732 | &end_badly, "from connect topology (timeout)"); |
743 | modnum = expected_connections / 4; | 733 | modnum = expected_connections / 4; |
744 | dotnum = (expected_connections / 50) + 1; | 734 | dotnum = (expected_connections / 50) + 1; |
@@ -762,13 +752,11 @@ create_topology () | |||
762 | } | 752 | } |
763 | else | 753 | else |
764 | { | 754 | { |
765 | GNUNET_SCHEDULER_cancel (sched, die_task); | 755 | GNUNET_SCHEDULER_cancel (die_task); |
766 | die_task = GNUNET_SCHEDULER_add_now (sched, | 756 | die_task = GNUNET_SCHEDULER_add_now (&end_badly, "from create topology (bad return)"); |
767 | &end_badly, "from create topology (bad return)"); | ||
768 | } | 757 | } |
769 | GNUNET_SCHEDULER_cancel (sched, die_task); | 758 | GNUNET_SCHEDULER_cancel (die_task); |
770 | die_task = GNUNET_SCHEDULER_add_delayed (sched, | 759 | die_task = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, |
771 | TEST_TIMEOUT, | ||
772 | &end_badly, "from continue startup (timeout)"); | 760 | &end_badly, "from continue startup (timeout)"); |
773 | } | 761 | } |
774 | 762 | ||
@@ -818,18 +806,16 @@ peers_started_callback (void *cls, | |||
818 | "All %d daemons started, now connecting peers!\n", | 806 | "All %d daemons started, now connecting peers!\n", |
819 | num_peers); | 807 | num_peers); |
820 | #endif | 808 | #endif |
821 | GNUNET_SCHEDULER_cancel (sched, die_task); | 809 | GNUNET_SCHEDULER_cancel (die_task); |
822 | /* Set up task in case topology creation doesn't finish | 810 | /* Set up task in case topology creation doesn't finish |
823 | * within a reasonable amount of time */ | 811 | * within a reasonable amount of time */ |
824 | die_task = GNUNET_SCHEDULER_add_delayed (sched, | 812 | die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
825 | GNUNET_TIME_relative_multiply | ||
826 | (GNUNET_TIME_UNIT_MINUTES, 8), | 813 | (GNUNET_TIME_UNIT_MINUTES, 8), |
827 | &end_badly, "from peers_started_callback"); | 814 | &end_badly, "from peers_started_callback"); |
828 | #if DELAY_FOR_LOGGING | 815 | #if DELAY_FOR_LOGGING |
829 | fprintf(stdout, "Connecting topology in 10 seconds\n"); | 816 | fprintf(stdout, "Connecting topology in 10 seconds\n"); |
830 | gather_log_data(); | 817 | gather_log_data(); |
831 | GNUNET_SCHEDULER_add_delayed (sched, | 818 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
832 | GNUNET_TIME_relative_multiply | ||
833 | (GNUNET_TIME_UNIT_SECONDS, 10), | 819 | (GNUNET_TIME_UNIT_SECONDS, 10), |
834 | &connect_topology, NULL); | 820 | &connect_topology, NULL); |
835 | #else | 821 | #else |
@@ -889,20 +875,18 @@ void hostkey_callback (void *cls, | |||
889 | "All %d hostkeys created, now creating topology!\n", | 875 | "All %d hostkeys created, now creating topology!\n", |
890 | num_peers); | 876 | num_peers); |
891 | #endif | 877 | #endif |
892 | GNUNET_SCHEDULER_cancel (sched, die_task); | 878 | GNUNET_SCHEDULER_cancel (die_task); |
893 | /* Set up task in case topology creation doesn't finish | 879 | /* Set up task in case topology creation doesn't finish |
894 | * within a reasonable amount of time */ | 880 | * within a reasonable amount of time */ |
895 | die_task = GNUNET_SCHEDULER_add_delayed (sched, | 881 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, |
896 | TIMEOUT, | ||
897 | &end_badly, "from create_topology"); | 882 | &end_badly, "from create_topology"); |
898 | GNUNET_SCHEDULER_add_now(sched, &create_topology, NULL); | 883 | GNUNET_SCHEDULER_add_now(&create_topology, NULL); |
899 | ok = 0; | 884 | ok = 0; |
900 | } | 885 | } |
901 | } | 886 | } |
902 | 887 | ||
903 | static void | 888 | static void |
904 | run (void *cls, | 889 | run (void *cls, |
905 | struct GNUNET_SCHEDULER_Handle *s, | ||
906 | char *const *args, | 890 | char *const *args, |
907 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) | 891 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) |
908 | { | 892 | { |
@@ -912,7 +896,6 @@ run (void *cls, | |||
912 | char * connect_topology_option_str; | 896 | char * connect_topology_option_str; |
913 | char * connect_topology_option_modifier_string; | 897 | char * connect_topology_option_modifier_string; |
914 | unsigned long long temp_settle; | 898 | unsigned long long temp_settle; |
915 | sched = s; | ||
916 | ok = 1; | 899 | ok = 1; |
917 | 900 | ||
918 | dotOutFile = fopen (dotOutFileName, "w"); | 901 | dotOutFile = fopen (dotOutFileName, "w"); |
@@ -1006,12 +989,11 @@ run (void *cls, | |||
1006 | fprintf (stdout, "Hostkey generation progress: ["); | 989 | fprintf (stdout, "Hostkey generation progress: ["); |
1007 | #endif | 990 | #endif |
1008 | /* Set up a task to end testing if peer start fails */ | 991 | /* Set up a task to end testing if peer start fails */ |
1009 | die_task = GNUNET_SCHEDULER_add_delayed (sched, | 992 | die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, SECONDS_PER_PEER_START * num_peers), |
1010 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, SECONDS_PER_PEER_START * num_peers), | ||
1011 | &end_badly, "didn't generate all hostkeys within a reasonable amount of time!!!"); | 993 | &end_badly, "didn't generate all hostkeys within a reasonable amount of time!!!"); |
1012 | 994 | ||
1013 | GNUNET_assert(num_peers > 0 && num_peers < (unsigned int)-1); | 995 | GNUNET_assert(num_peers > 0 && num_peers < (unsigned int)-1); |
1014 | pg = GNUNET_TESTING_daemons_start (sched, cfg, | 996 | pg = GNUNET_TESTING_daemons_start (cfg, |
1015 | peers_left, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, SECONDS_PER_PEER_START * num_peers), &hostkey_callback, NULL, &peers_started_callback, NULL, | 997 | peers_left, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, SECONDS_PER_PEER_START * num_peers), &hostkey_callback, NULL, &peers_started_callback, NULL, |
1016 | &topology_callback, NULL, NULL); | 998 | &topology_callback, NULL, NULL); |
1017 | 999 | ||