Skip to content

Commit

Permalink
Merge pull request #342 from gibizer/infra-test-helpers
Browse files Browse the repository at this point in the history
[envtest]Use infra helpers from infra-operator
  • Loading branch information
openshift-merge-robot authored Oct 2, 2023
2 parents 493e1bc + 6198d34 commit 615738e
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 45 deletions.
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
20 changes: 10 additions & 10 deletions tests/functional/ironic_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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),
Expand All @@ -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(
Expand All @@ -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)
Expand All @@ -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)
Expand Down
32 changes: 16 additions & 16 deletions tests/functional/ironicinspector_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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),
Expand All @@ -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(
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down
20 changes: 10 additions & 10 deletions tests/functional/ironicneutronagent_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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),
Expand All @@ -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,
Expand All @@ -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() {
Expand Down Expand Up @@ -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(
Expand Down
4 changes: 4 additions & 0 deletions tests/functional/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -66,6 +67,7 @@ var (
th *common_test.TestHelper
keystone *keystone_test.TestHelper
mariadb *mariadb_test.TestHelper
infra *infra_test.TestHelper
ironicNames IronicNames
)

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 615738e

Please sign in to comment.