From 6198d34bad949cbf7d07af536df0b9e1bb6d3c34 Mon Sep 17 00:00:00 2001 From: Balazs Gibizer Date: Mon, 2 Oct 2023 10:52:25 +0200 Subject: [PATCH] [envtest]Use infra helpers from infra-operator This is necessary to remove a dependency cycle from lib-common --- go.mod | 6 ++-- go.sum | 12 +++---- tests/functional/ironic_controller_test.go | 20 ++++++------ .../ironicinspector_controller_test.go | 32 +++++++++---------- .../ironicneutronagent_controller_test.go | 20 ++++++------ tests/functional/suite_test.go | 4 +++ 6 files changed, 49 insertions(+), 45 deletions(-) diff --git a/go.mod b/go.mod index db8a3060..a898c307 100644 --- a/go.mod +++ b/go.mod @@ -6,12 +6,12 @@ require ( github.com/go-logr/logr v1.2.4 github.com/k8snetworkplumbingwg/network-attachment-definition-client v1.4.0 github.com/onsi/ginkgo/v2 v2.12.1 - github.com/onsi/gomega v1.27.10 + github.com/onsi/gomega v1.28.0 github.com/openshift/api v3.9.0+incompatible - github.com/openstack-k8s-operators/infra-operator/apis v0.1.1-0.20230926144332-61ec188379c1 + github.com/openstack-k8s-operators/infra-operator/apis v0.1.1-0.20231001103054-f74a88ed4971 github.com/openstack-k8s-operators/ironic-operator/api v0.1.1-0.20230901035810-610538e222c9 github.com/openstack-k8s-operators/keystone-operator/api v0.1.1-0.20230925133339-116a3a39cdfa - github.com/openstack-k8s-operators/lib-common/modules/common v0.1.1-0.20230927082538-4f614f333d17 + github.com/openstack-k8s-operators/lib-common/modules/common v0.1.1-0.20231001084618-12369665b166 github.com/openstack-k8s-operators/lib-common/modules/database v0.1.1-0.20230927082538-4f614f333d17 github.com/openstack-k8s-operators/lib-common/modules/test v0.1.2-0.20230927082538-4f614f333d17 github.com/openstack-k8s-operators/mariadb-operator/api v0.1.1-0.20230928103342-106bb85983f4 diff --git a/go.sum b/go.sum index 1a441beb..cafb77f8 100644 --- a/go.sum +++ b/go.sum @@ -232,16 +232,16 @@ github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRW github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/onsi/ginkgo/v2 v2.12.1 h1:uHNEO1RP2SpuZApSkel9nEh1/Mu+hmQe7Q+Pepg5OYA= github.com/onsi/ginkgo/v2 v2.12.1/go.mod h1:TE309ZR8s5FsKKpuB1YAQYBzCaAfUgatB/xlT/ETL/o= -github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI= -github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3evPbQ0M= +github.com/onsi/gomega v1.28.0 h1:i2rg/p9n/UqIDAMFUJ6qIUUMcsqOuUHgbpbu235Vr1c= +github.com/onsi/gomega v1.28.0/go.mod h1:A1H2JE76sI14WIP57LMKj7FVfCHx3g3BcZVjJG8bjX8= github.com/openshift/api v0.0.0-20230414143018-3367bc7e6ac7 h1:rncLxJBpFGqBztyxCMwNRnMjhhIDOWHJowi6q8G6koI= github.com/openshift/api v0.0.0-20230414143018-3367bc7e6ac7/go.mod h1:ctXNyWanKEjGj8sss1KjjHQ3ENKFm33FFnS5BKaIPh4= -github.com/openstack-k8s-operators/infra-operator/apis v0.1.1-0.20230926144332-61ec188379c1 h1:mchH+0MYBISPuICvfBVHiNoKssJmyLZyu90SrXnRBkM= -github.com/openstack-k8s-operators/infra-operator/apis v0.1.1-0.20230926144332-61ec188379c1/go.mod h1:fOJ95wMSymtfoellY/TFKcrzW6bu/nTCTzEnFEgCGCc= +github.com/openstack-k8s-operators/infra-operator/apis v0.1.1-0.20231001103054-f74a88ed4971 h1:5kNS+gseixkgRhYPukQVJyewPTM0lfUOmKP0A03wFFY= +github.com/openstack-k8s-operators/infra-operator/apis v0.1.1-0.20231001103054-f74a88ed4971/go.mod h1:zqFs5MrBKeaE4HQroUgMWwIkBwmmcygg6sghcidSdCA= github.com/openstack-k8s-operators/keystone-operator/api v0.1.1-0.20230925133339-116a3a39cdfa h1:zKatN2iMa7Ukq7VuRbzt84n6yWZXW8RLuMnyxIN4ggQ= github.com/openstack-k8s-operators/keystone-operator/api v0.1.1-0.20230925133339-116a3a39cdfa/go.mod h1:Zyp4nHS/JggPqlsMNM8WZN546oYINvGVlHA1NivE3sU= -github.com/openstack-k8s-operators/lib-common/modules/common v0.1.1-0.20230927082538-4f614f333d17 h1:n5QmZLJfPtKbNnPVqqSQkLU1X/NMmW3CbML3yjBUjyY= -github.com/openstack-k8s-operators/lib-common/modules/common v0.1.1-0.20230927082538-4f614f333d17/go.mod h1:kZS5rqVWBZeCyYor2PeQB9IEZ19mGaeL/to3x8F9OJg= +github.com/openstack-k8s-operators/lib-common/modules/common v0.1.1-0.20231001084618-12369665b166 h1:pZPl9njjTchHSFf2OSuzyRxrRW8LLb1OscPxVNoATrk= +github.com/openstack-k8s-operators/lib-common/modules/common v0.1.1-0.20231001084618-12369665b166/go.mod h1:Ozg6SxfwOtMkiH553c0XQBWuygZQq4jDQCpR4hZqlxM= github.com/openstack-k8s-operators/lib-common/modules/database v0.1.1-0.20230927082538-4f614f333d17 h1:pjpbv2RqrBkAO7Gt/6wZ3SSjkd/1//c3s9TAOQ7Z0d4= github.com/openstack-k8s-operators/lib-common/modules/database v0.1.1-0.20230927082538-4f614f333d17/go.mod h1:RroLfB6Wstc+z7JVJY9o+6YPu+wBIzTAAfMpwhv7pDI= github.com/openstack-k8s-operators/lib-common/modules/openstack v0.1.1-0.20230927082538-4f614f333d17 h1:d3HP0nEGNd8cQ088beQbyWzcgdMppD+Zs8HeoMdzRws= diff --git a/tests/functional/ironic_controller_test.go b/tests/functional/ironic_controller_test.go index 007ce3e2..2c3c9de9 100644 --- a/tests/functional/ironic_controller_test.go +++ b/tests/functional/ironic_controller_test.go @@ -121,8 +121,8 @@ var _ = Describe("Ironic controller", func() { Expect(binding.Subjects[0].Name).To(Equal(sa.Name)) }) It("creates Transport URL and sets TransportURLSecret status field", func() { - th.GetTransportURL(ironicNames.IronicTransportURLName) - th.SimulateTransportURLReady(ironicNames.IronicTransportURLName) + infra.GetTransportURL(ironicNames.IronicTransportURLName) + infra.SimulateTransportURLReady(ironicNames.IronicTransportURLName) th.ExpectCondition( ironicNames.IronicName, ConditionGetterFunc(IronicConditionGetter), @@ -133,8 +133,8 @@ var _ = Describe("Ironic controller", func() { Expect(instance.Status.TransportURLSecret).To(Equal("rabbitmq-secret")) }) It("Creates ConfigMaps and gets Secrets (input) and set Hash of inputs", func() { - th.GetTransportURL(ironicNames.IronicTransportURLName) - th.SimulateTransportURLReady(ironicNames.IronicTransportURLName) + infra.GetTransportURL(ironicNames.IronicTransportURLName) + infra.SimulateTransportURLReady(ironicNames.IronicTransportURLName) th.ExpectCondition( ironicNames.IronicName, ConditionGetterFunc(IronicConditionGetter), @@ -154,8 +154,8 @@ var _ = Describe("Ironic controller", func() { ) }) It("Creates service database instance", func() { - th.GetTransportURL(ironicNames.IronicTransportURLName) - th.SimulateTransportURLReady(ironicNames.IronicTransportURLName) + infra.GetTransportURL(ironicNames.IronicTransportURLName) + infra.SimulateTransportURLReady(ironicNames.IronicTransportURLName) mariadb.GetMariaDBDatabase(ironicNames.IronicDatabaseName) mariadb.SimulateMariaDBDatabaseCompleted(ironicNames.IronicDatabaseName) th.ExpectCondition( @@ -166,8 +166,8 @@ var _ = Describe("Ironic controller", func() { ) }) It("Runs service database DBsync", func() { - th.GetTransportURL(ironicNames.IronicTransportURLName) - th.SimulateTransportURLReady(ironicNames.IronicTransportURLName) + infra.GetTransportURL(ironicNames.IronicTransportURLName) + infra.SimulateTransportURLReady(ironicNames.IronicTransportURLName) mariadb.GetMariaDBDatabase(ironicNames.IronicDatabaseName) mariadb.SimulateMariaDBDatabaseCompleted(ironicNames.IronicDatabaseName) th.SimulateJobSuccess(ironicNames.IronicDBSyncJobName) @@ -179,8 +179,8 @@ var _ = Describe("Ironic controller", func() { ) }) It("Creates deployment for API, Conductor, Inspector and INA", func() { - th.GetTransportURL(ironicNames.IronicTransportURLName) - th.SimulateTransportURLReady(ironicNames.IronicTransportURLName) + infra.GetTransportURL(ironicNames.IronicTransportURLName) + infra.SimulateTransportURLReady(ironicNames.IronicTransportURLName) mariadb.GetMariaDBDatabase(ironicNames.IronicDatabaseName) mariadb.SimulateMariaDBDatabaseCompleted(ironicNames.IronicDatabaseName) th.SimulateJobSuccess(ironicNames.IronicDBSyncJobName) diff --git a/tests/functional/ironicinspector_controller_test.go b/tests/functional/ironicinspector_controller_test.go index 634cab77..aa4434b0 100644 --- a/tests/functional/ironicinspector_controller_test.go +++ b/tests/functional/ironicinspector_controller_test.go @@ -101,8 +101,8 @@ var _ = Describe("IronicInspector controller", func() { Expect(binding.Subjects[0].Name).To(Equal(sa.Name)) }) It("creates Transport URL and sets TransportURLSecret status field", func() { - th.GetTransportURL(ironicNames.InspectorTransportURLName) - th.SimulateTransportURLReady(ironicNames.InspectorTransportURLName) + infra.GetTransportURL(ironicNames.InspectorTransportURLName) + infra.SimulateTransportURLReady(ironicNames.InspectorTransportURLName) th.ExpectCondition( ironicNames.InspectorName, ConditionGetterFunc(IronicInspectorConditionGetter), @@ -113,8 +113,8 @@ var _ = Describe("IronicInspector controller", func() { Expect(instance.Status.TransportURLSecret).To(Equal("rabbitmq-secret")) }) It("Creates ConfigMaps and gets Secrets (input)", func() { - th.GetTransportURL(ironicNames.InspectorTransportURLName) - th.SimulateTransportURLReady(ironicNames.InspectorTransportURLName) + infra.GetTransportURL(ironicNames.InspectorTransportURLName) + infra.SimulateTransportURLReady(ironicNames.InspectorTransportURLName) th.ExpectCondition( ironicNames.InspectorName, ConditionGetterFunc(IronicInspectorConditionGetter), @@ -129,8 +129,8 @@ var _ = Describe("IronicInspector controller", func() { ) }) It("Creates service database instance", func() { - th.GetTransportURL(ironicNames.InspectorTransportURLName) - th.SimulateTransportURLReady(ironicNames.InspectorTransportURLName) + infra.GetTransportURL(ironicNames.InspectorTransportURLName) + infra.SimulateTransportURLReady(ironicNames.InspectorTransportURLName) mariadb.GetMariaDBDatabase(ironicNames.InspectorDatabaseName) mariadb.SimulateMariaDBDatabaseCompleted(ironicNames.InspectorDatabaseName) th.ExpectCondition( @@ -141,8 +141,8 @@ var _ = Describe("IronicInspector controller", func() { ) }) It("Runs service database DBsync", func() { - th.GetTransportURL(ironicNames.InspectorTransportURLName) - th.SimulateTransportURLReady(ironicNames.InspectorTransportURLName) + infra.GetTransportURL(ironicNames.InspectorTransportURLName) + infra.SimulateTransportURLReady(ironicNames.InspectorTransportURLName) mariadb.GetMariaDBDatabase(ironicNames.InspectorDatabaseName) mariadb.SimulateMariaDBDatabaseCompleted(ironicNames.InspectorDatabaseName) th.SimulateJobSuccess(ironicNames.InspectorDBSyncJobName) @@ -154,8 +154,8 @@ var _ = Describe("IronicInspector controller", func() { ) }) It("Exposes services", func() { - th.GetTransportURL(ironicNames.InspectorTransportURLName) - th.SimulateTransportURLReady(ironicNames.InspectorTransportURLName) + infra.GetTransportURL(ironicNames.InspectorTransportURLName) + infra.SimulateTransportURLReady(ironicNames.InspectorTransportURLName) mariadb.GetMariaDBDatabase(ironicNames.InspectorDatabaseName) mariadb.SimulateMariaDBDatabaseCompleted(ironicNames.InspectorDatabaseName) th.SimulateJobSuccess(ironicNames.InspectorDBSyncJobName) @@ -167,8 +167,8 @@ var _ = Describe("IronicInspector controller", func() { ) }) It("Creates StatefulSet and set status fields - Deployment is Ready", func() { - th.GetTransportURL(ironicNames.InspectorTransportURLName) - th.SimulateTransportURLReady(ironicNames.InspectorTransportURLName) + infra.GetTransportURL(ironicNames.InspectorTransportURLName) + infra.SimulateTransportURLReady(ironicNames.InspectorTransportURLName) mariadb.GetMariaDBDatabase(ironicNames.InspectorDatabaseName) mariadb.SimulateMariaDBDatabaseCompleted(ironicNames.InspectorDatabaseName) th.SimulateJobSuccess(ironicNames.InspectorDBSyncJobName) @@ -183,8 +183,8 @@ var _ = Describe("IronicInspector controller", func() { ) }) It("Creates keystone service, users and endpoints", func() { - th.GetTransportURL(ironicNames.InspectorTransportURLName) - th.SimulateTransportURLReady(ironicNames.InspectorTransportURLName) + infra.GetTransportURL(ironicNames.InspectorTransportURLName) + infra.SimulateTransportURLReady(ironicNames.InspectorTransportURLName) mariadb.GetMariaDBDatabase(ironicNames.InspectorDatabaseName) mariadb.SimulateMariaDBDatabaseCompleted(ironicNames.InspectorDatabaseName) th.SimulateJobSuccess(ironicNames.InspectorDBSyncJobName) @@ -205,8 +205,8 @@ var _ = Describe("IronicInspector controller", func() { ) }) It("Sets ReadyCondition and replica count", func() { - th.GetTransportURL(ironicNames.InspectorTransportURLName) - th.SimulateTransportURLReady(ironicNames.InspectorTransportURLName) + infra.GetTransportURL(ironicNames.InspectorTransportURLName) + infra.SimulateTransportURLReady(ironicNames.InspectorTransportURLName) mariadb.GetMariaDBDatabase(ironicNames.InspectorDatabaseName) mariadb.SimulateMariaDBDatabaseCompleted(ironicNames.InspectorDatabaseName) th.SimulateJobSuccess(ironicNames.InspectorDBSyncJobName) diff --git a/tests/functional/ironicneutronagent_controller_test.go b/tests/functional/ironicneutronagent_controller_test.go index f2237989..781717ba 100644 --- a/tests/functional/ironicneutronagent_controller_test.go +++ b/tests/functional/ironicneutronagent_controller_test.go @@ -47,8 +47,8 @@ var _ = Describe("IronicNeutronAgent controller", func() { Expect(instance.Status.TransportURLSecret).To(BeEmpty()) }) It("creates Transport URL and sets TransportURLSecret status field", func() { - th.GetTransportURL(ironicNames.INATransportURLName) - th.SimulateTransportURLReady(ironicNames.INATransportURLName) + infra.GetTransportURL(ironicNames.INATransportURLName) + infra.SimulateTransportURLReady(ironicNames.INATransportURLName) th.ExpectCondition( ironicNames.INAName, ConditionGetterFunc(INAConditionGetter), @@ -59,8 +59,8 @@ var _ = Describe("IronicNeutronAgent controller", func() { Expect(instance.Status.TransportURLSecret).To(Equal("rabbitmq-secret")) }) It("Creates ConfigMaps and gets Secrets (input)", func() { - th.GetTransportURL(ironicNames.INATransportURLName) - th.SimulateTransportURLReady(ironicNames.INATransportURLName) + infra.GetTransportURL(ironicNames.INATransportURLName) + infra.SimulateTransportURLReady(ironicNames.INATransportURLName) th.ExpectCondition( ironicNames.INAName, ConditionGetterFunc(INAConditionGetter), @@ -75,8 +75,8 @@ var _ = Describe("IronicNeutronAgent controller", func() { ) }) It("Creates Deployment and set status fields - is Ready", func() { - th.GetTransportURL(ironicNames.INATransportURLName) - th.SimulateTransportURLReady(ironicNames.INATransportURLName) + infra.GetTransportURL(ironicNames.INATransportURLName) + infra.SimulateTransportURLReady(ironicNames.INATransportURLName) th.SimulateDeploymentReplicaReady(ironicNames.INAName) th.ExpectCondition( ironicNames.INAName, @@ -98,8 +98,8 @@ var _ = Describe("IronicNeutronAgent controller", func() { When("IronicNeutronAgent is created pointing to non existent Secret", func() { BeforeEach(func() { DeferCleanup(th.DeleteInstance, CreateIronicNeutronAgent(ironicNames.INAName, GetDefaultIronicNeutronAgentSpec())) - th.GetTransportURL(ironicNames.INATransportURLName) - th.SimulateTransportURLReady(ironicNames.INATransportURLName) + infra.GetTransportURL(ironicNames.INATransportURLName) + infra.SimulateTransportURLReady(ironicNames.INATransportURLName) DeferCleanup(keystone.DeleteKeystoneAPI, keystone.CreateKeystoneAPI(ironicNames.Namespace)) }) It("is missing secret", func() { @@ -135,8 +135,8 @@ var _ = Describe("IronicNeutronAgent controller", func() { } Expect(k8sClient.Create(ctx, secret)).Should(Succeed()) DeferCleanup(k8sClient.Delete, ctx, secret) - th.GetTransportURL(ironicNames.INATransportURLName) - th.SimulateTransportURLReady(ironicNames.INATransportURLName) + infra.GetTransportURL(ironicNames.INATransportURLName) + infra.SimulateTransportURLReady(ironicNames.INATransportURLName) }) It("is missing secret", func() { th.ExpectConditionWithDetails( diff --git a/tests/functional/suite_test.go b/tests/functional/suite_test.go index 4ea49e2d..67278645 100644 --- a/tests/functional/suite_test.go +++ b/tests/functional/suite_test.go @@ -46,6 +46,7 @@ import ( keystonev1 "github.com/openstack-k8s-operators/keystone-operator/api/v1beta1" mariadbv1 "github.com/openstack-k8s-operators/mariadb-operator/api/v1beta1" + infra_test "github.com/openstack-k8s-operators/infra-operator/apis/test/helpers" keystone_test "github.com/openstack-k8s-operators/keystone-operator/api/test/helpers" "github.com/openstack-k8s-operators/lib-common/modules/test" common_test "github.com/openstack-k8s-operators/lib-common/modules/test/helpers" @@ -66,6 +67,7 @@ var ( th *common_test.TestHelper keystone *keystone_test.TestHelper mariadb *mariadb_test.TestHelper + infra *infra_test.TestHelper ironicNames IronicNames ) @@ -148,6 +150,8 @@ var _ = BeforeSuite(func() { Expect(keystone).NotTo(BeNil()) mariadb = mariadb_test.NewTestHelper(ctx, k8sClient, timeout, interval, logger) Expect(mariadb).NotTo(BeNil()) + infra = infra_test.NewTestHelper(ctx, k8sClient, timeout, interval, logger) + Expect(infra).NotTo(BeNil()) // Start the controller-manager if goroutine webhookInstallOptions := &testEnv.WebhookInstallOptions