From 854cd7fa6a2af07f03eeb40d83875c7b49b7eab7 Mon Sep 17 00:00:00 2001 From: Michael Nairn Date: Mon, 29 Apr 2024 09:00:58 +0100 Subject: [PATCH] tests: Allow parallel execution of DNS and TLS Policy tests (#583) Creates a unique gateway class per test case and removes `Ordered` from the TLS policy tests. ``` ./bin/ginkgo -p --procs 20 --focus "DNSPolicy" --focus "TLSPolicy" --skip "Target status reconciler" -tags integration ./controllers/... ``` --- .../dnspolicy_controller_multi_cluster_test.go | 2 +- ...dnspolicy_controller_single_cluster_test.go | 2 +- controllers/dnspolicy_controller_test.go | 2 +- controllers/tlspolicy_controller_test.go | 18 ++++++------------ 4 files changed, 9 insertions(+), 15 deletions(-) diff --git a/controllers/dnspolicy_controller_multi_cluster_test.go b/controllers/dnspolicy_controller_multi_cluster_test.go index 6f092a4af..7932cbf06 100644 --- a/controllers/dnspolicy_controller_multi_cluster_test.go +++ b/controllers/dnspolicy_controller_multi_cluster_test.go @@ -42,7 +42,7 @@ var _ = Describe("DNSPolicy Multi Cluster", func() { ownerID, err = utils.GetClusterUID(ctx, k8sClient) Expect(err).To(BeNil()) - gatewayClass = testBuildGatewayClass("foo", "default", "kuadrant.io/bar") + gatewayClass = testBuildGatewayClass("gwc-"+testNamespace, "default", "kuadrant.io/bar") Expect(k8sClient.Create(ctx, gatewayClass)).To(Succeed()) managedZone = testBuildManagedZone("mz-example-com", testNamespace, "example.com") diff --git a/controllers/dnspolicy_controller_single_cluster_test.go b/controllers/dnspolicy_controller_single_cluster_test.go index 3a85d9307..d66db640c 100644 --- a/controllers/dnspolicy_controller_single_cluster_test.go +++ b/controllers/dnspolicy_controller_single_cluster_test.go @@ -41,7 +41,7 @@ var _ = Describe("DNSPolicy Single Cluster", func() { clusterUID, err := utils.GetClusterUID(ctx, k8sClient) Expect(err).To(BeNil()) - gatewayClass = testBuildGatewayClass("foo", "default", "kuadrant.io/bar") + gatewayClass = testBuildGatewayClass("gwc-"+testNamespace, "default", "kuadrant.io/bar") Expect(k8sClient.Create(ctx, gatewayClass)).To(Succeed()) managedZone = testBuildManagedZone("mz-example-com", testNamespace, "example.com") diff --git a/controllers/dnspolicy_controller_test.go b/controllers/dnspolicy_controller_test.go index c7e73cf2b..62ecc0d0e 100644 --- a/controllers/dnspolicy_controller_test.go +++ b/controllers/dnspolicy_controller_test.go @@ -39,7 +39,7 @@ var _ = Describe("DNSPolicy controller", func() { ctx = context.Background() testNamespace = CreateNamespaceWithContext(ctx) - gatewayClass = testBuildGatewayClass("foo", "default", "kuadrant.io/bar") + gatewayClass = testBuildGatewayClass("gwc-"+testNamespace, "default", "kuadrant.io/bar") Expect(k8sClient.Create(ctx, gatewayClass)).To(Succeed()) managedZone = testBuildManagedZone("mz-example-com", testNamespace, "example.com") diff --git a/controllers/tlspolicy_controller_test.go b/controllers/tlspolicy_controller_test.go index 93a7db088..2814d467b 100644 --- a/controllers/tlspolicy_controller_test.go +++ b/controllers/tlspolicy_controller_test.go @@ -24,24 +24,23 @@ import ( "github.com/kuadrant/kuadrant-operator/api/v1alpha1" ) -var _ = Describe("TLSPolicy controller", Ordered, func() { +var _ = Describe("TLSPolicy controller", func() { - var testNamespace string var gatewayClass *gatewayapiv1.GatewayClass + var testNamespace string var issuer *certmanv1.Issuer var issuerRef *certmanmetav1.ObjectReference var gateway *gatewayapiv1.Gateway var tlsPolicy *v1alpha1.TLSPolicy var ctx context.Context - BeforeAll(func() { + BeforeEach(func() { ctx = context.Background() - gatewayClass = testBuildGatewayClass("foo", "default", "kuadrant.io/bar") + testNamespace = CreateNamespaceWithContext(ctx) + + gatewayClass = testBuildGatewayClass("gwc-"+testNamespace, "default", "kuadrant.io/bar") Expect(k8sClient.Create(ctx, gatewayClass)).To(Succeed()) - }) - BeforeEach(func() { - testNamespace = CreateNamespaceWithContext(ctx) issuer, issuerRef = testBuildSelfSignedIssuer("testissuer", testNamespace) Expect(k8sClient.Create(ctx, issuer)).To(BeNil()) }) @@ -66,11 +65,6 @@ var _ = Describe("TLSPolicy controller", Ordered, func() { DeleteNamespaceCallbackWithContext(ctx, testNamespace) }) - AfterAll(func() { - err := k8sClient.Delete(ctx, gatewayClass) - Expect(client.IgnoreNotFound(err)).ToNot(HaveOccurred()) - }) - Context("invalid target", func() { BeforeEach(func() { tlsPolicy = v1alpha1.NewTLSPolicy("test-tls-policy", testNamespace).