Skip to content

Commit

Permalink
[envtest]Use keystone helpers from keystone-operator
Browse files Browse the repository at this point in the history
This was necessary to remove a dependency cycle from lib-common
  • Loading branch information
gibizer committed Sep 22, 2023
1 parent a862ac1 commit 2e753c5
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 71 deletions.
4 changes: 4 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,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/lib-common/modules/test => github.com/gibizer/lib-common/modules/test v0.0.0-20230922123428-e1f4a23e8389

replace github.com/openstack-k8s-operators/keystone-operator/api => github.com/gibizer/keystone-operator/api v0.0.0-20230922130836-e7371b163540
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/keystone-operator/api v0.0.0-20230922130836-e7371b163540 h1:Bk0Ip54Mb0Joldz68hzgUj07X2KKPT9dwN+uvyxq17g=
github.com/gibizer/keystone-operator/api v0.0.0-20230922130836-e7371b163540/go.mod h1:OvhT5VeVCQMVhTJP1nB3WF+4BTVepc51TvSvtei7a4s=
github.com/gibizer/lib-common/modules/test v0.0.0-20230922123428-e1f4a23e8389 h1:sJzsPbrw4Tv9T9o+xe9eJAuBJz4Mn3hw9q6T7cn1tX8=
github.com/gibizer/lib-common/modules/test v0.0.0-20230922123428-e1f4a23e8389/go.mod h1:3k/VsVeacu4iQJcr9XnDOK1+tau81fdxuUDkI6I0kHg=
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 @@ -238,16 +242,12 @@ 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.20230914145253-116f307c7875 h1:DUlCjbi3XxH66oL97MFZF5wgL28HdU+r8TkBZVw7WIc=
github.com/openstack-k8s-operators/infra-operator/apis v0.1.1-0.20230914145253-116f307c7875/go.mod h1:NgrvT3CKMu6fE8Nt1H79qHx11L3I7Bb2eItniM7c9ow=
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/mariadb-operator/api v0.1.1-0.20230913081601-9e4fc8aadad5 h1:dQcSQuXfgzgOhc4v+zD0jE6WWhn6FHr5nALOjJBPxyI=
github.com/openstack-k8s-operators/mariadb-operator/api v0.1.1-0.20230913081601-9e4fc8aadad5/go.mod h1:mJyhm/YiQZaYhLvOuLng/ITpwx8HvsYVht+VotS1Ed8=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
Expand Down
62 changes: 31 additions & 31 deletions test/functional/nova_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ var _ = Describe("Nova controller", func() {
},
),
)
DeferCleanup(th.DeleteKeystoneAPI, th.CreateKeystoneAPI(novaNames.NovaName.Namespace))
DeferCleanup(keystone.DeleteKeystoneAPI, keystone.CreateKeystoneAPI(novaNames.NovaName.Namespace))

DeferCleanup(th.DeleteInstance, CreateNovaWithCell0(novaNames.NovaName))
})
Expand Down Expand Up @@ -90,7 +90,7 @@ var _ = Describe("Nova controller", func() {
},
),
)
DeferCleanup(th.DeleteKeystoneAPI, th.CreateKeystoneAPI(novaNames.NovaName.Namespace))
DeferCleanup(keystone.DeleteKeystoneAPI, keystone.CreateKeystoneAPI(novaNames.NovaName.Namespace))

