Skip to content

Commit 975ff4d

Browse files
tmshortstevekuznetsov
authored andcommitted
Fix flake: Operator Group [It] e2e functionality
Signed-off-by: Todd Short <[email protected]> Upstream-repository: operator-lifecycle-manager Upstream-commit: da028e4f4b3da8eb5dbbe8b1355bec54f4cdca85
1 parent 4616d37 commit 975ff4d

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

staging/operator-lifecycle-manager/test/e2e/operator_groups_e2e_test.go

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -127,21 +127,30 @@ var _ = Describe("Operator Group", func() {
127127
}
128128
_, err = crc.OperatorsV1().OperatorGroups(opGroupNamespace).Create(context.TODO(), &operatorGroup, metav1.CreateOptions{})
129129
require.NoError(GinkgoT(), err)
130-
expectedOperatorGroupStatus := v1.OperatorGroupStatus{
131-
Namespaces: []string{opGroupNamespace, createdOtherNamespace.GetName()},
132-
}
130+
131+
// fetched namespaces might be in any order
132+
namespaces := map[string]bool{}
133+
namespaces[opGroupNamespace] = true
134+
namespaces[createdOtherNamespace.GetName()] = true
133135

134136
log("Waiting on operator group to have correct status")
135137
err = wait.Poll(pollInterval, pollDuration, func() (bool, error) {
136138
fetched, fetchErr := crc.OperatorsV1().OperatorGroups(opGroupNamespace).Get(context.TODO(), operatorGroup.Name, metav1.GetOptions{})
137139
if fetchErr != nil {
138-
return false, fetchErr
140+
log(fmt.Sprintf("error getting operatorgroup %s/%s: %v", opGroupNamespace, operatorGroup.Name, err))
141+
return false, nil
139142
}
140-
if len(fetched.Status.Namespaces) > 0 {
141-
require.ElementsMatch(GinkgoT(), expectedOperatorGroupStatus.Namespaces, fetched.Status.Namespaces, "have %#v", fetched.Status.Namespaces)
142-
return true, nil
143+
if len(namespaces) != len(fetched.Status.Namespaces) {
144+
log(fmt.Sprintf("element length mismatch: %v vs %v", namespaces, fetched.Status.Namespaces))
145+
return false, nil
143146
}
144-
return false, nil
147+
for _, v := range fetched.Status.Namespaces {
148+
if !namespaces[v] {
149+
log(fmt.Sprintf("element values mismatch: %v vs %v", namespaces, fetched.Status.Namespaces))
150+
return false, nil
151+
}
152+
}
153+
return true, nil
145154
})
146155
require.NoError(GinkgoT(), err)
147156

0 commit comments

Comments
 (0)