Skip to content

Commit

Permalink
Add functional test for dataplane extraMounts
Browse files Browse the repository at this point in the history
This change adds a functional test for the dataplane extraMounts,
this ensures we're able to validate our abstraction of the corev1.VolumeSource
struct during functional tests.

Signed-off-by: Brendan Shephard <[email protected]>
  • Loading branch information
bshephar committed Nov 5, 2024
1 parent f6f541e commit 450c6a4
Showing 1 changed file with 67 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
. "github.com/onsi/ginkgo/v2" //revive:disable:dot-imports
. "github.com/onsi/gomega" //revive:disable:dot-imports
"github.com/openstack-k8s-operators/lib-common/modules/common/condition"
"github.com/openstack-k8s-operators/lib-common/modules/storage"
openstackv1 "github.com/openstack-k8s-operators/openstack-operator/apis/core/v1beta1"
dataplanev1 "github.com/openstack-k8s-operators/openstack-operator/apis/dataplane/v1beta1"

Expand Down Expand Up @@ -1435,6 +1436,72 @@ var _ = Describe("Dataplane NodeSet Test", func() {
})
})

When("A NodeSet and Deployment are created with extraMounts with pvc template", func() {
BeforeEach(func() {
edpmVolClaimTemplate := corev1.PersistentVolumeClaimVolumeSource{
ClaimName: "edpm-ansible",
ReadOnly: true,
}
nodeSetSpec := DefaultDataPlaneNodeSetSpec("edpm-compute")
nodeSetSpec["preProvisioned"] = true
nodeSetSpec["services"] = []string{"bootstrap"}
nodeSetSpec["nodeTemplate"] = map[string]interface{}{
"extraMounts": []storage.VolMounts{
{
Mounts: []corev1.VolumeMount{
{
Name: "edpm-ansible",
MountPath: "/usr/share/ansible/collections/ansible_collections/osp/edpm",
},
},
Volumes: []storage.Volume{
{
Name: "edpm-ansible",
VolumeSource: storage.VolumeSource{
PersistentVolumeClaim: &edpmVolClaimTemplate,
},
},
},
},
},
"ansibleSSHPrivateKeySecret": "dataplane-ansible-ssh-private-key-secret",
"ansible": map[string]interface{}{
"ansibleUser": "cloud-user",
},
}
DeferCleanup(th.DeleteInstance, CreateNetConfig(dataplaneNetConfigName, DefaultNetConfigSpec()))
DeferCleanup(th.DeleteInstance, CreateDNSMasq(dnsMasqName, DefaultDNSMasqSpec()))
DeferCleanup(th.DeleteInstance, CreateDataplaneNodeSet(dataplaneNodeSetName, nodeSetSpec))
DeferCleanup(th.DeleteInstance, CreateDataplaneDeployment(dataplaneDeploymentName, DefaultDataPlaneDeploymentSpec()))
CreateSSHSecret(dataplaneSSHSecretName)
SimulateDNSMasqComplete(dnsMasqName)
SimulateIPSetComplete(dataplaneNodeName)
SimulateDNSDataComplete(dataplaneNodeSetName)

})
It("Should have ExtraMounts, SSH and Inventory volume mounts", func() {
Eventually(func(g Gomega) {
const bootstrapName string = "bootstrap"
// Make an AnsibleEE name for each service
ansibleeeName := types.NamespacedName{
Name: fmt.Sprintf(
bootstrapName + "-" + dataplaneDeploymentName.Name + "-" + dataplaneNodeSetName.Name),
Namespace: namespace,
}
ansibleEE := GetAnsibleee(ansibleeeName)
g.Expect(ansibleEE.Spec.Template.Spec.Volumes).To(HaveLen(3))
g.Expect(ansibleEE.Spec.Template.Spec.Volumes[0].Name).To(Equal("edpm-ansible"))
g.Expect(ansibleEE.Spec.Template.Spec.Volumes[1].Name).To(Equal("ssh-key"))
g.Expect(ansibleEE.Spec.Template.Spec.Volumes[2].Name).To(Equal("inventory"))
g.Expect(ansibleEE.Spec.Template.Spec.Volumes[0].VolumeSource.PersistentVolumeClaim.ClaimName).To(Equal("edpm-ansible"))
g.Expect(ansibleEE.Spec.Template.Spec.Volumes[1].VolumeSource.Secret.SecretName).To(Equal("dataplane-ansible-ssh-private-key-secret"))
g.Expect(ansibleEE.Spec.Template.Spec.Volumes[1].VolumeSource.Secret.Items[0].Path).To(Equal("ssh_key"))
g.Expect(ansibleEE.Spec.Template.Spec.Volumes[1].VolumeSource.Secret.Items[0].Key).To(Equal("ssh-privatekey"))

}, th.Timeout, th.Interval).Should(Succeed())
})
})

When("A ImageContentSourcePolicy exists in the cluster", func() {
BeforeEach(func() {
nodeSetSpec := DefaultDataPlaneNodeSetSpec("edpm-compute")
Expand Down

0 comments on commit 450c6a4

Please sign in to comment.