From a418678c67157ac54e7bcaff76ed87e7829ad567 Mon Sep 17 00:00:00 2001 From: Matthias Wachs Date: Tue, 20 May 2014 16:00:16 +0000 Subject: address switch test --- src/transport/Makefile.am | 42 +++++++++++++++++++ src/transport/test_transport_address_switch.c | 47 +++++++++++++++++++++ .../test_transport_address_switch_udp_peer1.conf | 49 ++++++++++++++++++++++ .../test_transport_address_switch_udp_peer2.conf | 49 ++++++++++++++++++++++ ...rt_test_transport_address_switch_tcp_peer1.conf | 2 +- 5 files changed, 188 insertions(+), 1 deletion(-) create mode 100644 src/transport/test_transport_address_switch_udp_peer1.conf create mode 100644 src/transport/test_transport_address_switch_udp_peer2.conf 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 HTTP_REL_TEST = test_transport_api_reliability_http HTTP_QUOTA_TEST = test_quota_compliance_http \ test_quota_compliance_http_asymmetric + HTTP_SWITCH = test_transport_address_switch_http HTTPS_API_TEST = test_transport_api_https HTTPS_API_TIMEOUT_TEST = test_transport_api_timeout_https HTTPS_REL_TEST = test_transport_api_reliability_https HTTPS_QUOTA_TEST = test_quota_compliance_https \ test_quota_compliance_https_asymmetric + HTTPS_SWITCH = test_transport_address_switch_https endif endif @@ -402,6 +404,7 @@ check_PROGRAMS = \ test_transport_api_tcp_nat \ test_transport_api_udp \ test_transport_api_timeout_udp \ + test_transport_address_switch_udp \ $(UNIX_PLUGIN_TEST) \ $(UNIX_PLUGIN_TIMEOUT_TEST) \ $(UNIX_API_ABSTRACT_TEST) \ @@ -409,8 +412,10 @@ check_PROGRAMS = \ $(HTTP_API_TEST) \ $(HTTP_REVERSE_API_TEST) \ $(HTTP_API_TIMEOUT_TEST) \ + $(HTTP_SWITCH) \ $(HTTPS_API_TEST) \ $(HTTPS_API_TIMEOUT_TEST) \ + $(HTTPS_SWITCH) \ $(WLAN_API_TEST) \ $(WLAN_TIMEOUT_TEST) \ $(BT_API_TEST) \ @@ -470,14 +475,17 @@ TESTS = \ test_transport_api_tcp_nat \ test_transport_api_udp \ test_transport_api_timeout_udp \ + test_transport_address_switch_udp \ $(UNIX_PLUGIN_TEST) \ $(UNIX_PLUGIN_TIMEOUT_TEST) \ $(UNIX_API_ABSTRACT_TEST) \ test_transport_api_udp_nat \ $(HTTP_API_TEST) \ $(HTTP_API_TIMEOUT_TEST) \ + $(HTTP_SWITCH) \ $(HTTPS_API_TEST) \ $(HTTPS_API_TIMEOUT_TEST) \ + $(HTTPS_SWITCH) \ $(WLAN_API_TEST) \ $(WLAN_TIMEOUT_TEST) \ $(BT_API_TEST) \ @@ -1023,6 +1031,34 @@ test_transport_address_switch_tcp_LDADD = \ $(top_builddir)/src/statistics/libgnunetstatistics.la \ $(top_builddir)/src/util/libgnunetutil.la \ $(top_builddir)/src/transport/libgnunettransporttesting.la + + test_transport_address_switch_udp_SOURCES = \ + test_transport_address_switch.c +test_transport_address_switch_udp_LDADD = \ + $(top_builddir)/src/transport/libgnunettransport.la \ + $(top_builddir)/src/hello/libgnunethello.la \ + $(top_builddir)/src/statistics/libgnunetstatistics.la \ + $(top_builddir)/src/util/libgnunetutil.la \ + $(top_builddir)/src/transport/libgnunettransporttesting.la + + + test_transport_address_switch_http_SOURCES = \ + test_transport_address_switch.c +test_transport_address_switch_http_LDADD = \ + $(top_builddir)/src/transport/libgnunettransport.la \ + $(top_builddir)/src/hello/libgnunethello.la \ + $(top_builddir)/src/statistics/libgnunetstatistics.la \ + $(top_builddir)/src/util/libgnunetutil.la \ + $(top_builddir)/src/transport/libgnunettransporttesting.la + + test_transport_address_switch_https_SOURCES = \ + test_transport_address_switch.c +test_transport_address_switch_https_LDADD = \ + $(top_builddir)/src/transport/libgnunettransport.la \ + $(top_builddir)/src/hello/libgnunethello.la \ + $(top_builddir)/src/statistics/libgnunetstatistics.la \ + $(top_builddir)/src/util/libgnunetutil.la \ + $(top_builddir)/src/transport/libgnunettransporttesting.la test_quota_compliance_tcp_SOURCES = \ test_quota_compliance.c @@ -1215,6 +1251,12 @@ test_transport_api_reliability_wlan_peer1.conf\ test_transport_api_reliability_wlan_peer2.conf\ test_transport_api_reliability_bluetooth_peer1.conf\ test_transport_api_reliability_bluetooth_peer2.conf\ +test_transport_test_transport_address_switch_http_peer1.conf\ +test_transport_test_transport_address_switch_http_peer2.conf\ +test_transport_test_transport_address_switch_https_peer1.conf\ +test_transport_test_transport_address_switch_https_peer2.conf\ +test_transport_test_transport_address_switch_udp_peer1.conf\ +test_transport_test_transport_address_switch_udp_peer2.conf\ test_transport_test_transport_address_switch_tcp_peer1.conf\ test_transport_test_transport_address_switch_tcp_peer2.conf\ test_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; static unsigned int p1_switch_attempts; static unsigned int p1_switch_success; static unsigned int p1_switch_fail; +static unsigned int p1_addresses_avail; static unsigned int p2_switch_attempts; static unsigned int p2_switch_success; static unsigned int p2_switch_fail; +static unsigned int p2_addresses_avail; static unsigned long long bytes_sent_total; static unsigned long long bytes_recv_total; @@ -169,6 +171,9 @@ static int stat_fail_attempt_cb (void *cls, const char *subsystem, const char *name, uint64_t value, int is_persistent) { + if (value == 0) + return GNUNET_OK; + if (cls == p1) { p1_switch_fail++; @@ -183,6 +188,21 @@ stat_fail_attempt_cb (void *cls, const char *subsystem, const char *name, return GNUNET_OK; } +static int +stat_addresses_available (void *cls, const char *subsystem, const char *name, + uint64_t value, int is_persistent) +{ + if (cls == p1) + { + p1_addresses_avail++; + } + if (cls == p2) + { + p2_addresses_avail++; + } + + return GNUNET_OK; +} static void clean_up () @@ -220,6 +240,9 @@ clean_up () GNUNET_STATISTICS_watch_cancel (p1_stat, "transport", "# Failed attempts to switch addresses (no response)", stat_fail_attempt_cb, p1); + GNUNET_STATISTICS_watch (p1_stat, "transport", + "# transport addresses", + stat_addresses_available, p1); GNUNET_STATISTICS_destroy (p1_stat, GNUNET_NO); p1_stat = NULL; } @@ -238,6 +261,9 @@ clean_up () GNUNET_STATISTICS_watch_cancel (p2_stat, "transport", "# Failed attempts to switch addresses (no response)", stat_fail_attempt_cb, p2); + GNUNET_STATISTICS_watch (p1_stat, "transport", + "# transport addresses", + stat_addresses_available, p1); GNUNET_STATISTICS_destroy (p2_stat, GNUNET_NO); p2_stat = NULL; } @@ -289,6 +315,11 @@ end () if (p1_switch_success != p1_switch_attempts) result ++; } + else + { + FPRINTF (stderr, "Peer 1 had %u addresses available, but did not try to switch\n", + p1_addresses_avail); + } if (p2_switch_attempts > 0) { FPRINTF (stderr, "Peer 2 tried %u times to switch and succeeded %u times, failed %u times\n", @@ -296,6 +327,11 @@ end () if (p2_switch_success != p2_switch_attempts) result ++; } + else + { + FPRINTF (stderr, "Peer 2 had %u addresses available, but did not try to switch\n", + p2_addresses_avail); + } if ( ((p1_switch_attempts > 0) || (p2_switch_attempts > 0)) && (bytes_sent_after_switch == 0) ) @@ -322,6 +358,11 @@ end_badly () die_task = GNUNET_SCHEDULER_NO_TASK; GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Fail! Stopping peers\n"); + FPRINTF (stderr, "Peer 1 had %u addresses available, but did not try to switch\n", + p1_addresses_avail); + FPRINTF (stderr, "Peer 2 had %u addresses available, but did not try to switch\n", + p2_addresses_avail); + if (test_connected == GNUNET_YES) GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Peers got connected\n"); else @@ -566,6 +607,9 @@ run (void *cls, char * const *args, const char *cfgfile, GNUNET_STATISTICS_watch (p1_stat, "transport", "# Failed attempts to switch addresses (no response)", stat_fail_attempt_cb, p1); + GNUNET_STATISTICS_watch (p1_stat, "transport", + "# transport addresses", + stat_addresses_available, p1); p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2, ¬ify_receive, ¬ify_connect, ¬ify_disconnect, &start_cb, NULL ); @@ -586,6 +630,9 @@ run (void *cls, char * const *args, const char *cfgfile, GNUNET_STATISTICS_watch (p2_stat, "transport", "# Failed attempts to switch addresses (no response)", stat_fail_attempt_cb, p2); + GNUNET_STATISTICS_watch (p2_stat, "transport", + "# transport addresses", + stat_addresses_available, p2); if ((p1 == NULL )|| (p2 == NULL)) { 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 @@ +@INLINE@ template_cfg_peer1.conf +[PATHS] +GNUNET_TEST_HOME = /tmp/test-transport/api-tcp-p1/ + +[ats] +UNSPECIFIED_QUOTA_IN = 8 KiB +UNSPECIFIED_QUOTA_OUT = 8 KiB +# LOOPBACK +LOOPBACK_QUOTA_IN = 8 KiB +LOOPBACK_QUOTA_OUT = 8 KiB +# LAN +LAN_QUOTA_IN = 8 KiB +LAN_QUOTA_OUT = 8 KiB +# WAN +WAN_QUOTA_IN = 8 KiB +WAN_QUOTA_OUT = 8 KiB +# WLAN +WLAN_QUOTA_IN = 8 KiB +WLAN_QUOTA_OUT = 8 KiB +# BLUETOOTH +BLUETOOTH_QUOTA_IN = 8 KiB +BLUETOOTH_QUOTA_OUT = 8 KiB + +[transport-tcp] +PORT = 12000 +TIMEOUT = 5 s + +[arm] +PORT = 12005 +DEFAULTSERVICES = transport +UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p1-service-arm.sock + +[statistics] +PORT = 12004 +UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p1-service-statistics.sock + +[resolver] +PORT = 12003 +UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p1-service-resolver.sock + +[peerinfo] +PORT = 12002 +UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p1-service-peerinfo.sock + +[transport] +PORT = 12001 +UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p1-service-transport.sock +PLUGINS = udp + 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 @@ +@INLINE@ template_cfg_peer2.conf +[PATHS] +GNUNET_TEST_HOME = /tmp/test-transport/api-tcp-p2/ + +[ats] +UNSPECIFIED_QUOTA_IN = 8 KiB +UNSPECIFIED_QUOTA_OUT = 8 KiB +# LOOPBACK +LOOPBACK_QUOTA_IN = 8 KiB +LOOPBACK_QUOTA_OUT = 8 KiB +# LAN +LAN_QUOTA_IN = 8 KiB +LAN_QUOTA_OUT = 8 KiB +# WAN +WAN_QUOTA_IN = 8 KiB +WAN_QUOTA_OUT = 8 KiB +# WLAN +WLAN_QUOTA_IN = 8 KiB +WLAN_QUOTA_OUT = 8 KiB +# BLUETOOTH +BLUETOOTH_QUOTA_IN = 8 KiB +BLUETOOTH_QUOTA_OUT = 8 KiB + +[transport-tcp] +PORT = 12015 +TIMEOUT = 5 s + +[arm] +PORT = 12014 +DEFAULTSERVICES = transport +UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p2-service-arm.sock + +[statistics] +PORT = 12013 +UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p2-service-statistics.sock + +[resolver] +PORT = 12012 +UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p2-service-resolver.sock + +[peerinfo] +PORT = 12011 +UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p2-service-peerinfo.sock + +[transport] +PORT = 12010 +PLUGINS = udp +UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p2-service-transport.sock + 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 @@ @INLINE@ template_cfg_peer1.conf + [ats] UNSPECIFIED_QUOTA_IN = 8 KiB UNSPECIFIED_QUOTA_OUT = 8 KiB @@ -18,7 +19,6 @@ WLAN_QUOTA_OUT = 8 KiB BLUETOOTH_QUOTA_IN = 8 KiB BLUETOOTH_QUOTA_OUT = 8 KiB - [PATHS] GNUNET_TEST_HOME = /tmp/test-transport/quota-tcp-p1/ -- cgit v1.2.3