aboutsummaryrefslogtreecommitdiff
path: root/src/integration-tests
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2012-04-11 09:18:54 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2012-04-11 09:18:54 +0000
commit2966af30d6d0ff2165ef6ac48d727a09590491fd (patch)
treef68311722d40338456ad8a578f06873de1b3af45 /src/integration-tests
parentf78f7a837db6f5203a28432c12f206cf59436e2b (diff)
downloadgnunet-2966af30d6d0ff2165ef6ac48d727a09590491fd.tar.gz
gnunet-2966af30d6d0ff2165ef6ac48d727a09590491fd.zip
- added check for low level connections
Diffstat (limited to 'src/integration-tests')
-rw-r--r--src/integration-tests/connection_watchdog.c92
1 files changed, 92 insertions, 0 deletions
diff --git a/src/integration-tests/connection_watchdog.c b/src/integration-tests/connection_watchdog.c
index 7348c3cef..27d605aab 100644
--- a/src/integration-tests/connection_watchdog.c
+++ b/src/integration-tests/connection_watchdog.c
@@ -132,14 +132,85 @@ map_check (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
132 } 132 }
133} 133}
134 134
135
135static void 136static void
136stats_check (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); 137stats_check (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
137 138
139enum protocol
140{
141 tcp,
142 udp,
143 unixdomain
144};
145
146static int
147check_lowlevel_connections (int port, int protocol)
148{
149 FILE *f;
150 char * cmdline;
151 char * proto;
152 char line[1024];
153 int count = -1;
154#ifdef MINGW
155 /* not supported */
156 return count;
157#else
158
159 switch (protocol) {
160 case tcp:
161 proto = "-t";
162 break;
163 case udp:
164 proto = "-u";
165 break;
166 case unixdomain:
167 proto = "-x";
168 break;
169 default:
170 proto = "";
171 break;
172 }
173
174
175 GNUNET_asprintf(&cmdline, "ss %s \\( sport = :%u or dport = :%u \\)", proto, port, port);
176
177 if (system ("ss > /dev/null 2> /dev/null"))
178 if (system ("ss > /dev/null 2> /dev/null") == 0)
179 f = popen (cmdline, "r");
180 else
181 f = NULL;
182 else
183 f = popen (cmdline, "r");
184 if (!f)
185 {
186 GNUNET_log_strerror(GNUNET_ERROR_TYPE_ERROR, "ss");
187 GNUNET_free (cmdline);
188 return -1;
189 }
190
191 while (NULL != fgets (line, sizeof (line), f))
192 {
193 /* read */
194
195 //printf ("%s", line);
196 count ++;
197 }
198
199 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%i TCP connections established with port %u\n",
200 count, port);
201
202 pclose (f);
203 GNUNET_free (cmdline);
204 return count;
205#endif
206}
207
138int stats_check_cb (void *cls, const char *subsystem, 208int stats_check_cb (void *cls, const char *subsystem,
139 const char *name, uint64_t value, 209 const char *name, uint64_t value,
140 int is_persistent) 210 int is_persistent)
141{ 211{
142 static int counter; 212 static int counter;
213
143 uint64_t *val = cls; 214 uint64_t *val = cls;
144 215
145 if (NULL != val) 216 if (NULL != val)
@@ -149,6 +220,9 @@ int stats_check_cb (void *cls, const char *subsystem,
149 if (STATS_VALUES == counter) 220 if (STATS_VALUES == counter)
150 { 221 {
151 int fail = GNUNET_NO; 222 int fail = GNUNET_NO;
223 int low_level_connections_tcp = check_lowlevel_connections (2086, tcp);
224 int low_level_connections_udp = check_lowlevel_connections (2086, udp);
225
152 if (transport_connections != core_connections) 226 if (transport_connections != core_connections)
153 { 227 {
154 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 228 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -185,6 +259,21 @@ int stats_check_cb (void *cls, const char *subsystem,
185 "Statistics consistency check successful : (%u transport / %u core) connections established\n", transport_connections, core_connections); 259 "Statistics consistency check successful : (%u transport / %u core) connections established\n", transport_connections, core_connections);
186 260
187 /* This is only an issue when transport_connections > statistics_transport_tcp_connections */ 261 /* This is only an issue when transport_connections > statistics_transport_tcp_connections */
262 if ((low_level_connections_tcp != -1) && (statistics_transport_tcp_connections > low_level_connections_tcp))
263 {
264 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
265 "Lowlevel connections are inconsistent: %u transport tcp sessions <-> %i established tcp connections\n",
266 statistics_transport_tcp_connections, low_level_connections_tcp);
267 fail = GNUNET_YES;
268 }
269 else
270 {
271 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
272 "%u TCP connections, %u UDP connections \n",
273 low_level_connections_tcp, low_level_connections_udp);
274 }
275
276
188 if (transport_connections > statistics_transport_tcp_connections) 277 if (transport_connections > statistics_transport_tcp_connections)
189 { 278 {
190 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 279 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -209,6 +298,7 @@ int stats_check_cb (void *cls, const char *subsystem,
209 return GNUNET_OK; 298 return GNUNET_OK;
210} 299}
211 300
301
212static void 302static void
213stats_check (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 303stats_check (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
214{ 304{
@@ -491,6 +581,7 @@ run (void *cls, char *const *args, const char *cfgfile,
491 transport_connections = 0; 581 transport_connections = 0;
492 core_connections = 0; 582 core_connections = 0;
493 mycfg = cfg; 583 mycfg = cfg;
584
494 stats = GNUNET_STATISTICS_create ("watchdog", cfg); 585 stats = GNUNET_STATISTICS_create ("watchdog", cfg);
495 peers = GNUNET_CONTAINER_multihashmap_create (20); 586 peers = GNUNET_CONTAINER_multihashmap_create (20);
496 587
@@ -509,6 +600,7 @@ run (void *cls, char *const *args, const char *cfgfile,
509 GNUNET_assert (ch != NULL); 600 GNUNET_assert (ch != NULL);
510 601
511 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleanup_task, NULL); 602 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleanup_task, NULL);
603
512} 604}
513 605
514 606