Skip to content

Commit 33696c8

Browse files
Merge pull request #374 from fmount/em_envtest
Add extraMounts functional tests
2 parents 084339f + 813ed2f commit 33696c8

File tree

3 files changed

+112
-0
lines changed

3 files changed

+112
-0
lines changed

test/functional/base_test.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,3 +336,37 @@ func GetCronJob(name types.NamespacedName) *batchv1.CronJob {
336336
}, timeout, interval).Should(Succeed())
337337
return cron
338338
}
339+
340+
// GetExtraMounts - Utility function that simulates extraMounts pointing
341+
// to a Ceph secret
342+
func GetExtraMounts() []map[string]interface{} {
343+
return []map[string]interface{}{
344+
{
345+
"name": manilaTest.Instance.Name,
346+
"region": "az0",
347+
"extraVol": []map[string]interface{}{
348+
{
349+
"extraVolType": ManilaCephExtraMountsSecretName,
350+
"propagation": []string{
351+
"ManilaShare",
352+
},
353+
"volumes": []map[string]interface{}{
354+
{
355+
"name": ManilaCephExtraMountsSecretName,
356+
"secret": map[string]interface{}{
357+
"secretName": ManilaCephExtraMountsSecretName,
358+
},
359+
},
360+
},
361+
"mounts": []map[string]interface{}{
362+
{
363+
"name": ManilaCephExtraMountsSecretName,
364+
"mountPath": ManilaCephExtraMountsPath,
365+
"readOnly": true,
366+
},
367+
},
368+
},
369+
},
370+
},
371+
}
372+
}

test/functional/manila_controller_test.go

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -856,6 +856,80 @@ var _ = Describe("Manila controller", func() {
856856
}, timeout, interval).Should(Succeed())
857857
})
858858
})
859+
When("Manila CR instance is built with ExtraMounts", func() {
860+
BeforeEach(func() {
861+
rawSpec := map[string]interface{}{
862+
"secret": SecretName,
863+
"databaseInstance": "openstack",
864+
"rabbitMqClusterName": "rabbitmq",
865+
"extraMounts": GetExtraMounts(),
866+
"manilaAPI": map[string]interface{}{
867+
"containerImage": manilav1.ManilaAPIContainerImage,
868+
},
869+
"manilaScheduler": map[string]interface{}{
870+
"containerImage": manilav1.ManilaSchedulerContainerImage,
871+
},
872+
"manilaShares": map[string]interface{}{
873+
"share0": map[string]interface{}{
874+
"containerImage": manilav1.ManilaShareContainerImage,
875+
},
876+
},
877+
}
878+
DeferCleanup(th.DeleteInstance, CreateManila(manilaTest.Instance, rawSpec))
879+
DeferCleanup(k8sClient.Delete, ctx, CreateManilaMessageBusSecret(manilaTest.Instance.Namespace, manilaTest.RabbitmqSecretName))
880+
DeferCleanup(
881+
mariadb.DeleteDBService,
882+
mariadb.CreateDBService(
883+
manilaTest.Instance.Namespace,
884+
GetManila(manilaTest.Instance).Spec.DatabaseInstance,
885+
corev1.ServiceSpec{
886+
Ports: []corev1.ServicePort{{Port: 3306}},
887+
},
888+
),
889+
)
890+
infra.SimulateTransportURLReady(manilaTest.ManilaTransportURL)
891+
DeferCleanup(infra.DeleteMemcached, infra.CreateMemcached(namespace, manilaTest.MemcachedInstance, memcachedSpec))
892+
infra.SimulateMemcachedReady(manilaTest.ManilaMemcached)
893+
keystoneAPIName := keystone.CreateKeystoneAPI(manilaTest.Instance.Namespace)
894+
DeferCleanup(keystone.DeleteKeystoneAPI, keystoneAPIName)
895+
keystoneAPI := keystone.GetKeystoneAPI(keystoneAPIName)
896+
keystoneAPI.Status.APIEndpoints["internal"] = "http://keystone-internal-openstack.testing"
897+
Eventually(func(g Gomega) {
898+
g.Expect(k8sClient.Status().Update(ctx, keystoneAPI.DeepCopy())).Should(Succeed())
899+
}, timeout, interval).Should(Succeed())
900+
mariadb.SimulateMariaDBDatabaseCompleted(manilaTest.ManilaDatabaseName)
901+
mariadb.SimulateMariaDBAccountCompleted(manilaTest.ManilaDatabaseAccount)
902+
th.SimulateJobSuccess(manilaTest.ManilaDBSync)
903+
keystone.SimulateKeystoneServiceReady(manilaTest.Instance)
904+
})
905+
It("Check the extraMounts of the resulting StatefulSets", func() {
906+
th.SimulateStatefulSetReplicaReady(manilaTest.ManilaAPI)
907+
th.SimulateStatefulSetReplicaReady(manilaTest.ManilaScheduler)
908+
th.SimulateStatefulSetReplicaReady(manilaTest.ManilaShares[0])
909+
keystone.SimulateKeystoneEndpointReady(manilaTest.ManilaKeystoneEndpoint)
910+
// Retrieve the generated resources
911+
share := manilaTest.ManilaShares[0]
912+
th.SimulateStatefulSetReplicaReady(share)
913+
ss := th.GetStatefulSet(share)
914+
// Check the resulting deployment fields
915+
Expect(int(*ss.Spec.Replicas)).To(Equal(1))
916+
Expect(ss.Spec.Template.Spec.Volumes).To(HaveLen(7))
917+
Expect(ss.Spec.Template.Spec.Containers).To(HaveLen(2))
918+
// Get the manila-share container
919+
container := ss.Spec.Template.Spec.Containers[1]
920+
// Fail if manila-share doesn't have the right number of
921+
// VolumeMounts entries
922+
Expect(container.VolumeMounts).To(HaveLen(9))
923+
// Inspect VolumeMounts and make sure we have the Ceph MountPath
924+
// provided through extraMounts
925+
for _, vm := range container.VolumeMounts {
926+
if vm.Name == "ceph" {
927+
Expect(vm.MountPath).To(
928+
ContainSubstring(ManilaCephExtraMountsPath))
929+
}
930+
}
931+
})
932+
})
859933

860934
// Run MariaDBAccount suite tests. these are pre-packaged ginkgo tests
861935
// that exercise standard account create / update patterns that should be

test/functional/manila_test_data.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ const (
3333
InternalCertSecretName = "internal-tls-certs"
3434
//CABundleSecretName -
3535
CABundleSecretName = "combined-ca-bundle"
36+
// ManilaCephExtraMountsPath -
37+
ManilaCephExtraMountsPath = "/etc/ceph"
38+
// ManilaCephExtraMountsSecretName -
39+
ManilaCephExtraMountsSecretName = "ceph"
3640
)
3741

3842
// ManilaTestData is the data structure used to provide input data to envTest

0 commit comments

Comments
 (0)