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 #476

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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 @@ -296,3 +296,37 @@ func CinderVolumeNotExists(name types.NamespacedName) {
g.Expect(k8s_errors.IsNotFound(err)).To(BeTrue())
}, timeout, interval).Should(Succeed())
}

// GetExtraMounts - Utility function that simulates extraMounts pointing
// to a Ceph secret
func GetExtraMounts() []map[string]interface{} {
return []map[string]interface{}{
{
"name": cinderTest.Instance.Name,
"region": "az0",
"extraVol": []map[string]interface{}{
{
"extraVolType": CinderCephExtraMountsSecretName,
"propagation": []string{
"CinderVolume",
},
"volumes": []map[string]interface{}{
{
"name": CinderCephExtraMountsSecretName,
"secret": map[string]interface{}{
"secretName": CinderCephExtraMountsSecretName,
},
},
},
"mounts": []map[string]interface{}{
{
"name": CinderCephExtraMountsSecretName,
"mountPath": CinderCephExtraMountsPath,
"readOnly": true,
},
},
},
},
},
}
}
69 changes: 69 additions & 0 deletions test/functional/cinder_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,75 @@ var _ = Describe("Cinder controller", func() {

})

When("Cinder CR instance is built with ExtraMounts", func() {
BeforeEach(func() {
rawSpec := map[string]interface{}{
"secret": SecretName,
"databaseInstance": "openstack",
"rabbitMqClusterName": "rabbitmq",
"extraMounts": GetExtraMounts(),
"cinderAPI": map[string]interface{}{
"containerImage": cinderv1.CinderAPIContainerImage,
},
"cinderScheduler": map[string]interface{}{
"containerImage": cinderv1.CinderSchedulerContainerImage,
},
"cinderVolumes": map[string]interface{}{
"volume1": map[string]interface{}{
"containerImage": cinderv1.CinderVolumeContainerImage,
},
},
}

DeferCleanup(th.DeleteInstance, CreateCinder(cinderTest.Instance, rawSpec))
DeferCleanup(k8sClient.Delete, ctx, CreateCinderMessageBusSecret(cinderTest.Instance.Namespace, cinderTest.RabbitmqSecretName))
DeferCleanup(
mariadb.DeleteDBService,
mariadb.CreateDBService(
cinderTest.Instance.Namespace,
GetCinder(cinderTest.Instance).Spec.DatabaseInstance,
corev1.ServiceSpec{
Ports: []corev1.ServicePort{{Port: 3306}},
},
),
)
infra.SimulateTransportURLReady(cinderTest.CinderTransportURL)
DeferCleanup(infra.DeleteMemcached, infra.CreateMemcached(namespace, cinderTest.MemcachedInstance, memcachedSpec))
infra.SimulateMemcachedReady(cinderTest.CinderMemcached)
keystoneAPIName := keystone.CreateKeystoneAPI(cinderTest.Instance.Namespace)
DeferCleanup(keystone.DeleteKeystoneAPI, keystoneAPIName)
mariadb.SimulateMariaDBAccountCompleted(cinderTest.Database)
mariadb.SimulateMariaDBDatabaseCompleted(cinderTest.Database)
th.SimulateJobSuccess(cinderTest.CinderDBSync)
keystone.SimulateKeystoneEndpointReady(cinderTest.CinderKeystoneEndpoint)
})

It("Check the extraMounts of the resulting StatefulSets", func() {
th.SimulateStatefulSetReplicaReady(cinderTest.CinderAPI)
th.SimulateStatefulSetReplicaReady(cinderTest.CinderScheduler)
// Retrieve the generated resources
volume := cinderTest.CinderVolumes[0]
th.SimulateStatefulSetReplicaReady(volume)
ss := th.GetStatefulSet(volume)
// Check the resulting deployment fields
Expect(int(*ss.Spec.Replicas)).To(Equal(1))
Expect(ss.Spec.Template.Spec.Volumes).To(HaveLen(15))
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(17))
// 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(CinderCephExtraMountsPath))
}
}
})
})
// Run MariaDBAccount suite tests. these are pre-packaged ginkgo tests
// that exercise standard account create / update patterns that should be
// common to all controllers that ensure MariaDBAccount CRs.
Expand Down
4 changes: 4 additions & 0 deletions test/functional/cinder_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"
// CinderCephExtraMountsPath -
CinderCephExtraMountsPath = "/etc/ceph"
// CinderCephExtraMountsSecretName -
CinderCephExtraMountsSecretName = "ceph"
)

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