Skip to content

Commit ce21b18

Browse files
committed
filter_kubernetes: tests: Add a test case for preventing backtracks on regex
Signed-off-by: Hiroshi Hatake <[email protected]>
1 parent 91cadfb commit ce21b18

File tree

4 files changed

+31
-0
lines changed

4 files changed

+31
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"log":"hello from uat pod","stream":"stdout","time":"2019-04-01T17:58:33.598656444Z"}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"apiVersion": "v1",
3+
"kind": "Pod",
4+
"metadata": {
5+
"name": "uat-myapp-12345",
6+
"namespace": "core",
7+
"uid": "00000000-0000-0000-0000-000000000000"
8+
},
9+
"spec": {
10+
"containers": [
11+
{
12+
"name": "container"
13+
}
14+
]
15+
}
16+
}
17+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[1554141513.598656,{"log":"hello from uat pod","stream":"stdout","kubernetes":{"pod_name":"uat-myapp-12345","namespace_name":"core","container_name":"fluent-bit"}}]

tests/runtime/filter_kubernetes.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,17 @@ static void flb_test_core_base_with_namespace_labels_and_annotations()
411411
flb_test_namespace_labels_and_annotations("core_base-with-namespace-labels-and-annotations_fluent-bit", NULL, 1);
412412
}
413413

414+
static void flb_test_kube_short_prefix_uat_podname()
415+
{
416+
kube_test("core/core_uat-myapp-12345_fluent-bit",
417+
KUBE_TAIL,
418+
NULL,
419+
1,
420+
"Use_Tag_For_Meta", "On",
421+
NULL);
422+
}
423+
424+
414425
#define flb_test_owner_references(target, suffix, nExpected) \
415426
kube_test("core/" target, KUBE_TAIL, suffix, nExpected, \
416427
"Labels", "Off", \
@@ -1113,5 +1124,6 @@ TEST_LIST = {
11131124
#ifdef FLB_HAVE_SYSTEMD
11141125
{"kube_systemd_logs", flb_test_systemd_logs},
11151126
#endif
1127+
{"kube_short_prefix_uat_podname", flb_test_kube_short_prefix_uat_podname},
11161128
{NULL, NULL}
11171129
};

0 commit comments

Comments
 (0)