diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2012-04-04 16:10:41 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2012-04-04 16:10:41 +0000 |
commit | 5f6cd00d4d79dbf8eef6d0b9be1b13c249eb54bd (patch) | |
tree | ce55ba353f55467c65113b9aa376f2f4f60da084 /src/integration-tests | |
parent | e4ecd9c418c7272de727e6ab388c1cfe7584001f (diff) | |
download | gnunet-5f6cd00d4d79dbf8eef6d0b9be1b13c249eb54bd.tar.gz gnunet-5f6cd00d4d79dbf8eef6d0b9be1b13c249eb54bd.zip |
- added check against statistics
Diffstat (limited to 'src/integration-tests')
-rw-r--r-- | src/integration-tests/Makefile.am | 1 | ||||
-rw-r--r-- | src/integration-tests/connection_watchdog.c | 138 |
2 files changed, 133 insertions, 6 deletions
diff --git a/src/integration-tests/Makefile.am b/src/integration-tests/Makefile.am index 31f82170b..68dc5a63f 100644 --- a/src/integration-tests/Makefile.am +++ b/src/integration-tests/Makefile.am | |||
@@ -44,6 +44,7 @@ endif | |||
44 | connection_watchdog_SOURCE = \ | 44 | connection_watchdog_SOURCE = \ |
45 | connection_watchdog.c | 45 | connection_watchdog.c |
46 | connection_watchdog_LDADD = \ | 46 | connection_watchdog_LDADD = \ |
47 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | ||
47 | $(top_builddir)/src/core/libgnunetcore.la \ | 48 | $(top_builddir)/src/core/libgnunetcore.la \ |
48 | $(top_builddir)/src/transport/libgnunettransport.la \ | 49 | $(top_builddir)/src/transport/libgnunettransport.la \ |
49 | $(top_builddir)/src/util/libgnunetutil.la | 50 | $(top_builddir)/src/util/libgnunetutil.la |
diff --git a/src/integration-tests/connection_watchdog.c b/src/integration-tests/connection_watchdog.c index 82ed56ba9..7cb8810c8 100644 --- a/src/integration-tests/connection_watchdog.c +++ b/src/integration-tests/connection_watchdog.c | |||
@@ -36,22 +36,34 @@ | |||
36 | 36 | ||
37 | 37 | ||
38 | #define CHECK_DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) | 38 | #define CHECK_DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) |
39 | #define STATS_DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) | ||
40 | #define REPEATED_STATS_DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) | ||
41 | #define STATS_VALUES 4 | ||
39 | 42 | ||
40 | /** | 43 | /** |
41 | * Final status code. | 44 | * Final status code. |
42 | */ | 45 | */ |
43 | static int ret; | 46 | static int ret; |
44 | static int retry; | ||
45 | 47 | ||
46 | struct GNUNET_TRANSPORT_Handle *th; | 48 | static struct GNUNET_TRANSPORT_Handle *th; |
47 | struct GNUNET_CORE_Handle *ch; | 49 | static struct GNUNET_CORE_Handle *ch; |
48 | struct GNUNET_PeerIdentity my_peer_id; | 50 | static struct GNUNET_PeerIdentity my_peer_id; |
51 | static const struct GNUNET_CONFIGURATION_Handle *mycfg; | ||
52 | static struct GNUNET_STATISTICS_Handle *stats; | ||
53 | |||
49 | 54 | ||
50 | static unsigned int transport_connections; | 55 | static unsigned int transport_connections; |
51 | static unsigned int core_connections; | 56 | static unsigned int core_connections; |
52 | 57 | ||
53 | static GNUNET_SCHEDULER_TaskIdentifier check_task; | 58 | static GNUNET_SCHEDULER_TaskIdentifier check_task; |
59 | static GNUNET_SCHEDULER_TaskIdentifier statistics_task; | ||
60 | |||
61 | static uint64_t statistics_transport_connections; | ||
62 | static uint64_t statistics_transport_tcp_connections; | ||
63 | static uint64_t statistics_core_neighbour_entries; | ||
64 | static uint64_t statistics_core_entries_session_map; | ||
54 | 65 | ||
66 | int stat_check_running; | ||
55 | 67 | ||
56 | static struct GNUNET_CONTAINER_MultiHashMap *peers; | 68 | static struct GNUNET_CONTAINER_MultiHashMap *peers; |
57 | 69 | ||
@@ -106,8 +118,13 @@ map_check (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
106 | int fail = 0; | 118 | int fail = 0; |
107 | check_task = GNUNET_SCHEDULER_NO_TASK; | 119 | check_task = GNUNET_SCHEDULER_NO_TASK; |
108 | GNUNET_CONTAINER_multihashmap_iterate (peers, &map_check_it, &fail); | 120 | GNUNET_CONTAINER_multihashmap_iterate (peers, &map_check_it, &fail); |
109 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 121 | if (0 > fail) |
122 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
110 | "Inconsistent peers after connection consistency check: %u\n", fail); | 123 | "Inconsistent peers after connection consistency check: %u\n", fail); |
124 | else | ||
125 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
126 | "Inconsistent peers after connection consistency check: %u\n", fail); | ||
127 | |||
111 | 128 | ||
112 | if (NULL != cls) | 129 | if (NULL != cls) |
113 | { | 130 | { |
@@ -116,6 +133,101 @@ map_check (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
116 | } | 133 | } |
117 | 134 | ||
118 | static void | 135 | static void |
136 | stats_check (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | ||
137 | |||
138 | int stats_check_cb (void *cls, const char *subsystem, | ||
139 | const char *name, uint64_t value, | ||
140 | int is_persistent) | ||
141 | { | ||
142 | static int counter; | ||
143 | uint64_t *val = cls; | ||
144 | |||
145 | if (NULL != val) | ||
146 | (*val) = value; | ||
147 | |||
148 | counter ++; | ||
149 | if (STATS_VALUES == counter) | ||
150 | { | ||
151 | int fail = GNUNET_NO; | ||
152 | if (transport_connections != core_connections) | ||
153 | { | ||
154 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
155 | "Transport connections are inconsistent: %u transport notifications <-> %u core notifications\n", | ||
156 | transport_connections, core_connections); | ||
157 | fail = GNUNET_YES; | ||
158 | } | ||
159 | |||
160 | if (transport_connections != statistics_transport_connections) | ||
161 | { | ||
162 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
163 | "Transport connections are inconsistent: %u transport notifications <-> %u in statistics (peers connected)\n", | ||
164 | transport_connections, statistics_transport_connections); | ||
165 | fail = GNUNET_YES; | ||
166 | } | ||
167 | |||
168 | if (transport_connections != statistics_transport_tcp_connections) | ||
169 | { | ||
170 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
171 | "Transport connections are inconsistent: %u transport notifications <-> %u in statistics (statistics_transport_tcp_connections)\n", | ||
172 | transport_connections, statistics_transport_tcp_connections); | ||
173 | fail = GNUNET_YES; | ||
174 | } | ||
175 | |||
176 | if (core_connections != statistics_core_entries_session_map) | ||
177 | { | ||
178 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
179 | "Transport connections are inconsistent: %u core notifications <-> %u in statistics (entries session map)\n", | ||
180 | core_connections, statistics_core_entries_session_map); | ||
181 | fail = GNUNET_YES; | ||
182 | } | ||
183 | |||
184 | if (core_connections != statistics_core_neighbour_entries) | ||
185 | { | ||
186 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
187 | "Transport connections are inconsistent: %u core notifications <-> %u in statistics (neighbour entries allocated)\n", | ||
188 | core_connections, statistics_core_neighbour_entries); | ||
189 | fail = GNUNET_YES; | ||
190 | } | ||
191 | |||
192 | if (GNUNET_NO == fail) | ||
193 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
194 | "Statistics consistency check successful : (%u transport / %u core) connections established\n", transport_connections, core_connections); | ||
195 | |||
196 | |||
197 | if (GNUNET_SCHEDULER_NO_TASK == statistics_task) | ||
198 | statistics_task = GNUNET_SCHEDULER_add_delayed(REPEATED_STATS_DELAY, &stats_check, NULL); | ||
199 | |||
200 | stat_check_running = GNUNET_NO; | ||
201 | counter = 0; | ||
202 | } | ||
203 | |||
204 | return GNUNET_OK; | ||
205 | } | ||
206 | |||
207 | static void | ||
208 | stats_check (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
209 | { | ||
210 | statistics_task = GNUNET_SCHEDULER_NO_TASK; | ||
211 | |||
212 | if (GNUNET_YES == stat_check_running) | ||
213 | { | ||
214 | statistics_task = GNUNET_SCHEDULER_add_delayed(STATS_DELAY, &stats_check, NULL); | ||
215 | } | ||
216 | |||
217 | stat_check_running = GNUNET_YES; | ||
218 | |||
219 | statistics_transport_connections = 0 ; | ||
220 | statistics_core_entries_session_map = 0; | ||
221 | statistics_core_neighbour_entries = 0; | ||
222 | |||
223 | GNUNET_STATISTICS_get (stats, "transport", "# peers connected", GNUNET_TIME_UNIT_MINUTES, NULL, &stats_check_cb, &statistics_transport_connections); | ||
224 | GNUNET_STATISTICS_get (stats, "transport", "# TCP sessions active", GNUNET_TIME_UNIT_MINUTES, NULL, &stats_check_cb, &statistics_transport_tcp_connections); | ||
225 | GNUNET_STATISTICS_get (stats, "core", "# neighbour entries allocated", GNUNET_TIME_UNIT_MINUTES, NULL, &stats_check_cb, &statistics_core_neighbour_entries); | ||
226 | GNUNET_STATISTICS_get (stats, "core", "# entries in session map", GNUNET_TIME_UNIT_MINUTES, NULL, &stats_check_cb, &statistics_core_entries_session_map); | ||
227 | } | ||
228 | |||
229 | |||
230 | static void | ||
119 | map_connect (const struct GNUNET_PeerIdentity *peer, void * source) | 231 | map_connect (const struct GNUNET_PeerIdentity *peer, void * source) |
120 | { | 232 | { |
121 | struct PeerContainer * pc; | 233 | struct PeerContainer * pc; |
@@ -164,6 +276,10 @@ map_connect (const struct GNUNET_PeerIdentity *peer, void * source) | |||
164 | if (GNUNET_SCHEDULER_NO_TASK != check_task) | 276 | if (GNUNET_SCHEDULER_NO_TASK != check_task) |
165 | GNUNET_SCHEDULER_cancel(check_task); | 277 | GNUNET_SCHEDULER_cancel(check_task); |
166 | check_task = GNUNET_SCHEDULER_add_delayed(CHECK_DELAY, &map_check, NULL); | 278 | check_task = GNUNET_SCHEDULER_add_delayed(CHECK_DELAY, &map_check, NULL); |
279 | |||
280 | if (GNUNET_SCHEDULER_NO_TASK != statistics_task) | ||
281 | GNUNET_SCHEDULER_cancel(statistics_task); | ||
282 | statistics_task = GNUNET_SCHEDULER_add_delayed(STATS_DELAY, &stats_check, NULL); | ||
167 | } | 283 | } |
168 | 284 | ||
169 | 285 | ||
@@ -236,6 +352,9 @@ map_disconnect (const struct GNUNET_PeerIdentity * peer, void * source) | |||
236 | GNUNET_SCHEDULER_cancel(check_task); | 352 | GNUNET_SCHEDULER_cancel(check_task); |
237 | check_task = GNUNET_SCHEDULER_add_delayed(CHECK_DELAY, &map_check, NULL); | 353 | check_task = GNUNET_SCHEDULER_add_delayed(CHECK_DELAY, &map_check, NULL); |
238 | 354 | ||
355 | if (GNUNET_SCHEDULER_NO_TASK != statistics_task) | ||
356 | GNUNET_SCHEDULER_cancel(statistics_task); | ||
357 | statistics_task = GNUNET_SCHEDULER_add_delayed(STATS_DELAY, &stats_check, NULL); | ||
239 | } | 358 | } |
240 | 359 | ||
241 | 360 | ||
@@ -255,6 +374,12 @@ cleanup_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
255 | ch = NULL; | 374 | ch = NULL; |
256 | } | 375 | } |
257 | 376 | ||
377 | if (GNUNET_SCHEDULER_NO_TASK != statistics_task) | ||
378 | { | ||
379 | GNUNET_SCHEDULER_cancel(statistics_task); | ||
380 | statistics_task = GNUNET_SCHEDULER_NO_TASK; | ||
381 | } | ||
382 | |||
258 | if (GNUNET_SCHEDULER_NO_TASK != check_task) | 383 | if (GNUNET_SCHEDULER_NO_TASK != check_task) |
259 | { | 384 | { |
260 | GNUNET_SCHEDULER_cancel(check_task); | 385 | GNUNET_SCHEDULER_cancel(check_task); |
@@ -360,7 +485,8 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
360 | { | 485 | { |
361 | transport_connections = 0; | 486 | transport_connections = 0; |
362 | core_connections = 0; | 487 | core_connections = 0; |
363 | 488 | mycfg = cfg; | |
489 | stats = GNUNET_STATISTICS_create ("watchdog", cfg); | ||
364 | peers = GNUNET_CONTAINER_multihashmap_create (20); | 490 | peers = GNUNET_CONTAINER_multihashmap_create (20); |
365 | 491 | ||
366 | th = GNUNET_TRANSPORT_connect(cfg, NULL, NULL, NULL, | 492 | th = GNUNET_TRANSPORT_connect(cfg, NULL, NULL, NULL, |