Skip to content

Commit 628e82f

Browse files
pwhelanscne59
authored andcommitted
tests: runtime: in_kubernetes_events: try/wait for output to make tests less flakey. re fluent#9570. (fluent#9877)
Signed-off-by: Phillip Adair Stewart Whelan <[email protected]>
1 parent 8627ae7 commit 628e82f

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

tests/runtime/in_kubernetes_events.c

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ void flb_test_events_v1_with_lastTimestamp()
328328
int ret;
329329
int num;
330330
const char *filename = "eventlist_v1_with_lastTimestamp";
331+
int trys;
331332

332333
clear_output_num();
333334

@@ -347,8 +348,10 @@ void flb_test_events_v1_with_lastTimestamp()
347348
ret = flb_start(ctx->flb);
348349
TEST_CHECK(ret == 0);
349350

350-
// waiting to flush
351-
flb_time_msleep(1500);
351+
// waiting to flush
352+
for (trys = 0; trys < 5 && get_output_num() <= 0; trys++) {
353+
flb_time_msleep(1000);
354+
}
352355

353356
num = get_output_num();
354357
if (!TEST_CHECK(num > 0)) {
@@ -365,6 +368,7 @@ void flb_test_events_v1_with_creationTimestamp()
365368
int ret;
366369
int num;
367370
const char *filename = "eventlist_v1_with_creationTimestamp";
371+
int trys;
368372

369373
clear_output_num();
370374

@@ -384,8 +388,10 @@ void flb_test_events_v1_with_creationTimestamp()
384388
ret = flb_start(ctx->flb);
385389
TEST_CHECK(ret == 0);
386390

387-
// waiting to flush
388-
flb_time_msleep(1500);
391+
// waiting to flush
392+
for (trys = 0; trys < 5 && get_output_num() <= 0; trys++) {
393+
flb_time_msleep(1000);
394+
}
389395

390396
num = get_output_num();
391397
if (!TEST_CHECK(num > 0)) {
@@ -399,6 +405,7 @@ void flb_test_events_with_chunkedrecv()
399405
{
400406
struct flb_lib_out_cb cb_data;
401407
struct test_ctx *ctx;
408+
int trys;
402409

403410
int ret;
404411
int num;
@@ -423,8 +430,10 @@ void flb_test_events_with_chunkedrecv()
423430
ret = flb_start(ctx->flb);
424431
TEST_CHECK(ret == 0);
425432

426-
// waiting to flush
427-
flb_time_msleep(5000);
433+
// waiting to flush
434+
for (trys = 0; trys < 5 && get_output_num() <= 1; trys++) {
435+
flb_time_msleep(1000);
436+
}
428437

429438
num = get_output_num();
430439
if (!TEST_CHECK(num >= 2)) {

0 commit comments

Comments
 (0)