diff options
author | Nathan S. Evans <evans@in.tum.de> | 2011-03-07 10:47:42 +0000 |
---|---|---|
committer | Nathan S. Evans <evans@in.tum.de> | 2011-03-07 10:47:42 +0000 |
commit | e4dd537d1b8b66a750d963c6502c7f48e2e810a3 (patch) | |
tree | f7f7ca27974331b929256761bed2508d88c93133 /src/testing | |
parent | 725b9c8b1ed55634e470947d856fcd38b18769c3 (diff) | |
download | gnunet-e4dd537d1b8b66a750d963c6502c7f48e2e810a3.tar.gz gnunet-e4dd537d1b8b66a750d963c6502c7f48e2e810a3.zip |
create nested directory structure for greater than 32k peers
Diffstat (limited to 'src/testing')
-rw-r--r-- | src/testing/testing.c | 38 | ||||
-rw-r--r-- | src/testing/testing_group.c | 27 |
2 files changed, 54 insertions, 11 deletions
diff --git a/src/testing/testing.c b/src/testing/testing.c index 8c50a2d91..e6671c99a 100644 --- a/src/testing/testing.c +++ b/src/testing/testing.c | |||
@@ -39,6 +39,7 @@ | |||
39 | 39 | ||
40 | #define DEBUG_TESTING GNUNET_NO | 40 | #define DEBUG_TESTING GNUNET_NO |
41 | #define DEBUG_TESTING_RECONNECT GNUNET_YES | 41 | #define DEBUG_TESTING_RECONNECT GNUNET_YES |
42 | #define WAIT_FOR_HELLO GNUNET_NO | ||
42 | 43 | ||
43 | /** | 44 | /** |
44 | * How long do we wait after starting gnunet-service-arm | 45 | * How long do we wait after starting gnunet-service-arm |
@@ -116,13 +117,16 @@ process_hello (void *cls, const struct GNUNET_MessageHeader *message) | |||
116 | } | 117 | } |
117 | daemon->phase = SP_START_DONE; | 118 | daemon->phase = SP_START_DONE; |
118 | 119 | ||
120 | #if WAIT_FOR_HELLO | ||
119 | if (NULL != cb) /* FIXME: what happens when this callback calls GNUNET_TESTING_daemon_stop? */ | 121 | if (NULL != cb) /* FIXME: what happens when this callback calls GNUNET_TESTING_daemon_stop? */ |
120 | cb (daemon->cb_cls, &daemon->id, daemon->cfg, daemon, NULL); | 122 | cb (daemon->cb_cls, &daemon->id, daemon->cfg, daemon, NULL); |
123 | #endif | ||
121 | } | 124 | } |
122 | 125 | ||
123 | static void | 126 | static void |
124 | start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | 127 | start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); |
125 | 128 | ||
129 | #if WAIT_FOR_HELLO | ||
126 | /** | 130 | /** |
127 | * Function called after GNUNET_CORE_connect has succeeded | 131 | * Function called after GNUNET_CORE_connect has succeeded |
128 | * (or failed for good). Note that the private key of the | 132 | * (or failed for good). Note that the private key of the |
@@ -163,7 +167,7 @@ testing_init (void *cls, | |||
163 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 167 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
164 | "Successfully started peer `%4s'.\n", GNUNET_i2s (my_identity)); | 168 | "Successfully started peer `%4s'.\n", GNUNET_i2s (my_identity)); |
165 | #endif | 169 | #endif |
166 | d->id = *my_identity; | 170 | d->id = *my_identity; /* FIXME: shouldn't we already have this from reading the hostkey file? */ |
167 | if (d->shortname == NULL) | 171 | if (d->shortname == NULL) |
168 | d->shortname = strdup (GNUNET_i2s (my_identity)); | 172 | d->shortname = strdup (GNUNET_i2s (my_identity)); |
169 | d->server = server; | 173 | d->server = server; |
@@ -210,7 +214,7 @@ testing_init (void *cls, | |||
210 | = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, | 214 | = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, |
211 | &start_fsm, d); | 215 | &start_fsm, d); |
212 | } | 216 | } |
213 | 217 | #endif | |
214 | 218 | ||
215 | /** | 219 | /** |
216 | * Finite-state machine for starting GNUnet. | 220 | * Finite-state machine for starting GNUnet. |
@@ -618,6 +622,7 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
618 | if (d->server != NULL) | 622 | if (d->server != NULL) |
619 | GNUNET_CORE_disconnect(d->server); | 623 | GNUNET_CORE_disconnect(d->server); |
620 | 624 | ||
625 | #if WAIT_FOR_HELLO | ||
621 | if (GNUNET_TIME_absolute_get_remaining (d->max_timeout).rel_value == | 626 | if (GNUNET_TIME_absolute_get_remaining (d->max_timeout).rel_value == |
622 | 0) | 627 | 0) |
623 | { | 628 | { |
@@ -645,6 +650,34 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
645 | d->task | 650 | d->task |
646 | = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_CONSTANTS_SERVICE_RETRY, 2), | 651 | = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_CONSTANTS_SERVICE_RETRY, 2), |
647 | &start_fsm, d); | 652 | &start_fsm, d); |
653 | #else | ||
654 | d->th = GNUNET_TRANSPORT_connect (d->cfg, &d->id, d, NULL, NULL, NULL); | ||
655 | if (d->th == NULL) | ||
656 | { | ||
657 | if (GNUNET_YES == d->dead) | ||
658 | GNUNET_TESTING_daemon_stop (d, | ||
659 | GNUNET_TIME_absolute_get_remaining | ||
660 | (d->max_timeout), d->dead_cb, | ||
661 | d->dead_cb_cls, GNUNET_YES, GNUNET_NO); | ||
662 | else if (NULL != d->cb) | ||
663 | d->cb (d->cb_cls, &d->id, d->cfg, d, | ||
664 | _("Failed to connect to transport service!\n")); | ||
665 | return; | ||
666 | } | ||
667 | #if DEBUG_TESTING | ||
668 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
669 | "Connected to transport service `%s', getting HELLO\n", | ||
670 | GNUNET_i2s (my_identity)); | ||
671 | #endif | ||
672 | |||
673 | GNUNET_TRANSPORT_get_hello (d->th, &process_hello, d); | ||
674 | cb = d->cb; | ||
675 | d->cb = NULL; | ||
676 | if (NULL != cb) /* FIXME: what happens when this callback calls GNUNET_TESTING_daemon_stop? */ | ||
677 | cb (d->cb_cls, &d->id, d->cfg, d, NULL); | ||
678 | d->running = GNUNET_YES; | ||
679 | d->phase = SP_GET_HELLO; | ||
680 | #endif | ||
648 | break; | 681 | break; |
649 | case SP_GET_HELLO: | 682 | case SP_GET_HELLO: |
650 | if (GNUNET_TIME_absolute_get_remaining (d->max_timeout).rel_value == | 683 | if (GNUNET_TIME_absolute_get_remaining (d->max_timeout).rel_value == |
@@ -1945,6 +1978,7 @@ GNUNET_TESTING_daemons_connect (struct GNUNET_TESTING_Daemon *d1, | |||
1945 | if (NULL != cb) | 1978 | if (NULL != cb) |
1946 | cb (cb_cls, &d1->id, &d2->id, 0, d1->cfg, d2->cfg, d1, d2, | 1979 | cb (cb_cls, &d1->id, &d2->id, 0, d1->cfg, d2->cfg, d1, d2, |
1947 | _("Peers are not fully running yet, can not connect!\n")); | 1980 | _("Peers are not fully running yet, can not connect!\n")); |
1981 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Peers are not up!\n"); | ||
1948 | return; | 1982 | return; |
1949 | } | 1983 | } |
1950 | 1984 | ||
diff --git a/src/testing/testing_group.c b/src/testing/testing_group.c index 155acb156..fb6d9adda 100644 --- a/src/testing/testing_group.c +++ b/src/testing/testing_group.c | |||
@@ -32,7 +32,7 @@ | |||
32 | 32 | ||
33 | #define VERBOSE_TESTING GNUNET_NO | 33 | #define VERBOSE_TESTING GNUNET_NO |
34 | 34 | ||
35 | #define VERBOSE_TOPOLOGY GNUNET_YES | 35 | #define VERBOSE_TOPOLOGY GNUNET_NO |
36 | 36 | ||
37 | #define DEBUG_CHURN GNUNET_NO | 37 | #define DEBUG_CHURN GNUNET_NO |
38 | 38 | ||
@@ -5704,6 +5704,7 @@ GNUNET_TESTING_daemons_start( | |||
5704 | struct GNUNET_DISK_FileHandle *fd; | 5704 | struct GNUNET_DISK_FileHandle *fd; |
5705 | struct GNUNET_CONFIGURATION_Handle *pcfg; | 5705 | struct GNUNET_CONFIGURATION_Handle *pcfg; |
5706 | unsigned int off; | 5706 | unsigned int off; |
5707 | struct OutstandingSSH *ssh_entry; | ||
5707 | unsigned int hostcnt; | 5708 | unsigned int hostcnt; |
5708 | unsigned int i; | 5709 | unsigned int i; |
5709 | uint16_t minport; | 5710 | uint16_t minport; |
@@ -5816,13 +5817,13 @@ GNUNET_TESTING_daemons_start( | |||
5816 | 5817 | ||
5817 | /* Create the servicehome directory for each remote peer */ | 5818 | /* Create the servicehome directory for each remote peer */ |
5818 | GNUNET_assert(GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (cfg, "PATHS", "SERVICEHOME", | 5819 | GNUNET_assert(GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (cfg, "PATHS", "SERVICEHOME", |
5819 | &baseservicehome)); | 5820 | &baseservicehome)); |
5820 | for (i = 0; i < pg->num_hosts; i++) | 5821 | for (i = 0; i < pg->num_hosts; i++) |
5821 | { | 5822 | { |
5822 | struct OutstandingSSH *ssh_entry; | ||
5823 | ssh_entry = GNUNET_malloc(sizeof(struct OutstandingSSH)); | 5823 | ssh_entry = GNUNET_malloc(sizeof(struct OutstandingSSH)); |
5824 | ssh_entry->hostname = pg->hosts[i].hostname; /* Don't free! */ | 5824 | ssh_entry->hostname = pg->hosts[i].hostname; /* Don't free! */ |
5825 | GNUNET_CONTAINER_DLL_insert(pg->ssh_head, pg->ssh_tail, ssh_entry); | 5825 | GNUNET_CONTAINER_DLL_insert(pg->ssh_head, pg->ssh_tail, ssh_entry); |
5826 | GNUNET_asprintf(&tmpdir, "%s/%s", baseservicehome, pg->hosts[i].hostname); | ||
5826 | if (NULL != pg->hosts[i].username) | 5827 | if (NULL != pg->hosts[i].username) |
5827 | GNUNET_asprintf (&arg, "%s@%s", pg->hosts[i].username, | 5828 | GNUNET_asprintf (&arg, "%s@%s", pg->hosts[i].username, |
5828 | pg->hosts[i].hostname); | 5829 | pg->hosts[i].hostname); |
@@ -5836,15 +5837,16 @@ GNUNET_TESTING_daemons_start( | |||
5836 | #if !DEBUG_TESTING | 5837 | #if !DEBUG_TESTING |
5837 | "-q", | 5838 | "-q", |
5838 | #endif | 5839 | #endif |
5839 | arg, "mkdir -p", baseservicehome, | 5840 | arg, "mkdir -p", tmpdir, |
5840 | NULL); | 5841 | NULL); |
5841 | } | 5842 | } |
5842 | else | 5843 | else |
5843 | proc = GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh", arg, | 5844 | proc = GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh", arg, |
5844 | "mkdir -p", baseservicehome, NULL); | 5845 | "mkdir -p", tmpdir, NULL); |
5845 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 5846 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
5846 | "Creating remote dir with command ssh %s %s %s\n", arg, | 5847 | "Creating remote dir with command ssh %s %s %s\n", arg, |
5847 | " mkdir -p ", baseservicehome); | 5848 | " mkdir -p ", tmpdir); |
5849 | GNUNET_free(tmpdir); | ||
5848 | GNUNET_free(arg); | 5850 | GNUNET_free(arg); |
5849 | GNUNET_OS_process_wait (proc); | 5851 | GNUNET_OS_process_wait (proc); |
5850 | GNUNET_OS_process_close(proc); | 5852 | GNUNET_OS_process_close(proc); |
@@ -5927,15 +5929,22 @@ GNUNET_TESTING_daemons_start( | |||
5927 | "SERVICEHOME", | 5929 | "SERVICEHOME", |
5928 | &baseservicehome)) | 5930 | &baseservicehome)) |
5929 | { | 5931 | { |
5930 | GNUNET_asprintf (&newservicehome, "%s/%d/", baseservicehome, off); | 5932 | if (hostname != NULL) |
5933 | GNUNET_asprintf (&newservicehome, "%s/%s/%d/", baseservicehome, hostname, off); | ||
5934 | else | ||
5935 | GNUNET_asprintf (&newservicehome, "%s/%d/", baseservicehome, off); | ||
5931 | GNUNET_free (baseservicehome); | 5936 | GNUNET_free (baseservicehome); |
5932 | } | 5937 | } |
5933 | else | 5938 | else |
5934 | { | 5939 | { |
5935 | tmpdir = getenv ("TMPDIR"); | 5940 | tmpdir = getenv ("TMPDIR"); |
5936 | tmpdir = tmpdir ? tmpdir : "/tmp"; | 5941 | tmpdir = tmpdir ? tmpdir : "/tmp"; |
5937 | GNUNET_asprintf (&newservicehome, "%s/%s/%d/", tmpdir, | 5942 | if (hostname != NULL) |
5938 | "gnunet-testing-test-test", off); | 5943 | GNUNET_asprintf (&newservicehome, "%s/%s/%s/%d/", tmpdir, hostname, |
5944 | "gnunet-testing-test-test", off); | ||
5945 | else | ||
5946 | GNUNET_asprintf (&newservicehome, "%s/%s/%d/", tmpdir, | ||
5947 | "gnunet-testing-test-test", off); | ||
5939 | } | 5948 | } |
5940 | GNUNET_CONFIGURATION_set_value_string (pcfg, "PATHS", "SERVICEHOME", | 5949 | GNUNET_CONFIGURATION_set_value_string (pcfg, "PATHS", "SERVICEHOME", |
5941 | newservicehome); | 5950 | newservicehome); |