aboutsummaryrefslogtreecommitdiffstats
path: root/tests/stats/stats_test.c
diff options
context:
space:
mode:
authorOliver Smith <osmith@sysmocom.de>2021-08-19 11:58:09 +0200
committerosmith <osmith@sysmocom.de>2021-08-20 14:04:54 +0000
commit11da4a4abde8fa3db07492e7f6695667fe4c4be9 (patch)
treefa2b4886ed0fc338aa7517b33f9dd7c21737c5b8 /tests/stats/stats_test.c
parenta79a549273de9fbd014f2602ebe1885d308e531e (diff)
stats: send real last value if no new values come
Background: * Individual values can be added to osmo_stat_item.values at any time. * Stats are reported at a fixed interval (see vty 'stats interval'), e.g. every 10 seconds. * In order to report a new stat value, we use the maximum of all osmo_stat_item.values added since the last report. * By default, we do not send new stat values if they did not change (see vty 'config-stats' -> 'flush-period' default of 0). Fix the following bug: * If 'flush-period' is 0, and no new osmo_stat_item.values are coming in, the last value that gets reported is not necessarily the last entry in osmo_stat_item.values. * For attached reporters (statsd), it could then be that the given stat stays at the wrong value for a long stretch of time (think of several hours/days/forever). Explanation of how the test shows that it is fixed: * stats get reported (value is irrelevant) * osmo_stat_item gets a new value: 20 * osmo_stat_item gets a new value: 10 * stats get reported (value: 20, the maximum of both new values) * osmo_stat_item gets no new values * stats get reported (value: 10, this is new because of the bug fix, the real last value in osmo_stat_item, different from the 20 sent earlier, without the fix it would not send anything here and the last sent value would be 20) * osmo_stat_item gets no new values * stats get reported (nothing gets sent, since the real last value was already sent and 'flush-period' is 0) Fixes: OS#5215 Change-Id: Ibeefd0e3d1dbe4be454ff05a21df4848b2abfabe
Diffstat (limited to 'tests/stats/stats_test.c')
-rw-r--r--tests/stats/stats_test.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/tests/stats/stats_test.c b/tests/stats/stats_test.c
index 6505e669..2f2c6ecc 100644
--- a/tests/stats/stats_test.c
+++ b/tests/stats/stats_test.c
@@ -445,7 +445,7 @@ static void test_reporting()
fprintf(stderr, "report (group 1, item 1 no update, send last item (!= last max), OS#5215):\n");
send_count = 0;
osmo_stats_report();
- OSMO_ASSERT(send_count == 0); /* BUG: should be 2! */
+ OSMO_ASSERT(send_count == 2);
fprintf(stderr, "report (group 1, item 1 no update, nothing to send):\n");
send_count = 0;