Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

an attempt to fix integration tests #2861

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions test/pipelinerun_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ func TestPipelineRun(t *testing.T) {
collectedEvents += ", "
}
}
t.Fatalf("Expected %d number of successful events from pipelinerun and taskrun but got %d; list of receieved events : %#v", td.expectedNumberOfEvents, len(events), collectedEvents)
t.Fatalf("Expected %d number of successful events from pipelinerun and taskrun but got %d; list of received events : %#v", td.expectedNumberOfEvents, len(events), collectedEvents)
}

// Wait for up to 10 minutes and restart every second to check if
Expand Down Expand Up @@ -550,6 +550,16 @@ func getName(namespace string, suffix int) string {
return fmt.Sprintf("%s%d", namespace, suffix)
}

// inEvents returns true if the specified event already exists in the list of specified events
func inEvents(events []*corev1.Event, event *corev1.Event) bool {
for _, e := range events {
if event.InvolvedObject.Name == e.InvolvedObject.Name && event.Reason == e.Reason {
return true
}
}
return false
}

// collectMatchingEvents collects list of events under 5 seconds that match
// 1. matchKinds which is a map of Kind of Object with name of objects
// 2. reason which is the expected reason of event
Expand All @@ -573,7 +583,9 @@ func collectMatchingEvents(kubeClient *knativetest.KubeClient, namespace string,
if val, ok := kinds[event.InvolvedObject.Kind]; ok {
for _, expectedName := range val {
if event.InvolvedObject.Name == expectedName && event.Reason == reason {
events = append(events, event)
if !inEvents(events, event) {
events = append(events, event)
}
}
}
}
Expand Down