Skip to content

Commit 2e2710e

Browse files
committed
test/e2e: Attempt to cleanup Operator test resources
1 parent b1cc69e commit 2e2710e

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

test/e2e/operator_test.go

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ var _ = Describe("Operator API", func() {
5151
Expect(err).ToNot(HaveOccurred())
5252
})
5353

54+
AfterEach(func() {
55+
Eventually(func() error {
56+
return operatorClient.DeleteCollection(clientCtx, metav1.DeleteOptions{}, listOpts)
57+
}).Should(Succeed())
58+
})
59+
5460
// Ensures that an Operator resource can select its components by label and surface them correctly in its status.
5561
//
5662
// Steps:
@@ -74,12 +80,12 @@ var _ = Describe("Operator API", func() {
7480
o := &operatorsv1.Operator{}
7581
o.SetName(genName("o-"))
7682

77-
Consistently(o).ShouldNot(ContainCopiedCSVReferences())
78-
7983
Eventually(func() error {
8084
return client.Create(clientCtx, o)
8185
}).Should(Succeed())
8286

87+
Consistently(o).ShouldNot(ContainCopiedCSVReferences())
88+
8389
defer func() {
8490
Eventually(func() error {
8591
err := client.Delete(clientCtx, o)
@@ -323,12 +329,21 @@ var _ = Describe("Operator API", func() {
323329
})
324330

325331
AfterEach(func() {
332+
By("Deleting the testing namespace")
326333
Eventually(func() error {
327-
err := client.Delete(clientCtx, ns)
328-
if apierrors.IsNotFound(err) {
329-
return nil
330-
}
331-
return err
334+
return controllerclient.IgnoreNotFound(client.Delete(clientCtx, ns))
335+
}).Should(Succeed())
336+
337+
By("Deleting the kiali-related CRDs")
338+
Eventually(func() error {
339+
return client.DeleteAllOf(clientCtx, &apiextensionsv1.CustomResourceDefinition{}, controllerclient.MatchingLabels{
340+
fmt.Sprintf("operators.coreos.com/%s", operatorName.Name): "",
341+
})
342+
}).Should(Succeed())
343+
344+
By("Deleting the test Operator resource")
345+
Eventually(func() error {
346+
return operatorClient.Delete(clientCtx, operatorName.Name, metav1.DeleteOptions{})
332347
}).Should(Succeed())
333348
})
334349

0 commit comments

Comments
 (0)