Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add extraMounts functional tests #374

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions test/functional/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,3 +336,37 @@ func GetCronJob(name types.NamespacedName) *batchv1.CronJob {
}, timeout, interval).Should(Succeed())
return cron
}

// GetExtraMounts - Utility function that simulates extraMounts pointing
// to a Ceph secret
func GetExtraMounts() []map[string]interface{} {
return []map[string]interface{}{
{
"name": manilaTest.Instance.Name,
"region": "az0",
"extraVol": []map[string]interface{}{
{
"extraVolType": ManilaCephExtraMountsSecretName,
"propagation": []string{
"ManilaShare",
},
"volumes": []map[string]interface{}{
{
"name": ManilaCephExtraMountsSecretName,
"secret": map[string]interface{}{
"secretName": ManilaCephExtraMountsSecretName,
},
},
},
"mounts": []map[string]interface{}{
{
"name": ManilaCephExtraMountsSecretName,
"mountPath": ManilaCephExtraMountsPath,
"readOnly": true,
},
},
},
},
},
}
}
74 changes: 74 additions & 0 deletions test/functional/manila_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,80 @@ var _ = Describe("Manila controller", func() {
}, timeout, interval).Should(Succeed())
})
})
When("Manila CR instance is built with ExtraMounts", func() {
BeforeEach(func() {
rawSpec := map[string]interface{}{
"secret": SecretName,
"databaseInstance": "openstack",
"rabbitMqClusterName": "rabbitmq",
"extraMounts": GetExtraMounts(),
"manilaAPI": map[string]interface{}{
"containerImage": manilav1.ManilaAPIContainerImage,
},
"manilaScheduler": map[string]interface{}{
"containerImage": manilav1.ManilaSchedulerContainerImage,
},
"manilaShares": map[string]interface{}{
"share0": map[string]interface{}{
"containerImage": manilav1.ManilaShareContainerImage,
},
},
}
DeferCleanup(th.DeleteInstance, CreateManila(manilaTest.Instance, rawSpec))
DeferCleanup(k8sClient.Delete, ctx, CreateManilaMessageBusSecret(manilaTest.Instance.Namespace, manilaTest.RabbitmqSecretName))
DeferCleanup(
mariadb.DeleteDBService,
mariadb.CreateDBService(
manilaTest.Instance.Namespace,
GetManila(manilaTest.Instance).Spec.DatabaseInstance,
corev1.ServiceSpec{
Ports: []corev1.ServicePort{{Port: 3306}},
},
),
)
infra.SimulateTransportURLReady(manilaTest.ManilaTransportURL)
DeferCleanup(infra.DeleteMemcached, infra.CreateMemcached(namespace, manilaTest.MemcachedInstance, memcachedSpec))
infra.SimulateMemcachedReady(manilaTest.ManilaMemcached)
keystoneAPIName := keystone.CreateKeystoneAPI(manilaTest.Instance.Namespace)
DeferCleanup(keystone.DeleteKeystoneAPI, keystoneAPIName)
keystoneAPI := keystone.GetKeystoneAPI(keystoneAPIName)
keystoneAPI.Status.APIEndpoints["internal"] = "http://keystone-internal-openstack.testing"
Eventually(func(g Gomega) {
g.Expect(k8sClient.Status().Update(ctx, keystoneAPI.DeepCopy())).Should(Succeed())
}, timeout, interval).Should(Succeed())
mariadb.SimulateMariaDBDatabaseCompleted(manilaTest.ManilaDatabaseName)
mariadb.SimulateMariaDBAccountCompleted(manilaTest.ManilaDatabaseAccount)
th.SimulateJobSuccess(manilaTest.ManilaDBSync)
keystone.SimulateKeystoneServiceReady(manilaTest.Instance)
})
It("Check the extraMounts of the resulting StatefulSets", func() {
th.SimulateStatefulSetReplicaReady(manilaTest.ManilaAPI)
th.SimulateStatefulSetReplicaReady(manilaTest.ManilaScheduler)
th.SimulateStatefulSetReplicaReady(manilaTest.ManilaShares[0])
keystone.SimulateKeystoneEndpointReady(manilaTest.ManilaKeystoneEndpoint)
// Retrieve the generated resources
share := manilaTest.ManilaShares[0]
th.SimulateStatefulSetReplicaReady(share)
ss := th.GetStatefulSet(share)
// Check the resulting deployment fields
Expect(int(*ss.Spec.Replicas)).To(Equal(1))
Expect(ss.Spec.Template.Spec.Volumes).To(HaveLen(7))
Expect(ss.Spec.Template.Spec.Containers).To(HaveLen(2))
// Get the manila-share container
container := ss.Spec.Template.Spec.Containers[1]
// Fail if manila-share doesn't have the right number of
// VolumeMounts entries
Expect(container.VolumeMounts).To(HaveLen(9))
// Inspect VolumeMounts and make sure we have the Ceph MountPath
// provided through extraMounts
for _, vm := range container.VolumeMounts {
if vm.Name == "ceph" {
Expect(vm.MountPath).To(
ContainSubstring(ManilaCephExtraMountsPath))
}
}
})
})

// Run MariaDBAccount suite tests. these are pre-packaged ginkgo tests
// that exercise standard account create / update patterns that should be
Expand Down
4 changes: 4 additions & 0 deletions test/functional/manila_test_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ const (
InternalCertSecretName = "internal-tls-certs"
//CABundleSecretName -
CABundleSecretName = "combined-ca-bundle"
// ManilaCephExtraMountsPath -
ManilaCephExtraMountsPath = "/etc/ceph"
// ManilaCephExtraMountsSecretName -
ManilaCephExtraMountsSecretName = "ceph"
)

// ManilaTestData is the data structure used to provide input data to envTest
Expand Down
Loading