|
5 | 5 | "errors"
|
6 | 6 | "io/ioutil"
|
7 | 7 | "net/http"
|
8 |
| - "sigs.k8s.io/controller-runtime/pkg/envtest/komega" |
9 | 8 | "time"
|
10 | 9 |
|
11 | 10 | . "github.com/onsi/ginkgo/v2"
|
@@ -89,37 +88,6 @@ var _ = Describe("exchange-controller", func() {
|
89 | 88 | })))
|
90 | 89 | })
|
91 | 90 | })
|
92 |
| - |
93 |
| - When("success", func() { |
94 |
| - BeforeEach(func() { |
95 |
| - exchangeName = "test-create-success" |
96 |
| - fakeRabbitMQClient.DeclareExchangeReturns(&http.Response{ |
97 |
| - Status: "201 Created", |
98 |
| - StatusCode: http.StatusCreated, |
99 |
| - }, nil) |
100 |
| - }) |
101 |
| - |
102 |
| - It("works", func() { |
103 |
| - Expect(client.Create(ctx, &exchange)).To(Succeed()) |
104 |
| - By("setting the correct finalizer") |
105 |
| - Eventually(komega.Object(&exchange)).WithTimeout(2 * time.Second).Should(HaveField("ObjectMeta.Finalizers", ConsistOf("deletion.finalizers.exchanges.rabbitmq.com"))) |
106 |
| - |
107 |
| - By("sets the status condition 'Ready' to 'true'") |
108 |
| - EventuallyWithOffset(1, func() []topology.Condition { |
109 |
| - _ = client.Get( |
110 |
| - ctx, |
111 |
| - types.NamespacedName{Name: exchange.Name, Namespace: exchange.Namespace}, |
112 |
| - &exchange, |
113 |
| - ) |
114 |
| - |
115 |
| - return exchange.Status.Conditions |
116 |
| - }, statusEventsUpdateTimeout, 1*time.Second).Should(ContainElement(MatchFields(IgnoreExtras, Fields{ |
117 |
| - "Type": Equal(topology.ConditionType("Ready")), |
118 |
| - "Reason": Equal("SuccessfulCreateOrUpdate"), |
119 |
| - "Status": Equal(corev1.ConditionTrue), |
120 |
| - }))) |
121 |
| - }) |
122 |
| - }) |
123 | 91 | })
|
124 | 92 | Context("LastTransitionTime", func() {
|
125 | 93 | BeforeEach(func() {
|
@@ -247,138 +215,5 @@ var _ = Describe("exchange-controller", func() {
|
247 | 215 | Expect(observedEvents()).To(ContainElement("Warning FailedDelete failed to delete exchange"))
|
248 | 216 | })
|
249 | 217 | })
|
250 |
| - |
251 |
| - When("the RabbitMQ Client successfully deletes a exchange", func() { |
252 |
| - BeforeEach(func() { |
253 |
| - exchangeName = "delete-exchange-success" |
254 |
| - fakeRabbitMQClient.DeleteExchangeReturns(&http.Response{ |
255 |
| - Status: "204 No Content", |
256 |
| - StatusCode: http.StatusNoContent, |
257 |
| - }, nil) |
258 |
| - }) |
259 |
| - |
260 |
| - It("publishes a normal event", func() { |
261 |
| - Expect(client.Delete(ctx, &exchange)).To(Succeed()) |
262 |
| - Eventually(func() bool { |
263 |
| - err := client.Get(ctx, types.NamespacedName{Name: exchange.Name, Namespace: exchange.Namespace}, &topology.Exchange{}) |
264 |
| - return apierrors.IsNotFound(err) |
265 |
| - }, statusEventsUpdateTimeout).Should(BeTrue()) |
266 |
| - Expect(observedEvents()).To(SatisfyAll( |
267 |
| - Not(ContainElement("Warning FailedDelete failed to delete exchange")), |
268 |
| - ContainElement("Normal SuccessfulDelete successfully deleted exchange"), |
269 |
| - )) |
270 |
| - }) |
271 |
| - }) |
272 |
| - }) |
273 |
| - |
274 |
| - When("an exchange references a cluster from a prohibited namespace", func() { |
275 |
| - JustBeforeEach(func() { |
276 |
| - exchangeName = "test-exchange-prohibited" |
277 |
| - exchange = topology.Exchange{ |
278 |
| - ObjectMeta: metav1.ObjectMeta{ |
279 |
| - Name: exchangeName, |
280 |
| - Namespace: "prohibited", |
281 |
| - }, |
282 |
| - Spec: topology.ExchangeSpec{ |
283 |
| - RabbitmqClusterReference: topology.RabbitmqClusterReference{ |
284 |
| - Name: "example-rabbit", |
285 |
| - Namespace: "default", |
286 |
| - }, |
287 |
| - }, |
288 |
| - } |
289 |
| - }) |
290 |
| - It("should throw an error about a cluster being prohibited", func() { |
291 |
| - Expect(client.Create(ctx, &exchange)).To(Succeed()) |
292 |
| - EventuallyWithOffset(1, func() []topology.Condition { |
293 |
| - _ = client.Get( |
294 |
| - ctx, |
295 |
| - types.NamespacedName{Name: exchange.Name, Namespace: exchange.Namespace}, |
296 |
| - &exchange, |
297 |
| - ) |
298 |
| - |
299 |
| - return exchange.Status.Conditions |
300 |
| - }, statusEventsUpdateTimeout, 1*time.Second).Should(ContainElement(MatchFields(IgnoreExtras, Fields{ |
301 |
| - "Type": Equal(topology.ConditionType("Ready")), |
302 |
| - "Reason": Equal("FailedCreateOrUpdate"), |
303 |
| - "Status": Equal(corev1.ConditionFalse), |
304 |
| - "Message": ContainSubstring("not allowed to reference"), |
305 |
| - }))) |
306 |
| - }) |
307 |
| - }) |
308 |
| - |
309 |
| - When("an exchange references a cluster from an allowed namespace", func() { |
310 |
| - JustBeforeEach(func() { |
311 |
| - exchangeName = "test-exchange-allowed" |
312 |
| - exchange = topology.Exchange{ |
313 |
| - ObjectMeta: metav1.ObjectMeta{ |
314 |
| - Name: exchangeName, |
315 |
| - Namespace: "allowed", |
316 |
| - }, |
317 |
| - Spec: topology.ExchangeSpec{ |
318 |
| - RabbitmqClusterReference: topology.RabbitmqClusterReference{ |
319 |
| - Name: "example-rabbit", |
320 |
| - Namespace: "default", |
321 |
| - }, |
322 |
| - }, |
323 |
| - } |
324 |
| - fakeRabbitMQClient.DeclareExchangeReturns(&http.Response{ |
325 |
| - Status: "201 Created", |
326 |
| - StatusCode: http.StatusCreated, |
327 |
| - }, nil) |
328 |
| - }) |
329 |
| - It("should be created", func() { |
330 |
| - Expect(client.Create(ctx, &exchange)).To(Succeed()) |
331 |
| - EventuallyWithOffset(1, func() []topology.Condition { |
332 |
| - _ = client.Get( |
333 |
| - ctx, |
334 |
| - types.NamespacedName{Name: exchange.Name, Namespace: exchange.Namespace}, |
335 |
| - &exchange, |
336 |
| - ) |
337 |
| - |
338 |
| - return exchange.Status.Conditions |
339 |
| - }, statusEventsUpdateTimeout, 1*time.Second).Should(ContainElement(MatchFields(IgnoreExtras, Fields{ |
340 |
| - "Type": Equal(topology.ConditionType("Ready")), |
341 |
| - "Reason": Equal("SuccessfulCreateOrUpdate"), |
342 |
| - "Status": Equal(corev1.ConditionTrue), |
343 |
| - }))) |
344 |
| - }) |
345 |
| - }) |
346 |
| - |
347 |
| - When("an exchange references a cluster that allows all namespaces", func() { |
348 |
| - JustBeforeEach(func() { |
349 |
| - exchangeName = "test-exchange-allowed-when-allow-all" |
350 |
| - exchange = topology.Exchange{ |
351 |
| - ObjectMeta: metav1.ObjectMeta{ |
352 |
| - Name: exchangeName, |
353 |
| - Namespace: "prohibited", |
354 |
| - }, |
355 |
| - Spec: topology.ExchangeSpec{ |
356 |
| - RabbitmqClusterReference: topology.RabbitmqClusterReference{ |
357 |
| - Name: "allow-all-rabbit", |
358 |
| - Namespace: "default", |
359 |
| - }, |
360 |
| - }, |
361 |
| - } |
362 |
| - fakeRabbitMQClient.DeclareExchangeReturns(&http.Response{ |
363 |
| - Status: "201 Created", |
364 |
| - StatusCode: http.StatusCreated, |
365 |
| - }, nil) |
366 |
| - }) |
367 |
| - It("should be created", func() { |
368 |
| - Expect(client.Create(ctx, &exchange)).To(Succeed()) |
369 |
| - EventuallyWithOffset(1, func() []topology.Condition { |
370 |
| - _ = client.Get( |
371 |
| - ctx, |
372 |
| - types.NamespacedName{Name: exchange.Name, Namespace: exchange.Namespace}, |
373 |
| - &exchange, |
374 |
| - ) |
375 |
| - |
376 |
| - return exchange.Status.Conditions |
377 |
| - }, statusEventsUpdateTimeout, 1*time.Second).Should(ContainElement(MatchFields(IgnoreExtras, Fields{ |
378 |
| - "Type": Equal(topology.ConditionType("Ready")), |
379 |
| - "Reason": Equal("SuccessfulCreateOrUpdate"), |
380 |
| - "Status": Equal(corev1.ConditionTrue), |
381 |
| - }))) |
382 |
| - }) |
383 | 218 | })
|
384 | 219 | })
|
0 commit comments