View Issue Details

IDProjectCategoryView StatusLast Update
0003060GNUnetobsoletepublic2024-05-03 13:49
ReporterLRN Assigned ToMatthias Wachs  
PrioritynormalSeverityminorReproducibilitysometimes
Status closedResolutionfixed 
Product VersionGit master 
Target Version0.10.0Fixed in Version0.10.0 
Summary0003060: test_ats_api_scheduling_destroy_address* test fails sometimes
DescriptionSuccessful run logs this (trimmed for brevity):
...
util-1600 DEBUG Received message of type 173 and size 24
test-ats-api-1600 INFO ATS statistics: `ats' `# addresses' 0
...
util-1600 DEBUG Received message of type 173 and size 24
test-ats-api-1600 INFO ATS statistics: `ats' `# addresses' 1
ats-scheduling-api-1600 DEBUG Get session ID for session 00000000 from peer 64OJ in 058595b0
test-ats-api-1600 DEBUG Deleting address for peer `64OJ', plugin `test', session 00000000
util-1600 DEBUG Scheduling transmission (0584b090).
...
util-1600 DEBUG Received message of type 173 and size 24
test-ats-api-1600 INFO ATS statistics: `ats' `# addresses' 0
...
test-ats-api-1600 DEBUG Shutting down

Unsuccessful run (which times out) logs this:
...
util-2880 DEBUG Received message of type 173 and size 24
test-ats-api-2880 INFO ATS statistics: `ats' `# addresses' 1
ats-scheduling-api-2880 DEBUG Get session ID for session 00000000 from peer 64OJ in 058f7330
test-ats-api-2880 DEBUG Deleting address for peer `64OJ', plugin `test', session 00000000
util-2880 DEBUG Scheduling transmission (058f1c80).
...
util-2880 DEBUG Received message of type 173 and size 24
test-ats-api-2880 INFO ATS statistics: `ats' `# addresses' 0
...
long wait
...
test-ats-api-2880 DEBUG Shutting down

That is, the test gets its very first statistics callback with ats value being 1, not 0 (as it expects).
Steps To ReproduceRun test_ats_api_scheduling_destroy_address enough times
TagsNo tags attached.
Attached Files
get_first.diff (2,422 bytes)   
diff --git a/src/ats/test_ats_api_scheduling_init.c b/src/ats/test_ats_api_scheduling_init.c
index aab5f23..3a75a78 100644
--- a/src/ats/test_ats_api_scheduling_init.c
+++ b/src/ats/test_ats_api_scheduling_init.c
@@ -35,6 +35,11 @@
 static GNUNET_SCHEDULER_TaskIdentifier die_task;
 
 /**
+ * Initial statistics get request handle
+ */
+struct GNUNET_STATISTICS_GetHandle *initial_get;
+
+/**
  * Statistics handle
  */
 struct GNUNET_STATISTICS_Handle *stats;
@@ -67,6 +72,14 @@ stat_cb(void *cls, const char *subsystem,
   return GNUNET_OK;
 }
 
+static int
+dummy_stat (void *cls, const char *subsystem, const char *name, uint64_t value,
+            int is_persistent)
+{
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Got dummy stat %s%s:%s = %llu\n",
+              is_persistent ? "!" : " ", subsystem, name, value);
+  return GNUNET_OK;
+}
 
 static void
 end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
@@ -115,18 +128,16 @@ address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address,
   return;
 }
 
-
 static void
-run (void *cls,
-     const struct GNUNET_CONFIGURATION_Handle *cfg,
-     struct GNUNET_TESTING_Peer *peer)
+got_initial_value (void *cls, int success)
 {
-  die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
-  stats = GNUNET_STATISTICS_create ("ats", cfg);
-  GNUNET_STATISTICS_watch (stats, "ats", "# addresses", &stat_cb, NULL);
+  struct GNUNET_CONFIGURATION_Handle *cfg = cls;
+
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Got initial value\n");
 
   /* Connect to ATS scheduling */
   sched_ats = GNUNET_ATS_scheduling_init (cfg, &address_suggest_cb, NULL);
+  GNUNET_CONFIGURATION_destroy (cfg);
   if (sched_ats == NULL)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not connect to ATS scheduling!\n");
@@ -135,6 +146,20 @@ run (void *cls,
   }
 }
 
+static void
+run (void *cls,
+     const struct GNUNET_CONFIGURATION_Handle *cfg,
+     struct GNUNET_TESTING_Peer *peer)
+{
+  die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
+  stats = GNUNET_STATISTICS_create ("ats", cfg);
+  GNUNET_STATISTICS_watch (stats, "ats", "# addresses", &stat_cb, NULL);
+
+  initial_get = GNUNET_STATISTICS_get (stats, "ats", "# addresses", TIMEOUT,
+                                       &got_initial_value, &dummy_stat,
+                                       GNUNET_CONFIGURATION_dup (cfg));
+}
+
 
 int
 main (int argc, char *argv[])
get_first.diff (2,422 bytes)   

Activities

LRN

2013-10-09 05:09

reporter   ~0007508

test_ats_api_scheduling_init suffers the same fate.
I checked the logs a bit further, and AFAICS, the problem is that the test sometimes connects to the statistics service _after_ ats does, which is why the test may not get the initial zero value.

LRN

2013-10-09 05:39

reporter   ~0007509

I've uploaded a patch that fixes test_ats_api_scheduling_init for me. Whether it does so due to the delay it introduces as a side-effect, or because it does enforce correct service startup order, i know not.

Matthias Wachs

2013-10-09 10:02

reporter   ~0007510

Issue was confirmed and a different solution was already commited.
This patch is helpful so will apply it

Matthias Wachs

2013-10-09 10:03

reporter   ~0007511

Has also to be applied to all other API tests ... work in progress

Issue History

Date Modified Username Field Change
2013-10-09 02:07 LRN New Issue
2013-10-09 02:07 LRN Status new => assigned
2013-10-09 02:07 LRN Assigned To => Matthias Wachs
2013-10-09 05:09 LRN Note Added: 0007508
2013-10-09 05:39 LRN File Added: get_first.diff
2013-10-09 05:39 LRN Note Added: 0007509
2013-10-09 10:02 Matthias Wachs Note Added: 0007510
2013-10-09 10:03 Matthias Wachs Note Added: 0007511
2013-10-09 10:03 Matthias Wachs Status assigned => resolved
2013-10-09 10:03 Matthias Wachs Resolution open => fixed
2013-10-09 13:36 Christian Grothoff Product Version => Git master
2013-10-09 13:36 Christian Grothoff Fixed in Version => 0.10.0
2013-10-09 13:36 Christian Grothoff Target Version => 0.10.0
2013-12-24 20:54 Christian Grothoff Status resolved => closed
2024-05-03 13:49 Christian Grothoff Category ATS service => obsolete