aboutsummaryrefslogtreecommitdiff
path: root/src/testing
diff options
context:
space:
mode:
authorNathan S. Evans <evans@in.tum.de>2010-03-04 10:16:43 +0000
committerNathan S. Evans <evans@in.tum.de>2010-03-04 10:16:43 +0000
commit2ca2d00cf87bdc35900e6d0de1d79cfc38d13eb9 (patch)
tree0c633ab4429db8cffc22a9639216701e165c7d0b /src/testing
parentcdc66da331d8cd56c6d00c0c05b539a74ae96287 (diff)
downloadgnunet-2ca2d00cf87bdc35900e6d0de1d79cfc38d13eb9.tar.gz
gnunet-2ca2d00cf87bdc35900e6d0de1d79cfc38d13eb9.zip
connecting peers relies on connections completed thus far, instead of estimating how many should be complete
Diffstat (limited to 'src/testing')
-rw-r--r--src/testing/test_testing_data_topology_clique.conf8
-rw-r--r--src/testing/test_testing_topology.c4
-rw-r--r--src/testing/testing_group.c83
3 files changed, 84 insertions, 11 deletions
diff --git a/src/testing/test_testing_data_topology_clique.conf b/src/testing/test_testing_data_topology_clique.conf
index 2a8934c34..535b6db8c 100644
--- a/src/testing/test_testing_data_topology_clique.conf
+++ b/src/testing/test_testing_data_topology_clique.conf
@@ -24,13 +24,17 @@ PORT = 2568
24 24
25[peerinfo] 25[peerinfo]
26PORT = 2569 26PORT = 2569
27#DEBUG = YES
28#PREFIX = xterm -e xterm -T peerinfo -e gdb --args
27 29
28[core] 30[core]
29PORT = 2570 31PORT = 2570
30#DEBUG = YES 32#PREFIX = xterm -e xterm -T CORE -e gdb --args
33#PREFIX = valgrind --tool=memcheck --log-file=logs%p
34DEBUG = YES
31 35
32[testing] 36[testing]
33NUM_PEERS = 5 37NUM_PEERS = 8
34WEAKRANDOM = YES 38WEAKRANDOM = YES
35TOPOLOGY = 0 39TOPOLOGY = 0
36F2F = YES 40F2F = YES
diff --git a/src/testing/test_testing_topology.c b/src/testing/test_testing_topology.c
index 778c0c00a..910dead55 100644
--- a/src/testing/test_testing_topology.c
+++ b/src/testing/test_testing_topology.c
@@ -25,10 +25,10 @@
25#include "gnunet_testing_lib.h" 25#include "gnunet_testing_lib.h"
26#include "gnunet_core_service.h" 26#include "gnunet_core_service.h"
27 27
28#define VERBOSE GNUNET_NO 28#define VERBOSE GNUNET_YES
29 29
30 30
31#define TEST_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60) 31#define TEST_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 360)
32/** 32/**
33 * How long until we give up on connecting the peers? 33 * How long until we give up on connecting the peers?
34 */ 34 */
diff --git a/src/testing/testing_group.c b/src/testing/testing_group.c
index 94f8dce04..30c4fc886 100644
--- a/src/testing/testing_group.c
+++ b/src/testing/testing_group.c
@@ -44,6 +44,8 @@
44 */ 44 */
45#define HIGH_PORT 32000 45#define HIGH_PORT 32000
46 46
47#define MAX_OUTSTANDING_CONNECTIONS 30
48
47#define CONNECT_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 180) 49#define CONNECT_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 180)
48 50
49struct PeerConnection 51struct PeerConnection
@@ -164,6 +166,22 @@ struct UpdateContext
164 unsigned int nport; 166 unsigned int nport;
165}; 167};
166 168
169
170struct ConnectContext
171{
172 struct GNUNET_TESTING_Daemon *first;
173
174 struct GNUNET_TESTING_Daemon *second;
175
176 struct GNUNET_TESTING_PeerGroup *pg;
177};
178
179/**
180 * Number of connects we are waiting on, allows us to rate limit
181 * connect attempts.
182 */
183static int outstanding_connects;
184
167/** 185/**
168 * Function to iterate over options. Copies 186 * Function to iterate over options. Copies
169 * the options to the target configuration, 187 * the options to the target configuration,
@@ -908,7 +926,53 @@ create_and_copy_friend_files (struct GNUNET_TESTING_PeerGroup *pg)
908 return ret; 926 return ret;
909} 927}
910 928
929/**
930 * Internal notification of a connection, kept so that we can ensure some connections
931 * happen instead of flooding all testing daemons with requests to connect.
932 */
933static void internal_connect_notify (void *cls,
934 const struct GNUNET_PeerIdentity *first,
935 const struct GNUNET_PeerIdentity *second,
936 const struct GNUNET_CONFIGURATION_Handle *first_cfg,
937 const struct GNUNET_CONFIGURATION_Handle *second_cfg,
938 struct GNUNET_TESTING_Daemon *first_daemon,
939 struct GNUNET_TESTING_Daemon *second_daemon,
940 const char *emsg)
941{
942 struct GNUNET_TESTING_PeerGroup *pg = cls;
943 outstanding_connects--;
944
945 pg->notify_connection(pg->notify_connection_cls, first, second, first_cfg, second_cfg, first_daemon, second_daemon, emsg);
946
947}
948
949static void schedule_connect(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
950{
951 struct ConnectContext *connect_context = cls;
911 952
953 if (outstanding_connects > MAX_OUTSTANDING_CONNECTIONS)
954 {
955#if VERBOSE_TESTING
956 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
957 _("Delaying connect, we have too many outstanding connections!\n"));
958#endif
959 GNUNET_SCHEDULER_add_delayed(connect_context->pg->sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 3), &schedule_connect, connect_context);
960 }
961 else
962 {
963#if VERBOSE_TESTING
964 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
965 _("Creating connection, outstanding_connections is %d\n"), outstanding_connects);
966#endif
967 outstanding_connects++;
968 GNUNET_TESTING_daemons_connect (connect_context->first,
969 connect_context->second,
970 CONNECT_TIMEOUT,
971 &internal_connect_notify,
972 connect_context->pg);
973 GNUNET_free(connect_context);
974 }
975}
912 976
913/* 977/*
914 * Connect the topology as specified by the PeerConnection's 978 * Connect the topology as specified by the PeerConnection's
@@ -921,29 +985,34 @@ connect_topology (struct GNUNET_TESTING_PeerGroup *pg)
921{ 985{
922 unsigned int pg_iter; 986 unsigned int pg_iter;
923 struct PeerConnection *connection_iter; 987 struct PeerConnection *connection_iter;
924 int connect_count; 988 struct ConnectContext *connect_context;
925 989
926 connect_count = 0;
927 for (pg_iter = 0; pg_iter < pg->total; pg_iter++) 990 for (pg_iter = 0; pg_iter < pg->total; pg_iter++)
928 { 991 {
929 connection_iter = pg->peers[pg_iter].connected_peers; 992 connection_iter = pg->peers[pg_iter].connected_peers;
930 while (connection_iter != NULL) 993 while (connection_iter != NULL)
931 { 994 {
932 GNUNET_TESTING_daemons_connect (pg->peers[pg_iter].daemon, 995 connect_context = GNUNET_malloc(sizeof(struct ConnectContext));
996 connect_context->pg = pg;
997 connect_context->first = pg->peers[pg_iter].daemon;
998 connect_context->second = connection_iter->daemon;
999
1000 GNUNET_SCHEDULER_add_now(pg->sched, &schedule_connect, connect_context);
1001 /*GNUNET_TESTING_daemons_connect (pg->peers[pg_iter].daemon,
933 connection_iter->daemon, 1002 connection_iter->daemon,
934 CONNECT_TIMEOUT, 1003 CONNECT_TIMEOUT,
935 pg->notify_connection, 1004 pg->notify_connection,
936 pg->notify_connection_cls); 1005 pg->notify_connection_cls);*/
937 connection_iter = connection_iter->next; 1006 connection_iter = connection_iter->next;
938 connect_count++; 1007
939 if (connect_count % 50 == 0) 1008 /*if (outstanding_connects > MAX_OUTSTANDING_CONNECTS)
940 { 1009 {
941#if VERBOSE_TESTING 1010#if VERBOSE_TESTING
942 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1011 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
943 _("Sleeping to give peers a chance to connect!\n")); 1012 _("Sleeping to give peers a chance to connect!\n"));
944#endif 1013#endif
945 sleep(2); 1014 sleep(2);
946 } 1015 } */
947 } 1016 }
948 } 1017 }
949} 1018}