Skip to content

Commit

Permalink
[envtest]Use database helpers from mariadb-operator
Browse files Browse the repository at this point in the history
This is necessary to remove a dependency cycle from lib-common
  • Loading branch information
gibizer committed Sep 28, 2023
1 parent 92a65e1 commit 87c4615
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 21 deletions.
4 changes: 4 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,7 @@ replace github.com/openshift/api => github.com/openshift/api v0.0.0-202304141430
// needed to to cert-manager v1.11.4 see https://github.com/cert-manager/cert-manager/blob/v1.11.4/go.mod#L263C1-L264C104
// remove this once we bump to cert-manager v1.12.x
replace github.com/Venafi/vcert/v4 => github.com/jetstack/vcert/v4 v4.9.6-0.20230519122548-219f317ae107 //allow-merging

replace github.com/openstack-k8s-operators/mariadb-operator/api => github.com/gibizer/mariadb-operator/api v0.0.0-20230927125835-d928d57aebb5

replace github.com/openstack-k8s-operators/lib-common/modules/test => github.com/gibizer/lib-common/modules/test v0.0.0-20230928090455-81c3333b6889
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ github.com/flowstack/go-jsonschema v0.1.1/go.mod h1:yL7fNggx1o8rm9RlgXv7hTBWxdBM
github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/gibizer/lib-common/modules/test v0.0.0-20230928090455-81c3333b6889 h1:9mfkwtby6sN7MQUOPK3bNyvMRP/qIpetnQZYgXPeWqQ=
github.com/gibizer/lib-common/modules/test v0.0.0-20230928090455-81c3333b6889/go.mod h1:i+7ijhNyqcPBBzYf4BvnNBzYrYvu9B2BHSEoQOR+FMk=
github.com/gibizer/mariadb-operator/api v0.0.0-20230927125835-d928d57aebb5 h1:Y7jf9PMuPk7omjPH5NINR3vlxdAJwsXqzCbEc6Qpy4k=
github.com/gibizer/mariadb-operator/api v0.0.0-20230927125835-d928d57aebb5/go.mod h1:xhiz5wFdKWwVM7BF/VYon4TT3NuUPXp/Pyn2hWcp0CE=
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
Expand Down Expand Up @@ -248,10 +252,6 @@ github.com/openstack-k8s-operators/lib-common/modules/openstack v0.1.1-0.2023092
github.com/openstack-k8s-operators/lib-common/modules/openstack v0.1.1-0.20230927082538-4f614f333d17/go.mod h1:+iJZo5alCeOGD/524hWWdlINA6zqY+MjfWT7cDcbvBE=
github.com/openstack-k8s-operators/lib-common/modules/storage v0.1.1-0.20230927082538-4f614f333d17 h1:epXz35gpdGp/CbYzAT926971T9kpO6r1v2GX8I1HHGM=
github.com/openstack-k8s-operators/lib-common/modules/storage v0.1.1-0.20230927082538-4f614f333d17/go.mod h1:kKFAr7wZw3mX83hlQVbf2hV7TGhNNxVgMSNt9YtUPzI=
github.com/openstack-k8s-operators/lib-common/modules/test v0.1.2-0.20230927082538-4f614f333d17 h1:zJguNin+9IwRnGKy1A7ranxASKO1vTvWxoXwkCz8MWw=
github.com/openstack-k8s-operators/lib-common/modules/test v0.1.2-0.20230927082538-4f614f333d17/go.mod h1:YOFHrNK/QqCvZUPlDJYmDyaCkbKIB98V04uyofiC9a8=
github.com/openstack-k8s-operators/mariadb-operator/api v0.1.1-0.20230927094006-890f79149df4 h1:NVvdjUKCVdwf/rboYM7mqZaBX7g65q1yw7tOJTxfT7g=
github.com/openstack-k8s-operators/mariadb-operator/api v0.1.1-0.20230927094006-890f79149df4/go.mod h1:xXHF/R/L0XamRHR/UkzlgzSTocBQ6GSQ2U16Q9Mf/bA=
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=
Expand Down
32 changes: 16 additions & 16 deletions test/functional/manila_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ var _ = Describe("Manila controller", func() {
DeferCleanup(k8sClient.Delete, ctx, CreateManilaMessageBusSecret(manilaTest.Instance.Namespace, manilaTest.RabbitmqSecretName))
DeferCleanup(th.DeleteInstance, CreateManila(manilaTest.Instance, GetDefaultManilaSpec()))
DeferCleanup(
th.DeleteDBService,
th.CreateDBService(
mariadb.DeleteDBService,
mariadb.CreateDBService(
namespace,
GetManila(manilaTest.Instance).Spec.DatabaseInstance,
corev1.ServiceSpec{
Expand All @@ -130,7 +130,7 @@ var _ = Describe("Manila controller", func() {
DeferCleanup(keystone.DeleteKeystoneAPI, keystone.CreateKeystoneAPI(namespace))
})
It("Should set DBReady Condition and set DatabaseHostname Status when DB is Created", func() {
th.SimulateMariaDBDatabaseCompleted(manilaTest.Instance)
mariadb.SimulateMariaDBDatabaseCompleted(manilaTest.Instance)
th.SimulateJobSuccess(manilaTest.ManilaDBSync)
Manila := GetManila(manilaTest.Instance)
Expect(Manila.Status.DatabaseHostname).To(Equal("hostname-for-openstack"))
Expand All @@ -148,7 +148,7 @@ var _ = Describe("Manila controller", func() {
)
})
It("Should fail if db-sync job fails when DB is Created", func() {
th.SimulateMariaDBDatabaseCompleted(manilaTest.Instance)
mariadb.SimulateMariaDBDatabaseCompleted(manilaTest.Instance)
th.SimulateJobFailure(manilaTest.ManilaDBSync)
th.ExpectCondition(
manilaTest.Instance,
Expand Down Expand Up @@ -177,7 +177,7 @@ var _ = Describe("Manila controller", func() {
BeforeEach(func() {
DeferCleanup(th.DeleteInstance, CreateManila(manilaTest.Instance, GetDefaultManilaSpec()))
DeferCleanup(k8sClient.Delete, ctx, CreateManilaMessageBusSecret(manilaTest.Instance.Namespace, manilaTest.RabbitmqSecretName))
DeferCleanup(th.DeleteDBService, th.CreateDBService(
DeferCleanup(mariadb.DeleteDBService, mariadb.CreateDBService(
manilaTest.Instance.Namespace,
GetManila(manilaName).Spec.DatabaseInstance,
corev1.ServiceSpec{
Expand Down Expand Up @@ -221,8 +221,8 @@ var _ = Describe("Manila controller", func() {
DeferCleanup(th.DeleteInstance, CreateManilaScheduler(manilaTest.Instance, GetDefaultManilaSchedulerSpec()))
DeferCleanup(th.DeleteInstance, CreateManilaShare(manilaTest.Instance, GetDefaultManilaShareSpec()))
DeferCleanup(
th.DeleteDBService,
th.CreateDBService(
mariadb.DeleteDBService,
mariadb.CreateDBService(
manilaTest.Instance.Namespace,
GetManila(manilaName).Spec.DatabaseInstance,
corev1.ServiceSpec{
Expand All @@ -232,7 +232,7 @@ var _ = Describe("Manila controller", func() {
)
th.SimulateTransportURLReady(manilaTest.ManilaTransportURL)
DeferCleanup(keystone.DeleteKeystoneAPI, keystone.CreateKeystoneAPI(manilaTest.Instance.Namespace))
th.SimulateMariaDBDatabaseCompleted(manilaTest.Instance)
mariadb.SimulateMariaDBDatabaseCompleted(manilaTest.Instance)
th.SimulateJobSuccess(manilaTest.ManilaDBSync)
keystone.SimulateKeystoneServiceReady(manilaTest.Instance)
keystone.SimulateKeystoneEndpointReady(manilaTest.ManilaKeystoneEndpoint)
Expand All @@ -256,8 +256,8 @@ var _ = Describe("Manila controller", func() {
DeferCleanup(th.DeleteInstance, CreateManila(manilaTest.Instance, GetDefaultManilaSpec()))
DeferCleanup(k8sClient.Delete, ctx, CreateManilaMessageBusSecret(manilaTest.Instance.Namespace, manilaTest.RabbitmqSecretName))
DeferCleanup(
th.DeleteDBService,
th.CreateDBService(
mariadb.DeleteDBService,
mariadb.CreateDBService(
manilaTest.Instance.Namespace,
GetManila(manilaTest.Instance).Spec.DatabaseInstance,
corev1.ServiceSpec{
Expand All @@ -267,18 +267,18 @@ var _ = Describe("Manila controller", func() {
)
th.SimulateTransportURLReady(manilaTest.ManilaTransportURL)
DeferCleanup(keystone.DeleteKeystoneAPI, keystone.CreateKeystoneAPI(manilaTest.Instance.Namespace))
th.SimulateMariaDBDatabaseCompleted(manilaTest.Instance)
mariadb.SimulateMariaDBDatabaseCompleted(manilaTest.Instance)
th.SimulateJobSuccess(manilaTest.ManilaDBSync)
})
It("removes the finalizers from the Manila DB", func() {
keystone.SimulateKeystoneServiceReady(manilaTest.Instance)

mDB := th.GetMariaDBDatabase(manilaTest.Instance)
mDB := mariadb.GetMariaDBDatabase(manilaTest.Instance)
Expect(mDB.Finalizers).To(ContainElement("Manila"))

th.DeleteInstance(GetManila(manilaTest.Instance))

mDB = th.GetMariaDBDatabase(manilaTest.Instance)
mDB = mariadb.GetMariaDBDatabase(manilaTest.Instance)
Expect(mDB.Finalizers).NotTo(ContainElement("Manila"))
})
})
Expand Down Expand Up @@ -329,8 +329,8 @@ var _ = Describe("Manila controller", func() {
DeferCleanup(th.DeleteInstance, CreateManila(manilaTest.Instance, rawSpec))
DeferCleanup(k8sClient.Delete, ctx, CreateManilaMessageBusSecret(manilaTest.Instance.Namespace, manilaTest.RabbitmqSecretName))
DeferCleanup(
th.DeleteDBService,
th.CreateDBService(
mariadb.DeleteDBService,
mariadb.CreateDBService(
manilaTest.Instance.Namespace,
GetManila(manilaTest.Instance).Spec.DatabaseInstance,
corev1.ServiceSpec{
Expand All @@ -346,7 +346,7 @@ var _ = Describe("Manila controller", func() {
Eventually(func(g Gomega) {
g.Expect(k8sClient.Status().Update(ctx, keystoneAPI.DeepCopy())).Should(Succeed())
}, timeout, interval).Should(Succeed())
th.SimulateMariaDBDatabaseCompleted(manilaTest.Instance)
mariadb.SimulateMariaDBDatabaseCompleted(manilaTest.Instance)
th.SimulateJobSuccess(manilaTest.ManilaDBSync)
keystone.SimulateKeystoneServiceReady(manilaTest.Instance)
})
Expand Down
6 changes: 5 additions & 1 deletion test/functional/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import (
keystonev1 "github.com/openstack-k8s-operators/keystone-operator/api/v1beta1"
"github.com/openstack-k8s-operators/lib-common/modules/test"
common_test "github.com/openstack-k8s-operators/lib-common/modules/test/helpers"
mariadb_test "github.com/openstack-k8s-operators/mariadb-operator/api/test/helpers"
mariadbv1 "github.com/openstack-k8s-operators/mariadb-operator/api/v1beta1"

"github.com/openstack-k8s-operators/manila-operator/controllers"
Expand All @@ -68,6 +69,7 @@ var (
logger logr.Logger
th *common_test.TestHelper
keystone *keystone_test.TestHelper
mariadb *mariadb_test.TestHelper
namespace string
manilaName types.NamespacedName
manilaTest ManilaTestData
Expand Down Expand Up @@ -156,7 +158,9 @@ var _ = BeforeSuite(func() {
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())
Expect(keystone).NotTo(BeNil())
mariadb = mariadb_test.NewTestHelper(ctx, k8sClient, timeout, interval, logger)
Expect(mariadb).NotTo(BeNil())

webhookInstallOptions := &testEnv.WebhookInstallOptions
k8sManager, err := ctrl.NewManager(cfg, ctrl.Options{
Expand Down

0 comments on commit 87c4615

Please sign in to comment.