Skip to content

Commit 4549841

Browse files
committed
test/e2e: add controller filter e2e test
Signed-off-by: Damien Grisonnet <[email protected]>
1 parent 5445ff0 commit 4549841

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

test/e2e/filter_test.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,35 @@ func TestEventTypeFilter(t *testing.T) {
8686
})
8787
}
8888
}
89+
90+
func TestControllerFilter(t *testing.T) {
91+
controller := framework.NewBasicEvent().Source.Component
92+
93+
testCases := []struct {
94+
name string
95+
controller string
96+
assert framework.AssertEventsTotalFunc
97+
}{
98+
{
99+
name: "Included",
100+
controller: controller,
101+
assert: f.AssertEventsTotalPresent,
102+
},
103+
{
104+
name: "Excluded",
105+
controller: fmt.Sprintf("not-%s", controller),
106+
assert: f.AssertEventsTotalAbsent,
107+
},
108+
}
109+
110+
for _, tc := range testCases {
111+
tc := tc
112+
t.Run(tc.name, func(t *testing.T) {
113+
f := *f
114+
f.ExporterArgs = []string{fmt.Sprintf("--reporting-controllers=%s", tc.controller)}
115+
exporter := f.CreateKubeEventsExporter(t)
116+
event := f.CreateBasicEvent(t)
117+
tc.assert(t, exporter, event, 1)
118+
})
119+
}
120+
}

test/framework/event.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ func NewBasicEvent() *v1.Event {
8787
Kind: "Pod",
8888
Namespace: "default",
8989
},
90+
Source: v1.EventSource{
91+
Component: "kubelet",
92+
},
9093
Count: 1,
9194
Reason: "test",
9295
Type: v1.EventTypeNormal,

0 commit comments

Comments
 (0)