summaryrefslogtreecommitdiffstats
path: root/exporting/tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2022-11-30 18:47:05 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2022-11-30 18:47:05 +0000
commit97e01009d69b8fbebfebf68f51e3d126d0ed43fc (patch)
tree02e8b836c3a9d89806f3e67d4a5fe9f52dbb0061 /exporting/tests
parentReleasing debian version 1.36.1-1. (diff)
downloadnetdata-97e01009d69b8fbebfebf68f51e3d126d0ed43fc.tar.xz
netdata-97e01009d69b8fbebfebf68f51e3d126d0ed43fc.zip
Merging upstream version 1.37.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'exporting/tests')
-rw-r--r--exporting/tests/exporting_fixtures.c95
-rw-r--r--exporting/tests/netdata_doubles.c40
-rw-r--r--exporting/tests/test_exporting_engine.c217
-rw-r--r--exporting/tests/test_exporting_engine.h3
4 files changed, 243 insertions, 112 deletions
diff --git a/exporting/tests/exporting_fixtures.c b/exporting/tests/exporting_fixtures.c
index aae1c53fb..c9fc9458c 100644
--- a/exporting/tests/exporting_fixtures.c
+++ b/exporting/tests/exporting_fixtures.c
@@ -33,31 +33,13 @@ int teardown_configured_engine(void **state)
return 0;
}
-int setup_rrdhost()
-{
- localhost = calloc(1, sizeof(RRDHOST));
-
- localhost->rrd_update_every = 1;
-
- localhost->tags = strdupz("TAG1=VALUE1 TAG2=VALUE2");
-
- localhost->host_labels = rrdlabels_create();
- rrdlabels_add(localhost->host_labels, "key1", "value1", RRDLABEL_SRC_CONFIG);
- rrdlabels_add(localhost->host_labels, "key2", "value2", RRDLABEL_SRC_CONFIG);
+static void rrddim_insert_callback(const DICTIONARY_ITEM *item __maybe_unused, void *rrddim, void *st) {
+ RRDDIM *rd = rrddim;
- localhost->rrdset_root = calloc(1, sizeof(RRDSET));
- RRDSET *st = localhost->rrdset_root;
- st->rrdhost = localhost;
- strcpy(st->id, "chart_id");
- st->name = strdupz("chart_name");
- st->rrd_memory_mode |= RRD_MEMORY_MODE_SAVE;
- st->update_every = 1;
+ rd->id = string_strdupz("dimension_id");
+ rd->name = string_strdupz("dimension_name");
- localhost->rrdset_root->dimensions = calloc(1, sizeof(RRDDIM));
- RRDDIM *rd = localhost->rrdset_root->dimensions;
- rd->rrdset = st;
- rd->id = strdupz("dimension_id");
- rd->name = strdupz("dimension_name");
+ rd->rrdset = (RRDSET *)st;
rd->last_collected_value = 123000321;
rd->last_collected_time.tv_sec = 15051;
rd->collections_counter++;
@@ -70,25 +52,74 @@ int setup_rrdhost()
rd->tiers[0]->query_ops.is_finished = __mock_rrddim_query_is_finished;
rd->tiers[0]->query_ops.next_metric = __mock_rrddim_query_next_metric;
rd->tiers[0]->query_ops.finalize = __mock_rrddim_query_finalize;
+}
+
+static void rrdset_insert_callback(const DICTIONARY_ITEM *item __maybe_unused, void *rrdset, void *constructor_data __maybe_unused) {
+ RRDHOST *host = localhost;
+ RRDSET *st = rrdset;
+
+ // const char *chart_full_id = dictionary_acquired_item_name(item);
+
+ st->id = string_strdupz("chart_id");
+ st->name = string_strdupz("chart_name");
+
+ st->update_every = 1;
+ st->rrd_memory_mode = RRD_MEMORY_MODE_SAVE;
+
+ st->rrdhost = host;
+
+ st->rrddim_root_index = dictionary_create(DICT_OPTION_DONT_OVERWRITE_VALUE);
+
+ dictionary_register_insert_callback(st->rrddim_root_index, rrddim_insert_callback, NULL);
+}
+
+int setup_rrdhost()
+{
+ localhost = calloc(1, sizeof(RRDHOST));
+
+ localhost->rrd_update_every = 1;
+
+ localhost->tags = string_strdupz("TAG1=VALUE1 TAG2=VALUE2");
+
+ localhost->rrdlabels = rrdlabels_create();
+ rrdlabels_add(localhost->rrdlabels, "key1", "value1", RRDLABEL_SRC_CONFIG);
+ rrdlabels_add(localhost->rrdlabels, "key2", "value2", RRDLABEL_SRC_CONFIG);
+
+ localhost->rrdset_root_index = dictionary_create(DICT_OPTION_DONT_OVERWRITE_VALUE);
+ dictionary_register_insert_callback(localhost->rrdset_root_index, rrdset_insert_callback, NULL);
+ RRDSET *st = dictionary_set_advanced(localhost->rrdset_root_index, "chart_id", -1, NULL, sizeof(RRDSET), NULL);
+
+ st->rrddim_root_index = dictionary_create(DICT_OPTION_DONT_OVERWRITE_VALUE);
+ dictionary_register_insert_callback(st->rrddim_root_index, rrddim_insert_callback, NULL);
+ st->dimensions = dictionary_set_advanced(st->rrddim_root_index, "dimension_id", -1, NULL, sizeof(RRDDIM), st);
return 0;
}
int teardown_rrdhost()
{
- RRDDIM *rd = localhost->rrdset_root->dimensions;
- free((void *)rd->name);
- free((void *)rd->id);
+ RRDSET *st;
+ rrdset_foreach_read(st, localhost);
+ break;
+ rrdset_foreach_done(st);
+
+ RRDDIM *rd;
+ rrddim_foreach_read(rd, st);
+ break;
+ rrddim_foreach_done(rd);
+
+ string_freez(rd->id);
+ string_freez(rd->name);
free(rd->tiers[0]);
- free(rd);
- RRDSET *st = localhost->rrdset_root;
- free((void *)st->name);
- free(st);
+ string_freez(st->id);
+ string_freez(st->name);
+ dictionary_destroy(st->rrddim_root_index);
- rrdlabels_destroy(localhost->host_labels);
+ rrdlabels_destroy(localhost->rrdlabels);
- free((void *)localhost->tags);
+ string_freez(localhost->tags);
+ dictionary_destroy(localhost->rrdset_root_index);
free(localhost);
return 0;
diff --git a/exporting/tests/netdata_doubles.c b/exporting/tests/netdata_doubles.c
index ee36e887a..7e5017a5f 100644
--- a/exporting/tests/netdata_doubles.c
+++ b/exporting/tests/netdata_doubles.c
@@ -177,20 +177,6 @@ const char *rrd_memory_mode_name(RRD_MEMORY_MODE id)
return RRD_MEMORY_MODE_NONE_NAME;
}
-NETDATA_DOUBLE rrdvar2number(RRDVAR *rv)
-{
- (void)rv;
- return 0;
-}
-
-int foreach_host_variable_callback(RRDHOST *host, int (*callback)(RRDVAR *rv, void *data), void *data)
-{
- (void)host;
- (void)callback;
- (void)data;
- return 0;
-}
-
void rrdset_update_heterogeneous_flag(RRDSET *st)
{
(void)st;
@@ -212,11 +198,10 @@ time_t __mock_rrddim_query_latest_time(STORAGE_METRIC_HANDLE *db_metric_handle)
return mock_type(time_t);
}
-void __mock_rrddim_query_init(STORAGE_METRIC_HANDLE *db_metric_handle, struct rrddim_query_handle *handle, time_t start_time, time_t end_time, TIER_QUERY_FETCH tier_query_fetch_type)
+void __mock_rrddim_query_init(STORAGE_METRIC_HANDLE *db_metric_handle, struct rrddim_query_handle *handle, time_t start_time, time_t end_time)
{
(void)db_metric_handle;
(void)handle;
- (void)tier_query_fetch_type;
function_called();
check_expected(start_time);
@@ -248,10 +233,23 @@ void __mock_rrddim_query_finalize(struct rrddim_query_handle *handle)
function_called();
}
-void sql_store_chart_label(uuid_t *chart_uuid, int source_type, char *label, char *value)
+void rrdcalc_update_rrdlabels(RRDSET *st)
+{
+ (void)st;
+}
+
+void rrdpush_sender_send_this_host_variable_now(RRDHOST *host, const RRDVAR_ACQUIRED *rva)
+{
+ (void)host;
+ (void)rva;
+}
+
+void db_execute(const char *cmd)
{
- (void)chart_uuid;
- (void)source_type;
- (void)label;
- (void)value;
+ (void)cmd;
+}
+
+DICTIONARY *rrdfamily_rrdvars_dict(const RRDFAMILY_ACQUIRED *rfa) {
+ (void)rfa;
+ return NULL;
}
diff --git a/exporting/tests/test_exporting_engine.c b/exporting/tests/test_exporting_engine.c
index 56a28059f..6ea6b1e5c 100644
--- a/exporting/tests/test_exporting_engine.c
+++ b/exporting/tests/test_exporting_engine.c
@@ -11,6 +11,7 @@ struct config netdata_config;
char *netdata_configured_user_config_dir = ".";
char *netdata_configured_stock_config_dir = ".";
char *netdata_configured_hostname = "test_global_host";
+bool global_statistics_enabled = true;
char log_line[MAX_LOG_LINE + 1];
@@ -257,7 +258,10 @@ static void test_rrdset_is_exportable(void **state)
{
struct engine *engine = *state;
struct instance *instance = engine->instance_root;
- RRDSET *st = localhost->rrdset_root;
+ RRDSET *st;
+ rrdset_foreach_read(st, localhost);
+ break;
+ rrdset_foreach_done(st);
assert_ptr_equal(st->exporting_flags, NULL);
@@ -271,7 +275,10 @@ static void test_false_rrdset_is_exportable(void **state)
{
struct engine *engine = *state;
struct instance *instance = engine->instance_root;
- RRDSET *st = localhost->rrdset_root;
+ RRDSET *st;
+ rrdset_foreach_read(st, localhost);
+ break;
+ rrdset_foreach_done(st);
simple_pattern_free(instance->config.charts_pattern);
instance->config.charts_pattern = simple_pattern_create("!*", NULL, SIMPLE_PATTERN_EXACT);
@@ -288,7 +295,17 @@ static void test_exporting_calculate_value_from_stored_data(void **state)
{
struct engine *engine = *state;
struct instance *instance = engine->instance_root;
- RRDDIM *rd = localhost->rrdset_root->dimensions;
+
+ RRDSET *st;
+ rrdset_foreach_read(st, localhost);
+ break;
+ rrdset_foreach_done(st);
+
+ RRDDIM *rd;
+ rrddim_foreach_read(rd, st);
+ break;
+ rrddim_foreach_done(rd);
+
time_t timestamp;
instance->after = 3;
@@ -348,7 +365,11 @@ static void test_prepare_buffers(void **state)
expect_value(__mock_start_host_formatting, host, localhost);
will_return(__mock_start_host_formatting, 0);
- RRDSET *st = localhost->rrdset_root;
+ RRDSET *st;
+ rrdset_foreach_read(st, localhost);
+ break;
+ rrdset_foreach_done(st);
+
expect_function_call(__wrap_rrdset_is_exportable);
expect_value(__wrap_rrdset_is_exportable, instance, instance);
expect_value(__wrap_rrdset_is_exportable, st, st);
@@ -359,7 +380,10 @@ static void test_prepare_buffers(void **state)
expect_value(__mock_start_chart_formatting, st, st);
will_return(__mock_start_chart_formatting, 0);
- RRDDIM *rd = localhost->rrdset_root->dimensions;
+ RRDDIM *rd;
+ rrddim_foreach_read(rd, st);
+ break;
+ rrddim_foreach_done(rd);
expect_function_call(__mock_metric_formatting);
expect_value(__mock_metric_formatting, instance, instance);
expect_value(__mock_metric_formatting, rd, rd);
@@ -412,7 +436,15 @@ static void test_format_dimension_collected_graphite_plaintext(void **state)
{
struct engine *engine = *state;
- RRDDIM *rd = localhost->rrdset_root->dimensions;
+ RRDSET *st;
+ rrdset_foreach_read(st, localhost);
+ break;
+ rrdset_foreach_done(st);
+
+ RRDDIM *rd;
+ rrddim_foreach_read(rd, st);
+ break;
+ rrddim_foreach_done(rd);
assert_int_equal(format_dimension_collected_graphite_plaintext(engine->instance_root, rd), 0);
assert_string_equal(
buffer_tostring(engine->instance_root->buffer),
@@ -426,7 +458,15 @@ static void test_format_dimension_stored_graphite_plaintext(void **state)
expect_function_call(__wrap_exporting_calculate_value_from_stored_data);
will_return(__wrap_exporting_calculate_value_from_stored_data, pack_storage_number(27, SN_DEFAULT_FLAGS));
- RRDDIM *rd = localhost->rrdset_root->dimensions;
+ RRDSET *st;
+ rrdset_foreach_read(st, localhost);
+ break;
+ rrdset_foreach_done(st);
+
+ RRDDIM *rd;
+ rrddim_foreach_read(rd, st);
+ break;
+ rrddim_foreach_done(rd);
assert_int_equal(format_dimension_stored_graphite_plaintext(engine->instance_root, rd), 0);
assert_string_equal(
buffer_tostring(engine->instance_root->buffer),
@@ -437,13 +477,21 @@ static void test_format_dimension_collected_json_plaintext(void **state)
{
struct engine *engine = *state;
- RRDDIM *rd = localhost->rrdset_root->dimensions;
+ RRDSET *st;
+ rrdset_foreach_read(st, localhost);
+ break;
+ rrdset_foreach_done(st);
+
+ RRDDIM *rd;
+ rrddim_foreach_read(rd, st);
+ break;
+ rrddim_foreach_done(rd);
assert_int_equal(format_dimension_collected_json_plaintext(engine->instance_root, rd), 0);
assert_string_equal(
buffer_tostring(engine->instance_root->buffer),
"{\"prefix\":\"netdata\",\"hostname\":\"test-host\",\"host_tags\":\"TAG1=VALUE1 TAG2=VALUE2\","
- "\"chart_id\":\"chart_id\",\"chart_name\":\"chart_name\",\"chart_family\":\"(null)\","
- "\"chart_context\":\"(null)\",\"chart_type\":\"(null)\",\"units\":\"(null)\",\"id\":\"dimension_id\","
+ "\"chart_id\":\"chart_id\",\"chart_name\":\"chart_name\",\"chart_family\":\"\","
+ "\"chart_context\":\"\",\"chart_type\":\"\",\"units\":\"\",\"id\":\"dimension_id\","
"\"name\":\"dimension_name\",\"value\":123000321,\"timestamp\":15051}\n");
}
@@ -454,13 +502,21 @@ static void test_format_dimension_stored_json_plaintext(void **state)
expect_function_call(__wrap_exporting_calculate_value_from_stored_data);
will_return(__wrap_exporting_calculate_value_from_stored_data, pack_storage_number(27, SN_DEFAULT_FLAGS));
- RRDDIM *rd = localhost->rrdset_root->dimensions;
+ RRDSET *st;
+ rrdset_foreach_read(st, localhost);
+ break;
+ rrdset_foreach_done(st);
+
+ RRDDIM *rd;
+ rrddim_foreach_read(rd, st);
+ break;
+ rrddim_foreach_done(rd);
assert_int_equal(format_dimension_stored_json_plaintext(engine->instance_root, rd), 0);
assert_string_equal(
buffer_tostring(engine->instance_root->buffer),
"{\"prefix\":\"netdata\",\"hostname\":\"test-host\",\"host_tags\":\"TAG1=VALUE1 TAG2=VALUE2\","
- "\"chart_id\":\"chart_id\",\"chart_name\":\"chart_name\",\"chart_family\":\"(null)\"," \
- "\"chart_context\": \"(null)\",\"chart_type\":\"(null)\",\"units\": \"(null)\",\"id\":\"dimension_id\","
+ "\"chart_id\":\"chart_id\",\"chart_name\":\"chart_name\",\"chart_family\":\"\"," \
+ "\"chart_context\": \"\",\"chart_type\":\"\",\"units\": \"\",\"id\":\"dimension_id\","
"\"name\":\"dimension_name\",\"value\":690565856.0000000,\"timestamp\": 15052}\n");
}
@@ -468,7 +524,15 @@ static void test_format_dimension_collected_opentsdb_telnet(void **state)
{
struct engine *engine = *state;
- RRDDIM *rd = localhost->rrdset_root->dimensions;
+ RRDSET *st;
+ rrdset_foreach_read(st, localhost);
+ break;
+ rrdset_foreach_done(st);
+
+ RRDDIM *rd;
+ rrddim_foreach_read(rd, st);
+ break;
+ rrddim_foreach_done(rd);
assert_int_equal(format_dimension_collected_opentsdb_telnet(engine->instance_root, rd), 0);
assert_string_equal(
buffer_tostring(engine->instance_root->buffer),
@@ -482,7 +546,15 @@ static void test_format_dimension_stored_opentsdb_telnet(void **state)
expect_function_call(__wrap_exporting_calculate_value_from_stored_data);
will_return(__wrap_exporting_calculate_value_from_stored_data, pack_storage_number(27, SN_DEFAULT_FLAGS));
- RRDDIM *rd = localhost->rrdset_root->dimensions;
+ RRDSET *st;
+ rrdset_foreach_read(st, localhost);
+ break;
+ rrdset_foreach_done(st);
+
+ RRDDIM *rd;
+ rrddim_foreach_read(rd, st);
+ break;
+ rrddim_foreach_done(rd);
assert_int_equal(format_dimension_stored_opentsdb_telnet(engine->instance_root, rd), 0);
assert_string_equal(
buffer_tostring(engine->instance_root->buffer),
@@ -493,7 +565,15 @@ static void test_format_dimension_collected_opentsdb_http(void **state)
{
struct engine *engine = *state;
- RRDDIM *rd = localhost->rrdset_root->dimensions;
+ RRDSET *st;
+ rrdset_foreach_read(st, localhost);
+ break;
+ rrdset_foreach_done(st);
+
+ RRDDIM *rd;
+ rrddim_foreach_read(rd, st);
+ break;
+ rrddim_foreach_done(rd);
assert_int_equal(format_dimension_collected_opentsdb_http(engine->instance_root, rd), 0);
assert_string_equal(
buffer_tostring(engine->instance_root->buffer),
@@ -510,7 +590,15 @@ static void test_format_dimension_stored_opentsdb_http(void **state)
expect_function_call(__wrap_exporting_calculate_value_from_stored_data);
will_return(__wrap_exporting_calculate_value_from_stored_data, pack_storage_number(27, SN_DEFAULT_FLAGS));
- RRDDIM *rd = localhost->rrdset_root->dimensions;
+ RRDSET *st;
+ rrdset_foreach_read(st, localhost);
+ break;
+ rrdset_foreach_done(st);
+
+ RRDDIM *rd;
+ rrddim_foreach_read(rd, st);
+ break;
+ rrddim_foreach_done(rd);
assert_int_equal(format_dimension_stored_opentsdb_http(engine->instance_root, rd), 0);
assert_string_equal(
buffer_tostring(engine->instance_root->buffer),
@@ -616,27 +704,14 @@ static void test_simple_connector_worker(void **state)
buffer_sprintf(simple_connector_data->last_buffer->header, "test header");
buffer_sprintf(simple_connector_data->last_buffer->buffer, "test buffer");
- expect_function_call(__wrap_connect_to_one_of);
- expect_string(__wrap_connect_to_one_of, destination, "localhost");
- expect_value(__wrap_connect_to_one_of, default_port, 2003);
- expect_not_value(__wrap_connect_to_one_of, reconnects_counter, 0);
- expect_string(__wrap_connect_to_one_of, connected_to, "localhost");
- expect_value(__wrap_connect_to_one_of, connected_to_size, CONNECTED_TO_MAX);
- will_return(__wrap_connect_to_one_of, 2);
+ expect_function_call(__wrap_now_realtime_sec);
+ will_return(__wrap_now_realtime_sec, 2);
- expect_function_call(__wrap_send);
- expect_value(__wrap_send, sockfd, 2);
- expect_not_value(__wrap_send, buf, buffer_tostring(simple_connector_data->last_buffer->buffer));
- expect_string(__wrap_send, buf, "test header");
- expect_value(__wrap_send, len, 11);
- expect_value(__wrap_send, flags, MSG_NOSIGNAL);
+ expect_function_call(__wrap_now_realtime_sec);
+ will_return(__wrap_now_realtime_sec, 2);
- expect_function_call(__wrap_send);
- expect_value(__wrap_send, sockfd, 2);
- expect_value(__wrap_send, buf, buffer_tostring(simple_connector_data->last_buffer->buffer));
- expect_string(__wrap_send, buf, "test buffer");
- expect_value(__wrap_send, len, 11);
- expect_value(__wrap_send, flags, MSG_NOSIGNAL);
+ expect_function_call(__wrap_now_realtime_sec);
+ will_return(__wrap_now_realtime_sec, 2);
expect_function_call(__wrap_send_internal_metrics);
expect_value(__wrap_send_internal_metrics, instance, instance);
@@ -986,21 +1061,26 @@ static void test_can_send_rrdset(void **state)
{
(void)*state;
- assert_int_equal(can_send_rrdset(prometheus_exporter_instance, localhost->rrdset_root, NULL), 1);
+ RRDSET *st;
+ rrdset_foreach_read(st, localhost);
+ break;
+ rrdset_foreach_done(st);
+
+ assert_int_equal(can_send_rrdset(prometheus_exporter_instance, st, NULL), 1);
- rrdset_flag_set(localhost->rrdset_root, RRDSET_FLAG_EXPORTING_IGNORE);
- assert_int_equal(can_send_rrdset(prometheus_exporter_instance, localhost->rrdset_root, NULL), 0);
- rrdset_flag_clear(localhost->rrdset_root, RRDSET_FLAG_EXPORTING_IGNORE);
+ rrdset_flag_set(st, RRDSET_FLAG_EXPORTING_IGNORE);
+ assert_int_equal(can_send_rrdset(prometheus_exporter_instance, st, NULL), 0);
+ rrdset_flag_clear(st, RRDSET_FLAG_EXPORTING_IGNORE);
// TODO: test with a denying simple pattern
- rrdset_flag_set(localhost->rrdset_root, RRDSET_FLAG_OBSOLETE);
- assert_int_equal(can_send_rrdset(prometheus_exporter_instance, localhost->rrdset_root, NULL), 0);
- rrdset_flag_clear(localhost->rrdset_root, RRDSET_FLAG_OBSOLETE);
+ rrdset_flag_set(st, RRDSET_FLAG_OBSOLETE);
+ assert_int_equal(can_send_rrdset(prometheus_exporter_instance, st, NULL), 0);
+ rrdset_flag_clear(st, RRDSET_FLAG_OBSOLETE);
- localhost->rrdset_root->rrd_memory_mode = RRD_MEMORY_MODE_NONE;
+ st->rrd_memory_mode = RRD_MEMORY_MODE_NONE;
prometheus_exporter_instance->config.options |= EXPORTING_SOURCE_DATA_AVERAGE;
- assert_int_equal(can_send_rrdset(prometheus_exporter_instance, localhost->rrdset_root, NULL), 0);
+ assert_int_equal(can_send_rrdset(prometheus_exporter_instance, st, NULL), 0);
}
static void test_prometheus_name_copy(void **state)
@@ -1055,9 +1135,14 @@ static void rrd_stats_api_v1_charts_allmetrics_prometheus(void **state)
BUFFER *buffer = buffer_create(0);
- localhost->hostname = strdupz("test_hostname");
- localhost->rrdset_root->family = strdupz("test_family");
- localhost->rrdset_root->context = strdupz("test_context");
+ RRDSET *st;
+ rrdset_foreach_read(st, localhost);
+ break;
+ rrdset_foreach_done(st);
+
+ localhost->hostname = string_strdupz("test_hostname");
+ st->family = string_strdupz("test_family");
+ st->context = string_strdupz("test_context");
expect_function_call(__wrap_now_realtime_sec);
will_return(__wrap_now_realtime_sec, 2);
@@ -1069,7 +1154,7 @@ static void rrd_stats_api_v1_charts_allmetrics_prometheus(void **state)
assert_string_equal(
buffer_tostring(buffer),
- "netdata_info{instance=\"test_hostname\",application=\"(null)\",version=\"(null)\",key1=\"value1\",key2=\"value2\"} 1\n"
+ "netdata_info{instance=\"test_hostname\",application=\"\",version=\"\",key1=\"value1\",key2=\"value2\"} 1\n"
"test_prefix_test_context{chart=\"chart_id\",family=\"test_family\",dimension=\"dimension_id\"} 690565856.0000000\n");
buffer_flush(buffer);
@@ -1085,7 +1170,7 @@ static void rrd_stats_api_v1_charts_allmetrics_prometheus(void **state)
assert_string_equal(
buffer_tostring(buffer),
- "netdata_info{instance=\"test_hostname\",application=\"(null)\",version=\"(null)\",key1=\"value1\",key2=\"value2\"} 1\n"
+ "netdata_info{instance=\"test_hostname\",application=\"\",version=\"\",key1=\"value1\",key2=\"value2\"} 1\n"
"# TYPE test_prefix_test_context gauge\n"
"test_prefix_test_context{chart=\"chart_name\",family=\"test_family\",dimension=\"dimension_name\"} 690565856.0000000\n");
@@ -1101,11 +1186,11 @@ static void rrd_stats_api_v1_charts_allmetrics_prometheus(void **state)
assert_string_equal(
buffer_tostring(buffer),
- "netdata_info{instance=\"test_hostname\",application=\"(null)\",version=\"(null)\",key1=\"value1\",key2=\"value2\"} 1\n"
+ "netdata_info{instance=\"test_hostname\",application=\"\",version=\"\",key1=\"value1\",key2=\"value2\"} 1\n"
"test_prefix_test_context{chart=\"chart_id\",family=\"test_family\",dimension=\"dimension_id\",instance=\"test_hostname\"} 690565856.0000000\n");
- free(localhost->rrdset_root->context);
- free(localhost->rrdset_root->family);
+ free(st->context);
+ free(st->family);
free(localhost->hostname);
buffer_free(buffer);
}
@@ -1207,8 +1292,8 @@ static void test_format_host_prometheus_remote_write(void **state)
simple_connector_data->connector_specific_data = (void *)connector_specific_data;
connector_specific_data->write_request = (void *)0xff;
- localhost->program_name = strdupz("test_program");
- localhost->program_version = strdupz("test_version");
+ localhost->program_name = string_strdupz("test_program");
+ localhost->program_version = string_strdupz("test_version");
expect_function_call(__wrap_add_host_info);
expect_value(__wrap_add_host_info, write_request_p, 0xff);
@@ -1249,7 +1334,15 @@ static void test_format_dimension_prometheus_remote_write(void **state)
simple_connector_data->connector_specific_data = (void *)connector_specific_data;
connector_specific_data->write_request = (void *)0xff;
- RRDDIM *rd = localhost->rrdset_root->dimensions;
+ RRDSET *st;
+ rrdset_foreach_read(st, localhost);
+ break;
+ rrdset_foreach_done(st);
+
+ RRDDIM *rd;
+ rrddim_foreach_read(rd, st);
+ break;
+ rrddim_foreach_done(rd);
expect_function_call(__wrap_exporting_calculate_value_from_stored_data);
will_return(__wrap_exporting_calculate_value_from_stored_data, pack_storage_number(27, SN_DEFAULT_FLAGS));
@@ -1428,7 +1521,11 @@ static void test_aws_kinesis_connector_worker(void **state)
expect_value(__wrap_rrdhost_is_exportable, host, localhost);
will_return(__wrap_rrdhost_is_exportable, 1);
- RRDSET *st = localhost->rrdset_root;
+ RRDSET *st;
+ rrdset_foreach_read(st, localhost);
+ break;
+ rrdset_foreach_done(st);
+
expect_function_call(__wrap_rrdset_is_exportable);
expect_value(__wrap_rrdset_is_exportable, instance, instance);
expect_value(__wrap_rrdset_is_exportable, st, st);
@@ -1563,7 +1660,11 @@ static void test_pubsub_connector_worker(void **state)
expect_value(__wrap_rrdhost_is_exportable, host, localhost);
will_return(__wrap_rrdhost_is_exportable, 1);
- RRDSET *st = localhost->rrdset_root;
+ RRDSET *st;
+ rrdset_foreach_read(st, localhost);
+ break;
+ rrdset_foreach_done(st);
+
expect_function_call(__wrap_rrdset_is_exportable);
expect_value(__wrap_rrdset_is_exportable, instance, instance);
expect_value(__wrap_rrdset_is_exportable, st, st);
diff --git a/exporting/tests/test_exporting_engine.h b/exporting/tests/test_exporting_engine.h
index ae0b7df9a..a9180a518 100644
--- a/exporting/tests/test_exporting_engine.h
+++ b/exporting/tests/test_exporting_engine.h
@@ -4,6 +4,7 @@
#define TEST_EXPORTING_ENGINE_H 1
#include "libnetdata/libnetdata.h"
+#include "database/rrdvar.h"
#include "exporting/exporting_engine.h"
#include "exporting/graphite/graphite.h"
@@ -59,7 +60,7 @@ void __rrdset_check_rdlock(RRDSET *st, const char *file, const char *function, c
void __rrd_check_rdlock(const char *file, const char *function, const unsigned long line);
time_t __mock_rrddim_query_oldest_time(STORAGE_METRIC_HANDLE *db_metric_handle);
time_t __mock_rrddim_query_latest_time(STORAGE_METRIC_HANDLE *db_metric_handle);
-void __mock_rrddim_query_init(STORAGE_METRIC_HANDLE *db_metric_handle, struct rrddim_query_handle *handle, time_t start_time, time_t end_time, TIER_QUERY_FETCH tier_query_fetch_type);
+void __mock_rrddim_query_init(STORAGE_METRIC_HANDLE *db_metric_handle, struct rrddim_query_handle *handle, time_t start_time, time_t end_time);
int __mock_rrddim_query_is_finished(struct rrddim_query_handle *handle);
STORAGE_POINT __mock_rrddim_query_next_metric(struct rrddim_query_handle *handle);
void __mock_rrddim_query_finalize(struct rrddim_query_handle *handle);