From 450c6a4e9b30a7c2db5d046f9ce6ab7695e3b3a6 Mon Sep 17 00:00:00 2001 From: Brendan Shephard Date: Mon, 4 Nov 2024 09:59:42 +1000 Subject: [PATCH] Add functional test for dataplane extraMounts 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 --- ...enstackdataplanenodeset_controller_test.go | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/tests/functional/dataplane/openstackdataplanenodeset_controller_test.go b/tests/functional/dataplane/openstackdataplanenodeset_controller_test.go index 482e757d4..1780e5805 100644 --- a/tests/functional/dataplane/openstackdataplanenodeset_controller_test.go +++ b/tests/functional/dataplane/openstackdataplanenodeset_controller_test.go @@ -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" @@ -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")