diff options
author | Julius Bünger <buenger@mytum.de> | 2017-12-29 00:51:12 +0100 |
---|---|---|
committer | Julius Bünger <buenger@mytum.de> | 2017-12-29 00:53:02 +0100 |
commit | 6380681b87431baa0155c8544f053de2aa78cb5d (patch) | |
tree | 4441bc3acbda3a4bcb8e0d53769bc1e38677a08e /src/rps/test_rps.c | |
parent | bbed9b3ecc520babb9152bafca87ccd287e7311d (diff) | |
download | gnunet-6380681b87431baa0155c8544f053de2aa78cb5d.tar.gz gnunet-6380681b87431baa0155c8544f053de2aa78cb5d.zip |
rps: improve churn testing
Diffstat (limited to 'src/rps/test_rps.c')
-rw-r--r-- | src/rps/test_rps.c | 58 |
1 files changed, 57 insertions, 1 deletions
diff --git a/src/rps/test_rps.c b/src/rps/test_rps.c index b8f7588e1..0114a19fe 100644 --- a/src/rps/test_rps.c +++ b/src/rps/test_rps.c | |||
@@ -1028,6 +1028,33 @@ req_cancel_cb (struct RPSPeer *rps_peer) | |||
1028 | } | 1028 | } |
1029 | 1029 | ||
1030 | /*********************************** | 1030 | /*********************************** |
1031 | * CHURN | ||
1032 | ***********************************/ | ||
1033 | |||
1034 | static void | ||
1035 | churn (void *cls); | ||
1036 | |||
1037 | static void | ||
1038 | churn_test_cb (struct RPSPeer *rps_peer) | ||
1039 | { | ||
1040 | /* Start churn */ | ||
1041 | if (GNUNET_YES == cur_test_run.have_churn && NULL == churn_task) | ||
1042 | { | ||
1043 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1044 | "Starting churn task\n"); | ||
1045 | churn_task = GNUNET_SCHEDULER_add_delayed ( | ||
1046 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5), | ||
1047 | churn, | ||
1048 | NULL); | ||
1049 | } else { | ||
1050 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1051 | "Not starting churn task\n"); | ||
1052 | } | ||
1053 | |||
1054 | schedule_missing_requests (rps_peer); | ||
1055 | } | ||
1056 | |||
1057 | /*********************************** | ||
1031 | * PROFILER | 1058 | * PROFILER |
1032 | ***********************************/ | 1059 | ***********************************/ |
1033 | 1060 | ||
@@ -1153,6 +1180,9 @@ churn (void *cls) | |||
1153 | double portion_go_online; | 1180 | double portion_go_online; |
1154 | double portion_go_offline; | 1181 | double portion_go_offline; |
1155 | 1182 | ||
1183 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1184 | "Churn function executing\n"); | ||
1185 | |||
1156 | /* Compute the probability for an online peer to go offline | 1186 | /* Compute the probability for an online peer to go offline |
1157 | * this round */ | 1187 | * this round */ |
1158 | portion_online = num_peers_online * 1.0 / num_peers; | 1188 | portion_online = num_peers_online * 1.0 / num_peers; |
@@ -1263,10 +1293,15 @@ profiler_cb (struct RPSPeer *rps_peer) | |||
1263 | /* Start churn */ | 1293 | /* Start churn */ |
1264 | if (GNUNET_YES == cur_test_run.have_churn && NULL == churn_task) | 1294 | if (GNUNET_YES == cur_test_run.have_churn && NULL == churn_task) |
1265 | { | 1295 | { |
1296 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1297 | "Starting churn task\n"); | ||
1266 | churn_task = GNUNET_SCHEDULER_add_delayed ( | 1298 | churn_task = GNUNET_SCHEDULER_add_delayed ( |
1267 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5), | 1299 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5), |
1268 | churn, | 1300 | churn, |
1269 | NULL); | 1301 | NULL); |
1302 | } else { | ||
1303 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1304 | "Not starting churn task\n"); | ||
1270 | } | 1305 | } |
1271 | 1306 | ||
1272 | /* Only request peer ids at one peer. | 1307 | /* Only request peer ids at one peer. |
@@ -1358,6 +1393,24 @@ run (void *cls, | |||
1358 | struct OpListEntry *entry; | 1393 | struct OpListEntry *entry; |
1359 | uint32_t num_mal_peers; | 1394 | uint32_t num_mal_peers; |
1360 | 1395 | ||
1396 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "RUN was called\n"); | ||
1397 | |||
1398 | /* Check whether we timed out */ | ||
1399 | if (n_peers != num_peers || | ||
1400 | NULL == peers || | ||
1401 | 0 == links_succeeded) | ||
1402 | { | ||
1403 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Going down due to args (eg. timeout)\n"); | ||
1404 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "\tn_peers: %u\n", n_peers); | ||
1405 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "\tnum_peers: %" PRIu32 "\n", num_peers); | ||
1406 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "\tpeers: %p\n", peers); | ||
1407 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "\tlinks_succeeded: %u\n", links_succeeded); | ||
1408 | GNUNET_SCHEDULER_shutdown (); | ||
1409 | return; | ||
1410 | } | ||
1411 | |||
1412 | |||
1413 | /* Initialize peers */ | ||
1361 | testbed_peers = peers; | 1414 | testbed_peers = peers; |
1362 | num_peers_online = 0; | 1415 | num_peers_online = 0; |
1363 | for (i = 0; i < num_peers; i++) | 1416 | for (i = 0; i < num_peers; i++) |
@@ -1515,7 +1568,10 @@ main (int argc, char *argv[]) | |||
1515 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test churn\n"); | 1568 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test churn\n"); |
1516 | cur_test_run.name = "test-rps-churn"; | 1569 | cur_test_run.name = "test-rps-churn"; |
1517 | num_peers = 5; | 1570 | num_peers = 5; |
1518 | cur_test_run.main_test = single_req_cb; | 1571 | cur_test_run.init_peer = default_init_peer; |
1572 | cur_test_run.main_test = churn_test_cb; | ||
1573 | cur_test_run.reply_handle = default_reply_handle; | ||
1574 | cur_test_run.eval_cb = default_eval_cb; | ||
1519 | cur_test_run.have_churn = GNUNET_YES; | 1575 | cur_test_run.have_churn = GNUNET_YES; |
1520 | timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10); | 1576 | timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10); |
1521 | } | 1577 | } |