summaryrefslogtreecommitdiffstats
path: root/daemon/unit_test.c
diff options
context:
space:
mode:
authorvkalintiris <vasilis@netdata.cloud>2022-11-22 04:52:15 +0200
committerGitHub <noreply@github.com>2022-11-22 04:52:15 +0200
commit2d5f3acf71f0c759056a3269987fee484566bc4c (patch)
tree5246e1080ea721ba84e5f749f8d8e98d978d81c8 /daemon/unit_test.c
parent147552807bc19af949fe3cb315c4743dadfa7f0b (diff)
Do not force internal collectors to call rrdset_next. (#13926)
* Remove calls to rrdset_next(). * Rm checks plugin * Update documentantion * Call rrdset_next from within rrdset_done This wraps up the removal of rrdset_next from internal collectors, which removes a lot of unecessary code and the need for if/else clauses in every place. The pluginsd parser is the only component that calls rrdset_next*() functions because it's not strictly speaking a collector but more of a collector manager/proxy. With the current changes it's possible to simplify the API we expose from RRD significantly, but this will be follow-up work in the future. * Remove stale reference to checks.plugin * Fix RRD unit test rrdset_next is not meant to be called from these tests. * Fix db engine unit test. * Schedule rrdset_next when we have completed at least one collection. * Mark chart creation clauses as unlikely. * Add missing brace to fix FreeBSD plugin.
Diffstat (limited to 'daemon/unit_test.c')
-rw-r--r--daemon/unit_test.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/daemon/unit_test.c b/daemon/unit_test.c
index 5b785118bb..02b67992bc 100644
--- a/daemon/unit_test.c
+++ b/daemon/unit_test.c
@@ -1206,7 +1206,9 @@ int run_test(struct test *test)
rrddim_set(st, "dim2", test->feed2[c]);
}
- rrdset_done(st);
+ struct timeval now;
+ now_realtime_timeval(&now);
+ rrdset_timed_done(st, now, false);
// align the first entry to second boundary
if(!c) {
@@ -1797,7 +1799,10 @@ static void test_dbengine_create_charts(RRDHOST *host, RRDSET *st[CHARTS], RRDDI
for (j = 0; j < DIMS; ++j) {
rrddim_set_by_pointer_fake_time(rd[i][j], 69, 2 * API_RELATIVE_TIME_MAX); // set first value to 69
}
- rrdset_done(st[i]);
+
+ struct timeval now;
+ now_realtime_timeval(&now);
+ rrdset_timed_done(st[i], now, false);
}
// Fluh pages for subsequent real values
for (i = 0 ; i < CHARTS ; ++i) {
@@ -1831,7 +1836,8 @@ static time_t test_dbengine_create_metrics(RRDSET *st[CHARTS], RRDDIM *rd[CHARTS
}
for (c = 0; c < REGION_POINTS[current_region] ; ++c) {
time_now += update_every; // time_now = start + (c + 1) * update_every
- for (i = 0 ; i < CHARTS ; ++i) {
+
+ for (i = 0 ; i < CHARTS ; ++i) {
st[i]->usec_since_last_update = USEC_PER_SEC * update_every;
for (j = 0; j < DIMS; ++j) {
@@ -1839,7 +1845,12 @@ static time_t test_dbengine_create_metrics(RRDSET *st[CHARTS], RRDDIM *rd[CHARTS
j * REGION_POINTS[current_region] + c;
rrddim_set_by_pointer_fake_time(rd[i][j], next, time_now);
}
- rrdset_done(st[i]);
+
+ struct timeval now;
+ now.tv_sec = time_now;
+ now.tv_usec = 0;
+
+ rrdset_timed_done(st[i], now, false);
}
}
return time_now; //time_end