fix permission race condition in foreigncluster test
@@ -5,6 +5,7 @@ import (
"os"
"path/filepath"
"testing"
+ "time"
. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/extensions/table"
@@ -29,6 +30,11 @@ import (
testUtils "github.com/liqotech/liqo/pkg/utils/testUtils"
)
+const (
+ timeout = time.Second * 30
+ interval = time.Millisecond * 250
+)
+
type configMock struct {
config v1alpha1.DiscoveryConfig
}
@@ -701,15 +707,17 @@ var _ = Describe("ForeignClusterOperator", func() {
Expect(controller.ensurePermission(ctx, &c.fc)).To(Succeed())
var roleBindingList rbacv1.RoleBindingList
+ Eventually(func() []string {
Expect(controller.Client.List(ctx, &roleBindingList)).To(Succeed())
names := make([]string, len(roleBindingList.Items))
for i := range roleBindingList.Items {
+ if roleBindingList.Items[i].DeletionTimestamp.IsZero() {
names[i] = roleBindingList.Items[i].Name
}
-
- Expect(names).To(c.expectedIncoming)
- Expect(names).To(c.expectedOutgoing)
+ }
+ return names
+ }, timeout, interval).Should(And(c.expectedIncoming, c.expectedOutgoing))
By("Delete RoleBindings")
@@ -719,15 +727,17 @@ var _ = Describe("ForeignClusterOperator", func() {
Expect(controller.ensurePermission(ctx, &c.fc)).To(Succeed())
+ Eventually(func() []string {
Expect(controller.Client.List(ctx, &roleBindingList)).To(Succeed())
- names = make([]string, len(roleBindingList.Items))
+ names := make([]string, len(roleBindingList.Items))
for i := range roleBindingList.Items {
+ if roleBindingList.Items[i].DeletionTimestamp.IsZero() {
names[i] = roleBindingList.Items[i].Name
}
-
- Expect(names).To(c.expectedIncoming)
- Expect(names).To(c.expectedOutgoing)
+ }
+ return names
+ }, timeout, interval).Should(And(c.expectedIncoming, c.expectedOutgoing))
},
Entry("none peering", permissionTestcase{
