Skip to content

Commit 42e867e

Browse files
committed
Add extraMounts envTests
As part of the extraMounts import, this patch adds envTests to make sure they are properly propagated to Keystone. Signed-off-by: Francesco Pantano <[email protected]>
1 parent dfd5294 commit 42e867e

File tree

2 files changed

+94
-1
lines changed

2 files changed

+94
-1
lines changed

tests/functional/base_test.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,3 +195,37 @@ func GetTopology(name types.NamespacedName) *topologyv1.Topology {
195195
}, timeout, interval).Should(Succeed())
196196
return instance
197197
}
198+
199+
// GetExtraMounts - Utility function that simulates extraMounts pointing
200+
// to a secret
201+
func GetExtraMounts(kemName string, kemPath string) []map[string]interface{} {
202+
return []map[string]interface{}{
203+
{
204+
"name": kemName,
205+
"region": "az0",
206+
"extraVol": []map[string]interface{}{
207+
{
208+
"extraVolType": kemName,
209+
"propagation": []string{
210+
"Keystone",
211+
},
212+
"volumes": []map[string]interface{}{
213+
{
214+
"name": kemName,
215+
"secret": map[string]interface{}{
216+
"secretName": kemName,
217+
},
218+
},
219+
},
220+
"mounts": []map[string]interface{}{
221+
{
222+
"name": kemName,
223+
"mountPath": kemPath,
224+
"readOnly": true,
225+
},
226+
},
227+
},
228+
},
229+
},
230+
}
231+
}

tests/functional/keystoneapi_controller_test.go

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1791,7 +1791,66 @@ OIDCRedirectURI "{{ .KeystoneEndpointPublic }}/v3/auth/OS-FEDERATION/websso/open
17911791
}
17921792
})
17931793
})
1794-
1794+
When("Keystone CR is built with ExtraMounts", func() {
1795+
var keystoneExtraMountsSecretName, keystoneExtraMountsPath string
1796+
BeforeEach(func() {
1797+
spec := GetDefaultKeystoneAPISpec()
1798+
keystoneExtraMountsPath = "/var/log/foo"
1799+
keystoneExtraMountsSecretName = "foo"
1800+
spec["extraMounts"] = GetExtraMounts(keystoneExtraMountsSecretName, keystoneExtraMountsPath)
1801+
DeferCleanup(
1802+
k8sClient.Delete, ctx, CreateKeystoneMessageBusSecret(namespace, "rabbitmq-secret"))
1803+
keystone := CreateKeystoneAPI(keystoneAPIName, spec)
1804+
DeferCleanup(th.DeleteInstance, keystone)
1805+
DeferCleanup(
1806+
k8sClient.Delete, ctx, CreateKeystoneAPISecret(namespace, SecretName))
1807+
DeferCleanup(infra.DeleteMemcached, infra.CreateMemcached(namespace, "memcached", memcachedSpec))
1808+
DeferCleanup(
1809+
mariadb.DeleteDBService,
1810+
mariadb.CreateDBService(
1811+
namespace,
1812+
GetKeystoneAPI(keystoneAPIName).Spec.DatabaseInstance,
1813+
corev1.ServiceSpec{
1814+
Ports: []corev1.ServicePort{{Port: 3306}},
1815+
},
1816+
),
1817+
)
1818+
mariadb.SimulateMariaDBAccountCompleted(keystoneAccountName)
1819+
mariadb.SimulateMariaDBDatabaseCompleted(keystoneDatabaseName)
1820+
infra.SimulateTransportURLReady(types.NamespacedName{
1821+
Name: fmt.Sprintf("%s-keystone-transport", keystoneAPIName.Name),
1822+
Namespace: namespace,
1823+
})
1824+
infra.SimulateMemcachedReady(types.NamespacedName{
1825+
Name: "memcached",
1826+
Namespace: namespace,
1827+
})
1828+
th.SimulateJobSuccess(dbSyncJobName)
1829+
th.SimulateJobSuccess(bootstrapJobName)
1830+
th.SimulateDeploymentReplicaReady(deploymentName)
1831+
})
1832+
It("Check extraMounts of the resulting Deployment", func() {
1833+
th.SimulateDeploymentReplicaReady(deploymentName)
1834+
// Get Keystone Deployment
1835+
dp := th.GetDeployment(deploymentName)
1836+
// Check the resulting deployment fields
1837+
Expect(dp.Spec.Template.Spec.Volumes).To(HaveLen(5))
1838+
Expect(dp.Spec.Template.Spec.Containers).To(HaveLen(1))
1839+
// Get the keystone-api container
1840+
container := dp.Spec.Template.Spec.Containers[0]
1841+
// Fail if keystone-api doesn't have the right number of VolumeMounts
1842+
// entries
1843+
Expect(container.VolumeMounts).To(HaveLen(6))
1844+
// Inspect VolumeMounts and make sure we have the Foo MountPath
1845+
// provided through extraMounts
1846+
for _, vm := range container.VolumeMounts {
1847+
if vm.Name == "foo" {
1848+
Expect(vm.MountPath).To(
1849+
ContainSubstring(keystoneExtraMountsPath))
1850+
}
1851+
}
1852+
})
1853+
})
17951854
// Run MariaDBAccount suite tests. these are pre-packaged ginkgo tests
17961855
// that exercise standard account create / update patterns that should be
17971856
// common to all controllers that ensure MariaDBAccount CRs.

0 commit comments

Comments
 (0)