diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2010-10-29 15:21:37 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2010-10-29 15:21:37 +0000 |
commit | 6cc39bc9d1e13c66495540ecde96414495102d6f (patch) | |
tree | 91acbdecdb521722608379a47d06f23e2febd38a | |
parent | c9147656de9142c516bc4a27b81bf49a683f0fe8 (diff) | |
download | gnunet-6cc39bc9d1e13c66495540ecde96414495102d6f.tar.gz gnunet-6cc39bc9d1e13c66495540ecde96414495102d6f.zip |
Added testcases for asymmetric quotas
-rw-r--r-- | src/transport/Makefile.am | 37 | ||||
-rw-r--r-- | 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 | |||
18 | HTTP_PLUGIN_TEST = test_plugin_transport_http | 18 | HTTP_PLUGIN_TEST = test_plugin_transport_http |
19 | HTTP_API_TEST = test_transport_api_http | 19 | HTTP_API_TEST = test_transport_api_http |
20 | HTTP_REL_TEST = test_transport_api_reliability_http | 20 | HTTP_REL_TEST = test_transport_api_reliability_http |
21 | HTTP_QUOTA_TEST = test_quota_compliance_http | ||
21 | 22 | ||
22 | HTTPS_PLUGIN_LA = libgnunet_plugin_transport_https.la | 23 | HTTPS_PLUGIN_LA = libgnunet_plugin_transport_https.la |
23 | HTTPS_PLUGIN_TEST = test_plugin_transport_https | 24 | HTTPS_PLUGIN_TEST = test_plugin_transport_https |
24 | HTTPS_API_TEST = test_transport_api_https | 25 | HTTPS_API_TEST = test_transport_api_https |
25 | HTTPS_REL_TEST = test_transport_api_reliability_https | 26 | HTTPS_REL_TEST = test_transport_api_reliability_https |
27 | HTTPS_QUOTA_TEST = test_quota_compliance_https | ||
26 | endif | 28 | endif |
27 | 29 | ||
28 | if USE_COVERAGE | 30 | if USE_COVERAGE |
@@ -202,9 +204,11 @@ check_PROGRAMS = \ | |||
202 | $(HTTP_REL_TEST) \ | 204 | $(HTTP_REL_TEST) \ |
203 | $(HTTPS_REL_TEST) \ | 205 | $(HTTPS_REL_TEST) \ |
204 | test_quota_compliance_tcp \ | 206 | test_quota_compliance_tcp \ |
205 | test_quota_compliance_http \ | 207 | test_quota_compliance_tcp_asymmetric_recv_constant \ |
206 | test_quota_compliance_https \ | 208 | test_quota_compliance_tcp_asymmetric_send_constant \ |
207 | test_quota_compliance_udp | 209 | test_quota_compliance_udp \ |
210 | $(HTTP_QUOTA_TEST) \ | ||
211 | $(HTTPS_QUOTA_TEST) | ||
208 | # TODO: add tests for nat, etc. | 212 | # TODO: add tests for nat, etc. |
209 | 213 | ||
210 | if !DISABLE_TEST_RUN | 214 | if !DISABLE_TEST_RUN |
@@ -222,9 +226,11 @@ TESTS = \ | |||
222 | $(HTTP_REL_TEST) \ | 226 | $(HTTP_REL_TEST) \ |
223 | $(HTTPS_REL_TEST) \ | 227 | $(HTTPS_REL_TEST) \ |
224 | test_quota_compliance_tcp \ | 228 | test_quota_compliance_tcp \ |
225 | test_quota_compliance_http \ | 229 | test_quota_compliance_tcp_asymmetric_recv_constant \ |
226 | test_quota_compliance_https \ | 230 | test_quota_compliance_tcp_asymmetric_send_constant \ |
227 | test_quota_compliance_udp | 231 | test_quota_compliance_udp \ |
232 | $(HTTP_QUOTA_TEST) \ | ||
233 | $(HTTPS_QUOTA_TEST) | ||
228 | endif | 234 | endif |
229 | 235 | ||
230 | test_transport_api_tcp_SOURCES = \ | 236 | test_transport_api_tcp_SOURCES = \ |
@@ -317,6 +323,18 @@ test_quota_compliance_tcp_LDADD = \ | |||
317 | $(top_builddir)/src/transport/libgnunettransport.la \ | 323 | $(top_builddir)/src/transport/libgnunettransport.la \ |
318 | $(top_builddir)/src/util/libgnunetutil.la | 324 | $(top_builddir)/src/util/libgnunetutil.la |
319 | 325 | ||
326 | test_quota_compliance_tcp_asymmetric_recv_constant_SOURCES = \ | ||
327 | test_quota_compliance.c | ||
328 | test_quota_compliance_tcp_asymmetric_recv_constant_LDADD = \ | ||
329 | $(top_builddir)/src/transport/libgnunettransport.la \ | ||
330 | $(top_builddir)/src/util/libgnunetutil.la | ||
331 | |||
332 | test_quota_compliance_tcp_asymmetric_send_constant_SOURCES = \ | ||
333 | test_quota_compliance.c | ||
334 | test_quota_compliance_tcp_asymmetric_send_constant_LDADD = \ | ||
335 | $(top_builddir)/src/transport/libgnunettransport.la \ | ||
336 | $(top_builddir)/src/util/libgnunetutil.la | ||
337 | |||
320 | test_quota_compliance_http_SOURCES = \ | 338 | test_quota_compliance_http_SOURCES = \ |
321 | test_quota_compliance.c | 339 | test_quota_compliance.c |
322 | test_quota_compliance_http_LDADD = \ | 340 | test_quota_compliance_http_LDADD = \ |
@@ -337,6 +355,7 @@ test_quota_compliance_udp_LDADD = \ | |||
337 | 355 | ||
338 | endif | 356 | endif |
339 | 357 | ||
358 | |||
340 | EXTRA_DIST = \ | 359 | EXTRA_DIST = \ |
341 | test_transport_api_data.conf \ | 360 | test_transport_api_data.conf \ |
342 | test_transport_api_tcp_peer1.conf \ | 361 | test_transport_api_tcp_peer1.conf \ |
@@ -364,4 +383,6 @@ EXTRA_DIST = \ | |||
364 | test_quota_compliance_http_peer1.conf \ | 383 | test_quota_compliance_http_peer1.conf \ |
365 | test_quota_compliance_http_peer2.conf \ | 384 | test_quota_compliance_http_peer2.conf \ |
366 | test_quota_compliance_https_peer1.conf \ | 385 | test_quota_compliance_https_peer1.conf \ |
367 | test_quota_compliance_https_peer2.conf \ No newline at end of file | 386 | test_quota_compliance_https_peer2.conf \ |
387 | test_quota_compliance_udp_peer1.conf \ | ||
388 | 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; | |||
137 | static int is_http; | 137 | static int is_http; |
138 | static int is_https; | 138 | static int is_https; |
139 | static int is_udp; | 139 | static int is_udp; |
140 | static int is_asymmetric_send_constant; | ||
141 | static int is_asymmetric_recv_constant; | ||
140 | 142 | ||
141 | static struct GNUNET_TIME_Absolute start_time; | 143 | static struct GNUNET_TIME_Absolute start_time; |
142 | 144 | ||
@@ -397,7 +399,7 @@ measurement_end (void *cls, | |||
397 | ok = 0; | 399 | ok = 0; |
398 | } | 400 | } |
399 | 401 | ||
400 | if (current_quota_p1 < MEASUREMENT_MIN_QUOTA) | 402 | if ((current_quota_p1 < MEASUREMENT_MIN_QUOTA) || (current_quota_p2 < MEASUREMENT_MIN_QUOTA)) |
401 | { | 403 | { |
402 | end(); | 404 | end(); |
403 | return; | 405 | return; |
@@ -408,7 +410,12 @@ measurement_end (void *cls, | |||
408 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 410 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
409 | "Scheduling next measurement\n"); | 411 | "Scheduling next measurement\n"); |
410 | #endif | 412 | #endif |
411 | measure (current_quota_p1 / 10, current_quota_p2 / 10); | 413 | if (is_asymmetric_send_constant == GNUNET_YES) |
414 | measure (current_quota_p1 / 10, MEASUREMENT_MAX_QUOTA); | ||
415 | else if (is_asymmetric_recv_constant == GNUNET_YES) | ||
416 | measure (MEASUREMENT_MAX_QUOTA, current_quota_p2 / 10); | ||
417 | else | ||
418 | measure (current_quota_p1 / 10, current_quota_p2 / 10); | ||
412 | } | 419 | } |
413 | } | 420 | } |
414 | 421 | ||
@@ -418,7 +425,7 @@ static void measure (unsigned long long quota_p1, unsigned long long quota_p2 ) | |||
418 | current_quota_p2 = quota_p2; | 425 | current_quota_p2 = quota_p2; |
419 | #if VERBOSE | 426 | #if VERBOSE |
420 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 427 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
421 | "Starting transport level measurement for %u seconds and quota %llu kB/s\n", MEASUREMENT_INTERVALL.rel_value / 1000 , current_quota_p1 / 1024); | 428 | "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); |
422 | #endif | 429 | #endif |
423 | GNUNET_TRANSPORT_set_quota (p1.th, | 430 | GNUNET_TRANSPORT_set_quota (p1.th, |
424 | &p2.id, | 431 | &p2.id, |
@@ -580,21 +587,25 @@ run (void *cls, | |||
580 | 587 | ||
581 | if (is_tcp) | 588 | if (is_tcp) |
582 | { | 589 | { |
590 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing quota compliance for TCP transport plugin\n"); | ||
583 | setup_peer (&p1, "test_quota_compliance_tcp_peer1.conf"); | 591 | setup_peer (&p1, "test_quota_compliance_tcp_peer1.conf"); |
584 | setup_peer (&p2, "test_quota_compliance_tcp_peer2.conf"); | 592 | setup_peer (&p2, "test_quota_compliance_tcp_peer2.conf"); |
585 | } | 593 | } |
586 | else if (is_http) | 594 | else if (is_http) |
587 | { | 595 | { |
596 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing quota compliance for HTTP transport plugin\n"); | ||
588 | setup_peer (&p1, "test_quota_compliance_http_peer1.conf"); | 597 | setup_peer (&p1, "test_quota_compliance_http_peer1.conf"); |
589 | setup_peer (&p2, "test_quota_compliance_http_peer2.conf"); | 598 | setup_peer (&p2, "test_quota_compliance_http_peer2.conf"); |
590 | } | 599 | } |
591 | else if (is_https) | 600 | else if (is_https) |
592 | { | 601 | { |
602 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing quota compliance for HTTPS transport plugin\n"); | ||
593 | setup_peer (&p1, "test_quota_compliance_https_peer1.conf"); | 603 | setup_peer (&p1, "test_quota_compliance_https_peer1.conf"); |
594 | setup_peer (&p2, "test_quota_compliance_https_peer2.conf"); | 604 | setup_peer (&p2, "test_quota_compliance_https_peer2.conf"); |
595 | } | 605 | } |
596 | else if (is_udp) | 606 | else if (is_udp) |
597 | { | 607 | { |
608 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing quota compliance for UDP transport plugin\n"); | ||
598 | setup_peer (&p1, "test_quota_compliance_udp_peer1.conf"); | 609 | setup_peer (&p1, "test_quota_compliance_udp_peer1.conf"); |
599 | setup_peer (&p2, "test_quota_compliance_udp_peer2.conf"); | 610 | setup_peer (&p2, "test_quota_compliance_udp_peer2.conf"); |
600 | } | 611 | } |
@@ -638,6 +649,7 @@ main (int argc, char *argv[]) | |||
638 | { | 649 | { |
639 | is_udp = GNUNET_YES; | 650 | is_udp = GNUNET_YES; |
640 | } | 651 | } |
652 | |||
641 | GNUNET_log_setup ("test-quota-compliance", | 653 | GNUNET_log_setup ("test-quota-compliance", |
642 | #if VERBOSE | 654 | #if VERBOSE |
643 | "DEBUG", | 655 | "DEBUG", |
@@ -657,6 +669,18 @@ main (int argc, char *argv[]) | |||
657 | GNUNET_GETOPT_OPTION_END | 669 | GNUNET_GETOPT_OPTION_END |
658 | }; | 670 | }; |
659 | 671 | ||
672 | if (strstr(argv[0], "asymmetric_recv") != NULL) | ||
673 | { | ||
674 | is_asymmetric_recv_constant = GNUNET_YES; | ||
675 | } | ||
676 | else | ||
677 | is_asymmetric_recv_constant = GNUNET_NO; | ||
678 | if (strstr(argv[0], "asymmetric_send") != NULL) | ||
679 | { | ||
680 | is_asymmetric_send_constant = GNUNET_YES; | ||
681 | } | ||
682 | else | ||
683 | is_asymmetric_send_constant = GNUNET_NO; | ||
660 | ok = 1; | 684 | ok = 1; |
661 | GNUNET_PROGRAM_run ((sizeof (argv1) / sizeof (char *)) - 1, | 685 | GNUNET_PROGRAM_run ((sizeof (argv1) / sizeof (char *)) - 1, |
662 | argv1, "test-quota-compliance", "nohelp", | 686 | argv1, "test-quota-compliance", "nohelp", |