@@ -31,6 +31,7 @@ import (
3131 "github.com/openstack-k8s-operators/lib-common/modules/common/condition"
3232 util "github.com/openstack-k8s-operators/lib-common/modules/common/util"
3333 mariadb_test "github.com/openstack-k8s-operators/mariadb-operator/api/test/helpers"
34+ appsv1 "k8s.io/api/apps/v1"
3435 corev1 "k8s.io/api/core/v1"
3536 "k8s.io/apimachinery/pkg/types"
3637 ptr "k8s.io/utils/ptr"
@@ -591,6 +592,69 @@ var _ = Describe("Glance controller", func() {
591592 })
592593 })
593594
595+ When ("Glance CR instance is built with ExtraMounts" , func () {
596+ BeforeEach (func () {
597+ DeferCleanup (infra .DeleteMemcached , infra .CreateMemcached (namespace , glanceTest .MemcachedInstance , memcachedSpec ))
598+ infra .SimulateMemcachedReady (glanceTest .GlanceMemcached )
599+
600+ rawSpec := map [string ]interface {}{
601+ "storage" : map [string ]interface {}{
602+ "storageRequest" : glanceTest .GlancePVCSize ,
603+ },
604+ "storageRequest" : glanceTest .GlancePVCSize ,
605+ "secret" : SecretName ,
606+ "databaseInstance" : glanceTest .GlanceDatabaseName .Name ,
607+ "databaseAccount" : glanceTest .GlanceDatabaseAccount .Name ,
608+ "customServiceConfig" : GlanceDummyBackend ,
609+ "extraMounts" : GetExtraMounts (),
610+ }
611+ DeferCleanup (th .DeleteInstance , CreateGlance (glanceTest .Instance , rawSpec ))
612+ DeferCleanup (
613+ mariadb .DeleteDBService ,
614+ mariadb .CreateDBService (
615+ glanceTest .Instance .Namespace ,
616+ GetGlance (glanceName ).Spec .DatabaseInstance ,
617+ corev1.ServiceSpec {
618+ Ports : []corev1.ServicePort {{Port : 3306 }},
619+ },
620+ ),
621+ )
622+ mariadb .SimulateMariaDBDatabaseCompleted (glanceTest .GlanceDatabaseName )
623+ mariadb .SimulateMariaDBAccountCompleted (glanceTest .GlanceDatabaseAccount )
624+ th .SimulateJobSuccess (glanceTest .GlanceDBSync )
625+ keystoneAPI := keystone .CreateKeystoneAPI (glanceTest .Instance .Namespace )
626+ DeferCleanup (keystone .DeleteKeystoneAPI , keystoneAPI )
627+ keystone .SimulateKeystoneServiceReady (glanceTest .KeystoneService )
628+ })
629+ It ("Check the extraMounts of the resulting StatefulSets" , func () {
630+ th .SimulateStatefulSetReplicaReady (glanceTest .GlanceInternalStatefulSet )
631+ th .SimulateStatefulSetReplicaReady (glanceTest .GlanceExternalStatefulSet )
632+ // Retrieve the generated resources and the two internal/external
633+ // instances that are split behind the scenes
634+ ssInternal := th .GetStatefulSet (glanceTest .GlanceInternalStatefulSet )
635+ ssExternal := th .GetStatefulSet (glanceTest .GlanceExternalStatefulSet )
636+
637+ for _ , ss := range []* appsv1.StatefulSet {ssInternal , ssExternal } {
638+ // Check the resulting deployment fields
639+ Expect (ss .Spec .Template .Spec .Volumes ).To (HaveLen (5 ))
640+ Expect (ss .Spec .Template .Spec .Containers ).To (HaveLen (3 ))
641+ // Get the glance-api container
642+ container := ss .Spec .Template .Spec .Containers [2 ]
643+ // Fail if glance-api doesn't have the right number of VolumeMounts
644+ // entries
645+ Expect (container .VolumeMounts ).To (HaveLen (7 ))
646+ // Inspect VolumeMounts and make sure we have the Ceph MountPath
647+ // provided through extraMounts
648+ for _ , vm := range container .VolumeMounts {
649+ if vm .Name == "ceph" {
650+ Expect (vm .MountPath ).To (
651+ ContainSubstring (GlanceCephExtraMountsPath ))
652+ }
653+ }
654+ }
655+ })
656+ })
657+
594658 // Run MariaDBAccount suite tests. these are pre-packaged ginkgo tests
595659 // that exercise standard account create / update patterns that should be
596660 // common to all controllers that ensure MariaDBAccount CRs.
0 commit comments