From 6cc39bc9d1e13c66495540ecde96414495102d6f Mon Sep 17 00:00:00 2001 From: Matthias Wachs Date: Fri, 29 Oct 2010 15:21:37 +0000 Subject: Added testcases for asymmetric quotas --- src/transport/Makefile.am | 37 +++++++++++++++++++++++++++-------- src/transport/test_quota_compliance.c | 30 +++++++++++++++++++++++++--- 2 files changed, 56 insertions(+), 11 deletions(-) diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am index a7d49d6e4..a5bf9dbe2 100644 --- a/src/transport/Makefile.am +++ b/src/transport/Makefile.am @@ -18,11 +18,13 @@ if HAVE_MHD HTTP_PLUGIN_TEST = test_plugin_transport_http HTTP_API_TEST = test_transport_api_http HTTP_REL_TEST = test_transport_api_reliability_http + HTTP_QUOTA_TEST = test_quota_compliance_http HTTPS_PLUGIN_LA = libgnunet_plugin_transport_https.la HTTPS_PLUGIN_TEST = test_plugin_transport_https HTTPS_API_TEST = test_transport_api_https - HTTPS_REL_TEST = test_transport_api_reliability_https + HTTPS_REL_TEST = test_transport_api_reliability_https + HTTPS_QUOTA_TEST = test_quota_compliance_https endif if USE_COVERAGE @@ -202,9 +204,11 @@ check_PROGRAMS = \ $(HTTP_REL_TEST) \ $(HTTPS_REL_TEST) \ test_quota_compliance_tcp \ - test_quota_compliance_http \ - test_quota_compliance_https \ - test_quota_compliance_udp + test_quota_compliance_tcp_asymmetric_recv_constant \ + test_quota_compliance_tcp_asymmetric_send_constant \ + test_quota_compliance_udp \ + $(HTTP_QUOTA_TEST) \ + $(HTTPS_QUOTA_TEST) # TODO: add tests for nat, etc. if !DISABLE_TEST_RUN @@ -222,9 +226,11 @@ TESTS = \ $(HTTP_REL_TEST) \ $(HTTPS_REL_TEST) \ test_quota_compliance_tcp \ - test_quota_compliance_http \ - test_quota_compliance_https \ - test_quota_compliance_udp + test_quota_compliance_tcp_asymmetric_recv_constant \ + test_quota_compliance_tcp_asymmetric_send_constant \ + test_quota_compliance_udp \ + $(HTTP_QUOTA_TEST) \ + $(HTTPS_QUOTA_TEST) endif test_transport_api_tcp_SOURCES = \ @@ -317,6 +323,18 @@ test_quota_compliance_tcp_LDADD = \ $(top_builddir)/src/transport/libgnunettransport.la \ $(top_builddir)/src/util/libgnunetutil.la +test_quota_compliance_tcp_asymmetric_recv_constant_SOURCES = \ + test_quota_compliance.c +test_quota_compliance_tcp_asymmetric_recv_constant_LDADD = \ + $(top_builddir)/src/transport/libgnunettransport.la \ + $(top_builddir)/src/util/libgnunetutil.la + + test_quota_compliance_tcp_asymmetric_send_constant_SOURCES = \ + test_quota_compliance.c +test_quota_compliance_tcp_asymmetric_send_constant_LDADD = \ + $(top_builddir)/src/transport/libgnunettransport.la \ + $(top_builddir)/src/util/libgnunetutil.la + test_quota_compliance_http_SOURCES = \ test_quota_compliance.c test_quota_compliance_http_LDADD = \ @@ -337,6 +355,7 @@ test_quota_compliance_udp_LDADD = \ endif + EXTRA_DIST = \ test_transport_api_data.conf \ test_transport_api_tcp_peer1.conf \ @@ -364,4 +383,6 @@ EXTRA_DIST = \ test_quota_compliance_http_peer1.conf \ test_quota_compliance_http_peer2.conf \ test_quota_compliance_https_peer1.conf \ - test_quota_compliance_https_peer2.conf \ No newline at end of file + test_quota_compliance_https_peer2.conf \ + test_quota_compliance_udp_peer1.conf \ + test_quota_compliance_udp_peer2.conf \ No newline at end of file diff --git a/src/transport/test_quota_compliance.c b/src/transport/test_quota_compliance.c index 087d72da0..3614fa0d7 100644 --- a/src/transport/test_quota_compliance.c +++ b/src/transport/test_quota_compliance.c @@ -137,6 +137,8 @@ static int is_tcp_nat; static int is_http; static int is_https; static int is_udp; +static int is_asymmetric_send_constant; +static int is_asymmetric_recv_constant; static struct GNUNET_TIME_Absolute start_time; @@ -397,7 +399,7 @@ measurement_end (void *cls, ok = 0; } - if (current_quota_p1 < MEASUREMENT_MIN_QUOTA) + if ((current_quota_p1 < MEASUREMENT_MIN_QUOTA) || (current_quota_p2 < MEASUREMENT_MIN_QUOTA)) { end(); return; @@ -408,7 +410,12 @@ measurement_end (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Scheduling next measurement\n"); #endif - measure (current_quota_p1 / 10, current_quota_p2 / 10); + if (is_asymmetric_send_constant == GNUNET_YES) + measure (current_quota_p1 / 10, MEASUREMENT_MAX_QUOTA); + else if (is_asymmetric_recv_constant == GNUNET_YES) + measure (MEASUREMENT_MAX_QUOTA, current_quota_p2 / 10); + else + measure (current_quota_p1 / 10, current_quota_p2 / 10); } } @@ -418,7 +425,7 @@ static void measure (unsigned long long quota_p1, unsigned long long quota_p2 ) current_quota_p2 = quota_p2; #if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Starting transport level measurement for %u seconds and quota %llu kB/s\n", MEASUREMENT_INTERVALL.rel_value / 1000 , current_quota_p1 / 1024); + "Starting transport level measurement for %u seconds and p1 quota %llu kB/s p2 quota %llu\n", MEASUREMENT_INTERVALL.rel_value / 1000 , current_quota_p1 / 1024, current_quota_p2 / 1024); #endif GNUNET_TRANSPORT_set_quota (p1.th, &p2.id, @@ -580,21 +587,25 @@ run (void *cls, if (is_tcp) { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing quota compliance for TCP transport plugin\n"); setup_peer (&p1, "test_quota_compliance_tcp_peer1.conf"); setup_peer (&p2, "test_quota_compliance_tcp_peer2.conf"); } else if (is_http) { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing quota compliance for HTTP transport plugin\n"); setup_peer (&p1, "test_quota_compliance_http_peer1.conf"); setup_peer (&p2, "test_quota_compliance_http_peer2.conf"); } else if (is_https) { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing quota compliance for HTTPS transport plugin\n"); setup_peer (&p1, "test_quota_compliance_https_peer1.conf"); setup_peer (&p2, "test_quota_compliance_https_peer2.conf"); } else if (is_udp) { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing quota compliance for UDP transport plugin\n"); setup_peer (&p1, "test_quota_compliance_udp_peer1.conf"); setup_peer (&p2, "test_quota_compliance_udp_peer2.conf"); } @@ -638,6 +649,7 @@ main (int argc, char *argv[]) { is_udp = GNUNET_YES; } + GNUNET_log_setup ("test-quota-compliance", #if VERBOSE "DEBUG", @@ -657,6 +669,18 @@ main (int argc, char *argv[]) GNUNET_GETOPT_OPTION_END }; + if (strstr(argv[0], "asymmetric_recv") != NULL) + { + is_asymmetric_recv_constant = GNUNET_YES; + } + else + is_asymmetric_recv_constant = GNUNET_NO; + if (strstr(argv[0], "asymmetric_send") != NULL) + { + is_asymmetric_send_constant = GNUNET_YES; + } + else + is_asymmetric_send_constant = GNUNET_NO; ok = 1; GNUNET_PROGRAM_run ((sizeof (argv1) / sizeof (char *)) - 1, argv1, "test-quota-compliance", "nohelp", -- cgit v1.2.3