Skip to content

Commit cdb6c4a

Browse files
committed
tests: runtime: out_loki: add test for flb_mp_accessor per worker
Signed-off-by: Eduardo Silva <[email protected]>
1 parent 0817e00 commit cdb6c4a

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

tests/runtime/out_loki.c

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,52 @@ void flb_test_remove_keys()
644644
flb_destroy(ctx);
645645
}
646646

647+
void flb_test_remove_keys_workers()
648+
{
649+
int ret;
650+
int i;
651+
int size = sizeof(JSON_LABEL_KEYS) - 1;
652+
flb_ctx_t *ctx;
653+
int in_ffd;
654+
int out_ffd;
655+
656+
/* Create context, flush every second (some checks omitted here) */
657+
ctx = flb_create();
658+
flb_service_set(ctx, "flush", "1", "grace", "1",
659+
"log_level", "error",
660+
NULL);
661+
662+
/* Lib input mode */
663+
in_ffd = flb_input(ctx, (char *) "lib", NULL);
664+
flb_input_set(ctx, in_ffd, "tag", "test", NULL);
665+
666+
/* Loki output with multiple workers */
667+
out_ffd = flb_output(ctx, (char *) "loki", NULL);
668+
flb_output_set(ctx, out_ffd,
669+
"match", "test",
670+
"remove_keys", "foo, $data['l_key']",
671+
"workers", "2",
672+
NULL);
673+
674+
/* Enable test mode */
675+
ret = flb_output_set_test(ctx, out_ffd, "formatter",
676+
cb_check_remove_keys,
677+
NULL, NULL);
678+
679+
/* Start */
680+
ret = flb_start(ctx);
681+
TEST_CHECK(ret == 0);
682+
683+
/* Ingest multiple data samples */
684+
for (i = 0; i < 10; i++) {
685+
flb_lib_push(ctx, in_ffd, (char *) JSON_LABEL_KEYS, size);
686+
}
687+
688+
sleep(2);
689+
flb_stop(ctx);
690+
flb_destroy(ctx);
691+
}
692+
647693
static void cb_check_label_map_path(void *ctx, int ffd,
648694
int res_ret, void *res_data, size_t res_size,
649695
void *data)
@@ -972,6 +1018,7 @@ TEST_LIST = {
9721018
{"remove_keys_remove_map" , flb_test_remove_map},
9731019
{"labels_ra" , flb_test_labels_ra },
9741020
{"remove_keys" , flb_test_remove_keys },
1021+
{"remove_keys_workers" , flb_test_remove_keys_workers },
9751022
{"basic" , flb_test_basic },
9761023
{"labels" , flb_test_labels },
9771024
{"label_keys" , flb_test_label_keys },

0 commit comments

Comments
 (0)