Skip to content

Commit

Permalink
test: add basic config format check
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick Stephens <[email protected]>
  • Loading branch information
patrick-stephens committed Dec 11, 2024
1 parent a6a9c9c commit 02d367d
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions tests/runtime/custom_calyptia_input_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,13 @@ void test_set_fleet_input_properties()
TEST_MSG("max_http_buffer_size expected=%s got=%s", t_ctx->ctx->fleet_max_http_buffer_size, value);
TEST_CHECK(value && strcmp(value, t_ctx->ctx->fleet_max_http_buffer_size) == 0);

// /* Check interval_sec */
/* Check interval_sec */
value = flb_input_get_property("interval_sec", t_ctx->fleet);
TEST_CHECK(value != NULL);
TEST_MSG("interval_sec expected=%s got=%s", t_ctx->ctx->fleet_interval_sec, value);
TEST_CHECK(value && strcmp(value, t_ctx->ctx->fleet_interval_sec) == 0);

// /* Check interval_nsec */
/* Check interval_nsec */
value = flb_input_get_property("interval_nsec", t_ctx->fleet);
TEST_CHECK(value != NULL);
TEST_MSG("interval_nsec expected=%s got=%s", t_ctx->ctx->fleet_interval_nsec, value);
Expand Down Expand Up @@ -276,9 +276,38 @@ static void test_calyptia_machine_id_generation() {
cleanup_test_context(t_ctx);
}

static void test_calyptia_config_format() {
struct test_context *t_ctx = init_test_context();
TEST_CHECK(t_ctx != NULL);

int ret = set_fleet_input_properties(t_ctx->ctx, t_ctx->fleet);
TEST_CHECK(ret == 0);

/* Verify properties were set correctly */
const char *value;

/* Default is true */
value = flb_input_get_property("fleet_config_legacy_format", t_ctx->fleet);
TEST_CHECK(value != NULL);
TEST_MSG("fleet_config_legacy_format default expected=%s got=%s", 'on', value);
TEST_CHECK(value && strcasecmp(value, 'on') == 0);

t_ctx->ctx->fleet_config_legacy_format = FLB_FALSE;
ret = set_fleet_input_properties(t_ctx->ctx, t_ctx->fleet);
TEST_CHECK(ret == 0);

value = flb_input_get_property("fleet_config_legacy_format", t_ctx->fleet);
TEST_CHECK(value != NULL);
TEST_MSG("fleet_config_legacy_format default expected=%s got=%s", 'off', value);
TEST_CHECK(value && strcasecmp(value, 'off') == 0);

cleanup_test_context(t_ctx);
}

/* Define test list */
TEST_LIST = {
{"set_fleet_input_properties", test_set_fleet_input_properties},
{"machine_id_generation", test_calyptia_machine_id_generation},
{"set_fleet_config_format", test_calyptia_config_format},
{NULL, NULL}
};

0 comments on commit 02d367d

Please sign in to comment.