Skip to content

Commit 4bf2416

Browse files
committed
WIP
1 parent 03b50cf commit 4bf2416

File tree

5 files changed

+46
-25
lines changed

5 files changed

+46
-25
lines changed

system_tests/operatorpolicy_system_test.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,20 @@ var _ = Describe("OperatorPolicy", func() {
3838
Pattern: "test-queue",
3939
ApplyTo: "queues",
4040
Definition: &runtime.RawExtension{
41-
Raw: []byte(`{"ha-mode":"all"}`),
41+
Raw: []byte(`{"delivery-limit": 5}`),
4242
},
4343
},
4444
}
4545
})
4646

4747
AfterEach(func() {
48+
if CurrentSpecReport().Failed() {
49+
out, err := kubectl("logs", "-n", "rabbitmq-system", rmq.Name+"server-0")
50+
if err != nil {
51+
GinkgoWriter.Printf("error getting rabbitmq logs: %v\n", err)
52+
}
53+
GinkgoWriter.Printf("rabbitmq logs:\n%s\n", string(out))
54+
}
4855
_ = k8sClient.Delete(ctx, policy)
4956
})
5057

@@ -66,7 +73,7 @@ var _ = Describe("OperatorPolicy", func() {
6673
"Priority": Equal(0),
6774
}))
6875

69-
Expect(fetchedPolicy.Definition).To(HaveKeyWithValue("ha-mode", "all"))
76+
Expect(fetchedPolicy.Definition).To(HaveKeyWithValue("delivery-limit", BeEquivalentTo(5)))
7077

