From e655ee9b822ad513cfefb07b1116782ad8348e3a Mon Sep 17 00:00:00 2001 From: Balazs Gibizer Date: Fri, 22 Sep 2023 18:59:22 +0200 Subject: [PATCH] [envtest]Use keystone helpers from keystone-operator --- api/go.mod | 3 +- api/go.sum | 5 +-- go.mod | 10 ++--- go.sum | 20 ++++----- .../placementapi_controller_test.go | 44 +++++++++---------- tests/functional/suite_test.go | 10 +++-- 6 files changed, 47 insertions(+), 45 deletions(-) diff --git a/api/go.mod b/api/go.mod index 943efe9e..ab6a3c61 100644 --- a/api/go.mod +++ b/api/go.mod @@ -3,7 +3,7 @@ module github.com/openstack-k8s-operators/placement-operator/api go 1.19 require ( - github.com/openstack-k8s-operators/lib-common/modules/common v0.1.1-0.20230919113507-d74c2f31d216 + github.com/openstack-k8s-operators/lib-common/modules/common v0.1.1-0.20230925103424-7dcb605ea0bb k8s.io/api v0.26.9 k8s.io/apimachinery v0.26.9 sigs.k8s.io/controller-runtime v0.14.6 @@ -35,7 +35,6 @@ require ( github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect - github.com/onsi/ginkgo/v2 v2.12.1 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/prometheus/client_golang v1.14.0 // indirect github.com/prometheus/client_model v0.3.0 // indirect diff --git a/api/go.sum b/api/go.sum index 44eae4db..5071b3d7 100644 --- a/api/go.sum +++ b/api/go.sum @@ -219,10 +219,9 @@ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8m github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= 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/openstack-k8s-operators/lib-common/modules/common v0.1.1-0.20230919113507-d74c2f31d216 h1:arYbQA6bLyXJkHm+6M6gPc4YpWMFjs5qkG16Yii4UDo= -github.com/openstack-k8s-operators/lib-common/modules/common v0.1.1-0.20230919113507-d74c2f31d216/go.mod h1:Ge7Yf6AUmjEvJK9AIW2bT5udLzBIcK59b1QxqymncaQ= +github.com/openstack-k8s-operators/lib-common/modules/common v0.1.1-0.20230925103424-7dcb605ea0bb h1:MRd/OrTTZeU/KXAzlIH003wPLmjZ4PHaQ7HisJC9hGY= +github.com/openstack-k8s-operators/lib-common/modules/common v0.1.1-0.20230925103424-7dcb605ea0bb/go.mod h1:kZS5rqVWBZeCyYor2PeQB9IEZ19mGaeL/to3x8F9OJg= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= diff --git a/go.mod b/go.mod index 963c1c98..e8b6548e 100644 --- a/go.mod +++ b/go.mod @@ -8,10 +8,10 @@ require ( 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/openstack-k8s-operators/keystone-operator/api v0.1.1-0.20230920085319-92ae0260bbf3 - github.com/openstack-k8s-operators/lib-common/modules/common v0.1.1-0.20230919113507-d74c2f31d216 - github.com/openstack-k8s-operators/lib-common/modules/database v0.1.1-0.20230919113507-d74c2f31d216 - github.com/openstack-k8s-operators/lib-common/modules/test v0.1.2-0.20230919113507-d74c2f31d216 + github.com/openstack-k8s-operators/keystone-operator/api v0.1.1-0.20230925115904-772bbf00ffcf + github.com/openstack-k8s-operators/lib-common/modules/common v0.1.1-0.20230925103424-7dcb605ea0bb + github.com/openstack-k8s-operators/lib-common/modules/database v0.1.1-0.20230925103424-7dcb605ea0bb + github.com/openstack-k8s-operators/lib-common/modules/test v0.1.2-0.20230925103424-7dcb605ea0bb github.com/openstack-k8s-operators/mariadb-operator/api v0.1.1-0.20230918111825-8999b3b2dc3c github.com/openstack-k8s-operators/placement-operator/api v0.0.0-20230602092913-53f380989946 go.uber.org/zap v1.26.0 @@ -57,7 +57,7 @@ require ( github.com/modern-go/reflect2 v1.0.2 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/openshift/api v3.9.0+incompatible // indirect - github.com/openstack-k8s-operators/lib-common/modules/openstack v0.1.1-0.20230919113507-d74c2f31d216 //indirect + github.com/openstack-k8s-operators/lib-common/modules/openstack v0.1.1-0.20230925103424-7dcb605ea0bb //indirect github.com/pkg/errors v0.9.1 // indirect github.com/prometheus/client_golang v1.14.0 // indirect github.com/prometheus/client_model v0.3.0 // indirect diff --git a/go.sum b/go.sum index f781f4da..9d4707a4 100644 --- a/go.sum +++ b/go.sum @@ -238,16 +238,16 @@ github.com/openshift/api v0.0.0-20230414143018-3367bc7e6ac7 h1:rncLxJBpFGqBztyxC 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.20230920125017-2c76cd203b44 h1:W2HZy+uk5fnVwvw3+/Jd/k7sNiVXCOd8SiV0dMvmjys= github.com/openstack-k8s-operators/infra-operator/apis v0.1.1-0.20230920125017-2c76cd203b44/go.mod h1:fOJ95wMSymtfoellY/TFKcrzW6bu/nTCTzEnFEgCGCc= -github.com/openstack-k8s-operators/keystone-operator/api v0.1.1-0.20230920085319-92ae0260bbf3 h1:6VCz/ZBTJEQJTx4+z8UxLv3WITa4Bgx5CSP237wJ5xM= -github.com/openstack-k8s-operators/keystone-operator/api v0.1.1-0.20230920085319-92ae0260bbf3/go.mod h1:ta6w/29i4WuWkQp6I4cOLwMGQ5/vJI0y8Em7u+M34jo= -github.com/openstack-k8s-operators/lib-common/modules/common v0.1.1-0.20230919113507-d74c2f31d216 h1:arYbQA6bLyXJkHm+6M6gPc4YpWMFjs5qkG16Yii4UDo= -github.com/openstack-k8s-operators/lib-common/modules/common v0.1.1-0.20230919113507-d74c2f31d216/go.mod h1:Ge7Yf6AUmjEvJK9AIW2bT5udLzBIcK59b1QxqymncaQ= -github.com/openstack-k8s-operators/lib-common/modules/database v0.1.1-0.20230919113507-d74c2f31d216 h1:PykqfrahtBUbhIuM0IDRyrtVCOzy7jdEZz3yVEnwpp0= -github.com/openstack-k8s-operators/lib-common/modules/database v0.1.1-0.20230919113507-d74c2f31d216/go.mod h1:gdmDHoWrDtq8gfJHl20rQwe9vfzJJkY+KnvM6aD9+08= -github.com/openstack-k8s-operators/lib-common/modules/openstack v0.1.1-0.20230919113507-d74c2f31d216 h1:h76faqi4WAXBs3D2B0GLUdlCjS0dh78wRL0d5RZUwhk= -github.com/openstack-k8s-operators/lib-common/modules/openstack v0.1.1-0.20230919113507-d74c2f31d216/go.mod h1:GHi64tgyC75/vuT8Crda0yN5iCIYiSyS4bpzYJjX7MA= -github.com/openstack-k8s-operators/lib-common/modules/test v0.1.2-0.20230919113507-d74c2f31d216 h1:QyzzvG8iaDFwx6Lo44dCyf2tRtgk0sqniXjgJpiW32g= -github.com/openstack-k8s-operators/lib-common/modules/test v0.1.2-0.20230919113507-d74c2f31d216/go.mod h1:RfLOPJbmPzPZ4XHwwDc2tFbbw5zxZL15JFGwb5c6VaU= +github.com/openstack-k8s-operators/keystone-operator/api v0.1.1-0.20230925115904-772bbf00ffcf h1:inyT3plUxpdFef3iZawwMK08uou1n+RSVEhyAQd7LFM= +github.com/openstack-k8s-operators/keystone-operator/api v0.1.1-0.20230925115904-772bbf00ffcf/go.mod h1:Zyp4nHS/JggPqlsMNM8WZN546oYINvGVlHA1NivE3sU= +github.com/openstack-k8s-operators/lib-common/modules/common v0.1.1-0.20230925103424-7dcb605ea0bb h1:MRd/OrTTZeU/KXAzlIH003wPLmjZ4PHaQ7HisJC9hGY= +github.com/openstack-k8s-operators/lib-common/modules/common v0.1.1-0.20230925103424-7dcb605ea0bb/go.mod h1:kZS5rqVWBZeCyYor2PeQB9IEZ19mGaeL/to3x8F9OJg= +github.com/openstack-k8s-operators/lib-common/modules/database v0.1.1-0.20230925103424-7dcb605ea0bb h1:bGhIosetHt4+Kle0+0Vpa204v19u3k0p5Ox7CYD7jfw= +github.com/openstack-k8s-operators/lib-common/modules/database v0.1.1-0.20230925103424-7dcb605ea0bb/go.mod h1:RroLfB6Wstc+z7JVJY9o+6YPu+wBIzTAAfMpwhv7pDI= +github.com/openstack-k8s-operators/lib-common/modules/openstack v0.1.1-0.20230925103424-7dcb605ea0bb h1:DKxySUUtfA8hU1PpXgHbAA+kaa55zdKPlxSFOnvD898= +github.com/openstack-k8s-operators/lib-common/modules/openstack v0.1.1-0.20230925103424-7dcb605ea0bb/go.mod h1:+iJZo5alCeOGD/524hWWdlINA6zqY+MjfWT7cDcbvBE= +github.com/openstack-k8s-operators/lib-common/modules/test v0.1.2-0.20230925103424-7dcb605ea0bb h1:djVcLDXr+SL397W2meEiACDMOZNXciEc4ypLDnZ75wU= +github.com/openstack-k8s-operators/lib-common/modules/test v0.1.2-0.20230925103424-7dcb605ea0bb/go.mod h1:HtR62cEJ+x0WlcvNi/nfjhZ+UssC1zfxRA63qnVbxp4= github.com/openstack-k8s-operators/mariadb-operator/api v0.1.1-0.20230918111825-8999b3b2dc3c h1:9R8T1WRwuPS5KMfsQWxAMSGPuJrGMJ7bODKK9dirhHA= github.com/openstack-k8s-operators/mariadb-operator/api v0.1.1-0.20230918111825-8999b3b2dc3c/go.mod h1:xXHF/R/L0XamRHR/UkzlgzSTocBQ6GSQ2U16Q9Mf/bA= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= diff --git a/tests/functional/placementapi_controller_test.go b/tests/functional/placementapi_controller_test.go index f6339dbc..56568fec 100644 --- a/tests/functional/placementapi_controller_test.go +++ b/tests/functional/placementapi_controller_test.go @@ -178,9 +178,9 @@ var _ = Describe("PlacementAPI controller", func() { DeferCleanup(th.DeleteInstance, CreatePlacementAPI(names.PlacementAPIName, GetDefaultPlacementAPISpec())) DeferCleanup( k8sClient.Delete, ctx, CreatePlacementAPISecret(namespace, SecretName)) - keystoneAPIName := th.CreateKeystoneAPI(namespace) - keystoneAPI = th.GetKeystoneAPI(keystoneAPIName) - DeferCleanup(th.DeleteKeystoneAPI, keystoneAPIName) + keystoneAPIName := keystone.CreateKeystoneAPI(namespace) + keystoneAPI = keystone.GetKeystoneAPI(keystoneAPIName) + DeferCleanup(keystone.DeleteKeystoneAPI, keystoneAPIName) }) It("should have config ready", func() { @@ -277,7 +277,7 @@ var _ = Describe("PlacementAPI controller", func() { ) th.SimulateMariaDBDatabaseCompleted(names.MariaDBDatabaseName) - th.SimulateKeystoneServiceReady(names.KeystoneServiceName) + keystone.SimulateKeystoneServiceReady(names.KeystoneServiceName) th.ExpectCondition( names.PlacementAPIName, @@ -301,7 +301,7 @@ var _ = Describe("PlacementAPI controller", func() { ) th.SimulateMariaDBDatabaseCompleted(names.MariaDBDatabaseName) - th.SimulateKeystoneEndpointReady(names.KeystoneEndpointName) + keystone.SimulateKeystoneEndpointReady(names.KeystoneEndpointName) th.ExpectCondition( names.PlacementAPIName, @@ -435,8 +435,8 @@ var _ = Describe("PlacementAPI controller", func() { th.CreateDBService(namespace, "openstack", serviceSpec), ) th.SimulateMariaDBDatabaseCompleted(names.MariaDBDatabaseName) - th.SimulateKeystoneServiceReady(names.KeystoneServiceName) - th.SimulateKeystoneEndpointReady(names.KeystoneEndpointName) + keystone.SimulateKeystoneServiceReady(names.KeystoneServiceName) + keystone.SimulateKeystoneEndpointReady(names.KeystoneEndpointName) th.SimulateJobSuccess(names.DBSyncJobName) th.SimulateDeploymentReplicaReady(names.DeploymentName) @@ -452,7 +452,7 @@ var _ = Describe("PlacementAPI controller", func() { When("A PlacementAPI is created with service override", func() { BeforeEach(func() { DeferCleanup(k8sClient.Delete, ctx, CreatePlacementAPISecret(namespace, SecretName)) - DeferCleanup(th.DeleteKeystoneAPI, th.CreateKeystoneAPI(namespace)) + DeferCleanup(keystone.DeleteKeystoneAPI, keystone.CreateKeystoneAPI(namespace)) spec := GetDefaultPlacementAPISpec() serviceOverride := map[string]interface{}{} @@ -493,13 +493,13 @@ var _ = Describe("PlacementAPI controller", func() { th.SimulateMariaDBDatabaseCompleted(names.MariaDBDatabaseName) th.SimulateJobSuccess(names.DBSyncJobName) th.SimulateDeploymentReplicaReady(names.DeploymentName) - th.SimulateKeystoneServiceReady(names.KeystoneServiceName) - th.SimulateKeystoneEndpointReady(names.KeystoneEndpointName) + keystone.SimulateKeystoneServiceReady(names.KeystoneServiceName) + keystone.SimulateKeystoneEndpointReady(names.KeystoneEndpointName) DeferCleanup(th.DeleteInstance, placementAPI) }) It("creates KeystoneEndpoint", func() { - keystoneEndpoint := th.GetKeystoneEndpoint(names.KeystoneEndpointName) + keystoneEndpoint := keystone.GetKeystoneEndpoint(names.KeystoneEndpointName) endpoints := keystoneEndpoint.Spec.Endpoints Expect(endpoints).To(HaveKeyWithValue("public", "http://placement-public."+namespace+".svc:8778")) Expect(endpoints).To(HaveKeyWithValue("internal", "http://placement-internal."+namespace+".svc:8778")) @@ -537,7 +537,7 @@ var _ = Describe("PlacementAPI controller", func() { When("A PlacementAPI is created with service override endpointURL set", func() { BeforeEach(func() { DeferCleanup(k8sClient.Delete, ctx, CreatePlacementAPISecret(namespace, SecretName)) - DeferCleanup(th.DeleteKeystoneAPI, th.CreateKeystoneAPI(namespace)) + DeferCleanup(keystone.DeleteKeystoneAPI, keystone.CreateKeystoneAPI(namespace)) spec := GetDefaultPlacementAPISpec() serviceOverride := map[string]interface{}{} @@ -564,13 +564,13 @@ var _ = Describe("PlacementAPI controller", func() { th.SimulateMariaDBDatabaseCompleted(names.MariaDBDatabaseName) th.SimulateJobSuccess(names.DBSyncJobName) th.SimulateDeploymentReplicaReady(names.DeploymentName) - th.SimulateKeystoneServiceReady(names.KeystoneServiceName) - th.SimulateKeystoneEndpointReady(names.KeystoneEndpointName) + keystone.SimulateKeystoneServiceReady(names.KeystoneServiceName) + keystone.SimulateKeystoneEndpointReady(names.KeystoneEndpointName) DeferCleanup(th.DeleteInstance, placementAPI) }) It("creates KeystoneEndpoint", func() { - keystoneEndpoint := th.GetKeystoneEndpoint(names.KeystoneEndpointName) + keystoneEndpoint := keystone.GetKeystoneEndpoint(names.KeystoneEndpointName) endpoints := keystoneEndpoint.Spec.Endpoints Expect(endpoints).To(HaveKeyWithValue("public", "http://placement-openstack.apps-crc.testing")) Expect(endpoints).To(HaveKeyWithValue("internal", "http://placement-internal."+namespace+".svc:8778")) @@ -589,7 +589,7 @@ var _ = Describe("PlacementAPI controller", func() { DeferCleanup(th.DeleteInstance, CreatePlacementAPI(names.PlacementAPIName, GetDefaultPlacementAPISpec())) DeferCleanup( k8sClient.Delete, ctx, CreatePlacementAPISecret(namespace, SecretName)) - DeferCleanup(th.DeleteKeystoneAPI, th.CreateKeystoneAPI(namespace)) + DeferCleanup(keystone.DeleteKeystoneAPI, keystone.CreateKeystoneAPI(namespace)) serviceSpec := corev1.ServiceSpec{Ports: []corev1.ServicePort{{Port: 3306}}} DeferCleanup( @@ -597,8 +597,8 @@ var _ = Describe("PlacementAPI controller", func() { th.CreateDBService(namespace, "openstack", serviceSpec), ) th.SimulateMariaDBDatabaseCompleted(names.MariaDBDatabaseName) - th.SimulateKeystoneServiceReady(names.KeystoneServiceName) - th.SimulateKeystoneEndpointReady(names.KeystoneEndpointName) + keystone.SimulateKeystoneServiceReady(names.KeystoneServiceName) + keystone.SimulateKeystoneEndpointReady(names.KeystoneEndpointName) th.SimulateJobSuccess(names.DBSyncJobName) th.SimulateDeploymentReplicaReady(names.DeploymentName) @@ -613,18 +613,18 @@ var _ = Describe("PlacementAPI controller", func() { It("removes the finalizers when deleted", func() { placement := GetPlacementAPI(names.PlacementAPIName) Expect(placement.Finalizers).To(ContainElement("PlacementAPI")) - keystoneService := th.GetKeystoneService(names.KeystoneServiceName) + keystoneService := keystone.GetKeystoneService(names.KeystoneServiceName) Expect(keystoneService.Finalizers).To(ContainElement("PlacementAPI")) - keystoneEndpoint := th.GetKeystoneService(names.KeystoneEndpointName) + keystoneEndpoint := keystone.GetKeystoneService(names.KeystoneEndpointName) Expect(keystoneEndpoint.Finalizers).To(ContainElement("PlacementAPI")) db := th.GetMariaDBDatabase(names.MariaDBDatabaseName) Expect(db.Finalizers).To(ContainElement("PlacementAPI")) th.DeleteInstance(GetPlacementAPI(names.PlacementAPIName)) - keystoneService = th.GetKeystoneService(names.KeystoneServiceName) + keystoneService = keystone.GetKeystoneService(names.KeystoneServiceName) Expect(keystoneService.Finalizers).NotTo(ContainElement("PlacementAPI")) - keystoneEndpoint = th.GetKeystoneService(names.KeystoneEndpointName) + keystoneEndpoint = keystone.GetKeystoneService(names.KeystoneEndpointName) Expect(keystoneEndpoint.Finalizers).NotTo(ContainElement("PlacementAPI")) db = th.GetMariaDBDatabase(names.MariaDBDatabaseName) Expect(db.Finalizers).NotTo(ContainElement("PlacementAPI")) diff --git a/tests/functional/suite_test.go b/tests/functional/suite_test.go index 3a7dbee2..80663a16 100644 --- a/tests/functional/suite_test.go +++ b/tests/functional/suite_test.go @@ -45,7 +45,8 @@ import ( placementv1 "github.com/openstack-k8s-operators/placement-operator/api/v1beta1" "github.com/openstack-k8s-operators/placement-operator/controllers" - . "github.com/openstack-k8s-operators/lib-common/modules/test/helpers" + keystone_test "github.com/openstack-k8s-operators/keystone-operator/api/test/helpers" + common_test "github.com/openstack-k8s-operators/lib-common/modules/test/helpers" //+kubebuilder:scaffold:imports ) @@ -59,7 +60,8 @@ var ( ctx context.Context cancel context.CancelFunc logger logr.Logger - th *TestHelper + th *common_test.TestHelper + keystone *keystone_test.TestHelper namespace string names Names ) @@ -130,7 +132,9 @@ var _ = BeforeSuite(func() { k8sClient, err = client.New(cfg, client.Options{Scheme: scheme.Scheme}) Expect(err).NotTo(HaveOccurred()) Expect(k8sClient).NotTo(BeNil()) - th = NewTestHelper(ctx, k8sClient, timeout, interval, logger) + th = common_test.NewTestHelper(ctx, k8sClient, timeout, interval, logger) + Expect(th).NotTo(BeNil()) + keystone = keystone_test.NewTestHelper(ctx, k8sClient, timeout, interval, logger) Expect(th).NotTo(BeNil()) // Start the controller-manager if goroutine