File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed
Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff 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+ }
Original file line number Diff line number Diff 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 ,
You can’t perform that action at this time.
0 commit comments