Skip to content

Commit 0f81f75

Browse files
authored
Merge pull request #221 from rabbitmq/flaky-finalizer-test
Fix flaky finalizer test
2 parents 6400cdc + f09d843 commit 0f81f75

10 files changed

+40
-10
lines changed

controllers/binding_controller_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,10 @@ var _ = Describe("bindingController", func() {
208208
Expect(client.Create(ctx, &binding)).To(Succeed())
209209
Eventually(func() []string {
210210
var fetched topology.Binding
211-
Expect(client.Get(ctx, types.NamespacedName{Name: binding.Name, Namespace: binding.Namespace}, &fetched)).To(Succeed())
211+
err := client.Get(ctx, types.NamespacedName{Name: binding.Name, Namespace: binding.Namespace}, &fetched)
212+
if err != nil {
213+
return []string{}
214+
}
212215
return fetched.ObjectMeta.Finalizers
213216
}, 5).Should(ConsistOf("deletion.finalizers.bindings.rabbitmq.com"))
214217
})

controllers/exchange_controller_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,10 @@ var _ = Describe("exchange-controller", func() {
208208
Expect(client.Create(ctx, &exchange)).To(Succeed())
209209
Eventually(func() []string {
210210
var fetched topology.Exchange
211-
Expect(client.Get(ctx, types.NamespacedName{Name: exchange.Name, Namespace: exchange.Namespace}, &fetched)).To(Succeed())
211+
err := client.Get(ctx, types.NamespacedName{Name: exchange.Name, Namespace: exchange.Namespace}, &fetched)
212+
if err != nil {
213+
return []string{}
214+
}
212215
return fetched.ObjectMeta.Finalizers
213216
}, 5).Should(ConsistOf("deletion.finalizers.exchanges.rabbitmq.com"))
214217
})

controllers/federation_controller_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,10 @@ var _ = Describe("federation-controller", func() {
211211
Expect(client.Create(ctx, &federation)).To(Succeed())
212212
Eventually(func() []string {
213213
var fetched topology.Federation
214-
Expect(client.Get(ctx, types.NamespacedName{Name: federation.Name, Namespace: federation.Namespace}, &fetched)).To(Succeed())
214+
err := client.Get(ctx, types.NamespacedName{Name: federation.Name, Namespace: federation.Namespace}, &fetched)
215+
if err != nil {
216+
return []string{}
217+
}
215218
return fetched.ObjectMeta.Finalizers
216219
}, 5).Should(ConsistOf("deletion.finalizers.federations.rabbitmq.com"))
217220
})

controllers/permission_controller_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,10 @@ var _ = Describe("permission-controller", func() {
207207
Expect(client.Create(ctx, &permission)).To(Succeed())
208208
Eventually(func() []string {
209209
var fetched topology.Permission
210-
Expect(client.Get(ctx, types.NamespacedName{Name: permission.Name, Namespace: permission.Namespace}, &fetched)).To(Succeed())
210+
err := client.Get(ctx, types.NamespacedName{Name: permission.Name, Namespace: permission.Namespace}, &fetched)
211+
if err != nil {
212+
return []string{}
213+
}
211214
return fetched.ObjectMeta.Finalizers
212215
}, 5).Should(ConsistOf("deletion.finalizers.permissions.rabbitmq.com"))
213216
})

controllers/policy_controller_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,10 @@ var _ = Describe("policy-controller", func() {
213213
Expect(client.Create(ctx, &policy)).To(Succeed())
214214
Eventually(func() []string {
215215
var fetched topology.Policy
216-
Expect(client.Get(ctx, types.NamespacedName{Name: policy.Name, Namespace: policy.Namespace}, &fetched)).To(Succeed())
216+
err := client.Get(ctx, types.NamespacedName{Name: policy.Name, Namespace: policy.Namespace}, &fetched)
217+
if err != nil {
218+
return []string{}
219+
}
217220
return fetched.ObjectMeta.Finalizers
218221
}, 5).Should(ConsistOf("deletion.finalizers.policies.rabbitmq.com"))
219222
})

