Skip to content

Commit e79d647

Browse files
openshift integration (#403)
Wrap expect into eventually on updating status condition in system tests to let tests be more stable in the smaller openshift environment
1 parent 2a1b7b3 commit e79d647

13 files changed

+57
-21
lines changed

system_tests/binding_system_test.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,12 @@ var _ = Describe("Binding", func() {
111111

112112
By("updating status condition 'Ready'")
113113
updatedBinding := topology.Binding{}
114-
Expect(k8sClient.Get(ctx, types.NamespacedName{Name: binding.Name, Namespace: binding.Namespace}, &updatedBinding)).To(Succeed())
115114

116-
Expect(updatedBinding.Status.Conditions).To(HaveLen(1))
115+
Eventually(func() []topology.Condition {
116+
Expect(k8sClient.Get(ctx, types.NamespacedName{Name: binding.Name, Namespace: binding.Namespace}, &updatedBinding)).To(Succeed())
117+
return updatedBinding.Status.Conditions
118+
}, waitUpdatedStatusCondition, 2).Should(HaveLen(1), "Binding status condition should be present")
119+
117120
readyCondition := updatedBinding.Status.Conditions[0]
118121
Expect(string(readyCondition.Type)).To(Equal("Ready"))
119122
Expect(readyCondition.Status).To(Equal(corev1.ConditionTrue))

system_tests/exchange_system_test.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ var _ = Describe("Exchange", func() {
5353
var err error
5454
exchangeInfo, err = rabbitClient.GetExchange(exchange.Spec.Vhost, exchange.Name)
5555
return err
56-
}, 10, 2).Should(BeNil())
56+
}, waitUpdatedStatusCondition, 2).Should(BeNil())
5757

5858
Expect(*exchangeInfo).To(MatchFields(IgnoreExtras, Fields{
5959
"Name": Equal(exchange.Spec.Name),
@@ -66,9 +66,12 @@ var _ = Describe("Exchange", func() {
6666

6767
By("updating status condition 'Ready'")
6868
fetched := topology.Exchange{}
69-
Expect(k8sClient.Get(ctx, types.NamespacedName{Name: exchange.Name, Namespace: exchange.Namespace}, &fetched)).To(Succeed())
7069

71-
Expect(fetched.Status.Conditions).To(HaveLen(1))
70+
Eventually(func() []topology.Condition {
71+
Expect(k8sClient.Get(ctx, types.NamespacedName{Name: exchange.Name, Namespace: exchange.Namespace}, &fetched)).To(Succeed())
72+
return fetched.Status.Conditions
73+
}, 20, 2).Should(HaveLen(1), "Exchange status condition should be present")
74+
7275
readyCondition := fetched.Status.Conditions[0]
7376
Expect(string(readyCondition.Type)).To(Equal("Ready"))
7477
Expect(readyCondition.Status).To(Equal(corev1.ConditionTrue))

system_tests/federation_system_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,11 @@ var _ = Describe("federation", func() {
8181
updatedFederation := topology.Federation{}
8282
Expect(k8sClient.Get(ctx, types.NamespacedName{Name: federation.Name, Namespace: federation.Namespace}, &updatedFederation)).To(Succeed())
8383

84-
Expect(updatedFederation.Status.Conditions).To(HaveLen(1))
84+
Eventually(func() []topology.Condition {
85+
Expect(k8sClient.Get(ctx, types.NamespacedName{Name: federation.Name, Namespace: federation.Namespace}, &updatedFederation)).To(Succeed())
86+
return updatedFederation.Status.Conditions
87+
}, waitUpdatedStatusCondition, 2).Should(HaveLen(1), "Federation status condition should be present")
88+
8589
readyCondition := updatedFederation.Status.Conditions[0]
8690
Expect(string(readyCondition.Type)).To(Equal("Ready"))
8791
Expect(readyCondition.Status).To(Equal(corev1.ConditionTrue))

system_tests/permissions_system_test.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,12 @@ var _ = Describe("Permission", func() {
100100

101101
By("updating status condition 'Ready'")
102102
updatedPermission := topology.Permission{}
103-
Expect(k8sClient.Get(ctx, types.NamespacedName{Name: permission.Name, Namespace: permission.Namespace}, &updatedPermission)).To(Succeed())
104103

105-
Expect(updatedPermission.Status.Conditions).To(HaveLen(1))
104+
Eventually(func() []topology.Condition {
105+
Expect(k8sClient.Get(ctx, types.NamespacedName{Name: permission.Name, Namespace: permission.Namespace}, &updatedPermission)).To(Succeed())
106+
return updatedPermission.Status.Conditions
107+
}, waitUpdatedStatusCondition, 2).Should(HaveLen(1), "Permission status condition should be present")
108+
106109
readyCondition := updatedPermission.Status.Conditions[0]
107110
Expect(string(readyCondition.Type)).To(Equal("Ready"))
108111
Expect(readyCondition.Status).To(Equal(corev1.ConditionTrue))

system_tests/policy_system_test.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,12 @@ var _ = Describe("Policy", func() {
6666

6767
By("updating status condition 'Ready'")
6868
updatedPolicy := topology.Policy{}
69-
Expect(k8sClient.Get(ctx, types.NamespacedName{Name: policy.Name, Namespace: policy.Namespace}, &updatedPolicy)).To(Succeed())
7069

71-
Expect(updatedPolicy.Status.Conditions).To(HaveLen(1))
70+
Eventually(func() []topology.Condition {
71+
Expect(k8sClient.Get(ctx, types.NamespacedName{Name: policy.Name, Namespace: policy.Namespace}, &updatedPolicy)).To(Succeed())
72+
return updatedPolicy.Status.Conditions
73+
}, waitUpdatedStatusCondition, 2).Should(HaveLen(1), "Policy status condition should be present")
74+
7275
readyCondition := updatedPolicy.Status.Conditions[0]
7376
Expect(string(readyCondition.Type)).To(Equal("Ready"))
7477
Expect(readyCondition.Status).To(Equal(corev1.ConditionTrue))

system_tests/queue_system_test.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,12 @@ var _ = Describe("Queue Controller", func() {
6666

6767
By("updating status condition 'Ready'")
6868
updatedQueue := topology.Queue{}
69-
Expect(k8sClient.Get(ctx, types.NamespacedName{Name: q.Name, Namespace: q.Namespace}, &updatedQueue)).To(Succeed())
7069

71-
Expect(updatedQueue.Status.Conditions).To(HaveLen(1))
70+
Eventually(func() []topology.Condition {
71+
Expect(k8sClient.Get(ctx, types.NamespacedName{Name: q.Name, Namespace: q.Namespace}, &updatedQueue)).To(Succeed())
72+
return updatedQueue.Status.Conditions
73+
}, waitUpdatedStatusCondition, 2).Should(HaveLen(1), "Queue status condition should be present")
74+
7275
readyCondition := updatedQueue.Status.Conditions[0]
7376
Expect(string(readyCondition.Type)).To(Equal("Ready"))
7477
Expect(readyCondition.Status).To(Equal(corev1.ConditionTrue))

system_tests/rabbitmq_connection_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ var _ = Describe("RabbitMQ connection using provided connection secret", func()
6464
var err error
6565
qInfo, err = rabbitClient.GetQueue("/", q.Name)
6666
return err
67-
}, 10, 2).Should(BeNil())
67+
}, 20, 2).Should(BeNil())
6868

6969
Expect(qInfo.Name).To(Equal(q.Name))
7070
Expect(qInfo.Vhost).To(Equal("/"))

system_tests/schema_replication_system_test.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,12 @@ var _ = Describe("schema replication", func() {
8080

8181
By("updating status condition 'Ready'")
8282
updatedReplication := topology.SchemaReplication{}
83-
Expect(k8sClient.Get(ctx, types.NamespacedName{Name: replication.Name, Namespace: replication.Namespace}, &updatedReplication)).To(Succeed())
8483

85-
Expect(updatedReplication.Status.Conditions).To(HaveLen(1))
84+
Eventually(func() []topology.Condition {
85+
Expect(k8sClient.Get(ctx, types.NamespacedName{Name: replication.Name, Namespace: replication.Namespace}, &updatedReplication)).To(Succeed())
86+
return updatedReplication.Status.Conditions
87+
}, waitUpdatedStatusCondition, 2).Should(HaveLen(1), "Schema Replication status condition should be present")
88+
8689
readyCondition := updatedReplication.Status.Conditions[0]
8790
Expect(string(readyCondition.Type)).To(Equal("Ready"))
8891
Expect(readyCondition.Status).To(Equal(corev1.ConditionTrue))

system_tests/shovel_system_test.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,12 @@ var _ = Describe("Shovel", func() {
8686

8787
By("updating status condition 'Ready'")
8888
updatedShovel := topology.Shovel{}
89-
Expect(k8sClient.Get(ctx, types.NamespacedName{Name: shovel.Name, Namespace: shovel.Namespace}, &updatedShovel)).To(Succeed())
9089

91-
Expect(updatedShovel.Status.Conditions).To(HaveLen(1))
90+
Eventually(func() []topology.Condition {
91+
Expect(k8sClient.Get(ctx, types.NamespacedName{Name: shovel.Name, Namespace: shovel.Namespace}, &updatedShovel)).To(Succeed())
92+
return updatedShovel.Status.Conditions
93+
}, waitUpdatedStatusCondition, 2).Should(HaveLen(1), "Shovel status condition should be present")
94+
9295
readyCondition := updatedShovel.Status.Conditions[0]
9396
Expect(string(readyCondition.Type)).To(Equal("Ready"))
9497
Expect(readyCondition.Status).To(Equal(corev1.ConditionTrue))

system_tests/tls_system_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ var _ = Describe("RabbitMQ Cluster with TLS enabled", func() {
141141
Eventually(func() []topology.Condition {
142142
Expect(k8sClient.Get(ctx, types.NamespacedName{Name: policy.Name, Namespace: policy.Namespace}, &fetchedPolicy)).To(Succeed())
143143
return fetchedPolicy.Status.Conditions
144-
}, 10, 2).Should(HaveLen(1))
144+
}, waitUpdatedStatusCondition, 2).Should(HaveLen(1), "policy status condition should be present")
145145

146146
readyCondition := fetchedPolicy.Status.Conditions[0]
147147
Expect(string(readyCondition.Type)).To(Equal("Ready"))

system_tests/user_system_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,11 @@ var _ = Describe("Users", func() {
102102
updatedUser := topology.User{}
103103
Expect(k8sClient.Get(ctx, types.NamespacedName{Name: user.Name, Namespace: user.Namespace}, &updatedUser)).To(Succeed())
104104

105-
Expect(updatedUser.Status.Conditions).To(HaveLen(1))
105+
Eventually(func() []topology.Condition {
106+
Expect(k8sClient.Get(ctx, types.NamespacedName{Name: user.Name, Namespace: user.Namespace}, &updatedUser)).To(Succeed())
107+
return updatedUser.Status.Conditions
108+
}, waitUpdatedStatusCondition, 2).Should(HaveLen(1), "User status condition should be present")
109+
106110
readyCondition := updatedUser.Status.Conditions[0]
107111
Expect(string(readyCondition.Type)).To(Equal("Ready"))
108112
Expect(readyCondition.Status).To(Equal(corev1.ConditionTrue))

system_tests/utils.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"os/exec"
1111
"path/filepath"
1212
"strconv"
13+
"time"
1314

1415
"sigs.k8s.io/controller-runtime/pkg/client"
1516

@@ -27,6 +28,9 @@ import (
2728
"k8s.io/utils/pointer"
2829
)
2930

31+
// Useful for small Openshift environment while updating status takes a long time
32+
const waitUpdatedStatusCondition = 20 * time.Second
33+
3034
func createRestConfig() (*rest.Config, error) {
3135
var config *rest.Config
3236
var err error

system_tests/vhost_system_test.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,12 @@ var _ = Describe("vhost", func() {
5353

5454
By("updating status condition 'Ready'")
5555
updatedVhost := topology.Vhost{}
56-
Expect(k8sClient.Get(ctx, types.NamespacedName{Name: vhost.Name, Namespace: vhost.Namespace}, &updatedVhost)).To(Succeed())
5756

58-
Expect(updatedVhost.Status.Conditions).To(HaveLen(1))
57+
Eventually(func() []topology.Condition {
58+
Expect(k8sClient.Get(ctx, types.NamespacedName{Name: vhost.Name, Namespace: vhost.Namespace}, &updatedVhost)).To(Succeed())
59+
return updatedVhost.Status.Conditions
60+
}, waitUpdatedStatusCondition, 2).Should(HaveLen(1), "Vhost status condition should be present")
61+
5962
readyCondition := updatedVhost.Status.Conditions[0]
6063
Expect(string(readyCondition.Type)).To(Equal("Ready"))
6164
Expect(readyCondition.Status).To(Equal(corev1.ConditionTrue))

0 commit comments

Comments
 (0)