aboutsummaryrefslogtreecommitdiff
path: root/src/testing
diff options
context:
space:
mode:
authorNathan S. Evans <evans@in.tum.de>2010-06-14 12:17:47 +0000
committerNathan S. Evans <evans@in.tum.de>2010-06-14 12:17:47 +0000
commitf108c06868a1a9062e0098b6bc7dfeb9dcfddfe1 (patch)
treed1e72b0c949fac18f67d7057689a7dfb65e088e4 /src/testing
parentcc3a0bc78da6f3d29003e1f84c57742e9cf3da3c (diff)
downloadgnunet-f108c06868a1a9062e0098b6bc7dfeb9dcfddfe1.tar.gz
gnunet-f108c06868a1a9062e0098b6bc7dfeb9dcfddfe1.zip
changes to use names instead of numbers for topologies and topology options
Diffstat (limited to 'src/testing')
-rw-r--r--src/testing/test_testing_topology.c56
-rw-r--r--src/testing/testing_group.c255
2 files changed, 248 insertions, 63 deletions
diff --git a/src/testing/test_testing_topology.c b/src/testing/test_testing_topology.c
index 5d71d2016..dfc59ab74 100644
--- a/src/testing/test_testing_topology.c
+++ b/src/testing/test_testing_topology.c
@@ -658,11 +658,11 @@ run (void *cls,
658 char *const *args, 658 char *const *args,
659 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) 659 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
660{ 660{
661 unsigned long long topology_num; 661 char * topology_str;
662 unsigned long long connect_topology_num; 662 char * connect_topology_str;
663 unsigned long long blacklist_topology_num; 663 char * blacklist_topology_str;
664 unsigned long long connect_topology_option_num; 664 char * connect_topology_option_str;
665 char *connect_topology_option_modifier_string; 665 char * connect_topology_option_modifier_string;
666 sched = s; 666 sched = s;
667 ok = 1; 667 ok = 1;
668 668
@@ -683,20 +683,31 @@ run (void *cls,
683 return; 683 return;
684 } 684 }
685 685
686 if (GNUNET_YES == 686 if ((GNUNET_YES ==
687 GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "topology", 687 GNUNET_CONFIGURATION_get_value_string(cfg, "testing", "topology",
688 &topology_num)) 688 &topology_str)) && (GNUNET_NO == GNUNET_TESTING_topology_get(&topology, topology_str)))
689 topology = topology_num; 689 {
690 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
691 "Invalid topology `%s' given for section %s option %s\n", topology_str, "TESTING", "TOPOLOGY");
692 topology = GNUNET_TESTING_TOPOLOGY_CLIQUE; /* Defaults to NONE, so set better default here */
693 }
690 694
691 if (GNUNET_YES == 695 if ((GNUNET_YES ==
692 GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "connect_topology", 696 GNUNET_CONFIGURATION_get_value_string(cfg, "testing", "connect_topology",
693 &connect_topology_num)) 697 &connect_topology_str)) && (GNUNET_NO == GNUNET_TESTING_topology_get(&connection_topology, connect_topology_str)))
694 connection_topology = connect_topology_num; 698 {
699 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
700 "Invalid connect topology `%s' given for section %s option %s\n", connect_topology_str, "TESTING", "CONNECT_TOPOLOGY");
701 }
695 702
696 if (GNUNET_YES == 703 if ((GNUNET_YES ==
697 GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "connect_topology_option", 704 GNUNET_CONFIGURATION_get_value_string(cfg, "testing", "connect_topology_option",
698 &connect_topology_option_num)) 705 &connect_topology_option_str)) && (GNUNET_NO == GNUNET_TESTING_topology_option_get(&connect_topology_option, connect_topology_option_str)))
699 connect_topology_option = connect_topology_option_num; 706 {
707 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
708 "Invalid connect topology option `%s' given for section %s option %s\n", connect_topology_option_str, "TESTING", "CONNECT_TOPOLOGY_OPTION");
709 connect_topology_option = GNUNET_TESTING_TOPOLOGY_OPTION_ALL; /* Defaults to NONE, set to ALL */
710 }
700 711
701 if (GNUNET_YES == 712 if (GNUNET_YES ==
702 GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "connect_topology_option_modifier", 713 GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "connect_topology_option_modifier",
@@ -717,10 +728,13 @@ run (void *cls,
717 &blacklist_transports)) 728 &blacklist_transports))
718 blacklist_transports = NULL; 729 blacklist_transports = NULL;
719 730
720 if (GNUNET_YES == 731 if ((GNUNET_YES ==
721 GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "blacklist_topology", 732 GNUNET_CONFIGURATION_get_value_string(cfg, "testing", "blacklist_topology",
722 &blacklist_topology_num)) 733 & blacklist_topology_str)) && (GNUNET_NO == GNUNET_TESTING_topology_get(&blacklist_topology, blacklist_topology_str)))
723 blacklist_topology = blacklist_topology_num; 734 {
735 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
736 "Invalid topology `%s' given for section %s option %s\n", topology_str, "TESTING", "BLACKLIST_TOPOLOGY");
737 }
724 738
725 if (GNUNET_SYSERR == 739 if (GNUNET_SYSERR ==
726 GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "num_peers", 740 GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "num_peers",
diff --git a/src/testing/testing_group.c b/src/testing/testing_group.c
index 2f8db6a81..36aa42615 100644
--- a/src/testing/testing_group.c
+++ b/src/testing/testing_group.c
@@ -29,6 +29,8 @@
29 29
30#define VERBOSE_TESTING GNUNET_NO 30#define VERBOSE_TESTING GNUNET_NO
31 31
32#define VERBOSE_TOPOLOGY GNUNET_NO
33
32#define DEBUG_CHURN GNUNET_NO 34#define DEBUG_CHURN GNUNET_NO
33 35
34/** 36/**
@@ -60,6 +62,92 @@ typedef int (*GNUNET_TESTING_ConnectionProcessor)
60(struct GNUNET_TESTING_PeerGroup *pg, unsigned int first, unsigned int second); 62(struct GNUNET_TESTING_PeerGroup *pg, unsigned int first, unsigned int second);
61 63
62/** 64/**
65 * Strings representing topologies in enum
66 */
67static char * GNUNET_TESTING_TopologyStrings[] =
68{
69 /**
70 * A clique (everyone connected to everyone else).
71 */
72 "CLIQUE",
73
74 /**
75 * Small-world network (2d torus plus random links).
76 */
77 "SMALL_WORLD",
78
79 /**
80 * Small-world network (ring plus random links).
81 */
82 "SMALL_WORLD_RING",
83
84 /**
85 * Ring topology.
86 */
87 "RING",
88
89 /**
90 * 2-d torus.
91 */
92 "2D_TORUS",
93
94 /**
95 * Random graph.
96 */
97 "ERDOS_RENYI",
98
99 /**
100 * Certain percentage of peers are unable to communicate directly
101 * replicating NAT conditions
102 */
103 "INTERNAT",
104
105 /**
106 * Scale free topology.
107 */
108 "SCALE_FREE",
109
110 /**
111 * All peers are disconnected.
112 */
113 "NONE"
114};
115
116/**
117 * Options for connecting a topology as strings.
118 */
119static char * GNUNET_TESTING_TopologyOptionStrings[] =
120{
121 /**
122 * Try to connect all peers specified in the topology.
123 */
124 "CONNECT_ALL",
125
126 /**
127 * Choose a random subset of connections to create.
128 */
129 "CONNECT_RANDOM_SUBSET",
130
131 /**
132 * Create at least X connections for each peer.
133 */
134 "CONNECT_MINIMUM",
135
136 /**
137 * Using a depth first search, create one connection
138 * per peer. If any are missed (graph disconnected)
139 * start over at those peers until all have at least one
140 * connection.
141 */
142 "CONNECT_DFS",
143
144 /**
145 * No options specified.
146 */
147 "CONNECT_NONE"
148};
149
150/**
63 * Context for handling churning a peer group 151 * Context for handling churning a peer group
64 */ 152 */
65struct ChurnContext 153struct ChurnContext
@@ -334,6 +422,73 @@ struct ConnectContext
334 */ 422 */
335static int outstanding_connects; 423static int outstanding_connects;
336 424
425/**
426 * Get a topology from a string input.
427 *
428 * @param topology where to write the retrieved topology
429 * @param topology_string The string to attempt to
430 * get a configuration value from
431 * @return GNUNET_YES if topology string matched a
432 * known topology, GNUNET_NO if not
433 */
434int
435GNUNET_TESTING_topology_get(enum GNUNET_TESTING_Topology *topology, char * topology_string)
436{
437 int found = 0;
438 int curr = 0;
439
440 if (topology_string == NULL)
441 return GNUNET_NO;
442
443 do
444 {
445 if (strcmp(GNUNET_TESTING_TopologyStrings[curr], topology_string) == 0)
446 {
447 found = GNUNET_YES;
448 break;
449 }
450 curr++;
451 } while (strcmp(GNUNET_TESTING_TopologyStrings[curr], "NONE") != 0);
452 *topology = curr;
453 if (found)
454 return GNUNET_YES;
455 else
456 return GNUNET_NO;
457}
458
459/**
460 * Get connect topology option from string input.
461 *
462 * @param topology where to write the retrieved topology
463 * @param topology_string The string to attempt to
464 * get a configuration value from
465 * @return GNUNET_YES if string matched a known
466 * topology option, GNUNET_NO if not
467 */
468int
469GNUNET_TESTING_topology_option_get(enum GNUNET_TESTING_TopologyOption *topology, char * topology_string)
470{
471 int found = 0;
472 int curr = 0;
473
474 if (topology_string == NULL)
475 return GNUNET_NO;
476
477 do
478 {
479 if (strcmp(GNUNET_TESTING_TopologyOptionStrings[curr], topology_string) == 0)
480 {
481 found = GNUNET_YES;
482 break;
483 }
484 curr++;
485 } while (strcmp(GNUNET_TESTING_TopologyOptionStrings[curr], "CONNECT_NONE") != 0);
486 *topology = curr;
487 if (found)
488 return GNUNET_YES;
489 else
490 return GNUNET_NO;
491}
337 492
338/** 493/**
339 * Function to iterate over options. Copies 494 * Function to iterate over options. Copies
@@ -1792,49 +1947,49 @@ GNUNET_TESTING_create_topology (struct GNUNET_TESTING_PeerGroup *pg,
1792 switch (topology) 1947 switch (topology)
1793 { 1948 {
1794 case GNUNET_TESTING_TOPOLOGY_CLIQUE: 1949 case GNUNET_TESTING_TOPOLOGY_CLIQUE:
1795#if VERBOSE_TESTING 1950#if VERBOSE_TOPOLOGY
1796 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1951 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1797 _("Creating clique topology\n")); 1952 _("Creating clique topology\n"));
1798#endif 1953#endif
1799 num_connections = create_clique (pg, &add_allowed_connections); 1954 num_connections = create_clique (pg, &add_allowed_connections);
1800 break; 1955 break;
1801 case GNUNET_TESTING_TOPOLOGY_SMALL_WORLD_RING: 1956 case GNUNET_TESTING_TOPOLOGY_SMALL_WORLD_RING:
1802#if VERBOSE_TESTING 1957#if VERBOSE_TOPOLOGY
1803 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1958 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1804 _("Creating small world (ring) topology\n")); 1959 _("Creating small world (ring) topology\n"));
1805#endif 1960#endif
1806 num_connections = create_small_world_ring (pg, &add_allowed_connections); 1961 num_connections = create_small_world_ring (pg, &add_allowed_connections);
1807 break; 1962 break;
1808 case GNUNET_TESTING_TOPOLOGY_SMALL_WORLD: 1963 case GNUNET_TESTING_TOPOLOGY_SMALL_WORLD:
1809#if VERBOSE_TESTING 1964#if VERBOSE_TOPOLOGY
1810 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1965 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1811 _("Creating small world (2d-torus) topology\n")); 1966 _("Creating small world (2d-torus) topology\n"));
1812#endif 1967#endif
1813 num_connections = create_small_world (pg, &add_allowed_connections); 1968 num_connections = create_small_world (pg, &add_allowed_connections);
1814 break; 1969 break;
1815 case GNUNET_TESTING_TOPOLOGY_RING: 1970 case GNUNET_TESTING_TOPOLOGY_RING:
1816#if VERBOSE_TESTING 1971#if VERBOSE_TOPOLOGY
1817 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1972 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1818 _("Creating ring topology\n")); 1973 _("Creating ring topology\n"));
1819#endif 1974#endif
1820 num_connections = create_ring (pg, &add_allowed_connections); 1975 num_connections = create_ring (pg, &add_allowed_connections);
1821 break; 1976 break;
1822 case GNUNET_TESTING_TOPOLOGY_2D_TORUS: 1977 case GNUNET_TESTING_TOPOLOGY_2D_TORUS:
1823#if VERBOSE_TESTING 1978#if VERBOSE_TOPOLOGY
1824 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1979 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1825 _("Creating 2d torus topology\n")); 1980 _("Creating 2d torus topology\n"));
1826#endif 1981#endif
1827 num_connections = create_2d_torus (pg, &add_allowed_connections); 1982 num_connections = create_2d_torus (pg, &add_allowed_connections);
1828 break; 1983 break;
1829 case GNUNET_TESTING_TOPOLOGY_ERDOS_RENYI: 1984 case GNUNET_TESTING_TOPOLOGY_ERDOS_RENYI:
1830#if VERBOSE_TESTING 1985#if VERBOSE_TOPOLOGY
1831 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1986 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1832 _("Creating Erdos-Renyi topology\n")); 1987 _("Creating Erdos-Renyi topology\n"));
1833#endif 1988#endif
1834 num_connections = create_erdos_renyi (pg, &add_allowed_connections); 1989 num_connections = create_erdos_renyi (pg, &add_allowed_connections);
1835 break; 1990 break;
1836 case GNUNET_TESTING_TOPOLOGY_INTERNAT: 1991 case GNUNET_TESTING_TOPOLOGY_INTERNAT:
1837#if VERBOSE_TESTING 1992#if VERBOSE_TOPOLOGY
1838 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1993 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1839 _("Creating InterNAT topology\n")); 1994 _("Creating InterNAT topology\n"));
1840#endif 1995#endif
@@ -2363,62 +2518,66 @@ GNUNET_TESTING_connect_topology (struct GNUNET_TESTING_PeerGroup *pg,
2363 switch (topology) 2518 switch (topology)
2364 { 2519 {
2365 case GNUNET_TESTING_TOPOLOGY_CLIQUE: 2520 case GNUNET_TESTING_TOPOLOGY_CLIQUE:
2366 #if VERBOSE_TESTING 2521#if VERBOSE_TOPOLOGY
2367 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2522 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2368 _("Creating clique topology\n")); 2523 _("Creating clique CONNECT topology\n"));
2369 #endif 2524#endif
2370 create_clique (pg, &add_actual_connections); 2525 create_clique (pg, &add_actual_connections);
2371 break; 2526 break;
2372 case GNUNET_TESTING_TOPOLOGY_SMALL_WORLD_RING: 2527 case GNUNET_TESTING_TOPOLOGY_SMALL_WORLD_RING:
2373 #if VERBOSE_TESTING 2528#if VERBOSE_TOPOLOGY
2374 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2529 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2375 _("Creating small world (ring) topology\n")); 2530 _("Creating small world (ring) CONNECT topology\n"));
2376 #endif 2531#endif
2377 create_small_world_ring (pg, &add_actual_connections); 2532 create_small_world_ring (pg, &add_actual_connections);
2378 break; 2533 break;
2379 case GNUNET_TESTING_TOPOLOGY_SMALL_WORLD: 2534 case GNUNET_TESTING_TOPOLOGY_SMALL_WORLD:
2380 #if VERBOSE_TESTING 2535#if VERBOSE_TOPOLOGY
2381 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2536 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2382 _("Creating small world (2d-torus) topology\n")); 2537 _("Creating small world (2d-torus) CONNECT topology\n"));
2383 #endif 2538#endif
2384 create_small_world (pg, &add_actual_connections); 2539 create_small_world (pg, &add_actual_connections);
2385 break; 2540 break;
2386 case GNUNET_TESTING_TOPOLOGY_RING: 2541 case GNUNET_TESTING_TOPOLOGY_RING:
2387 #if VERBOSE_TESTING 2542#if VERBOSE_TOPOLOGY
2388 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2543 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2389 _("Creating ring topology\n")); 2544 _("Creating ring CONNECT topology\n"));
2390 #endif 2545#endif
2391 create_ring (pg, &add_actual_connections); 2546 create_ring (pg, &add_actual_connections);
2392 break; 2547 break;
2393 case GNUNET_TESTING_TOPOLOGY_2D_TORUS: 2548 case GNUNET_TESTING_TOPOLOGY_2D_TORUS:
2394 #if VERBOSE_TESTING 2549#if VERBOSE_TOPOLOGY
2395 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2550 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2396 _("Creating 2d torus topology\n")); 2551 _("Creating 2d torus CONNECT topology\n"));
2397 #endif 2552#endif
2398 create_2d_torus (pg, &add_actual_connections); 2553 create_2d_torus (pg, &add_actual_connections);
2399 break; 2554 break;
2400 case GNUNET_TESTING_TOPOLOGY_ERDOS_RENYI: 2555 case GNUNET_TESTING_TOPOLOGY_ERDOS_RENYI:
2401 #if VERBOSE_TESTING 2556#if VERBOSE_TOPOLOGY
2402 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2557 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2403 _("Creating Erdos-Renyi topology\n")); 2558 _("Creating Erdos-Renyi CONNECT topology\n"));
2404 #endif 2559#endif
2405 create_erdos_renyi (pg, &add_actual_connections); 2560 create_erdos_renyi (pg, &add_actual_connections);
2406 break; 2561 break;
2407 case GNUNET_TESTING_TOPOLOGY_INTERNAT: 2562 case GNUNET_TESTING_TOPOLOGY_INTERNAT:
2408 #if VERBOSE_TESTING 2563#if VERBOSE_TOPOLOGY
2409 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2564 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2410 _("Creating InterNAT topology\n")); 2565 _("Creating InterNAT CONNECT topology\n"));
2411 #endif 2566#endif
2412 create_nated_internet (pg, &add_actual_connections); 2567 create_nated_internet (pg, &add_actual_connections);
2413 break; 2568 break;
2414 case GNUNET_TESTING_TOPOLOGY_SCALE_FREE: 2569 case GNUNET_TESTING_TOPOLOGY_SCALE_FREE:
2415 #if VERBOSE_TESTING 2570#if VERBOSE_TOPOLOGY
2416 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2571 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2417 _("Creating Scale Free topology\n")); 2572 _("Creating Scale Free CONNECT topology\n"));
2418 #endif 2573#endif
2419 create_scale_free (pg, &add_actual_connections); 2574 create_scale_free (pg, &add_actual_connections);
2420 break; 2575 break;
2421 case GNUNET_TESTING_TOPOLOGY_NONE: 2576 case GNUNET_TESTING_TOPOLOGY_NONE:
2577#if VERBOSE_TOPOLOGY
2578 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2579 _("Creating no CONNECT topology\n"));
2580#endif
2422 copy_allowed_topology(pg); 2581 copy_allowed_topology(pg);
2423 break; 2582 break;
2424 default: 2583 default:
@@ -2429,13 +2588,25 @@ GNUNET_TESTING_connect_topology (struct GNUNET_TESTING_PeerGroup *pg,
2429 2588
2430 switch (options) 2589 switch (options)
2431 { 2590 {
2432 case GNUNET_TESTING_TOPOLOGY_OPTION_RANDOM: 2591 case GNUNET_TESTING_TOPOLOGY_OPTION_RANDOM:
2592#if VERBOSE_TOPOLOGY
2593 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2594 _("Connecting random subset (%'.2f percent) of possible peers\n"), 100 * option_modifier);
2595#endif
2433 choose_random_connections(pg, option_modifier); 2596 choose_random_connections(pg, option_modifier);
2434 break; 2597 break;
2435 case GNUNET_TESTING_TOPOLOGY_OPTION_MINIMUM: 2598 case GNUNET_TESTING_TOPOLOGY_OPTION_MINIMUM:
2599#if VERBOSE_TOPOLOGY
2600 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2601 _("Connecting a minimum of %u peers each (if possible)\n"), (unsigned int)option_modifier);
2602#endif
2436 choose_minimum(pg, (unsigned int)option_modifier); 2603 choose_minimum(pg, (unsigned int)option_modifier);
2437 break; 2604 break;
2438 case GNUNET_TESTING_TOPOLOGY_OPTION_DFS: 2605 case GNUNET_TESTING_TOPOLOGY_OPTION_DFS:
2606#if VERBOSE_TOPOLOGY
2607 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2608 _("Using DFS to connect a minimum of %u peers each (if possible)\n"), (unsigned int)option_modifier);
2609#endif
2439 perform_dfs(pg, (int)option_modifier); 2610 perform_dfs(pg, (int)option_modifier);
2440 break; 2611 break;
2441 case GNUNET_TESTING_TOPOLOGY_OPTION_NONE: 2612 case GNUNET_TESTING_TOPOLOGY_OPTION_NONE: