diff options
author | Nathan S. Evans <evans@in.tum.de> | 2011-03-14 18:30:08 +0000 |
---|---|---|
committer | Nathan S. Evans <evans@in.tum.de> | 2011-03-14 18:30:08 +0000 |
commit | 86559fb594b8a9c9c99575d4915caa4937b14311 (patch) | |
tree | 6d552e9ccb4e2dec941af45132147220d92d2af6 | |
parent | 2ebe944c1ef77807610668fefd716e2adf9a2e9a (diff) | |
download | gnunet-86559fb594b8a9c9c99575d4915caa4937b14311.tar.gz gnunet-86559fb594b8a9c9c99575d4915caa4937b14311.zip |
code not to be used by anyone, ever
-rw-r--r-- | src/include/gnunet_testing_lib.h | 3 | ||||
-rw-r--r-- | src/testing/test_testing.c | 2 | ||||
-rw-r--r-- | src/testing/test_testing_connect.c | 4 | ||||
-rw-r--r-- | src/testing/test_testing_reconnect.c | 6 | ||||
-rw-r--r-- | src/testing/testing.c | 189 | ||||
-rw-r--r-- | src/testing/testing_group.c | 262 |
6 files changed, 319 insertions, 147 deletions
diff --git a/src/include/gnunet_testing_lib.h b/src/include/gnunet_testing_lib.h index 0de51af78..f08dd9d20 100644 --- a/src/include/gnunet_testing_lib.h +++ b/src/include/gnunet_testing_lib.h | |||
@@ -418,6 +418,8 @@ typedef void (*GNUNET_TESTING_NotifyTopology)(void *cls, | |||
418 | * | 418 | * |
419 | * @param cfg configuration to use | 419 | * @param cfg configuration to use |
420 | * @param timeout how long to wait starting up peers | 420 | * @param timeout how long to wait starting up peers |
421 | * @param pretend GNUNET_YES to set up files but not start peer GNUNET_NO | ||
422 | * to really start the peer (default) | ||
421 | * @param hostname name of the machine where to run GNUnet | 423 | * @param hostname name of the machine where to run GNUnet |
422 | * (use NULL for localhost). | 424 | * (use NULL for localhost). |
423 | * @param ssh_username ssh username to use when connecting to hostname | 425 | * @param ssh_username ssh username to use when connecting to hostname |
@@ -434,6 +436,7 @@ typedef void (*GNUNET_TESTING_NotifyTopology)(void *cls, | |||
434 | struct GNUNET_TESTING_Daemon * | 436 | struct GNUNET_TESTING_Daemon * |
435 | GNUNET_TESTING_daemon_start (const struct GNUNET_CONFIGURATION_Handle *cfg, | 437 | GNUNET_TESTING_daemon_start (const struct GNUNET_CONFIGURATION_Handle *cfg, |
436 | struct GNUNET_TIME_Relative timeout, | 438 | struct GNUNET_TIME_Relative timeout, |
439 | int pretend, | ||
437 | const char *hostname, | 440 | const char *hostname, |
438 | const char *ssh_username, | 441 | const char *ssh_username, |
439 | uint16_t sshport, | 442 | uint16_t sshport, |
diff --git a/src/testing/test_testing.c b/src/testing/test_testing.c index 30ad9b13d..7045ee6b1 100644 --- a/src/testing/test_testing.c +++ b/src/testing/test_testing.c | |||
@@ -86,7 +86,7 @@ run (void *cls, | |||
86 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting daemon.\n"); | 86 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting daemon.\n"); |
87 | #endif | 87 | #endif |
88 | d = | 88 | d = |
89 | GNUNET_TESTING_daemon_start (cfg, TIMEOUT, NULL, NULL, 0, NULL, NULL, NULL, | 89 | GNUNET_TESTING_daemon_start (cfg, TIMEOUT, GNUNET_NO, NULL, NULL, 0, NULL, NULL, NULL, |
90 | &my_cb, NULL); | 90 | &my_cb, NULL); |
91 | GNUNET_assert (d != NULL); | 91 | GNUNET_assert (d != NULL); |
92 | } | 92 | } |
diff --git a/src/testing/test_testing_connect.c b/src/testing/test_testing_connect.c index 6c6507737..631b224f5 100644 --- a/src/testing/test_testing_connect.c +++ b/src/testing/test_testing_connect.c | |||
@@ -134,7 +134,7 @@ my_cb1 (void *cls, | |||
134 | "Daemon `%s' started.\n", GNUNET_i2s (id)); | 134 | "Daemon `%s' started.\n", GNUNET_i2s (id)); |
135 | #endif | 135 | #endif |
136 | d2 = | 136 | d2 = |
137 | GNUNET_TESTING_daemon_start (c2, TIMEOUT, NULL, NULL, 0, NULL, NULL, NULL, | 137 | GNUNET_TESTING_daemon_start (c2, TIMEOUT, GNUNET_NO, NULL, NULL, 0, NULL, NULL, NULL, |
138 | &my_cb2, NULL); | 138 | &my_cb2, NULL); |
139 | GNUNET_assert (d2 != NULL); | 139 | GNUNET_assert (d2 != NULL); |
140 | 140 | ||
@@ -155,7 +155,7 @@ run (void *cls, | |||
155 | c2 = GNUNET_CONFIGURATION_create (); | 155 | c2 = GNUNET_CONFIGURATION_create (); |
156 | GNUNET_CONFIGURATION_parse (c2, "test_testing_connect_peer2.conf"); | 156 | GNUNET_CONFIGURATION_parse (c2, "test_testing_connect_peer2.conf"); |
157 | d1 = | 157 | d1 = |
158 | GNUNET_TESTING_daemon_start (c1, TIMEOUT, NULL, NULL, 0, NULL, NULL, NULL, | 158 | GNUNET_TESTING_daemon_start (c1, TIMEOUT, GNUNET_NO, NULL, NULL, 0, NULL, NULL, NULL, |
159 | &my_cb1, NULL); | 159 | &my_cb1, NULL); |
160 | GNUNET_assert (d1 != NULL); | 160 | GNUNET_assert (d1 != NULL); |
161 | } | 161 | } |
diff --git a/src/testing/test_testing_reconnect.c b/src/testing/test_testing_reconnect.c index 46b7934f1..7cec78f98 100644 --- a/src/testing/test_testing_reconnect.c +++ b/src/testing/test_testing_reconnect.c | |||
@@ -24,7 +24,7 @@ | |||
24 | #include "platform.h" | 24 | #include "platform.h" |
25 | #include "gnunet_testing_lib.h" | 25 | #include "gnunet_testing_lib.h" |
26 | 26 | ||
27 | #define VERBOSE GNUNET_NO | 27 | #define VERBOSE GNUNET_YES |
28 | 28 | ||
29 | /** | 29 | /** |
30 | * How long until we give up on connecting the peers? | 30 | * How long until we give up on connecting the peers? |
@@ -164,7 +164,7 @@ my_cb1 (void *cls, | |||
164 | "Daemon `%s' started.\n", GNUNET_i2s (id)); | 164 | "Daemon `%s' started.\n", GNUNET_i2s (id)); |
165 | #endif | 165 | #endif |
166 | d2 = | 166 | d2 = |
167 | GNUNET_TESTING_daemon_start (c2, TIMEOUT, NULL, NULL, 0, NULL, NULL, NULL, | 167 | GNUNET_TESTING_daemon_start (c2, TIMEOUT, GNUNET_NO, NULL, NULL, 0, NULL, NULL, NULL, |
168 | &my_cb2, NULL); | 168 | &my_cb2, NULL); |
169 | GNUNET_assert (d2 != NULL); | 169 | GNUNET_assert (d2 != NULL); |
170 | } | 170 | } |
@@ -191,7 +191,7 @@ run_phase () | |||
191 | { | 191 | { |
192 | phase++; | 192 | phase++; |
193 | d1 = | 193 | d1 = |
194 | GNUNET_TESTING_daemon_start (c1, TIMEOUT, NULL, NULL, 0, NULL, NULL, NULL, | 194 | GNUNET_TESTING_daemon_start (c1, TIMEOUT, GNUNET_NO, NULL, NULL, 0, NULL, NULL, NULL, |
195 | &my_cb1, NULL); | 195 | &my_cb1, NULL); |
196 | GNUNET_assert (d1 != NULL); | 196 | GNUNET_assert (d1 != NULL); |
197 | } | 197 | } |
diff --git a/src/testing/testing.c b/src/testing/testing.c index 1bd88ddc0..024be6ff5 100644 --- a/src/testing/testing.c +++ b/src/testing/testing.c | |||
@@ -72,7 +72,7 @@ process_hello (void *cls, const struct GNUNET_MessageHeader *message) | |||
72 | if (daemon == NULL) | 72 | if (daemon == NULL) |
73 | return; | 73 | return; |
74 | 74 | ||
75 | GNUNET_assert (daemon->phase == SP_GET_HELLO); | 75 | GNUNET_assert (daemon->phase == SP_GET_HELLO || daemon->phase == SP_START_DONE); |
76 | 76 | ||
77 | cb = daemon->cb; | 77 | cb = daemon->cb; |
78 | daemon->cb = NULL; | 78 | daemon->cb = NULL; |
@@ -514,7 +514,7 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
514 | = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, | 514 | = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, |
515 | &start_fsm, d); | 515 | &start_fsm, d); |
516 | break; | 516 | break; |
517 | case SP_TOPOLOGY_SETUP: | 517 | case SP_TOPOLOGY_SETUP: /* Indicates topology setup has completed! */ |
518 | /* start GNUnet on remote host */ | 518 | /* start GNUnet on remote host */ |
519 | if (NULL == d->hostname) | 519 | if (NULL == d->hostname) |
520 | { | 520 | { |
@@ -950,6 +950,8 @@ GNUNET_TESTING_daemon_start_stopped (struct GNUNET_TESTING_Daemon *daemon, | |||
950 | * | 950 | * |
951 | * @param cfg configuration to use | 951 | * @param cfg configuration to use |
952 | * @param timeout how long to wait starting up peers | 952 | * @param timeout how long to wait starting up peers |
953 | * @param pretend GNUNET_YES to set up files but not start peer GNUNET_NO | ||
954 | * to really start the peer (default) | ||
953 | * @param hostname name of the machine where to run GNUnet | 955 | * @param hostname name of the machine where to run GNUnet |
954 | * (use NULL for localhost). | 956 | * (use NULL for localhost). |
955 | * @param ssh_username ssh username to use when connecting to hostname | 957 | * @param ssh_username ssh username to use when connecting to hostname |
@@ -966,6 +968,7 @@ GNUNET_TESTING_daemon_start_stopped (struct GNUNET_TESTING_Daemon *daemon, | |||
966 | struct GNUNET_TESTING_Daemon * | 968 | struct GNUNET_TESTING_Daemon * |
967 | GNUNET_TESTING_daemon_start (const struct GNUNET_CONFIGURATION_Handle *cfg, | 969 | GNUNET_TESTING_daemon_start (const struct GNUNET_CONFIGURATION_Handle *cfg, |
968 | struct GNUNET_TIME_Relative timeout, | 970 | struct GNUNET_TIME_Relative timeout, |
971 | int pretend, | ||
969 | const char *hostname, | 972 | const char *hostname, |
970 | const char *ssh_username, | 973 | const char *ssh_username, |
971 | uint16_t sshport, | 974 | uint16_t sshport, |
@@ -1084,88 +1087,91 @@ GNUNET_TESTING_daemon_start (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1084 | } | 1087 | } |
1085 | ret->username = username; | 1088 | ret->username = username; |
1086 | 1089 | ||
1087 | /* copy directory to remote host */ | 1090 | if (GNUNET_NO == pretend) /* Copy files, enter finite state machine */ |
1088 | if (NULL != hostname) | ||
1089 | { | 1091 | { |
1092 | /* copy directory to remote host */ | ||
1093 | if (NULL != hostname) | ||
1094 | { | ||
1090 | #if DEBUG_TESTING | 1095 | #if DEBUG_TESTING |
1091 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1096 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1092 | "Copying configuration directory to host `%s'.\n", hostname); | 1097 | "Copying configuration directory to host `%s'.\n", hostname); |
1093 | #endif | 1098 | #endif |
1094 | baseservicehome = GNUNET_strdup(servicehome); | 1099 | baseservicehome = GNUNET_strdup(servicehome); |
1095 | /* Remove trailing /'s */ | 1100 | /* Remove trailing /'s */ |
1096 | while (baseservicehome[strlen(baseservicehome) - 1] == '/') | 1101 | while (baseservicehome[strlen(baseservicehome) - 1] == '/') |
1097 | baseservicehome[strlen(baseservicehome) - 1] = '\0'; | 1102 | baseservicehome[strlen(baseservicehome) - 1] = '\0'; |
1098 | /* Find next directory /, jump one ahead */ | 1103 | /* Find next directory /, jump one ahead */ |
1099 | slash = strrchr(baseservicehome, '/'); | 1104 | slash = strrchr(baseservicehome, '/'); |
1100 | if (slash != NULL) | 1105 | if (slash != NULL) |
1101 | *(++slash) = '\0'; | 1106 | *(++slash) = '\0'; |
1102 | 1107 | ||
1103 | ret->phase = SP_COPYING; | 1108 | ret->phase = SP_COPYING; |
1104 | if (NULL != username) | 1109 | if (NULL != username) |
1105 | GNUNET_asprintf (&arg, "%s@%s:%s", username, hostname, baseservicehome); | 1110 | GNUNET_asprintf (&arg, "%s@%s:%s", username, hostname, baseservicehome); |
1106 | else | 1111 | else |
1107 | GNUNET_asprintf (&arg, "%s:%s", hostname, baseservicehome); | 1112 | GNUNET_asprintf (&arg, "%s:%s", hostname, baseservicehome); |
1108 | 1113 | ||
1109 | if (ret->ssh_port_str == NULL) | 1114 | if (ret->ssh_port_str == NULL) |
1110 | { | 1115 | { |
1111 | ret->proc = GNUNET_OS_start_process (NULL, NULL, "scp", "scp", "-r", | 1116 | ret->proc = GNUNET_OS_start_process (NULL, NULL, "scp", "scp", "-r", |
1112 | #if !DEBUG_TESTING | 1117 | #if !DEBUG_TESTING |
1113 | "-q", | 1118 | "-q", |
1114 | #endif | 1119 | #endif |
1115 | servicehome, arg, NULL); | 1120 | servicehome, arg, NULL); |
1116 | #if DEBUG_TESTING | 1121 | #if DEBUG_TESTING |
1117 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "copying directory with command scp -r %s %s\n", servicehome, arg); | 1122 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "copying directory with command scp -r %s %s\n", servicehome, arg); |
1118 | #endif | 1123 | #endif |
1119 | } | 1124 | } |
1120 | else | 1125 | else |
1121 | { | 1126 | { |
1122 | ret->proc = GNUNET_OS_start_process (NULL, NULL, "scp", | 1127 | ret->proc = GNUNET_OS_start_process (NULL, NULL, "scp", |
1123 | "scp", "-r", "-P", ret->ssh_port_str, | 1128 | "scp", "-r", "-P", ret->ssh_port_str, |
1124 | #if !DEBUG_TESTING | 1129 | #if !DEBUG_TESTING |
1125 | "-q", | 1130 | "-q", |
1126 | #endif | 1131 | #endif |
1127 | servicehome, arg, NULL); | 1132 | servicehome, arg, NULL); |
1128 | } | 1133 | } |
1129 | GNUNET_free (arg); | 1134 | GNUNET_free (arg); |
1130 | if (NULL == ret->proc) | 1135 | if (NULL == ret->proc) |
1131 | { | 1136 | { |
1132 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1137 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1133 | _ | 1138 | _ |
1134 | ("Could not start `%s' process to copy configuration directory.\n"), | 1139 | ("Could not start `%s' process to copy configuration directory.\n"), |
1135 | "scp"); | 1140 | "scp"); |
1136 | if (0 != UNLINK (ret->cfgfile)) | 1141 | if (0 != UNLINK (ret->cfgfile)) |
1137 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, | 1142 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, |
1138 | "unlink", ret->cfgfile); | 1143 | "unlink", ret->cfgfile); |
1139 | GNUNET_CONFIGURATION_destroy (ret->cfg); | 1144 | GNUNET_CONFIGURATION_destroy (ret->cfg); |
1140 | GNUNET_free_non_null (ret->hostname); | 1145 | GNUNET_free_non_null (ret->hostname); |
1141 | GNUNET_free_non_null (ret->username); | 1146 | GNUNET_free_non_null (ret->username); |
1142 | GNUNET_free (ret->cfgfile); | 1147 | GNUNET_free (ret->cfgfile); |
1143 | GNUNET_free (ret); | 1148 | GNUNET_free (ret); |
1144 | if ((hostkey != NULL) && (0 != UNLINK(hostkeyfile))) | 1149 | if ((hostkey != NULL) && (0 != UNLINK(hostkeyfile))) |
1145 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, | 1150 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, |
1146 | "unlink", hostkeyfile); | 1151 | "unlink", hostkeyfile); |
1152 | GNUNET_free_non_null(hostkeyfile); | ||
1153 | GNUNET_assert (GNUNET_OK == GNUNET_DISK_directory_remove (servicehome)); | ||
1154 | GNUNET_free(servicehome); | ||
1155 | return NULL; | ||
1156 | } | ||
1157 | |||
1158 | ret->task | ||
1159 | = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, | ||
1160 | &start_fsm, ret); | ||
1147 | GNUNET_free_non_null(hostkeyfile); | 1161 | GNUNET_free_non_null(hostkeyfile); |
1148 | GNUNET_assert (GNUNET_OK == GNUNET_DISK_directory_remove (servicehome)); | 1162 | GNUNET_free(baseservicehome); |
1149 | GNUNET_free(servicehome); | 1163 | GNUNET_free(servicehome); |
1150 | return NULL; | 1164 | return ret; |
1151 | } | 1165 | } |
1152 | |||
1153 | ret->task | ||
1154 | = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, | ||
1155 | &start_fsm, ret); | ||
1156 | GNUNET_free_non_null(hostkeyfile); | ||
1157 | GNUNET_free(baseservicehome); | ||
1158 | GNUNET_free(servicehome); | ||
1159 | return ret; | ||
1160 | } | ||
1161 | #if DEBUG_TESTING | 1166 | #if DEBUG_TESTING |
1162 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1167 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1163 | "No need to copy configuration file since we are running locally.\n"); | 1168 | "No need to copy configuration file since we are running locally.\n"); |
1164 | #endif | 1169 | #endif |
1165 | ret->phase = SP_COPIED; | 1170 | ret->phase = SP_COPIED; |
1166 | GNUNET_SCHEDULER_add_continuation (&start_fsm, | 1171 | GNUNET_SCHEDULER_add_continuation (&start_fsm, |
1167 | ret, | 1172 | ret, |
1168 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); | 1173 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); |
1174 | } | ||
1169 | GNUNET_free_non_null(hostkeyfile); | 1175 | GNUNET_free_non_null(hostkeyfile); |
1170 | GNUNET_free(servicehome); | 1176 | GNUNET_free(servicehome); |
1171 | return ret; | 1177 | return ret; |
@@ -1867,6 +1873,36 @@ reattempt_daemons_connect (void *cls, | |||
1867 | return; | 1873 | return; |
1868 | } | 1874 | } |
1869 | 1875 | ||
1876 | /* Don't know reason for initial connect failure, update the HELLO for the second peer */ | ||
1877 | if (NULL != ctx->d2->hello) | ||
1878 | { | ||
1879 | GNUNET_free(ctx->d2->hello); | ||
1880 | ctx->d2->hello = NULL; | ||
1881 | if (NULL != ctx->d2->th) | ||
1882 | { | ||
1883 | GNUNET_TRANSPORT_get_hello_cancel(ctx->d2->th, &process_hello, ctx->d2); | ||
1884 | GNUNET_TRANSPORT_disconnect(ctx->d2->th); | ||
1885 | } | ||
1886 | ctx->d2->th = GNUNET_TRANSPORT_connect (ctx->d2->cfg, &ctx->d2->id, NULL, NULL, NULL, NULL); | ||
1887 | GNUNET_assert(ctx->d2->th != NULL); | ||
1888 | GNUNET_TRANSPORT_get_hello (ctx->d2->th, &process_hello, ctx->d2); | ||
1889 | } | ||
1890 | |||
1891 | if ((NULL == ctx->d2->hello) && (ctx->d2->th == NULL)) | ||
1892 | { | ||
1893 | ctx->d2->th = GNUNET_TRANSPORT_connect (ctx->d2->cfg, &ctx->d2->id, NULL, NULL, NULL, NULL); | ||
1894 | if (ctx->d2->th == NULL) | ||
1895 | { | ||
1896 | GNUNET_CORE_disconnect (ctx->d1core); | ||
1897 | GNUNET_free (ctx); | ||
1898 | if (NULL != ctx->cb) | ||
1899 | ctx->cb (ctx->cb_cls, &ctx->d1->id, &ctx->d2->id, 0, ctx->d1->cfg, ctx->d2->cfg, ctx->d1, ctx->d2, | ||
1900 | _("Failed to connect to transport service!\n")); | ||
1901 | return; | ||
1902 | } | ||
1903 | GNUNET_TRANSPORT_get_hello (ctx->d2->th, &process_hello, ctx->d2); | ||
1904 | } | ||
1905 | |||
1870 | if (ctx->send_hello == GNUNET_YES) | 1906 | if (ctx->send_hello == GNUNET_YES) |
1871 | { | 1907 | { |
1872 | ctx->d1th = GNUNET_TRANSPORT_connect (ctx->d1->cfg, | 1908 | ctx->d1th = GNUNET_TRANSPORT_connect (ctx->d1->cfg, |
@@ -1955,6 +1991,21 @@ core_initial_iteration (void *cls, | |||
1955 | return; | 1991 | return; |
1956 | } | 1992 | } |
1957 | 1993 | ||
1994 | if ((NULL == ctx->d2->hello) && (ctx->d2->th == NULL)) /* Do not yet have the second peer's hello, set up a task to get it */ | ||
1995 | { | ||
1996 | ctx->d2->th = GNUNET_TRANSPORT_connect (ctx->d2->cfg, &ctx->d2->id, NULL, NULL, NULL, NULL); | ||
1997 | if (ctx->d2->th == NULL) | ||
1998 | { | ||
1999 | GNUNET_CORE_disconnect (ctx->d1core); | ||
2000 | GNUNET_free (ctx); | ||
2001 | if (NULL != ctx->cb) | ||
2002 | ctx->cb (ctx->cb_cls, &ctx->d1->id, &ctx->d2->id, 0, ctx->d1->cfg, ctx->d2->cfg, ctx->d1, ctx->d2, | ||
2003 | _("Failed to connect to transport service!\n")); | ||
2004 | return; | ||
2005 | } | ||
2006 | GNUNET_TRANSPORT_get_hello (ctx->d2->th, &process_hello, ctx->d2); | ||
2007 | } | ||
2008 | |||
1958 | if (ctx->send_hello == GNUNET_YES) | 2009 | if (ctx->send_hello == GNUNET_YES) |
1959 | { | 2010 | { |
1960 | ctx->d1th = GNUNET_TRANSPORT_connect (ctx->d1->cfg, | 2011 | ctx->d1th = GNUNET_TRANSPORT_connect (ctx->d1->cfg, |
diff --git a/src/testing/testing_group.c b/src/testing/testing_group.c index 14bf31bbc..083e67750 100644 --- a/src/testing/testing_group.c +++ b/src/testing/testing_group.c | |||
@@ -36,8 +36,11 @@ | |||
36 | 36 | ||
37 | #define DEBUG_CHURN GNUNET_NO | 37 | #define DEBUG_CHURN GNUNET_NO |
38 | 38 | ||
39 | #define USE_START_HELPER GNUNET_YES | ||
40 | |||
39 | #define OLD 1 | 41 | #define OLD 1 |
40 | 42 | ||
43 | /* Before connecting peers, send all of the HELLOs */ | ||
41 | #define USE_SEND_HELLOS GNUNET_NO | 44 | #define USE_SEND_HELLOS GNUNET_NO |
42 | 45 | ||
43 | #define TOPOLOGY_HACK GNUNET_YES | 46 | #define TOPOLOGY_HACK GNUNET_YES |
@@ -3474,12 +3477,9 @@ static void schedule_send_hellos (void *cls, const struct GNUNET_SCHEDULER_TaskC | |||
3474 | if (send_hello_context->peer->daemon->th == NULL) | 3477 | if (send_hello_context->peer->daemon->th == NULL) |
3475 | { | 3478 | { |
3476 | pg->outstanding_connects++; /* Actual TRANSPORT, CORE connections! */ | 3479 | pg->outstanding_connects++; /* Actual TRANSPORT, CORE connections! */ |
3477 | send_hello_context->peer->daemon->th = GNUNET_TRANSPORT_connect(send_hello_context->peer->cfg, | 3480 | send_hello_context->peer->daemon->th |
3478 | NULL, | 3481 | = GNUNET_TRANSPORT_connect (send_hello_context->peer->cfg, NULL, |
3479 | send_hello_context, | 3482 | send_hello_context, NULL, NULL, NULL); |
3480 | NULL, | ||
3481 | NULL, | ||
3482 | NULL); | ||
3483 | } | 3483 | } |
3484 | #if DEBUG_TESTING | 3484 | #if DEBUG_TESTING |
3485 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 3485 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
@@ -3606,7 +3606,7 @@ schedule_connect(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
3606 | connect_context->ct_ctx->connect_timeout, | 3606 | connect_context->ct_ctx->connect_timeout, |
3607 | connect_context->ct_ctx->connect_attempts, | 3607 | connect_context->ct_ctx->connect_attempts, |
3608 | #if USE_SEND_HELLOS | 3608 | #if USE_SEND_HELLOS |
3609 | GNUNET_NO, | 3609 | GNUNET_NO, |
3610 | #else | 3610 | #else |
3611 | GNUNET_YES, | 3611 | GNUNET_YES, |
3612 | #endif | 3612 | #endif |
@@ -3741,7 +3741,7 @@ connect_topology(struct GNUNET_TESTING_PeerGroup *pg, | |||
3741 | struct PeerConnection *connection_iter; | 3741 | struct PeerConnection *connection_iter; |
3742 | #endif | 3742 | #endif |
3743 | #if USE_SEND_HELLOS | 3743 | #if USE_SEND_HELLOS |
3744 | struct SendHelloContext *send_hello_context | 3744 | struct SendHelloContext *send_hello_context; |
3745 | #endif | 3745 | #endif |
3746 | 3746 | ||
3747 | total = 0; | 3747 | total = 0; |
@@ -5532,6 +5532,7 @@ schedule_churn_restart(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
5532 | } | 5532 | } |
5533 | } | 5533 | } |
5534 | 5534 | ||
5535 | |||
5535 | static void | 5536 | static void |
5536 | internal_start(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 5537 | internal_start(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
5537 | { | 5538 | { |
@@ -5556,6 +5557,7 @@ internal_start(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
5556 | internal_context->peer->daemon | 5557 | internal_context->peer->daemon |
5557 | = GNUNET_TESTING_daemon_start (internal_context->peer->cfg, | 5558 | = GNUNET_TESTING_daemon_start (internal_context->peer->cfg, |
5558 | internal_context->timeout, | 5559 | internal_context->timeout, |
5560 | GNUNET_NO, | ||
5559 | internal_context->hostname, | 5561 | internal_context->hostname, |
5560 | internal_context->username, | 5562 | internal_context->username, |
5561 | internal_context->sshport, | 5563 | internal_context->sshport, |
@@ -5574,6 +5576,66 @@ internal_start(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
5574 | &internal_start, internal_context); | 5576 | &internal_start, internal_context); |
5575 | } | 5577 | } |
5576 | } | 5578 | } |
5579 | #if USE_START_HELPER | ||
5580 | |||
5581 | struct PeerStartHelperContext | ||
5582 | { | ||
5583 | struct GNUNET_TESTING_PeerGroup *pg; | ||
5584 | |||
5585 | struct HostData *host; | ||
5586 | }; | ||
5587 | |||
5588 | static void | ||
5589 | start_peer_helper (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
5590 | { | ||
5591 | struct PeerStartHelperContext *helper = cls; | ||
5592 | char *baseservicehome; | ||
5593 | char *tempdir; | ||
5594 | struct GNUNET_OS_Process *proc; | ||
5595 | unsigned int i; | ||
5596 | char *arg; | ||
5597 | GNUNET_TESTING_NotifyDaemonRunning cb; | ||
5598 | /* ssh user@host peerStartHelper /path/to/basedirectory */ | ||
5599 | |||
5600 | GNUNET_assert(GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (helper->pg->cfg, "PATHS", "SERVICEHOME", | ||
5601 | &baseservicehome)); | ||
5602 | GNUNET_asprintf(&tempdir, "%s/%s/", baseservicehome, helper->host->hostname); | ||
5603 | if (NULL != helper->host->username) | ||
5604 | GNUNET_asprintf (&arg, "%s@%s", helper->host->username, helper->host->hostname); | ||
5605 | else | ||
5606 | GNUNET_asprintf (&arg, "%s", helper->host->hostname); | ||
5607 | |||
5608 | /* FIXME: Doesn't support ssh_port option! */ | ||
5609 | proc = GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh", arg, | ||
5610 | "peerStartHelper.pl", tempdir, NULL); | ||
5611 | |||
5612 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "starting peers with cmd ssh %s %s %s\n", arg, "peerStartHelper.pl", tempdir); | ||
5613 | |||
5614 | GNUNET_OS_process_wait (proc); | ||
5615 | GNUNET_OS_process_close(proc); | ||
5616 | GNUNET_free (tempdir); | ||
5617 | GNUNET_free (baseservicehome); | ||
5618 | GNUNET_free (arg); | ||
5619 | |||
5620 | helper->pg->starting--; | ||
5621 | if (helper->pg->starting == 0) /* All peers have finished starting! */ | ||
5622 | { | ||
5623 | /* Call the peer started callback for each peer, set proper FSM state (?) */ | ||
5624 | for (i = 0; i < helper->pg->total; i++) | ||
5625 | { | ||
5626 | cb = helper->pg->peers[i].daemon->cb; | ||
5627 | helper->pg->peers[i].daemon->cb = NULL; | ||
5628 | if (NULL != cb) | ||
5629 | cb (helper->pg->peers[i].daemon->cb_cls, | ||
5630 | &helper->pg->peers[i].daemon->id, | ||
5631 | helper->pg->peers[i].daemon->cfg, helper->pg->peers[i].daemon, | ||
5632 | NULL); | ||
5633 | |||
5634 | } | ||
5635 | } | ||
5636 | |||
5637 | } | ||
5638 | #endif | ||
5577 | 5639 | ||
5578 | /** | 5640 | /** |
5579 | * Function which continues a peer group starting up | 5641 | * Function which continues a peer group starting up |
@@ -5587,14 +5649,57 @@ GNUNET_TESTING_daemons_continue_startup(struct GNUNET_TESTING_PeerGroup *pg) | |||
5587 | { | 5649 | { |
5588 | unsigned int i; | 5650 | unsigned int i; |
5589 | 5651 | ||
5652 | #if USE_START_HELPER | ||
5653 | if ((pg->num_hosts > 0) && (pg->hostkey_data != NULL)) | ||
5654 | { | ||
5655 | struct PeerStartHelperContext *helper; | ||
5656 | pg->starting = pg->num_hosts; | ||
5657 | for (i = 0; i < pg->num_hosts; i++) | ||
5658 | { | ||
5659 | helper = GNUNET_malloc(sizeof(struct PeerStartHelperContext)); | ||
5660 | helper->pg = pg; | ||
5661 | helper->host = &pg->hosts[i]; | ||
5662 | GNUNET_SCHEDULER_add_now(&start_peer_helper, helper); | ||
5663 | } | ||
5664 | } | ||
5665 | else | ||
5666 | { | ||
5667 | pg->starting = 0; | ||
5668 | for (i = 0; i < pg->total; i++) | ||
5669 | { | ||
5670 | GNUNET_SCHEDULER_add_now (&internal_continue_startup, | ||
5671 | &pg->peers[i].internal_context); | ||
5672 | } | ||
5673 | } | ||
5674 | #else | ||
5590 | pg->starting = 0; | 5675 | pg->starting = 0; |
5591 | for (i = 0; i < pg->total; i++) | 5676 | for (i = 0; i < pg->total; i++) |
5592 | { | 5677 | { |
5593 | GNUNET_SCHEDULER_add_now (&internal_continue_startup, | 5678 | GNUNET_SCHEDULER_add_now (&internal_continue_startup, |
5594 | &pg->peers[i].internal_context); | 5679 | &pg->peers[i].internal_context); |
5595 | //GNUNET_TESTING_daemon_continue_startup(pg->peers[i].daemon); | ||
5596 | } | 5680 | } |
5681 | #endif | ||
5682 | } | ||
5683 | |||
5684 | #if USE_START_HELPER | ||
5685 | static void | ||
5686 | call_hostkey_callbacks (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
5687 | { | ||
5688 | struct GNUNET_TESTING_PeerGroup *pg = cls; | ||
5689 | unsigned int i; | ||
5690 | for (i = 0; i < pg->total; i++) | ||
5691 | { | ||
5692 | if (pg->peers[i].internal_context.hostkey_callback != NULL) | ||
5693 | pg->peers[i].internal_context.hostkey_callback (pg->peers[i].internal_context.hostkey_cls, | ||
5694 | &pg->peers[i].daemon->id, | ||
5695 | pg->peers[i].daemon, | ||
5696 | NULL); | ||
5697 | } | ||
5698 | |||
5699 | if (pg->peers[0].internal_context.hostkey_callback == NULL) | ||
5700 | GNUNET_TESTING_daemons_continue_startup (pg); | ||
5597 | } | 5701 | } |
5702 | #endif | ||
5598 | 5703 | ||
5599 | /** | 5704 | /** |
5600 | * Start count gnunet instances with the same set of transports and | 5705 | * Start count gnunet instances with the same set of transports and |
@@ -5624,8 +5729,7 @@ GNUNET_TESTING_daemons_continue_startup(struct GNUNET_TESTING_PeerGroup *pg) | |||
5624 | * @return NULL on error, otherwise handle to control peer group | 5729 | * @return NULL on error, otherwise handle to control peer group |
5625 | */ | 5730 | */ |
5626 | struct GNUNET_TESTING_PeerGroup * | 5731 | struct GNUNET_TESTING_PeerGroup * |
5627 | GNUNET_TESTING_daemons_start( | 5732 | GNUNET_TESTING_daemons_start(const struct GNUNET_CONFIGURATION_Handle *cfg, |
5628 | const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
5629 | unsigned int total, | 5733 | unsigned int total, |
5630 | unsigned int max_concurrent_connections, | 5734 | unsigned int max_concurrent_connections, |
5631 | unsigned int max_concurrent_ssh, | 5735 | unsigned int max_concurrent_ssh, |
@@ -5640,11 +5744,6 @@ GNUNET_TESTING_daemons_start( | |||
5640 | { | 5744 | { |
5641 | struct GNUNET_TESTING_PeerGroup *pg; | 5745 | struct GNUNET_TESTING_PeerGroup *pg; |
5642 | const struct GNUNET_TESTING_Host *hostpos; | 5746 | const struct GNUNET_TESTING_Host *hostpos; |
5643 | #if 0 | ||
5644 | char *pos; | ||
5645 | const char *rpos; | ||
5646 | char *start; | ||
5647 | #endif | ||
5648 | const char *hostname; | 5747 | const char *hostname; |
5649 | const char *username; | 5748 | const char *username; |
5650 | char *baseservicehome; | 5749 | char *baseservicehome; |
@@ -5715,51 +5814,6 @@ GNUNET_TESTING_daemons_start( | |||
5715 | hostcnt = off; | 5814 | hostcnt = off; |
5716 | minport = 0; | 5815 | minport = 0; |
5717 | pg->num_hosts = off; | 5816 | pg->num_hosts = off; |
5718 | |||
5719 | #if NO_LL | ||
5720 | off = 2; | ||
5721 | /* skip leading spaces */ | ||
5722 | while ((0 != *hostnames) && (isspace ((unsigned char) *hostnames))) | ||
5723 | hostnames++; | ||
5724 | rpos = hostnames; | ||
5725 | while ('\0' != *rpos) | ||
5726 | { | ||
5727 | if (isspace ((unsigned char) *rpos)) | ||
5728 | off++; | ||
5729 | rpos++; | ||
5730 | } | ||
5731 | pg->hosts = GNUNET_malloc (off * sizeof (struct HostData)); | ||
5732 | off = 0; | ||
5733 | start = GNUNET_strdup (hostnames); | ||
5734 | pos = start; | ||
5735 | while ('\0' != *pos) | ||
5736 | { | ||
5737 | if (isspace ((unsigned char) *pos)) | ||
5738 | { | ||
5739 | *pos = '\0'; | ||
5740 | if (strlen (start) > 0) | ||
5741 | { | ||
5742 | pg->hosts[off].minport = LOW_PORT; | ||
5743 | pg->hosts[off++].hostname = start; | ||
5744 | } | ||
5745 | start = pos + 1; | ||
5746 | } | ||
5747 | pos++; | ||
5748 | } | ||
5749 | if (strlen (start) > 0) | ||
5750 | { | ||
5751 | pg->hosts[off].minport = LOW_PORT; | ||
5752 | pg->hosts[off++].hostname = start; | ||
5753 | } | ||
5754 | if (off == 0) | ||
5755 | { | ||
5756 | GNUNET_free (start); | ||
5757 | GNUNET_free (pg->hosts); | ||
5758 | pg->hosts = NULL; | ||
5759 | } | ||
5760 | hostcnt = off; | ||
5761 | minport = 0; /* make gcc happy */ | ||
5762 | #endif | ||
5763 | } | 5817 | } |
5764 | else | 5818 | else |
5765 | { | 5819 | { |
@@ -5885,7 +5939,9 @@ GNUNET_TESTING_daemons_start( | |||
5885 | GNUNET_asprintf (&newservicehome, "%s/%s/%d/", baseservicehome, hostname, off); | 5939 | GNUNET_asprintf (&newservicehome, "%s/%s/%d/", baseservicehome, hostname, off); |
5886 | else | 5940 | else |
5887 | GNUNET_asprintf (&newservicehome, "%s/%d/", baseservicehome, off); | 5941 | GNUNET_asprintf (&newservicehome, "%s/%d/", baseservicehome, off); |
5942 | #if !USE_START_HELPER | ||
5888 | GNUNET_free (baseservicehome); | 5943 | GNUNET_free (baseservicehome); |
5944 | #endif | ||
5889 | } | 5945 | } |
5890 | else | 5946 | else |
5891 | { | 5947 | { |
@@ -5902,16 +5958,6 @@ GNUNET_TESTING_daemons_start( | |||
5902 | newservicehome); | 5958 | newservicehome); |
5903 | GNUNET_free (newservicehome); | 5959 | GNUNET_free (newservicehome); |
5904 | pg->peers[off].cfg = pcfg; | 5960 | pg->peers[off].cfg = pcfg; |
5905 | #if DEFER | ||
5906 | /* Can we do this later? */ | ||
5907 | pg->peers[off].allowed_peers = | ||
5908 | GNUNET_CONTAINER_multihashmap_create (total); | ||
5909 | pg->peers[off].connect_peers = | ||
5910 | GNUNET_CONTAINER_multihashmap_create (total); | ||
5911 | pg->peers[off].blacklisted_peers = | ||
5912 | GNUNET_CONTAINER_multihashmap_create (total); | ||
5913 | |||
5914 | #endif | ||
5915 | pg->peers[off].pg = pg; | 5961 | pg->peers[off].pg = pg; |
5916 | pg->peers[off].internal_context.peer = &pg->peers[off]; | 5962 | pg->peers[off].internal_context.peer = &pg->peers[off]; |
5917 | pg->peers[off].internal_context.timeout = timeout; | 5963 | pg->peers[off].internal_context.timeout = timeout; |
@@ -5925,11 +5971,83 @@ GNUNET_TESTING_daemons_start( | |||
5925 | pg->peers[off].internal_context.hostkey_cls = hostkey_cls; | 5971 | pg->peers[off].internal_context.hostkey_cls = hostkey_cls; |
5926 | pg->peers[off].internal_context.start_cb = cb; | 5972 | pg->peers[off].internal_context.start_cb = cb; |
5927 | pg->peers[off].internal_context.start_cb_cls = cb_cls; | 5973 | pg->peers[off].internal_context.start_cb_cls = cb_cls; |
5928 | 5974 | #if !USE_START_HELPER | |
5929 | GNUNET_SCHEDULER_add_now (&internal_start, | 5975 | GNUNET_SCHEDULER_add_now (&internal_start, |
5930 | &pg->peers[off].internal_context); | 5976 | &pg->peers[off].internal_context); |
5977 | #else | ||
5978 | if ((pg->hostkey_data != NULL) && (hostcnt > 0)) | ||
5979 | { | ||
5980 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Have hostkey data and running on remote hosts!\n"); | ||
5981 | GNUNET_TESTING_daemon_start (pcfg, | ||
5982 | timeout, | ||
5983 | GNUNET_YES, | ||
5984 | hostname, | ||
5985 | username, | ||
5986 | sshport, | ||
5987 | pg->peers[off].internal_context.hostkey, | ||
5988 | &internal_hostkey_callback, | ||
5989 | &pg->peers[off].internal_context, | ||
5990 | &internal_startup_callback, | ||
5991 | &pg->peers[off].internal_context); | ||
5992 | /** | ||
5993 | * At this point, given that we had a hostkeyfile, | ||
5994 | * we can call the hostkey callback! | ||
5995 | * But first, we should copy (rsync) all of the configs | ||
5996 | * and hostkeys to the remote peers. Then let topology | ||
5997 | * creation happen, then call the peer start helper processes, | ||
5998 | * then set pg->whatever_phase for each peer and let them | ||
5999 | * enter the fsm to get the HELLO's for peers and start connecting. | ||
6000 | */ | ||
6001 | } | ||
6002 | else | ||
6003 | { | ||
6004 | GNUNET_SCHEDULER_add_now (&internal_start, | ||
6005 | &pg->peers[off].internal_context); | ||
6006 | } | ||
6007 | |||
6008 | #endif | ||
6009 | } | ||
6010 | |||
6011 | #if USE_START_HELPER /* Now the peergroup has been set up, hostkeys and configs written to files. */ | ||
6012 | if ((pg->hostkey_data != NULL) && (hostcnt > 0)) | ||
6013 | { | ||
6014 | for (off = 0; off < hostcnt; off++) | ||
6015 | { | ||
6016 | GNUNET_asprintf(&newservicehome, "%s/%s/", baseservicehome, pg->hosts[off].hostname); | ||
6017 | |||
6018 | if (NULL != username) | ||
6019 | GNUNET_asprintf (&arg, "%s@%s:%s", username, pg->hosts[off].hostname, newservicehome); | ||
6020 | else | ||
6021 | GNUNET_asprintf (&arg, "%s:%s", pg->hosts[off].hostname, newservicehome); | ||
6022 | |||
6023 | /* FIXME: Doesn't support ssh_port option! */ | ||
6024 | proc = GNUNET_OS_start_process (NULL, NULL, "scp", "scp", "-r", | ||
6025 | #if !DEBUG_TESTING | ||
6026 | "-q", | ||
6027 | #endif | ||
6028 | newservicehome, arg, NULL); | ||
6029 | |||
6030 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "copying directory with command scp -r %s %s\n", newservicehome, arg); | ||
5931 | 6031 | ||
6032 | |||
6033 | GNUNET_free (arg); | ||
6034 | if (NULL == proc) | ||
6035 | { | ||
6036 | GNUNET_log ( | ||
6037 | GNUNET_ERROR_TYPE_ERROR, | ||
6038 | _ | ||
6039 | ("Could not start `%s' process to copy configuration directory.\n"), | ||
6040 | "scp"); | ||
6041 | GNUNET_assert(0); | ||
6042 | } | ||
6043 | GNUNET_OS_process_wait (proc); | ||
6044 | GNUNET_OS_process_close (proc); | ||
6045 | } | ||
6046 | /* Now all the configuration files and hostkeys are copied to the remote host. Call the hostkey callback for each peer! */ | ||
6047 | GNUNET_SCHEDULER_add_now(&call_hostkey_callbacks, pg); | ||
5932 | } | 6048 | } |
6049 | GNUNET_free (baseservicehome); | ||
6050 | #endif | ||
5933 | return pg; | 6051 | return pg; |
5934 | } | 6052 | } |
5935 | 6053 | ||