controllers/queue_controller_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,10 @@ var _ = Describe("queue-controller", func() {
208208
Expect(client.Create(ctx, &queue)).To(Succeed())
209209
Eventually(func() []string {
210210
var fetched topology.Queue
211-
Expect(client.Get(ctx, types.NamespacedName{Name: queue.Name, Namespace: queue.Namespace}, &fetched)).To(Succeed())
211+
err := client.Get(ctx, types.NamespacedName{Name: queue.Name, Namespace: queue.Namespace}, &fetched)
212+
if err != nil {
213+
return []string{}
214+
}
212215
return fetched.ObjectMeta.Finalizers
213216
}, 5).Should(ConsistOf("deletion.finalizers.queues.rabbitmq.com"))
214217
})

controllers/schemareplication_controller_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,10 @@ var _ = Describe("schema-replication-controller", func() {
211211
Expect(client.Create(ctx, &replication)).To(Succeed())
212212
Eventually(func() []string {
213213
var fetched topology.SchemaReplication
214-
Expect(client.Get(ctx, types.NamespacedName{Name: replication.Name, Namespace: replication.Namespace}, &fetched)).To(Succeed())
214+
err := client.Get(ctx, types.NamespacedName{Name: replication.Name, Namespace: replication.Namespace}, &fetched)
215+
if err != nil {
216+
return []string{}
217+
}
215218
return fetched.ObjectMeta.Finalizers
216219
}, 5).Should(ConsistOf("deletion.finalizers.schemareplications.rabbitmq.com"))
217220
})

controllers/shovel_controller_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,10 @@ var _ = Describe("shovel-controller", func() {
211211
Expect(client.Create(ctx, &shovel)).To(Succeed())
212212
Eventually(func() []string {
213213
var fetched topology.Shovel
214-
Expect(client.Get(ctx, types.NamespacedName{Name: shovel.Name, Namespace: shovel.Namespace}, &fetched)).To(Succeed())
214+
err := client.Get(ctx, types.NamespacedName{Name: shovel.Name, Namespace: shovel.Namespace}, &fetched)
215+
if err != nil {
216+
return []string{}
217+
}
215218
return fetched.ObjectMeta.Finalizers
216219
}, 5).Should(ConsistOf("deletion.finalizers.shovels.rabbitmq.com"))
217220
})

controllers/user_controller_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,10 @@ var _ = Describe("UserController", func() {
240240
Expect(client.Create(ctx, &user)).To(Succeed())
241241
Eventually(func() []string {
242242
var fetched topology.User
243-
Expect(client.Get(ctx, types.NamespacedName{Name: user.Name, Namespace: user.Namespace}, &fetched)).To(Succeed())
243+
err := client.Get(ctx, types.NamespacedName{Name: user.Name, Namespace: user.Namespace}, &fetched)
244+
if err != nil {
245+
return []string{}
246+
}
244247
return fetched.ObjectMeta.Finalizers
245248
}, 5).Should(ConsistOf("deletion.finalizers.users.rabbitmq.com"))
246249
})

controllers/vhost_controller_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,10 @@ var _ = Describe("vhost-controller", func() {
208208
Expect(client.Create(ctx, &vhost)).To(Succeed())
209209
Eventually(func() []string {
210210
var fetched topology.Vhost
211-
Expect(client.Get(ctx, types.NamespacedName{Name: vhost.Name, Namespace: vhost.Namespace}, &fetched)).To(Succeed())
211+
err := client.Get(ctx, types.NamespacedName{Name: vhost.Name, Namespace: vhost.Namespace}, &fetched)
212+
if err != nil {
213+
return []string{}
214+
}
212215
return fetched.ObjectMeta.Finalizers
213216
}, 5).Should(ConsistOf("deletion.finalizers.vhosts.rabbitmq.com"))
214217
})

0 commit comments

Comments
 (0)