7178
By("updating status condition 'Ready'")
7279
updatedPolicy := topology.OperatorPolicy{}
@@ -97,9 +104,7 @@ var _ = Describe("OperatorPolicy", func() {
97104
By("updating operator policy definitions successfully")
98105
Expect(k8sClient.Get(ctx, types.NamespacedName{Name: policy.Name, Namespace: policy.Namespace}, policy)).To(Succeed())
99106
policy.Spec.Definition = &runtime.RawExtension{
100-
Raw: []byte(`{"ha-mode":"exactly",
101-
"ha-params": 2
102-
}`)}
107+
Raw: []byte(`{"delivery-limit": 3, "expires": 1800}`)}
103108
Expect(k8sClient.Update(ctx, policy, &client.UpdateOptions{})).To(Succeed())
104109

105110
Eventually(func() rabbithole.PolicyDefinition {
@@ -109,8 +114,8 @@ var _ = Describe("OperatorPolicy", func() {
109114
return fetchedPolicy.Definition
110115
}, 10, 2).Should(HaveLen(2))
111116

112-
Expect(fetchedPolicy.Definition).To(HaveKeyWithValue("ha-mode", "exactly"))
113-
Expect(fetchedPolicy.Definition).To(HaveKeyWithValue("ha-params", float64(2)))
117+
Expect(fetchedPolicy.Definition).To(HaveKeyWithValue("delivery-limit", BeEquivalentTo(3)))
118+
Expect(fetchedPolicy.Definition).To(HaveKeyWithValue("expires", BeEquivalentTo(1800)))
114119

115120
By("deleting policy")
116121
Expect(k8sClient.Delete(ctx, policy)).To(Succeed())

system_tests/policy_system_test.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ var _ = Describe("Policy", func() {
3737
Pattern: "test-queue",
3838
ApplyTo: "queues",
3939
Definition: &runtime.RawExtension{
40-
Raw: []byte(`{"ha-mode":"all"}`),
40+
Raw: []byte(`{"delivery-limit": 5}`),
4141
},
4242
},
4343
}
@@ -65,7 +65,7 @@ var _ = Describe("Policy", func() {
6565
"Priority": Equal(0),
6666
}))
6767

68-
Expect(fetchedPolicy.Definition).To(HaveKeyWithValue("ha-mode", "all"))
68+
Expect(fetchedPolicy.Definition).To(HaveKeyWithValue("delivery-limit", BeEquivalentTo(5)))
6969

7070
By("updating status condition 'Ready'")
7171
updatedPolicy := topology.Policy{}
@@ -96,9 +96,7 @@ var _ = Describe("Policy", func() {
9696
By("updating policy definitions successfully")
9797
Expect(k8sClient.Get(ctx, types.NamespacedName{Name: policy.Name, Namespace: policy.Namespace}, policy)).To(Succeed())
9898
policy.Spec.Definition = &runtime.RawExtension{
99-
Raw: []byte(`{"ha-mode":"exactly",
100-
"ha-params": 2
101-
}`)}
99+
Raw: []byte(`{"delivery-limit": 3, "expires": 180}`)}
102100
Expect(k8sClient.Update(ctx, policy, &client.UpdateOptions{})).To(Succeed())
103101

104102
Eventually(func() rabbithole.PolicyDefinition {
@@ -108,8 +106,8 @@ var _ = Describe("Policy", func() {
108106
return fetchedPolicy.Definition
109107
}, 10, 2).Should(HaveLen(2))
110108

111-
Expect(fetchedPolicy.Definition).To(HaveKeyWithValue("ha-mode", "exactly"))
112-
Expect(fetchedPolicy.Definition).To(HaveKeyWithValue("ha-params", float64(2)))
109+
Expect(fetchedPolicy.Definition).To(HaveKeyWithValue("delivery-limit", BeEquivalentTo(3)))
110+
Expect(fetchedPolicy.Definition).To(HaveKeyWithValue("expires", BeEquivalentTo(180)))
113111

114112
By("deleting policy")
115113
Expect(k8sClient.Delete(ctx, policy)).To(Succeed())

system_tests/schema_replication_system_test.go

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,23 +59,32 @@ var _ = Describe("schema replication", func() {
5959
It("works", func() {
6060
By("setting schema replication upstream global parameters successfully")
6161
Expect(k8sClient.Create(ctx, replication, &client.CreateOptions{})).To(Succeed())
62+
DeferCleanup(func() {
63+
Expect(k8sClient.Delete(ctx, replication, &client.DeleteOptions{})).To(Succeed())
64+
})
6265
var allGlobalParams []rabbithole.GlobalRuntimeParameter
6366
Eventually(func() []rabbithole.GlobalRuntimeParameter {
6467
var err error
6568
allGlobalParams, err = rabbitClient.ListGlobalParameters()
6669
Expect(err).NotTo(HaveOccurred())
6770
return allGlobalParams
68-
}, 30, 2).Should(HaveLen(3)) // cluster_name and internal_cluster_id are set by default by RabbitMQ
69-
70-
Expect(allGlobalParams).To(ContainElement(
71-
rabbithole.GlobalRuntimeParameter{
72-
Name: "schema_definition_sync_upstream",
73-
Value: map[string]interface{}{
74-
"endpoints": []interface{}{"abc.endpoints.local:5672", "efg.endpoints.local:1234"},
75-
"username": "some-username",
76-
"password": "some-password",
77-
},
78-
}))
71+
}, 30, 2).Should(ContainElement(HaveField("Name", "schema_definition_sync_upstream")))
72+
73+
Expect(allGlobalParams).To(ContainElement(HaveField("Value", And(
74+
HaveKeyWithValue("endpoints", ContainElements("abc.endpoints.local:5672", "efg.endpoints.local:1234")),
75+
HaveKeyWithValue("username", "some-username"),
76+
HaveKeyWithValue("password", "some-password"),
77+
))))
78+
79+
//Expect(allGlobalParams).To(ContainElement(
80+
// rabbithole.GlobalRuntimeParameter{
81+
// Name: "schema_definition_sync_upstream",
82+
// Value: map[string]interface{}{
83+
// "endpoints": []interface{}{"abc.endpoints.local:5672", "efg.endpoints.local:1234"},
84+
// "username": "some-username",
85+
// "password": "some-password",
86+
// },
87+
// }))
7988

8089
By("updating status condition 'Ready'")
8190
updatedReplication := topology.SchemaReplication{}

system_tests/utils.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ func basicTestRabbitmqCluster(name, namespace string) *rabbitmqv1beta1.RabbitmqC
195195
},
196196
Rabbitmq: rabbitmqv1beta1.RabbitmqClusterConfigurationSpec{
197197
AdditionalPlugins: []rabbitmqv1beta1.Plugin{"rabbitmq_federation", "rabbitmq_shovel", "rabbitmq_stream"},
198+
AdditionalConfig: "log.console.level = debug",
198199
},
199200
},
200201
}

system_tests/vhost_system_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,18 @@ var _ = Describe("vhost", func() {
178178
})
179179

180180
AfterEach(func() {
181+
if CurrentSpecReport().Failed() {
182+
out, err := kubectl("logs", "-n", "rabbitmq-system", rmq.Name+"server-0")
183+
if err != nil {
184+
GinkgoWriter.Printf("error getting rabbitmq logs: %v\n", err)
185+
}
186+
GinkgoWriter.Printf("rabbitmq logs:\n%s\n", string(out))
187+
}
181188
Expect(k8sClient.Delete(ctx, vhostWithLimits)).To(Succeed())
182189
})
183190

184191
It("configures the limits", func() {
192+
// TODO: this test seems flaky, perhaps it's racy to create the vhost, get the vhost and set/get vhost limits
185193
var err error
186194
var vhostLimitsInfoResponse []rabbithole.VhostLimitsInfo
187195
Eventually(func() error {

0 commit comments

Comments
 (0)