diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2010-11-17 15:58:30 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2010-11-17 15:58:30 +0000 |
commit | 8d1e110fce531925bf66a70722198081370799cd (patch) | |
tree | 7136b4259bc57ad3afca617afb04e3da17edd220 /src | |
parent | 8fb486de8ffe62372483e3941e67976f4cc77a83 (diff) | |
download | gnunet-8d1e110fce531925bf66a70722198081370799cd.tar.gz gnunet-8d1e110fce531925bf66a70722198081370799cd.zip |
Quota compliance testcases should ready to be commited...
Diffstat (limited to 'src')
-rw-r--r-- | src/core/Makefile.am | 33 | ||||
-rw-r--r-- | src/core/core.h | 4 | ||||
-rw-r--r-- | src/core/test_core_api.c | 2 | ||||
-rw-r--r-- | src/core/test_core_quota_compliance.c | 120 | ||||
-rw-r--r-- | src/core/test_core_quota_peer1.conf | 7 | ||||
-rw-r--r-- | src/core/test_core_quota_peer2.conf | 4 |
6 files changed, 141 insertions, 29 deletions
diff --git a/src/core/Makefile.am b/src/core/Makefile.am index 0b8a34ff9..de9616737 100644 --- a/src/core/Makefile.am +++ b/src/core/Makefile.am | |||
@@ -36,12 +36,14 @@ gnunet_service_core_LDADD = \ | |||
36 | $(top_builddir)/src/transport/libgnunettransport.la \ | 36 | $(top_builddir)/src/transport/libgnunettransport.la \ |
37 | $(top_builddir)/src/util/libgnunetutil.la \ | 37 | $(top_builddir)/src/util/libgnunetutil.la \ |
38 | $(GN_LIBINTL) | 38 | $(GN_LIBINTL) |
39 | 39 | ||
40 | |||
41 | check_PROGRAMS = \ | 40 | check_PROGRAMS = \ |
42 | test_core_api_start_only \ | 41 | test_core_api_start_only \ |
43 | test_core_api \ | 42 | test_core_api \ |
44 | test_core_api_reliability | 43 | test_core_api_reliability \ |
44 | test_core_quota_compliance_symmetric \ | ||
45 | test_core_quota_compliance_asymmetric_send_limited \ | ||
46 | test_core_quota_compliance_asymmetric_recv_limited | ||
45 | 47 | ||
46 | if !DISABLE_TEST_RUN | 48 | if !DISABLE_TEST_RUN |
47 | TESTS = $(check_PROGRAMS) | 49 | TESTS = $(check_PROGRAMS) |
@@ -65,8 +67,31 @@ test_core_api_start_only_SOURCES = \ | |||
65 | test_core_api_start_only.c | 67 | test_core_api_start_only.c |
66 | test_core_api_start_only_LDADD = \ | 68 | test_core_api_start_only_LDADD = \ |
67 | $(top_builddir)/src/core/libgnunetcore.la \ | 69 | $(top_builddir)/src/core/libgnunetcore.la \ |
68 | $(top_builddir)/src/util/libgnunetutil.la | 70 | $(top_builddir)/src/util/libgnunetutil.la |
71 | |||
72 | test_core_quota_compliance_symmetric_SOURCES = \ | ||
73 | test_core_quota_compliance.c | ||
74 | test_core_quota_compliance_symmetric_LDADD = \ | ||
75 | $(top_builddir)/src/core/libgnunetcore.la \ | ||
76 | $(top_builddir)/src/transport/libgnunettransport.la \ | ||
77 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
78 | $(top_builddir)/src/statistics/libgnunetstatistics.la | ||
69 | 79 | ||
80 | test_core_quota_compliance_asymmetric_send_limited_SOURCES = \ | ||
81 | test_core_quota_compliance.c | ||
82 | test_core_quota_compliance_asymmetric_send_limited_LDADD = \ | ||
83 | $(top_builddir)/src/core/libgnunetcore.la \ | ||
84 | $(top_builddir)/src/transport/libgnunettransport.la \ | ||
85 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
86 | $(top_builddir)/src/statistics/libgnunetstatistics.la | ||
87 | |||
88 | test_core_quota_compliance_asymmetric_recv_limited_SOURCES = \ | ||
89 | test_core_quota_compliance.c | ||
90 | test_core_quota_compliance_asymmetric_recv_limited_LDADD = \ | ||
91 | $(top_builddir)/src/core/libgnunetcore.la \ | ||
92 | $(top_builddir)/src/transport/libgnunettransport.la \ | ||
93 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
94 | $(top_builddir)/src/statistics/libgnunetstatistics.la | ||
70 | 95 | ||
71 | EXTRA_DIST = \ | 96 | EXTRA_DIST = \ |
72 | test_core_api_data.conf \ | 97 | test_core_api_data.conf \ |
diff --git a/src/core/core.h b/src/core/core.h index 6fd595b8b..a8d90b81a 100644 --- a/src/core/core.h +++ b/src/core/core.h | |||
@@ -41,12 +41,12 @@ | |||
41 | /** | 41 | /** |
42 | * General core debugging. | 42 | * General core debugging. |
43 | */ | 43 | */ |
44 | #define DEBUG_CORE GNUNET_YES | 44 | #define DEBUG_CORE GNUNET_NO |
45 | 45 | ||
46 | /** | 46 | /** |
47 | * Debugging interaction core-clients. | 47 | * Debugging interaction core-clients. |
48 | */ | 48 | */ |
49 | #define DEBUG_CORE_CLIENT GNUNET_YES | 49 | #define DEBUG_CORE_CLIENT GNUNET_NO |
50 | 50 | ||
51 | /** | 51 | /** |
52 | * Definition of bits in the InitMessage's options field that specify | 52 | * Definition of bits in the InitMessage's options field that specify |
diff --git a/src/core/test_core_api.c b/src/core/test_core_api.c index f153cb5eb..814ebe889 100644 --- a/src/core/test_core_api.c +++ b/src/core/test_core_api.c | |||
@@ -35,7 +35,6 @@ | |||
35 | #include "gnunet_transport_service.h" | 35 | #include "gnunet_transport_service.h" |
36 | 36 | ||
37 | #define VERBOSE GNUNET_NO | 37 | #define VERBOSE GNUNET_NO |
38 | |||
39 | #define START_ARM GNUNET_YES | 38 | #define START_ARM GNUNET_YES |
40 | 39 | ||
41 | #define MTYPE 12345 | 40 | #define MTYPE 12345 |
@@ -319,7 +318,6 @@ run (void *cls, | |||
319 | GNUNET_YES, &outbound_notify, GNUNET_YES, handlers); | 318 | GNUNET_YES, &outbound_notify, GNUNET_YES, handlers); |
320 | } | 319 | } |
321 | 320 | ||
322 | |||
323 | static void | 321 | static void |
324 | stop_arm (struct PeerContext *p) | 322 | stop_arm (struct PeerContext *p) |
325 | { | 323 | { |
diff --git a/src/core/test_core_quota_compliance.c b/src/core/test_core_quota_compliance.c index a54cf4e0b..efdcefac5 100644 --- a/src/core/test_core_quota_compliance.c +++ b/src/core/test_core_quota_compliance.c | |||
@@ -34,8 +34,9 @@ | |||
34 | #include "gnunet_program_lib.h" | 34 | #include "gnunet_program_lib.h" |
35 | #include "gnunet_scheduler_lib.h" | 35 | #include "gnunet_scheduler_lib.h" |
36 | #include "gnunet_transport_service.h" | 36 | #include "gnunet_transport_service.h" |
37 | #include "gnunet_statistics_service.h" | ||
37 | 38 | ||
38 | #define VERBOSE GNUNET_YES | 39 | #define VERBOSE GNUNET_NO |
39 | #define DEBUG_TRANSMISSION GNUNET_NO | 40 | #define DEBUG_TRANSMISSION GNUNET_NO |
40 | 41 | ||
41 | #define SYMMETRIC 0 | 42 | #define SYMMETRIC 0 |
@@ -84,6 +85,7 @@ struct PeerContext | |||
84 | struct GNUNET_PeerIdentity id; | 85 | struct GNUNET_PeerIdentity id; |
85 | struct GNUNET_TRANSPORT_Handle *th; | 86 | struct GNUNET_TRANSPORT_Handle *th; |
86 | struct GNUNET_MessageHeader *hello; | 87 | struct GNUNET_MessageHeader *hello; |
88 | struct GNUNET_STATISTICS_Handle *stats; | ||
87 | int connect_status; | 89 | int connect_status; |
88 | #if START_ARM | 90 | #if START_ARM |
89 | struct GNUNET_OS_Process *arm_proc; | 91 | struct GNUNET_OS_Process *arm_proc; |
@@ -151,6 +153,37 @@ terminate_task_error (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
151 | ok = 42; | 153 | ok = 42; |
152 | } | 154 | } |
153 | 155 | ||
156 | |||
157 | /** | ||
158 | * Callback function to process statistic values. | ||
159 | * | ||
160 | * @param cls closure | ||
161 | * @param subsystem name of subsystem that created the statistic | ||
162 | * @param name the name of the datum | ||
163 | * @param value the current value | ||
164 | * @param is_persistent GNUNET_YES if the value is persistent, GNUNET_NO if not | ||
165 | * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration | ||
166 | */ | ||
167 | static int | ||
168 | print_stat (void *cls, | ||
169 | const char *subsystem, | ||
170 | const char *name, | ||
171 | uint64_t value, | ||
172 | int is_persistent) | ||
173 | { | ||
174 | if (cls==&p1) | ||
175 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
176 | "Peer1 %50s = %12llu\n", | ||
177 | name, | ||
178 | (unsigned long long) value); | ||
179 | if (cls==&p2) | ||
180 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
181 | "Peer2 %50s = %12llu\n", | ||
182 | name, | ||
183 | (unsigned long long) value); | ||
184 | return GNUNET_OK; | ||
185 | } | ||
186 | |||
154 | static void | 187 | static void |
155 | measurement_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 188 | measurement_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
156 | { | 189 | { |
@@ -185,33 +218,86 @@ measurement_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
185 | quota_delta = max_quota_out / 10; | 218 | quota_delta = max_quota_out / 10; |
186 | 219 | ||
187 | if ((throughput_out < (max_quota_out/1024)) && (throughput_out < (max_quota_in/1024))) | 220 | if ((throughput_out < (max_quota_out/1024)) && (throughput_out < (max_quota_in/1024))) |
188 | { | ||
189 | ok = 0; | 221 | ok = 0; |
190 | } | ||
191 | else | 222 | else |
192 | { | ||
193 | ok = 1; | 223 | ok = 1; |
224 | |||
225 | GNUNET_STATISTICS_get (p1.stats, | ||
226 | "core", | ||
227 | "# discarded CORE_SEND requests", | ||
228 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
229 | NULL, | ||
230 | &print_stat, &p1); | ||
231 | |||
232 | GNUNET_STATISTICS_get (p1.stats, | ||
233 | "core", | ||
234 | "# discarded CORE_SEND request bytes", | ||
235 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
236 | NULL, | ||
237 | &print_stat, &p1); | ||
238 | GNUNET_STATISTICS_get (p1.stats, | ||
239 | "core", | ||
240 | "# discarded lower priority CORE_SEND requests", | ||
241 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
242 | NULL, | ||
243 | &print_stat, NULL); | ||
244 | GNUNET_STATISTICS_get (p1.stats, | ||
245 | "core", | ||
246 | "# discarded lower priority CORE_SEND request bytes", | ||
247 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
248 | NULL, | ||
249 | &print_stat, &p1); | ||
250 | GNUNET_STATISTICS_get (p2.stats, | ||
251 | "core", | ||
252 | "# discarded CORE_SEND requests", | ||
253 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
254 | NULL, | ||
255 | &print_stat, &p2); | ||
256 | |||
257 | GNUNET_STATISTICS_get (p2.stats, | ||
258 | "core", | ||
259 | "# discarded CORE_SEND request bytes", | ||
260 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
261 | NULL, | ||
262 | &print_stat, &p2); | ||
263 | GNUNET_STATISTICS_get (p2.stats, | ||
264 | "core", | ||
265 | "# discarded lower priority CORE_SEND requests", | ||
266 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
267 | NULL, | ||
268 | &print_stat, &p2); | ||
269 | GNUNET_STATISTICS_get (p2.stats, | ||
270 | "core", | ||
271 | "# discarded lower priority CORE_SEND request bytes", | ||
272 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
273 | NULL, | ||
274 | &print_stat, &p2); | ||
275 | |||
276 | enum GNUNET_ErrorType kind = GNUNET_ERROR_TYPE_DEBUG; | ||
277 | if (ok==1) | ||
278 | { | ||
279 | kind = GNUNET_ERROR_TYPE_ERROR; | ||
194 | } | 280 | } |
195 | switch (test) | 281 | switch (test) |
196 | { | 282 | { |
197 | case SYMMETRIC: | 283 | case SYMMETRIC: |
198 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Core quota compliance test with symmetric quotas\n"); | 284 | GNUNET_log (kind,"Core quota compliance test with symmetric quotas: %s\n", (ok==0)?"PASSED":"FAILED"); |
199 | break; | 285 | break; |
200 | case ASYMMETRIC_SEND_LIMITED: | 286 | case ASYMMETRIC_SEND_LIMITED: |
201 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Core quota compliance test with limited sender quota\n",throughput_in,total_bytes_recv, delta/1000); | 287 | GNUNET_log (kind,"Core quota compliance test with limited sender quota: %s\n", (ok==0)?"PASSED":"FAILED"); |
202 | break; | 288 | break; |
203 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Core quota compliance test with limited receiver quota\n",throughput_in,total_bytes_recv, delta/1000); | ||
204 | case ASYMMETRIC_RECV_LIMITED: | 289 | case ASYMMETRIC_RECV_LIMITED: |
290 | GNUNET_log (kind,"Core quota compliance test with limited receiver quota: %s\n", (ok==0)?"PASSED":"FAILED"); | ||
205 | break; | 291 | break; |
206 | }; | 292 | }; |
207 | 293 | GNUNET_log (kind,"Peer 1 send rate: %llu kB/s (%llu Bytes in %u sec.)\n",throughput_out,total_bytes_sent, delta/1000); | |
208 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Peer 1 send rate: %llu kB/s (%llu Bytes in %u sec.)\n",throughput_out,total_bytes_sent, delta/1000); | 294 | GNUNET_log (kind,"Peer 1 send quota: %llu kB/s\n",current_quota_p1_out / 1024); |
209 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Peer 2 receive rate: %llu kB/s (%llu Bytes in %u sec.)\n",throughput_in,total_bytes_recv, delta/1000); | 295 | GNUNET_log (kind,"Peer 2 receive rate: %llu kB/s (%llu Bytes in %u sec.)\n",throughput_in,total_bytes_recv, delta/1000); |
210 | 296 | GNUNET_log (kind,"Peer 2 receive quota: %llu kB/s\n",current_quota_p2_in / 1024); | |
211 | 297 | /* | |
212 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Max. inbound quota allowed: %llu kB/s\n",max_quota_in /1024); | 298 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Max. inbound quota allowed: %llu kB/s\n",max_quota_in /1024); |
213 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Max. outbound quota allowed: %llu kB/s\n",max_quota_out/1024); | 299 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Max. outbound quota allowed: %llu kB/s\n",max_quota_out/1024); |
214 | 300 | */ | |
215 | GNUNET_SCHEDULER_cancel (err_task); | 301 | GNUNET_SCHEDULER_cancel (err_task); |
216 | GNUNET_SCHEDULER_add_now (&terminate_task, NULL); | 302 | GNUNET_SCHEDULER_add_now (&terminate_task, NULL); |
217 | 303 | ||
@@ -293,6 +379,7 @@ connect_notify (void *cls, | |||
293 | "Asking core (1) for transmission to peer `%4s'\n", | 379 | "Asking core (1) for transmission to peer `%4s'\n", |
294 | GNUNET_i2s (&p2.id)); | 380 | GNUNET_i2s (&p2.id)); |
295 | #endif | 381 | #endif |
382 | if (err_task != GNUNET_SCHEDULER_NO_TASK) GNUNET_SCHEDULER_cancel (err_task); | ||
296 | err_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, | 383 | err_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, |
297 | &terminate_task_error, | 384 | &terminate_task_error, |
298 | NULL); | 385 | NULL); |
@@ -515,6 +602,8 @@ setup_peer (struct PeerContext *p, const char *cfgname) | |||
515 | "-c", cfgname, NULL); | 602 | "-c", cfgname, NULL); |
516 | #endif | 603 | #endif |
517 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); | 604 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); |
605 | p->stats = GNUNET_STATISTICS_create ("core",p->cfg); | ||
606 | GNUNET_assert (p->stats!=NULL); | ||
518 | p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, NULL, NULL); | 607 | p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, NULL, NULL); |
519 | GNUNET_assert (p->th != NULL); | 608 | GNUNET_assert (p->th != NULL); |
520 | GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p); | 609 | GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p); |
@@ -529,6 +618,9 @@ run (void *cls, | |||
529 | { | 618 | { |
530 | GNUNET_assert (ok == 1); | 619 | GNUNET_assert (ok == 1); |
531 | OKPP; | 620 | OKPP; |
621 | err_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, | ||
622 | &terminate_task_error, | ||
623 | NULL); | ||
532 | if (test == SYMMETRIC) | 624 | if (test == SYMMETRIC) |
533 | { | 625 | { |
534 | setup_peer (&p1, "test_core_quota_peer1.conf"); | 626 | setup_peer (&p1, "test_core_quota_peer1.conf"); |
@@ -640,8 +732,6 @@ main (int argc, char *argv[]) | |||
640 | "WARNING", | 732 | "WARNING", |
641 | #endif | 733 | #endif |
642 | NULL); | 734 | NULL); |
643 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
644 | "argv[0] %s",argv[0]); | ||
645 | ret = check (); | 735 | ret = check (); |
646 | GNUNET_DISK_directory_remove ("/tmp/test-gnunet-core-peer-1"); | 736 | GNUNET_DISK_directory_remove ("/tmp/test-gnunet-core-peer-1"); |
647 | GNUNET_DISK_directory_remove ("/tmp/test-gnunet-core-peer-2"); | 737 | GNUNET_DISK_directory_remove ("/tmp/test-gnunet-core-peer-2"); |
diff --git a/src/core/test_core_quota_peer1.conf b/src/core/test_core_quota_peer1.conf index 492a41b9d..5c0f853f1 100644 --- a/src/core/test_core_quota_peer1.conf +++ b/src/core/test_core_quota_peer1.conf | |||
@@ -1,6 +1,6 @@ | |||
1 | [PATHS] | 1 | [PATHS] |
2 | SERVICEHOME = /tmp/test-gnunet-core-peer-1/ | 2 | SERVICEHOME = /tmp/test-gnunet-core-quote-peer-1/ |
3 | DEFAULTCONFIG = test_core_api_peer1.conf | 3 | DEFAULTCONFIG = test_core_quota_peer1.conf |
4 | 4 | ||
5 | [resolver] | 5 | [resolver] |
6 | PORT = 12464 | 6 | PORT = 12464 |
@@ -50,8 +50,7 @@ UNIXPATH = /tmp/gnunet-p1-service-core.sock | |||
50 | #OPTIONS = -l log-core-1 | 50 | #OPTIONS = -l log-core-1 |
51 | #PREFIX = xterm -e xterm -T core1 -e gdb --args | 51 | #PREFIX = xterm -e xterm -T core1 -e gdb --args |
52 | #PREFIX = xterm -T core1 -e | 52 | #PREFIX = xterm -T core1 -e |
53 | #DEBUG = YES | 53 | DEBUG = NO |
54 | #BINARY=/home/grothoff/bin/gnunet-service-core | ||
55 | 54 | ||
56 | [testing] | 55 | [testing] |
57 | WEAKRANDOM = YES | 56 | WEAKRANDOM = YES |
diff --git a/src/core/test_core_quota_peer2.conf b/src/core/test_core_quota_peer2.conf index d9820ed1d..26f8e72f5 100644 --- a/src/core/test_core_quota_peer2.conf +++ b/src/core/test_core_quota_peer2.conf | |||
@@ -1,5 +1,5 @@ | |||
1 | [PATHS] | 1 | [PATHS] |
2 | SERVICEHOME = /tmp/test-gnunet-core-peer-2/ | 2 | SERVICEHOME = /tmp/test-gnunet-core-quote-peer-2/ |
3 | DEFAULTCONFIG = test_core_api_peer2.conf | 3 | DEFAULTCONFIG = test_core_api_peer2.conf |
4 | 4 | ||
5 | [resolver] | 5 | [resolver] |
@@ -49,7 +49,7 @@ TOTAL_QUOTA_OUT = 10240 | |||
49 | UNIXPATH = /tmp/gnunet-p2-service-core.sock | 49 | UNIXPATH = /tmp/gnunet-p2-service-core.sock |
50 | #PREFIX = xterm -T core2 -e | 50 | #PREFIX = xterm -T core2 -e |
51 | #PREFIX = valgrind --tool=memcheck | 51 | #PREFIX = valgrind --tool=memcheck |
52 | #DEBUG = YES | 52 | DEBUG = NO |
53 | #BINARY=/home/grothoff/bin/gnunet-service-core | 53 | #BINARY=/home/grothoff/bin/gnunet-service-core |
54 | 54 | ||
55 | [testing] | 55 | [testing] |