aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulius Bünger <buenger@mytum.de>2018-01-07 20:59:54 +0100
committerJulius Bünger <buenger@mytum.de>2018-01-07 22:33:07 +0100
commitc87570b26f307261f4522a2f5d42f11f2dd514f7 (patch)
tree668263671d880561ce4bc6821abe21c7339924f4
parent608c456a6849dadecab156657854f5335d86cb3d (diff)
downloadgnunet-c87570b26f307261f4522a2f5d42f11f2dd514f7.tar.gz
gnunet-c87570b26f307261f4522a2f5d42f11f2dd514f7.zip
rps tests: comments and logging
-rw-r--r--src/rps/test_rps.c56
1 files changed, 48 insertions, 8 deletions
diff --git a/src/rps/test_rps.c b/src/rps/test_rps.c
index 0114a19fe..e321cca09 100644
--- a/src/rps/test_rps.c
+++ b/src/rps/test_rps.c
@@ -84,8 +84,8 @@ struct OpListEntry
84 struct GNUNET_TESTBED_Operation *op; 84 struct GNUNET_TESTBED_Operation *op;
85 85
86 /** 86 /**
87 * Depending on whether we start or stop NSE service at the peer set this to 1 87 * Depending on whether we start or stop RPS service at the peer set this to 1 (start)
88 * or -1 88 * or -1 (stop)
89 */ 89 */
90 int delta; 90 int delta;
91 91
@@ -188,7 +188,7 @@ struct RPSPeer
188 int online; 188 int online;
189 189
190 /** 190 /**
191 * Number of Peer IDs to request 191 * Number of Peer IDs to request during the whole test
192 */ 192 */
193 unsigned int num_ids_to_request; 193 unsigned int num_ids_to_request;
194 194
@@ -272,8 +272,13 @@ typedef void (*InitPeer) (struct RPSPeer *rps_peer);
272typedef void (*PreTest) (void *cls, struct GNUNET_RPS_Handle *h); 272typedef void (*PreTest) (void *cls, struct GNUNET_RPS_Handle *h);
273 273
274/** 274/**
275 * @brief Executes functions to test the api/service for a given peer
276 *
275 * Called from within #rps_connect_complete_cb () 277 * Called from within #rps_connect_complete_cb ()
276 * Executes functions to test the api/service 278 * Implemented by #churn_test_cb, #profiler_cb, #mal_cb, #single_req_cb,
279 * #delay_req_cb, #seed_big_cb, #single_peer_seed_cb, #seed_cb, #req_cancel_cb
280 *
281 * @param rps_peer the peer the task runs on
277 */ 282 */
278typedef void (*MainTest) (struct RPSPeer *rps_peer); 283typedef void (*MainTest) (struct RPSPeer *rps_peer);
279 284
@@ -306,7 +311,7 @@ struct SingleTestRun
306 char *name; 311 char *name;
307 312
308 /** 313 /**
309 * Called to initialise peer 314 * Called with a single peer in order to initialise that peer
310 */ 315 */
311 InitPeer init_peer; 316 InitPeer init_peer;
312 317
@@ -316,7 +321,7 @@ struct SingleTestRun
316 PreTest pre_test; 321 PreTest pre_test;
317 322
318 /** 323 /**
319 * Function to execute the functions to be tested 324 * Main function for each peer
320 */ 325 */
321 MainTest main_test; 326 MainTest main_test;
322 327
@@ -502,6 +507,8 @@ shutdown_op (void *cls)
502{ 507{
503 unsigned int i; 508 unsigned int i;
504 509
510 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
511 "Shutdown task scheduled, going down.\n");
505 in_shutdown = GNUNET_YES; 512 in_shutdown = GNUNET_YES;
506 if (NULL != churn_task) 513 if (NULL != churn_task)
507 { 514 {
@@ -1034,6 +1041,17 @@ req_cancel_cb (struct RPSPeer *rps_peer)
1034static void 1041static void
1035churn (void *cls); 1042churn (void *cls);
1036 1043
1044/**
1045 * @brief Starts churn
1046 *
1047 * Has signature of #MainTest
1048 *
1049 * This is not implemented too nicely as this is called for each peer, but we
1050 * only need to call it once. (Yes we check that we only schedule the task
1051 * once.)
1052 *
1053 * @param rps_peer The peer it's called for
1054 */
1037static void 1055static void
1038churn_test_cb (struct RPSPeer *rps_peer) 1056churn_test_cb (struct RPSPeer *rps_peer)
1039{ 1057{
@@ -1132,6 +1150,16 @@ churn_cb (void *cls,
1132 // run_round (); 1150 // run_round ();
1133} 1151}
1134 1152
1153/**
1154 * @brief Set the rps-service up or down for a specific peer
1155 *
1156 * TODO use enum instead of 1/-1 for delta
1157 *
1158 * @param i index of action
1159 * @param j index of peer
1160 * @param delta down (-1) or up (1)
1161 * @param prob_go_on_off the probability of the action
1162 */
1135static void 1163static void
1136manage_service_wrapper (unsigned int i, unsigned int j, int delta, 1164manage_service_wrapper (unsigned int i, unsigned int j, int delta,
1137 double prob_go_on_off) 1165 double prob_go_on_off)
@@ -1154,6 +1182,10 @@ manage_service_wrapper (unsigned int i, unsigned int j, int delta,
1154 GNUNET_i2s (rps_peers[j].peer_id), 1182 GNUNET_i2s (rps_peers[j].peer_id),
1155 (0 > delta) ? "offline" : "online"); 1183 (0 > delta) ? "offline" : "online");
1156 1184
1185 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1186 "testbed_peers points to %p, peer 0 to %p\n",
1187 testbed_peers, testbed_peers[0]);
1188
1157 if (0 > delta) 1189 if (0 > delta)
1158 cancel_pending_req_rep (&rps_peers[j]); 1190 cancel_pending_req_rep (&rps_peers[j]);
1159 entry = make_oplist_entry (); 1191 entry = make_oplist_entry ();
@@ -1426,6 +1458,7 @@ run (void *cls,
1426 entry); 1458 entry);
1427 } 1459 }
1428 1460
1461 /* Bring peers up */
1429 num_mal_peers = round (portion * num_peers); 1462 num_mal_peers = round (portion * num_peers);
1430 GNUNET_assert (num_peers == n_peers); 1463 GNUNET_assert (num_peers == n_peers);
1431 for (i = 0; i < n_peers; i++) 1464 for (i = 0; i < n_peers; i++)
@@ -1609,14 +1642,21 @@ main (int argc, char *argv[])
1609 with the malicious portion */ 1642 with the malicious portion */
1610 1643
1611 ok = 1; 1644 ok = 1;
1612 (void) GNUNET_TESTBED_test_run (cur_test_run.name, 1645 ret_value = GNUNET_TESTBED_test_run (cur_test_run.name,
1613 "test_rps.conf", 1646 "test_rps.conf",
1614 num_peers, 1647 num_peers,
1615 0, NULL, NULL, 1648 0, NULL, NULL,
1616 &run, NULL); 1649 &run, NULL);
1650 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1651 "_test_run returned.\n");
1652 if (GNUNET_OK != ret_value)
1653 {
1654 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1655 "Test did not run successfully!\n");
1656 }
1617 1657
1618 ret_value = cur_test_run.eval_cb(); 1658 ret_value = cur_test_run.eval_cb();
1619 GNUNET_free (rps_peers ); 1659 GNUNET_free (rps_peers);
1620 GNUNET_free (rps_peer_ids); 1660 GNUNET_free (rps_peer_ids);
1621 GNUNET_CONTAINER_multipeermap_destroy (peer_map); 1661 GNUNET_CONTAINER_multipeermap_destroy (peer_map);
1622 return ret_value; 1662 return ret_value;