DeferCleanup(th.DeleteInstance, CreateNovaWithCell0(novaNames.NovaName))
})
Expand Down Expand Up @@ -138,11 +138,11 @@ var _ = Describe("Nova controller", func() {

It("registers nova service to keystone", func() {
// assert that the KeystoneService for nova is created
th.GetKeystoneService(novaNames.KeystoneServiceName)
keystone.GetKeystoneService(novaNames.KeystoneServiceName)
// and simulate that it becomes ready i.e. the keystone-operator
// did its job and registered the nova service
th.SimulateKeystoneServiceReady(novaNames.KeystoneServiceName)
keystone := th.GetKeystoneService(novaNames.KeystoneServiceName)
keystone.SimulateKeystoneServiceReady(novaNames.KeystoneServiceName)
keystone := keystone.GetKeystoneService(novaNames.KeystoneServiceName)
Expect(keystone.Status.Conditions).ToNot(BeNil())

th.ExpectCondition(
Expand All @@ -154,7 +154,7 @@ var _ = Describe("Nova controller", func() {
})

It("creates nova_api DB", func() {
th.SimulateKeystoneServiceReady(novaNames.KeystoneServiceName)
keystone.SimulateKeystoneServiceReady(novaNames.KeystoneServiceName)
th.ExpectCondition(
novaNames.NovaName,
ConditionGetterFunc(NovaConditionGetter),
Expand All @@ -173,7 +173,7 @@ var _ = Describe("Nova controller", func() {
})

It("creates nova-api MQ", func() {
th.SimulateKeystoneServiceReady(novaNames.KeystoneServiceName)
keystone.SimulateKeystoneServiceReady(novaNames.KeystoneServiceName)
th.ExpectCondition(
novaNames.NovaName,
ConditionGetterFunc(NovaConditionGetter),
Expand All @@ -192,7 +192,7 @@ var _ = Describe("Nova controller", func() {
})

It("creates nova_cell0 DB", func() {
th.SimulateKeystoneServiceReady(novaNames.KeystoneServiceName)
keystone.SimulateKeystoneServiceReady(novaNames.KeystoneServiceName)
th.ExpectCondition(
novaNames.NovaName,
ConditionGetterFunc(NovaConditionGetter),
Expand All @@ -211,7 +211,7 @@ var _ = Describe("Nova controller", func() {
})

It("creates cell0 NovaCell", func() {
th.SimulateKeystoneServiceReady(novaNames.KeystoneServiceName)
keystone.SimulateKeystoneServiceReady(novaNames.KeystoneServiceName)
th.SimulateMariaDBDatabaseCompleted(novaNames.APIMariaDBDatabaseName)
th.SimulateMariaDBDatabaseCompleted(cell0.MariaDBDatabaseName)
th.SimulateTransportURLReady(cell0.TransportURLName)
Expand Down Expand Up @@ -312,7 +312,7 @@ var _ = Describe("Nova controller", func() {
})

It("creates an internal Secret for the top level services", func() {
th.SimulateKeystoneServiceReady(novaNames.KeystoneServiceName)
keystone.SimulateKeystoneServiceReady(novaNames.KeystoneServiceName)
th.SimulateMariaDBDatabaseCompleted(novaNames.APIMariaDBDatabaseName)
th.SimulateMariaDBDatabaseCompleted(cell0.MariaDBDatabaseName)
th.SimulateTransportURLReady(cell0.TransportURLName)
Expand All @@ -339,7 +339,7 @@ var _ = Describe("Nova controller", func() {
})

It("creates NovaAPI", func() {
th.SimulateKeystoneServiceReady(novaNames.KeystoneServiceName)
keystone.SimulateKeystoneServiceReady(novaNames.KeystoneServiceName)
th.SimulateMariaDBDatabaseCompleted(novaNames.APIMariaDBDatabaseName)
th.SimulateMariaDBDatabaseCompleted(cell0.MariaDBDatabaseName)
th.SimulateTransportURLReady(cell0.TransportURLName)
Expand All @@ -355,7 +355,7 @@ var _ = Describe("Nova controller", func() {
Expect(api.Spec.Secret).To(Equal(novaNames.InternalTopLevelSecretName.Name))

th.SimulateStatefulSetReplicaReady(novaNames.APIDeploymentName)
th.SimulateKeystoneEndpointReady(novaNames.APIKeystoneEndpointName)
keystone.SimulateKeystoneEndpointReady(novaNames.APIKeystoneEndpointName)
th.ExpectCondition(
novaNames.APIName,
ConditionGetterFunc(NovaAPIConditionGetter),
Expand All @@ -378,15 +378,15 @@ var _ = Describe("Nova controller", func() {
})

It("creates NovaScheduler", func() {
th.SimulateKeystoneServiceReady(novaNames.KeystoneServiceName)
keystone.SimulateKeystoneServiceReady(novaNames.KeystoneServiceName)
th.SimulateMariaDBDatabaseCompleted(novaNames.APIMariaDBDatabaseName)
th.SimulateMariaDBDatabaseCompleted(cell0.MariaDBDatabaseName)
th.SimulateTransportURLReady(cell0.TransportURLName)
th.SimulateJobSuccess(cell0.DBSyncJobName)
th.SimulateStatefulSetReplicaReady(cell0.ConductorStatefulSetName)
th.SimulateJobSuccess(cell0.CellMappingJobName)
th.SimulateStatefulSetReplicaReady(novaNames.APIDeploymentName)
th.SimulateKeystoneEndpointReady(novaNames.APIKeystoneEndpointName)
keystone.SimulateKeystoneEndpointReady(novaNames.APIKeystoneEndpointName)
th.SimulateStatefulSetReplicaReady(novaNames.MetadataStatefulSetName)

scheduler := GetNovaScheduler(novaNames.SchedulerName)
Expand Down Expand Up @@ -417,15 +417,15 @@ var _ = Describe("Nova controller", func() {
})

It("creates NovaMetadata", func() {
th.SimulateKeystoneServiceReady(novaNames.KeystoneServiceName)
keystone.SimulateKeystoneServiceReady(novaNames.KeystoneServiceName)
th.SimulateMariaDBDatabaseCompleted(novaNames.APIMariaDBDatabaseName)
th.SimulateMariaDBDatabaseCompleted(cell0.MariaDBDatabaseName)
th.SimulateTransportURLReady(cell0.TransportURLName)
th.SimulateJobSuccess(cell0.DBSyncJobName)
th.SimulateStatefulSetReplicaReady(cell0.ConductorStatefulSetName)
th.SimulateJobSuccess(cell0.CellMappingJobName)
th.SimulateStatefulSetReplicaReady(novaNames.APIDeploymentName)
th.SimulateKeystoneEndpointReady(novaNames.APIKeystoneEndpointName)
keystone.SimulateKeystoneEndpointReady(novaNames.APIKeystoneEndpointName)
th.SimulateStatefulSetReplicaReady(novaNames.SchedulerStatefulSetName)

metadata := GetNovaMetadata(novaNames.MetadataName)
Expand Down Expand Up @@ -472,11 +472,11 @@ var _ = Describe("Nova controller", func() {
},
),
)
DeferCleanup(th.DeleteKeystoneAPI, th.CreateKeystoneAPI(novaNames.NovaName.Namespace))
DeferCleanup(keystone.DeleteKeystoneAPI, keystone.CreateKeystoneAPI(novaNames.NovaName.Namespace))

DeferCleanup(th.DeleteInstance, CreateNovaWithCell0(novaNames.NovaName))

th.SimulateKeystoneServiceReady(novaNames.KeystoneServiceName)
keystone.SimulateKeystoneServiceReady(novaNames.KeystoneServiceName)
th.SimulateMariaDBDatabaseCompleted(novaNames.APIMariaDBDatabaseName)
th.SimulateMariaDBDatabaseCompleted(cell0.MariaDBDatabaseName)
th.SimulateTransportURLReady(cell0.TransportURLName)
Expand Down Expand Up @@ -538,11 +538,11 @@ var _ = Describe("Nova controller", func() {
},
),
)
DeferCleanup(th.DeleteKeystoneAPI, th.CreateKeystoneAPI(novaNames.NovaName.Namespace))
DeferCleanup(keystone.DeleteKeystoneAPI, keystone.CreateKeystoneAPI(novaNames.NovaName.Namespace))

DeferCleanup(th.DeleteInstance, CreateNovaWithCell0(novaNames.NovaName))

th.SimulateKeystoneServiceReady(novaNames.KeystoneServiceName)
keystone.SimulateKeystoneServiceReady(novaNames.KeystoneServiceName)
th.SimulateMariaDBDatabaseCompleted(novaNames.APIMariaDBDatabaseName)
th.SimulateMariaDBDatabaseCompleted(cell0.MariaDBDatabaseName)
th.SimulateTransportURLReady(cell0.TransportURLName)
Expand Down Expand Up @@ -596,7 +596,7 @@ var _ = Describe("Nova controller", func() {
},
),
)
DeferCleanup(th.DeleteKeystoneAPI, th.CreateKeystoneAPI(novaNames.NovaName.Namespace))
DeferCleanup(keystone.DeleteKeystoneAPI, keystone.CreateKeystoneAPI(novaNames.NovaName.Namespace))

spec := GetDefaultNovaSpec()
cell0template := GetDefaultNovaCellTemplate()
Expand All @@ -608,7 +608,7 @@ var _ = Describe("Nova controller", func() {
})

It("uses the correct hostnames to access the different DB services", func() {
th.SimulateKeystoneServiceReady(novaNames.KeystoneServiceName)
keystone.SimulateKeystoneServiceReady(novaNames.KeystoneServiceName)
th.SimulateMariaDBDatabaseCompleted(novaNames.APIMariaDBDatabaseName)
th.SimulateMariaDBDatabaseCompleted(cell0.MariaDBDatabaseName)
th.SimulateTransportURLReady(cell0.TransportURLName)
Expand Down Expand Up @@ -673,7 +673,7 @@ var _ = Describe("Nova controller", func() {
Expect(configData).To(ContainSubstring("password = service-password"))

th.SimulateStatefulSetReplicaReady(novaNames.APIName)
th.SimulateKeystoneEndpointReady(novaNames.APIKeystoneEndpointName)
keystone.SimulateKeystoneEndpointReady(novaNames.APIKeystoneEndpointName)

th.ExpectCondition(
cell0.ConductorName,
Expand Down Expand Up @@ -730,30 +730,30 @@ var _ = Describe("Nova controller", func() {
},
),
)
DeferCleanup(th.DeleteKeystoneAPI, th.CreateKeystoneAPI(novaNames.NovaName.Namespace))
DeferCleanup(keystone.DeleteKeystoneAPI, keystone.CreateKeystoneAPI(novaNames.NovaName.Namespace))

DeferCleanup(th.DeleteInstance, CreateNovaWithCell0(novaNames.NovaName))
})

It("removes the finalizer from KeystoneService", func() {
th.SimulateKeystoneServiceReady(novaNames.KeystoneServiceName)
keystone.SimulateKeystoneServiceReady(novaNames.KeystoneServiceName)
th.ExpectCondition(
novaNames.NovaName,
ConditionGetterFunc(NovaConditionGetter),
condition.KeystoneServiceReadyCondition,
corev1.ConditionTrue,
)

service := th.GetKeystoneService(novaNames.KeystoneServiceName)
service := keystone.GetKeystoneService(novaNames.KeystoneServiceName)
Expect(service.Finalizers).To(ContainElement("Nova"))

th.DeleteInstance(GetNova(novaNames.NovaName))
service = th.GetKeystoneService(novaNames.KeystoneServiceName)
service = keystone.GetKeystoneService(novaNames.KeystoneServiceName)
Expect(service.Finalizers).NotTo(ContainElement("Nova"))
})

It("removes the finalizers from the nova dbs", func() {
th.SimulateKeystoneServiceReady(novaNames.KeystoneServiceName)
keystone.SimulateKeystoneServiceReady(novaNames.KeystoneServiceName)

apiDB := th.GetMariaDBDatabase(novaNames.APIMariaDBDatabaseName)
Expect(apiDB.Finalizers).To(ContainElement("Nova"))
Expand Down Expand Up @@ -785,7 +785,7 @@ var _ = Describe("Nova controller", func() {
},
),
)
DeferCleanup(th.DeleteKeystoneAPI, th.CreateKeystoneAPI(novaNames.NovaName.Namespace))
DeferCleanup(keystone.DeleteKeystoneAPI, keystone.CreateKeystoneAPI(novaNames.NovaName.Namespace))

nad := th.CreateNetworkAttachmentDefinition(novaNames.InternalAPINetworkNADName)
DeferCleanup(th.DeleteInstance, nad)
Expand Down Expand Up @@ -823,7 +823,7 @@ var _ = Describe("Nova controller", func() {
}
DeferCleanup(th.DeleteInstance, CreateNova(novaNames.NovaName, rawSpec))

th.SimulateKeystoneServiceReady(novaNames.KeystoneServiceName)
keystone.SimulateKeystoneServiceReady(novaNames.KeystoneServiceName)
th.SimulateMariaDBDatabaseCompleted(novaNames.APIMariaDBDatabaseName)
th.SimulateMariaDBDatabaseCompleted(cell0.MariaDBDatabaseName)
th.SimulateTransportURLReady(cell0.TransportURLName)
Expand All @@ -849,7 +849,7 @@ var _ = Describe("Nova controller", func() {
novaNames.MetadataStatefulSetName,
map[string][]string{novaNames.NovaName.Namespace + "/internalapi": {"10.0.0.1"}},
)
th.SimulateKeystoneEndpointReady(novaNames.APIKeystoneEndpointName)
keystone.SimulateKeystoneEndpointReady(novaNames.APIKeystoneEndpointName)

th.ExpectCondition(
novaNames.NovaName,
Expand Down
Loading

0 comments on commit 2e753c5

Please sign in to comment.