Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

in_dummy: Add flush_on_startup config. #8222

Merged
merged 1 commit into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions plugins/in_dummy/in_dummy.c
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,10 @@ static int in_dummy_init(struct flb_input_instance *in,

flb_input_set_context(in, ctx);

if (ctx->flush_on_startup) {
in_dummy_collect(in, config, ctx);
}

ret = flb_input_set_collector_time(in,
in_dummy_collect,
tm.tv_sec,
Expand Down Expand Up @@ -444,6 +448,11 @@ static struct flb_config_map config_map[] = {
0, FLB_TRUE, offsetof(struct flb_dummy, fixed_timestamp),
"used a fixed timestamp, allows the message to pre-generated once."
},
{
FLB_CONFIG_MAP_BOOL, "flush_on_startup", "false",
0, FLB_TRUE, offsetof(struct flb_dummy, flush_on_startup),
"generate the first event on startup"
},
{0}
};

Expand Down
1 change: 1 addition & 0 deletions plugins/in_dummy/in_dummy.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ struct flb_dummy {
int start_time_nsec;

bool fixed_timestamp;
bool flush_on_startup;

char *ref_metadata_msgpack;
size_t ref_metadata_msgpack_size;
Expand Down
10 changes: 10 additions & 0 deletions tests/runtime/in_simple_systems.c
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,11 @@ void flb_test_dummy_records_message_interval_nsec(struct callback_records *recor
TEST_CHECK(records->num_records >= 1);
}

void flb_test_dummy_records_message_flush_on_startup(struct callback_records *records)
{
TEST_CHECK(records->num_records >= 2);
}

void flb_test_in_dummy_flush()
{
do_test("dummy", NULL);
Expand Down Expand Up @@ -589,6 +594,11 @@ void flb_test_in_dummy_flush()
"interval_sec", "0",
"interval_nsec", "700000000",
NULL);
do_test_records_wait_time("dummy", 5, flb_test_dummy_records_message_flush_on_startup,
"interval_sec", "5",
"interval_nsec", "0",
"flush_on_startup", "true",
NULL);
}

void flb_test_in_dummy_thread_flush()
Expand Down
Loading