aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2014-05-20 16:00:16 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2014-05-20 16:00:16 +0000
commita418678c67157ac54e7bcaff76ed87e7829ad567 (patch)
tree85e024bd58a954aa4d3c7a0510a7d659a1ff0e16
parent7504bac6839abe0e6117d4beb2111801d15b928a (diff)
downloadgnunet-a418678c67157ac54e7bcaff76ed87e7829ad567.tar.gz
gnunet-a418678c67157ac54e7bcaff76ed87e7829ad567.zip
address switch test
-rw-r--r--src/transport/Makefile.am42
-rw-r--r--src/transport/test_transport_address_switch.c47
-rw-r--r--src/transport/test_transport_address_switch_udp_peer1.conf49
-rw-r--r--src/transport/test_transport_address_switch_udp_peer2.conf49
-rw-r--r--src/transport/test_transport_test_transport_address_switch_tcp_peer1.conf2
5 files changed, 188 insertions, 1 deletions
diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am
index 60d49f9cf..f3d63b0d7 100644
--- a/src/transport/Makefile.am
+++ b/src/transport/Makefile.am
@@ -33,11 +33,13 @@ if HAVE_LIBGNURL
33 HTTP_REL_TEST = test_transport_api_reliability_http 33 HTTP_REL_TEST = test_transport_api_reliability_http
34 HTTP_QUOTA_TEST = test_quota_compliance_http \ 34 HTTP_QUOTA_TEST = test_quota_compliance_http \
35 test_quota_compliance_http_asymmetric 35 test_quota_compliance_http_asymmetric
36 HTTP_SWITCH = test_transport_address_switch_http
36 HTTPS_API_TEST = test_transport_api_https 37 HTTPS_API_TEST = test_transport_api_https
37 HTTPS_API_TIMEOUT_TEST = test_transport_api_timeout_https 38 HTTPS_API_TIMEOUT_TEST = test_transport_api_timeout_https
38 HTTPS_REL_TEST = test_transport_api_reliability_https 39 HTTPS_REL_TEST = test_transport_api_reliability_https
39 HTTPS_QUOTA_TEST = test_quota_compliance_https \ 40 HTTPS_QUOTA_TEST = test_quota_compliance_https \
40 test_quota_compliance_https_asymmetric 41 test_quota_compliance_https_asymmetric
42 HTTPS_SWITCH = test_transport_address_switch_https
41endif 43endif
42endif 44endif
43 45
@@ -402,6 +404,7 @@ check_PROGRAMS = \
402 test_transport_api_tcp_nat \ 404 test_transport_api_tcp_nat \
403 test_transport_api_udp \ 405 test_transport_api_udp \
404 test_transport_api_timeout_udp \ 406 test_transport_api_timeout_udp \
407 test_transport_address_switch_udp \
405 $(UNIX_PLUGIN_TEST) \ 408 $(UNIX_PLUGIN_TEST) \
406 $(UNIX_PLUGIN_TIMEOUT_TEST) \ 409 $(UNIX_PLUGIN_TIMEOUT_TEST) \
407 $(UNIX_API_ABSTRACT_TEST) \ 410 $(UNIX_API_ABSTRACT_TEST) \
@@ -409,8 +412,10 @@ check_PROGRAMS = \
409 $(HTTP_API_TEST) \ 412 $(HTTP_API_TEST) \
410 $(HTTP_REVERSE_API_TEST) \ 413 $(HTTP_REVERSE_API_TEST) \
411 $(HTTP_API_TIMEOUT_TEST) \ 414 $(HTTP_API_TIMEOUT_TEST) \
415 $(HTTP_SWITCH) \
412 $(HTTPS_API_TEST) \ 416 $(HTTPS_API_TEST) \
413 $(HTTPS_API_TIMEOUT_TEST) \ 417 $(HTTPS_API_TIMEOUT_TEST) \
418 $(HTTPS_SWITCH) \
414 $(WLAN_API_TEST) \ 419 $(WLAN_API_TEST) \
415 $(WLAN_TIMEOUT_TEST) \ 420 $(WLAN_TIMEOUT_TEST) \
416 $(BT_API_TEST) \ 421 $(BT_API_TEST) \
@@ -470,14 +475,17 @@ TESTS = \
470 test_transport_api_tcp_nat \ 475 test_transport_api_tcp_nat \
471 test_transport_api_udp \ 476 test_transport_api_udp \
472 test_transport_api_timeout_udp \ 477 test_transport_api_timeout_udp \
478 test_transport_address_switch_udp \
473 $(UNIX_PLUGIN_TEST) \ 479 $(UNIX_PLUGIN_TEST) \
474 $(UNIX_PLUGIN_TIMEOUT_TEST) \ 480 $(UNIX_PLUGIN_TIMEOUT_TEST) \
475 $(UNIX_API_ABSTRACT_TEST) \ 481 $(UNIX_API_ABSTRACT_TEST) \
476 test_transport_api_udp_nat \ 482 test_transport_api_udp_nat \
477 $(HTTP_API_TEST) \ 483 $(HTTP_API_TEST) \
478 $(HTTP_API_TIMEOUT_TEST) \ 484 $(HTTP_API_TIMEOUT_TEST) \
485 $(HTTP_SWITCH) \
479 $(HTTPS_API_TEST) \ 486 $(HTTPS_API_TEST) \
480 $(HTTPS_API_TIMEOUT_TEST) \ 487 $(HTTPS_API_TIMEOUT_TEST) \
488 $(HTTPS_SWITCH) \
481 $(WLAN_API_TEST) \ 489 $(WLAN_API_TEST) \
482 $(WLAN_TIMEOUT_TEST) \ 490 $(WLAN_TIMEOUT_TEST) \
483 $(BT_API_TEST) \ 491 $(BT_API_TEST) \
@@ -1023,6 +1031,34 @@ test_transport_address_switch_tcp_LDADD = \
1023 $(top_builddir)/src/statistics/libgnunetstatistics.la \ 1031 $(top_builddir)/src/statistics/libgnunetstatistics.la \
1024 $(top_builddir)/src/util/libgnunetutil.la \ 1032 $(top_builddir)/src/util/libgnunetutil.la \
1025 $(top_builddir)/src/transport/libgnunettransporttesting.la 1033 $(top_builddir)/src/transport/libgnunettransporttesting.la
1034
1035 test_transport_address_switch_udp_SOURCES = \
1036 test_transport_address_switch.c
1037test_transport_address_switch_udp_LDADD = \
1038 $(top_builddir)/src/transport/libgnunettransport.la \
1039 $(top_builddir)/src/hello/libgnunethello.la \
1040 $(top_builddir)/src/statistics/libgnunetstatistics.la \
1041 $(top_builddir)/src/util/libgnunetutil.la \
1042 $(top_builddir)/src/transport/libgnunettransporttesting.la
1043
1044
1045 test_transport_address_switch_http_SOURCES = \
1046 test_transport_address_switch.c
1047test_transport_address_switch_http_LDADD = \
1048 $(top_builddir)/src/transport/libgnunettransport.la \
1049 $(top_builddir)/src/hello/libgnunethello.la \
1050 $(top_builddir)/src/statistics/libgnunetstatistics.la \
1051 $(top_builddir)/src/util/libgnunetutil.la \
1052 $(top_builddir)/src/transport/libgnunettransporttesting.la
1053
1054 test_transport_address_switch_https_SOURCES = \
1055 test_transport_address_switch.c
1056test_transport_address_switch_https_LDADD = \
1057 $(top_builddir)/src/transport/libgnunettransport.la \
1058 $(top_builddir)/src/hello/libgnunethello.la \
1059 $(top_builddir)/src/statistics/libgnunetstatistics.la \
1060 $(top_builddir)/src/util/libgnunetutil.la \
1061 $(top_builddir)/src/transport/libgnunettransporttesting.la
1026 1062
1027test_quota_compliance_tcp_SOURCES = \ 1063test_quota_compliance_tcp_SOURCES = \
1028 test_quota_compliance.c 1064 test_quota_compliance.c
@@ -1215,6 +1251,12 @@ test_transport_api_reliability_wlan_peer1.conf\
1215test_transport_api_reliability_wlan_peer2.conf\ 1251test_transport_api_reliability_wlan_peer2.conf\
1216test_transport_api_reliability_bluetooth_peer1.conf\ 1252test_transport_api_reliability_bluetooth_peer1.conf\
1217test_transport_api_reliability_bluetooth_peer2.conf\ 1253test_transport_api_reliability_bluetooth_peer2.conf\
1254test_transport_test_transport_address_switch_http_peer1.conf\
1255test_transport_test_transport_address_switch_http_peer2.conf\
1256test_transport_test_transport_address_switch_https_peer1.conf\
1257test_transport_test_transport_address_switch_https_peer2.conf\
1258test_transport_test_transport_address_switch_udp_peer1.conf\
1259test_transport_test_transport_address_switch_udp_peer2.conf\
1218test_transport_test_transport_address_switch_tcp_peer1.conf\ 1260test_transport_test_transport_address_switch_tcp_peer1.conf\
1219test_transport_test_transport_address_switch_tcp_peer2.conf\ 1261test_transport_test_transport_address_switch_tcp_peer2.conf\
1220test_transport_api_wlan_peer1.conf\ 1262test_transport_api_wlan_peer1.conf\
diff --git a/src/transport/test_transport_address_switch.c b/src/transport/test_transport_address_switch.c
index d59d5d265..469dfbf55 100644
--- a/src/transport/test_transport_address_switch.c
+++ b/src/transport/test_transport_address_switch.c
@@ -97,10 +97,12 @@ static GNUNET_TRANSPORT_TESTING_ConnectRequest cc;
97static unsigned int p1_switch_attempts; 97static unsigned int p1_switch_attempts;
98static unsigned int p1_switch_success; 98static unsigned int p1_switch_success;
99static unsigned int p1_switch_fail; 99static unsigned int p1_switch_fail;
100static unsigned int p1_addresses_avail;
100 101
101static unsigned int p2_switch_attempts; 102static unsigned int p2_switch_attempts;
102static unsigned int p2_switch_success; 103static unsigned int p2_switch_success;
103static unsigned int p2_switch_fail; 104static unsigned int p2_switch_fail;
105static unsigned int p2_addresses_avail;
104 106
105static unsigned long long bytes_sent_total; 107static unsigned long long bytes_sent_total;
106static unsigned long long bytes_recv_total; 108static unsigned long long bytes_recv_total;
@@ -169,6 +171,9 @@ static int
169stat_fail_attempt_cb (void *cls, const char *subsystem, const char *name, 171stat_fail_attempt_cb (void *cls, const char *subsystem, const char *name,
170 uint64_t value, int is_persistent) 172 uint64_t value, int is_persistent)
171{ 173{
174 if (value == 0)
175 return GNUNET_OK;
176
172 if (cls == p1) 177 if (cls == p1)
173 { 178 {
174 p1_switch_fail++; 179 p1_switch_fail++;
@@ -183,6 +188,21 @@ stat_fail_attempt_cb (void *cls, const char *subsystem, const char *name,
183 return GNUNET_OK; 188 return GNUNET_OK;
184} 189}
185 190
191static int
192stat_addresses_available (void *cls, const char *subsystem, const char *name,
193 uint64_t value, int is_persistent)
194{
195 if (cls == p1)
196 {
197 p1_addresses_avail++;
198 }
199 if (cls == p2)
200 {
201 p2_addresses_avail++;
202 }
203
204 return GNUNET_OK;
205}
186 206
187static void 207static void
188clean_up () 208clean_up ()
@@ -220,6 +240,9 @@ clean_up ()
220 GNUNET_STATISTICS_watch_cancel (p1_stat, "transport", 240 GNUNET_STATISTICS_watch_cancel (p1_stat, "transport",
221 "# Failed attempts to switch addresses (no response)", 241 "# Failed attempts to switch addresses (no response)",
222 stat_fail_attempt_cb, p1); 242 stat_fail_attempt_cb, p1);
243 GNUNET_STATISTICS_watch (p1_stat, "transport",
244 "# transport addresses",
245 stat_addresses_available, p1);
223 GNUNET_STATISTICS_destroy (p1_stat, GNUNET_NO); 246 GNUNET_STATISTICS_destroy (p1_stat, GNUNET_NO);
224 p1_stat = NULL; 247 p1_stat = NULL;
225 } 248 }
@@ -238,6 +261,9 @@ clean_up ()
238 GNUNET_STATISTICS_watch_cancel (p2_stat, "transport", 261 GNUNET_STATISTICS_watch_cancel (p2_stat, "transport",
239 "# Failed attempts to switch addresses (no response)", 262 "# Failed attempts to switch addresses (no response)",
240 stat_fail_attempt_cb, p2); 263 stat_fail_attempt_cb, p2);
264 GNUNET_STATISTICS_watch (p1_stat, "transport",
265 "# transport addresses",
266 stat_addresses_available, p1);
241 GNUNET_STATISTICS_destroy (p2_stat, GNUNET_NO); 267 GNUNET_STATISTICS_destroy (p2_stat, GNUNET_NO);
242 p2_stat = NULL; 268 p2_stat = NULL;
243 } 269 }
@@ -289,6 +315,11 @@ end ()
289 if (p1_switch_success != p1_switch_attempts) 315 if (p1_switch_success != p1_switch_attempts)
290 result ++; 316 result ++;
291 } 317 }
318 else
319 {
320 FPRINTF (stderr, "Peer 1 had %u addresses available, but did not try to switch\n",
321 p1_addresses_avail);
322 }
292 if (p2_switch_attempts > 0) 323 if (p2_switch_attempts > 0)
293 { 324 {
294 FPRINTF (stderr, "Peer 2 tried %u times to switch and succeeded %u times, failed %u times\n", 325 FPRINTF (stderr, "Peer 2 tried %u times to switch and succeeded %u times, failed %u times\n",
@@ -296,6 +327,11 @@ end ()
296 if (p2_switch_success != p2_switch_attempts) 327 if (p2_switch_success != p2_switch_attempts)
297 result ++; 328 result ++;
298 } 329 }
330 else
331 {
332 FPRINTF (stderr, "Peer 2 had %u addresses available, but did not try to switch\n",
333 p2_addresses_avail);
334 }
299 335
300 if ( ((p1_switch_attempts > 0) || (p2_switch_attempts > 0)) && 336 if ( ((p1_switch_attempts > 0) || (p2_switch_attempts > 0)) &&
301 (bytes_sent_after_switch == 0) ) 337 (bytes_sent_after_switch == 0) )
@@ -322,6 +358,11 @@ end_badly ()
322 die_task = GNUNET_SCHEDULER_NO_TASK; 358 die_task = GNUNET_SCHEDULER_NO_TASK;
323 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Fail! Stopping peers\n"); 359 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Fail! Stopping peers\n");
324 360
361 FPRINTF (stderr, "Peer 1 had %u addresses available, but did not try to switch\n",
362 p1_addresses_avail);
363 FPRINTF (stderr, "Peer 2 had %u addresses available, but did not try to switch\n",
364 p2_addresses_avail);
365
325 if (test_connected == GNUNET_YES) 366 if (test_connected == GNUNET_YES)
326 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Peers got connected\n"); 367 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Peers got connected\n");
327 else 368 else
@@ -566,6 +607,9 @@ run (void *cls, char * const *args, const char *cfgfile,
566 GNUNET_STATISTICS_watch (p1_stat, "transport", 607 GNUNET_STATISTICS_watch (p1_stat, "transport",
567 "# Failed attempts to switch addresses (no response)", 608 "# Failed attempts to switch addresses (no response)",
568 stat_fail_attempt_cb, p1); 609 stat_fail_attempt_cb, p1);
610 GNUNET_STATISTICS_watch (p1_stat, "transport",
611 "# transport addresses",
612 stat_addresses_available, p1);
569 613
570 p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2, 614 p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2,
571 &notify_receive, &notify_connect, &notify_disconnect, &start_cb, NULL ); 615 &notify_receive, &notify_connect, &notify_disconnect, &start_cb, NULL );
@@ -586,6 +630,9 @@ run (void *cls, char * const *args, const char *cfgfile,
586 GNUNET_STATISTICS_watch (p2_stat, "transport", 630 GNUNET_STATISTICS_watch (p2_stat, "transport",
587 "# Failed attempts to switch addresses (no response)", 631 "# Failed attempts to switch addresses (no response)",
588 stat_fail_attempt_cb, p2); 632 stat_fail_attempt_cb, p2);
633 GNUNET_STATISTICS_watch (p2_stat, "transport",
634 "# transport addresses",
635 stat_addresses_available, p2);
589 636
590 if ((p1 == NULL )|| (p2 == NULL)) 637 if ((p1 == NULL )|| (p2 == NULL))
591 { 638 {
diff --git a/src/transport/test_transport_address_switch_udp_peer1.conf b/src/transport/test_transport_address_switch_udp_peer1.conf
new file mode 100644
index 000000000..12fe3d25f
--- /dev/null
+++ b/src/transport/test_transport_address_switch_udp_peer1.conf
@@ -0,0 +1,49 @@
1@INLINE@ template_cfg_peer1.conf
2[PATHS]
3GNUNET_TEST_HOME = /tmp/test-transport/api-tcp-p1/
4
5[ats]
6UNSPECIFIED_QUOTA_IN = 8 KiB
7UNSPECIFIED_QUOTA_OUT = 8 KiB
8# LOOPBACK
9LOOPBACK_QUOTA_IN = 8 KiB
10LOOPBACK_QUOTA_OUT = 8 KiB
11# LAN
12LAN_QUOTA_IN = 8 KiB
13LAN_QUOTA_OUT = 8 KiB
14# WAN
15WAN_QUOTA_IN = 8 KiB
16WAN_QUOTA_OUT = 8 KiB
17# WLAN
18WLAN_QUOTA_IN = 8 KiB
19WLAN_QUOTA_OUT = 8 KiB
20# BLUETOOTH
21BLUETOOTH_QUOTA_IN = 8 KiB
22BLUETOOTH_QUOTA_OUT = 8 KiB
23
24[transport-tcp]
25PORT = 12000
26TIMEOUT = 5 s
27
28[arm]
29PORT = 12005
30DEFAULTSERVICES = transport
31UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p1-service-arm.sock
32
33[statistics]
34PORT = 12004
35UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p1-service-statistics.sock
36
37[resolver]
38PORT = 12003
39UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p1-service-resolver.sock
40
41[peerinfo]
42PORT = 12002
43UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p1-service-peerinfo.sock
44
45[transport]
46PORT = 12001
47UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p1-service-transport.sock
48PLUGINS = udp
49
diff --git a/src/transport/test_transport_address_switch_udp_peer2.conf b/src/transport/test_transport_address_switch_udp_peer2.conf
new file mode 100644
index 000000000..f9f1cfa5e
--- /dev/null
+++ b/src/transport/test_transport_address_switch_udp_peer2.conf
@@ -0,0 +1,49 @@
1@INLINE@ template_cfg_peer2.conf
2[PATHS]
3GNUNET_TEST_HOME = /tmp/test-transport/api-tcp-p2/
4
5[ats]
6UNSPECIFIED_QUOTA_IN = 8 KiB
7UNSPECIFIED_QUOTA_OUT = 8 KiB
8# LOOPBACK
9LOOPBACK_QUOTA_IN = 8 KiB
10LOOPBACK_QUOTA_OUT = 8 KiB
11# LAN
12LAN_QUOTA_IN = 8 KiB
13LAN_QUOTA_OUT = 8 KiB
14# WAN
15WAN_QUOTA_IN = 8 KiB
16WAN_QUOTA_OUT = 8 KiB
17# WLAN
18WLAN_QUOTA_IN = 8 KiB
19WLAN_QUOTA_OUT = 8 KiB
20# BLUETOOTH
21BLUETOOTH_QUOTA_IN = 8 KiB
22BLUETOOTH_QUOTA_OUT = 8 KiB
23
24[transport-tcp]
25PORT = 12015
26TIMEOUT = 5 s
27
28[arm]
29PORT = 12014
30DEFAULTSERVICES = transport
31UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p2-service-arm.sock
32
33[statistics]
34PORT = 12013
35UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p2-service-statistics.sock
36
37[resolver]
38PORT = 12012
39UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p2-service-resolver.sock
40
41[peerinfo]
42PORT = 12011
43UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p2-service-peerinfo.sock
44
45[transport]
46PORT = 12010
47PLUGINS = udp
48UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p2-service-transport.sock
49
diff --git a/src/transport/test_transport_test_transport_address_switch_tcp_peer1.conf b/src/transport/test_transport_test_transport_address_switch_tcp_peer1.conf
index d693704dc..17954c83c 100644
--- a/src/transport/test_transport_test_transport_address_switch_tcp_peer1.conf
+++ b/src/transport/test_transport_test_transport_address_switch_tcp_peer1.conf
@@ -1,4 +1,5 @@
1@INLINE@ template_cfg_peer1.conf 1@INLINE@ template_cfg_peer1.conf
2
2[ats] 3[ats]
3UNSPECIFIED_QUOTA_IN = 8 KiB 4UNSPECIFIED_QUOTA_IN = 8 KiB
4UNSPECIFIED_QUOTA_OUT = 8 KiB 5UNSPECIFIED_QUOTA_OUT = 8 KiB
@@ -18,7 +19,6 @@ WLAN_QUOTA_OUT = 8 KiB
18BLUETOOTH_QUOTA_IN = 8 KiB 19BLUETOOTH_QUOTA_IN = 8 KiB
19BLUETOOTH_QUOTA_OUT = 8 KiB 20BLUETOOTH_QUOTA_OUT = 8 KiB
20 21
21
22[PATHS] 22[PATHS]
23GNUNET_TEST_HOME = /tmp/test-transport/quota-tcp-p1/ 23GNUNET_TEST_HOME = /tmp/test-transport/quota-tcp-p1/
24 24