Skip to content

Commit cfdd0ac

Browse files
tchronoedsiper
authored andcommitted
tests: runtime: processor_metrics_selector: check if works as an output processor
Signed-off-by: Thiago Padilha <[email protected]>
1 parent dc3718e commit cfdd0ac

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

tests/runtime/processor_metrics_selector.c

+65
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,70 @@ void flb_test_selector_substring_exclude(void)
549549
flb_destroy(ctx);
550550
}
551551

552+
void flb_test_selector_can_modify_output(void)
553+
{
554+
int ret;
555+
flb_ctx_t *ctx;
556+
int in_ffd;
557+
int out_ffd;
558+
struct flb_processor *proc;
559+
struct flb_processor_unit *pu;
560+
struct cfl_variant var = {
561+
.type = CFL_VARIANT_STRING,
562+
.data.as_string = "/kubernetes/",
563+
};
564+
struct cfl_variant action = {
565+
.type = CFL_VARIANT_STRING,
566+
.data.as_string = "include",
567+
};
568+
569+
ctx = flb_create();
570+
flb_service_set(ctx,
571+
"Flush", "0.200000000",
572+
"Grace", "2",
573+
NULL);
574+
575+
proc = flb_processor_create(ctx->config, "unit_test", NULL, 0);
576+
TEST_CHECK(proc != NULL);
577+
578+
pu = flb_processor_unit_create(proc, FLB_PROCESSOR_METRICS, "metrics_selector");
579+
TEST_CHECK(pu != NULL);
580+
ret = flb_processor_unit_set_property(pu, "metric_name", &var);
581+
TEST_CHECK(ret == 0);
582+
ret = flb_processor_unit_set_property(pu, "action", &action);
583+
TEST_CHECK(ret == 0);
584+
585+
/* Input */
586+
in_ffd = flb_input(ctx, (char *) "event_type", NULL);
587+
TEST_CHECK(in_ffd >= 0);
588+
ret = flb_input_set(ctx, in_ffd, "tag", "test", NULL);
589+
TEST_CHECK(ret == 0);
590+
ret = flb_input_set(ctx, in_ffd, "type", "metrics", NULL);
591+
TEST_CHECK(ret == 0);
592+
ret = flb_input_set(ctx, in_ffd, "interval_sec", "1", NULL);
593+
TEST_CHECK(ret == 0);
594+
595+
out_ffd = flb_output(ctx, (char *) "stdout", NULL);
596+
TEST_CHECK(out_ffd >= 0);
597+
ret = flb_output_set(ctx, out_ffd, "match", "test", NULL);
598+
TEST_CHECK(ret == 0);
599+
ret = flb_output_set(ctx, out_ffd, "format", "msgpack", NULL);
600+
TEST_CHECK(ret == 0);
601+
602+
/* set up processor */
603+
ret = flb_output_set_processor(ctx, out_ffd, proc);
604+
TEST_CHECK(ret == 0);
605+
606+
clear_output_num();
607+
608+
ret = flb_start(ctx);
609+
TEST_CHECK(ret == 0);
610+
611+
flb_time_msleep(1500); /* waiting flush */
612+
613+
flb_stop(ctx);
614+
flb_destroy(ctx);
615+
}
552616
#endif
553617

554618
/* Test list */
@@ -560,6 +624,7 @@ TEST_LIST = {
560624
{"prefix_exclude", flb_test_selector_prefix_exclude},
561625
{"substring_include", flb_test_selector_substring_include},
562626
{"substring_exclude", flb_test_selector_substring_exclude},
627+
{"can_modify_output", flb_test_selector_can_modify_output},
563628
#endif
564629
{NULL, NULL}
565630
};

0 commit comments

Comments
 (0)