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

tests: in_dummy: try and wait for the first record before doing checks. #8276

Merged
merged 1 commit into from
Dec 12, 2023
Merged
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
43 changes: 32 additions & 11 deletions tests/runtime/in_simple_systems.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ void do_test(char *system, ...)
va_list va;
char *key;
char *value;
int trys;
struct flb_lib_out_cb cb;

cb.cb = callback_test;
Expand Down Expand Up @@ -150,17 +151,20 @@ void do_test(char *system, ...)
/* Start test */
TEST_CHECK(flb_start(ctx) == 0);

/* 2 sec passed. It must have flushed */
sleep(2);
for (trys = 0; trys < 5 && get_result() == 0; trys++) {
sleep(1);
}

flb_info("[test] check status 1");
ret = get_result();
TEST_CHECK(ret > 0);

/* 4 sec passed. It must have flushed */
sleep(2);
for (trys = 0; trys < 5 && get_result() == ret; trys++) {
sleep(1);
}

flb_info("[test] check status 2");
ret = get_result();
TEST_CHECK(ret > 0);
TEST_CHECK(get_result() > ret);

flb_stop(ctx);
flb_destroy(ctx);
Expand All @@ -174,7 +178,8 @@ void do_test_records(char *system, void (*records_cb)(struct callback_records *)
va_list va;
char *key;
char *value;
int i;
int idx;
int trys;
struct flb_lib_out_cb cb;
struct callback_records *records;

Expand Down Expand Up @@ -212,15 +217,16 @@ void do_test_records(char *system, void (*records_cb)(struct callback_records *)
/* Start test */
TEST_CHECK(flb_start(ctx) == 0);

/* 4 sec passed. It must have flushed */
sleep(5);
for (trys = 0; trys < 5 && records->num_records <= 0; trys++) {
sleep(1);
}

records_cb(records);

flb_stop(ctx);

for (i = 0; i < records->num_records; i++) {
flb_lib_free(records->records[i].data);
for (idx = 0; idx < records->num_records; idx++) {
flb_lib_free(records->records[idx].data);
}
flb_free(records->records);
flb_free(records);
Expand Down Expand Up @@ -525,16 +531,31 @@ void flb_test_dummy_records_message_copies_1(struct callback_records *records)

void flb_test_dummy_records_message_copies_5(struct callback_records *records)
{
int trys;

for (trys = 0; trys < 5 && records->num_records < 5; trys++) {
sleep(1);
}
TEST_CHECK(records->num_records >= 5);
}

void flb_test_dummy_records_message_copies_100(struct callback_records *records)
{
int trys;

for (trys = 0; trys < 100 && records->num_records < 100; trys++) {
sleep(1);
}
TEST_CHECK(records->num_records >= 100);
}

void flb_test_dummy_records_message_rate(struct callback_records *records)
{
int trys;

for (trys = 0; trys < 20 && records->num_records < 20; trys++) {
sleep(1);
}
TEST_CHECK(records->num_records >= 20);
}

Expand Down
Loading