Skip to content

Commit

Permalink
Validate error events are skipped when error event is not configured …
Browse files Browse the repository at this point in the history
…for a resource
  • Loading branch information
Divya063 committed Oct 27, 2020
1 parent d5b3d6c commit 623e38e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/e2e/notifier/error/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ func (c *context) testSKipErrorEvent(t *testing.T) {
// Modifying AllowedEventKindsMap to remove error event for pod resource
delete(utils.AllowedEventKindsMap, utils.EventKind{Resource: "v1/pods", Namespace: "all", EventType: "error"})

// Modifying AllowedEventKindsMap to remove error event for service resource
delete(utils.AllowedEventKindsMap, utils.EventKind{Resource: "v1/services", Namespace: "all", EventType: "error"})

// Modifying AllowedEventKindsMap to add error event for only dummy namespace and ignore everything
utils.AllowedEventKindsMap[utils.EventKind{Resource: "v1/pods", Namespace: "dummy", EventType: "error"}] = true

Expand All @@ -40,6 +43,13 @@ func (c *context) testSKipErrorEvent(t *testing.T) {
Namespace: "test",
Specs: &v1.Pod{ObjectMeta: metav1.ObjectMeta{Name: "test-pod"}, Spec: v1.PodSpec{Containers: []v1.Container{{Name: "test-pod-container", Image: "tomcat:9.0.34"}}}},
},
"skip error event for resources not added in test_config": {
// error event should not be allowed for service resource so event should be skipped
GVR: schema.GroupVersionResource{Group: "", Version: "v1", Resource: "services"},
Kind: "Service",
Namespace: "test",
Specs: &v1.Service{ObjectMeta: metav1.ObjectMeta{Name: "test-service-error"}},
},
}

for name, test := range tests {
Expand All @@ -53,6 +63,8 @@ func (c *context) testSKipErrorEvent(t *testing.T) {
// Resetting original configuration as per test_config
defer delete(utils.AllowedEventKindsMap, utils.EventKind{Resource: "v1/pods", Namespace: "dummy", EventType: "error"})
utils.AllowedEventKindsMap[utils.EventKind{Resource: "v1/pods", Namespace: "all", EventType: "error"}] = true
utils.AllowedEventKindsMap[utils.EventKind{Resource: "v1/services", Namespace: "all", EventType: "error"}] = true

}

// Run tests
Expand Down

0 comments on commit 623e38e

Please sign in to comment.