Skip to content

Commit c3d35b8

Browse files
kuiwang02ci-robot
authored andcommitted
UPSTREAM: <carry>: verify volume/volumeMount override
1 parent 0d27a8b commit c3d35b8

1 file changed

Lines changed: 88 additions & 54 deletions

File tree

openshift/tests-extension/test/qe/specs/olmv1_ce_deploymentconfig.go

Lines changed: 88 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -467,12 +467,14 @@ var _ = g.Describe("[sig-olmv1][Jira:OLM] OLMv1 ClusterExtension DeploymentConfi
467467
saClusterRoleBindingTemplate = filepath.Join(baseDir, "sa-admin.yaml")
468468

469469
// Define inline config as JSON string (for ${{}} template parsing)
470-
// Add two volumes: one ConfigMap volume and one Secret volume
470+
// Volume 1: Same name as bundle (bundle-emptydir-vol) but different type (ConfigMap vs emptyDir)
471+
// Should OVERRIDE bundle volume, not create duplicate
472+
// Volume 2: Different name (config-secret-vol) - Should be APPENDED
471473
inlineConfig = `{
472474
"deploymentConfig": {
473475
"volumes": [
474476
{
475-
"name": "config-cm-vol",
477+
"name": "bundle-emptydir-vol",
476478
"configMap": {
477479
"name": "test-cm-vol"
478480
}
@@ -566,17 +568,34 @@ var _ = g.Describe("[sig-olmv1][Jira:OLM] OLMv1 ClusterExtension DeploymentConfi
566568
g.By("Dump Deployment manifest for debugging")
567569
olmv1util.DumpDeploymentManifest(oc, deploymentName, ns)
568570

569-
g.By("Test Point 1: Verify volumes appended to Deployment")
571+
g.By("Test Point 1: Verify volumes merge-with-override behavior in Deployment")
570572
// Get all volume names from Deployment spec.template.spec.volumes
571573
volumesPath := `jsonpath={range .spec.template.spec.volumes[*]}{.name}{"\n"}{end}`
572574
volumesList, err := olmv1util.GetNoEmpty(oc, "deployment", deploymentName, "-n", ns, "-o", volumesPath)
573575
o.Expect(err).NotTo(o.HaveOccurred())
574576
e2e.Logf("Volumes list:\n%s", volumesList)
575577

576-
// Verify config volumes are present
577-
o.Expect(volumesList).To(o.ContainSubstring("config-cm-vol"), "ConfigMap volume should be appended")
578+
// Verify volumes are present
579+
o.Expect(volumesList).To(o.ContainSubstring("bundle-emptydir-vol"), "Volume with bundle name should exist")
578580
o.Expect(volumesList).To(o.ContainSubstring("config-secret-vol"), "Secret volume should be appended")
579-
e2e.Logf("Test Point 1 passed: Config volumes appended to Deployment")
581+
582+
// CRITICAL: Verify no duplicate volumes
583+
volumeLines := strings.Split(strings.TrimSpace(volumesList), "\n")
584+
bundleVolCount := 0
585+
for _, vol := range volumeLines {
586+
if strings.TrimSpace(vol) == "bundle-emptydir-vol" {
587+
bundleVolCount++
588+
}
589+
}
590+
o.Expect(bundleVolCount).To(o.Equal(1), "Should have exactly 1 bundle-emptydir-vol (no duplicates)")
591+
592+
// Verify bundle-emptydir-vol is now ConfigMap type (override), not emptyDir
593+
volumeTypePath := `jsonpath={.spec.template.spec.volumes[?(@.name=="bundle-emptydir-vol")].configMap.name}`
594+
volumeType, err := olmv1util.GetNoEmpty(oc, "deployment", deploymentName, "-n", ns, "-o", volumeTypePath)
595+
o.Expect(err).NotTo(o.HaveOccurred())
596+
o.Expect(volumeType).To(o.Equal("test-cm-vol"), "bundle-emptydir-vol should be ConfigMap (override), not emptyDir")
597+
598+
e2e.Logf("Test Point 1 passed: Config volume OVERRIDES bundle volume (same name), no duplicates created")
580599

581600
g.By("Get operator Pod name")
582601
podName, err := olmv1util.GetOperatorPodName(oc, ns, deploymentName, 1*time.Minute)
@@ -587,23 +606,21 @@ var _ = g.Describe("[sig-olmv1][Jira:OLM] OLMv1 ClusterExtension DeploymentConfi
587606
g.By("Dump Pod manifest for debugging")
588607
olmv1util.DumpPodManifest(oc, podName, ns)
589608

590-
g.By("Test Point 2: Verify direct append behavior in actual Pod (bundle volume + config volumes)")
609+
g.By("Test Point 2: Verify merge-with-override behavior in actual Pod")
591610
// Get all volume names from Pod spec.volumes
592611
podVolumesPath := `jsonpath={range .spec.volumes[*]}{.name}{"\n"}{end}`
593612
podVolumesList, err := olmv1util.GetNoEmpty(oc, "pod", podName, "-n", ns, "-o", podVolumesPath)
594613
o.Expect(err).NotTo(o.HaveOccurred())
595614
e2e.Logf("Pod volumes list:\n%s", podVolumesList)
596615

597-
// Verify bundle volume is present (bundle has predefined emptyDir volume)
598-
o.Expect(podVolumesList).To(o.ContainSubstring("bundle-emptydir-vol"), "Bundle emptyDir volume should be preserved in Pod")
599-
600-
// Verify config volumes are present in Pod
601-
o.Expect(podVolumesList).To(o.ContainSubstring("config-cm-vol"), "ConfigMap volume should be appended to Pod")
616+
// Verify volumes are present in Pod
617+
o.Expect(podVolumesList).To(o.ContainSubstring("bundle-emptydir-vol"), "Volume with bundle name should exist in Pod")
602618
o.Expect(podVolumesList).To(o.ContainSubstring("config-secret-vol"), "Secret volume should be appended to Pod")
603619

604-
// Count our configured volumes (not system volumes)
605-
// Bundle has 1 volume: bundle-emptydir-vol
606-
// Config adds 2 volumes: config-cm-vol, config-secret-vol
620+
// CRITICAL: Count volumes to verify no duplicates
621+
// Config has 2 volumes: bundle-emptydir-vol (override), config-secret-vol (append)
622+
// Bundle originally had: bundle-emptydir-vol (emptyDir)
623+
// Result should be: bundle-emptydir-vol (ConfigMap - overridden) + config-secret-vol (appended) = 2
607624
podVolumeLines := strings.Split(strings.TrimSpace(podVolumesList), "\n")
608625
bundleVolumeCount := 0
609626
configVolumeCount := 0
@@ -612,20 +629,26 @@ var _ = g.Describe("[sig-olmv1][Jira:OLM] OLMv1 ClusterExtension DeploymentConfi
612629
if vol == "bundle-emptydir-vol" {
613630
bundleVolumeCount++
614631
}
615-
if vol == "config-cm-vol" || vol == "config-secret-vol" {
632+
if vol == "config-secret-vol" {
616633
configVolumeCount++
617634
}
618635
}
619636

620-
o.Expect(bundleVolumeCount).To(o.Equal(1), "Pod should have 1 bundle volume")
621-
o.Expect(configVolumeCount).To(o.Equal(2), "Pod should have 2 config volumes appended")
637+
o.Expect(bundleVolumeCount).To(o.Equal(1), "Pod should have exactly 1 bundle-emptydir-vol (no duplicates)")
638+
o.Expect(configVolumeCount).To(o.Equal(1), "Pod should have 1 config-secret-vol (appended)")
639+
640+
// Verify bundle-emptydir-vol is ConfigMap type in Pod (proving override worked)
641+
podVolumeTypePath := `jsonpath={.spec.volumes[?(@.name=="bundle-emptydir-vol")].configMap.name}`
642+
podVolumeType, err := olmv1util.GetNoEmpty(oc, "pod", podName, "-n", ns, "-o", podVolumeTypePath)
643+
o.Expect(err).NotTo(o.HaveOccurred())
644+
o.Expect(podVolumeType).To(o.Equal("test-cm-vol"), "Pod bundle-emptydir-vol should be ConfigMap (override), not emptyDir")
622645

623646
// Note: Pod may have additional system volumes (e.g., kube-api-access-xxx for serviceaccount token)
624647
// We only verify our configured volumes are present, not the total count
625-
e2e.Logf("Test Point 2 passed: Direct append in Pod - bundle volume (1) + config volumes (2) = %d configured volumes (total volumes: %d including system volumes)",
648+
e2e.Logf("Test Point 2 passed: Merge-with-override in Pod - override (1) + append (1) = %d configured volumes (total volumes: %d including system volumes)",
626649
bundleVolumeCount+configVolumeCount, len(podVolumeLines))
627650

628-
e2e.Logf("Test completed successfully - volumes direct append mechanism works correctly")
651+
e2e.Logf("Test completed successfully - volumes merge-with-override mechanism works correctly")
629652
})
630653

631654
g.It("PolarionID:87542-[Skipped:Disconnected]deploymentConfig volumeMounts are appended to all operator containers", func() {
@@ -644,12 +667,16 @@ var _ = g.Describe("[sig-olmv1][Jira:OLM] OLMv1 ClusterExtension DeploymentConfi
644667
saClusterRoleBindingTemplate = filepath.Join(baseDir, "sa-admin.yaml")
645668

646669
// Define inline config as JSON string (for ${{}} template parsing)
647-
// Add volumes and volumeMounts together
670+
// Volume 1: Same name as bundle (bundle-emptydir-vol) - matches volumeMount 1
671+
// Volume 2: Different name (config-secret-vol) - matches volumeMount 2
672+
// VolumeMount 1: Same name as bundle (bundle-emptydir-vol) but different path (/config-override vs /bundle-mount)
673+
// Should OVERRIDE bundle volumeMount, not create duplicate
674+
// VolumeMount 2: Different name (config-secret-vol) - Should be APPENDED
648675
inlineConfig = `{
649676
"deploymentConfig": {
650677
"volumes": [
651678
{
652-
"name": "config-cm-vol",
679+
"name": "bundle-emptydir-vol",
653680
"configMap": {
654681
"name": "test-cm-vol"
655682
}
@@ -663,8 +690,8 @@ var _ = g.Describe("[sig-olmv1][Jira:OLM] OLMv1 ClusterExtension DeploymentConfi
663690
],
664691
"volumeMounts": [
665692
{
666-
"name": "config-cm-vol",
667-
"mountPath": "/config-cm-mount"
693+
"name": "bundle-emptydir-vol",
694+
"mountPath": "/config-override"
668695
},
669696
{
670697
"name": "config-secret-vol",
@@ -753,31 +780,18 @@ var _ = g.Describe("[sig-olmv1][Jira:OLM] OLMv1 ClusterExtension DeploymentConfi
753780
g.By("Dump Deployment manifest for debugging")
754781
olmv1util.DumpDeploymentManifest(oc, deploymentName, ns)
755782

756-
g.By("Test Point 1: Verify volumeMounts appended to Deployment containers")
757-
// NOTE: This test uses DIFFERENT volumeMount names to avoid duplicate name scenario
758-
// Bundle has: bundle-emptydir-vol
759-
// Config has: config-cm-vol, config-secret-vol
760-
// This validates current OLMv1 "direct append" behavior
761-
// If OLMv1 should align with OLMv0 "merge with override", this test needs update
762-
//
783+
g.By("Test Point 1: Verify volumeMounts merge-with-override behavior in Deployment")
763784
// Get all volumeMount names from the first (main) container
764785
volumeMountsPath := `jsonpath={range .spec.template.spec.containers[0].volumeMounts[*]}{.name}{"\n"}{end}`
765786
volumeMountsList, err := olmv1util.GetNoEmpty(oc, "deployment", deploymentName, "-n", ns, "-o", volumeMountsPath)
766787
o.Expect(err).NotTo(o.HaveOccurred())
767788
e2e.Logf("VolumeMounts list (main container):\n%s", volumeMountsList)
768789

769-
// Verify config volumeMounts are present (different names from bundle)
770-
o.Expect(volumeMountsList).To(o.ContainSubstring("config-cm-vol"), "ConfigMap volumeMount should be appended")
790+
// Verify volumeMounts are present
791+
o.Expect(volumeMountsList).To(o.ContainSubstring("bundle-emptydir-vol"), "VolumeMount with bundle name should exist")
771792
o.Expect(volumeMountsList).To(o.ContainSubstring("config-secret-vol"), "Secret volumeMount should be appended")
772-
e2e.Logf("Test Point 1 passed: Config volumeMounts appended to container")
773-
774-
g.By("Verify bundle volumeMount is preserved")
775-
// Verify bundle volumeMount is present (bundle has predefined volumeMount)
776-
o.Expect(volumeMountsList).To(o.ContainSubstring("bundle-emptydir-vol"), "Bundle emptyDir volumeMount should be preserved")
777793

778-
// Count volumeMounts: should have bundle volumeMount(s) + 2 config volumeMounts
779-
// Bundle has 1 volumeMount: bundle-emptydir-vol
780-
// Config adds 2 volumeMounts: config-cm-vol, config-secret-vol
794+
// CRITICAL: Verify no duplicate volumeMounts
781795
volumeMountLines := strings.Split(strings.TrimSpace(volumeMountsList), "\n")
782796
bundleVolumeMountCount := 0
783797
configVolumeMountCount := 0
@@ -786,14 +800,22 @@ var _ = g.Describe("[sig-olmv1][Jira:OLM] OLMv1 ClusterExtension DeploymentConfi
786800
if vm == "bundle-emptydir-vol" {
787801
bundleVolumeMountCount++
788802
}
789-
if vm == "config-cm-vol" || vm == "config-secret-vol" {
803+
if vm == "config-secret-vol" {
790804
configVolumeMountCount++
791805
}
792806
}
793807

794-
o.Expect(bundleVolumeMountCount).To(o.Equal(1), "Should have 1 bundle volumeMount preserved")
795-
o.Expect(configVolumeMountCount).To(o.Equal(2), "Should have 2 config volumeMounts appended")
796-
e2e.Logf("VolumeMounts count: bundle (1) + config (2) = %d total", bundleVolumeMountCount+configVolumeMountCount)
808+
o.Expect(bundleVolumeMountCount).To(o.Equal(1), "Should have exactly 1 bundle-emptydir-vol volumeMount (no duplicates)")
809+
o.Expect(configVolumeMountCount).To(o.Equal(1), "Should have 1 config-secret-vol volumeMount (appended)")
810+
811+
// Verify bundle-emptydir-vol has override mountPath, not bundle's original path
812+
volumeMountPathPath := `jsonpath={.spec.template.spec.containers[0].volumeMounts[?(@.name=="bundle-emptydir-vol")].mountPath}`
813+
volumeMountPath, err := olmv1util.GetNoEmpty(oc, "deployment", deploymentName, "-n", ns, "-o", volumeMountPathPath)
814+
o.Expect(err).NotTo(o.HaveOccurred())
815+
o.Expect(volumeMountPath).To(o.Equal("/config-override"), "bundle-emptydir-vol should have override mountPath (/config-override), not bundle's /bundle-mount")
816+
817+
e2e.Logf("Test Point 1 passed: Config volumeMount OVERRIDES bundle volumeMount (same name), no duplicates created")
818+
e2e.Logf("VolumeMounts count: override (1) + append (1) = %d total", bundleVolumeMountCount+configVolumeMountCount)
797819

798820
g.By("Get operator Pod name")
799821
podName, err := olmv1util.GetOperatorPodName(oc, ns, deploymentName, 1*time.Minute)
@@ -804,7 +826,7 @@ var _ = g.Describe("[sig-olmv1][Jira:OLM] OLMv1 ClusterExtension DeploymentConfi
804826
g.By("Dump Pod manifest for debugging")
805827
olmv1util.DumpPodManifest(oc, podName, ns)
806828

807-
g.By("Test Point 2: Verify volumeMounts applied to ALL containers in actual Pod")
829+
g.By("Test Point 2: Verify volumeMounts merge-with-override in ALL containers in actual Pod")
808830
// Get all containers info as JSON (one call instead of multiple)
809831
podContainersJSONPath := `jsonpath={.spec.containers}`
810832
podContainersJSON, err := olmv1util.GetNoEmpty(oc, "pod", podName, "-n", ns, "-o", podContainersJSONPath)
@@ -816,26 +838,38 @@ var _ = g.Describe("[sig-olmv1][Jira:OLM] OLMv1 ClusterExtension DeploymentConfi
816838
containerCount := len(podContainersArray)
817839
e2e.Logf("Total containers in Pod: %d", containerCount)
818840

819-
// Verify each container in Pod has the config volumeMounts
841+
// Verify each container in Pod has the config volumeMounts with override behavior
820842
for i, container := range podContainersArray {
821843
containerName := container.Get("name").String()
822844
volumeMountsArray := container.Get("volumeMounts").Array()
823845

824-
// Collect volumeMount names for verification
846+
// Collect volumeMount names and paths for verification
825847
volumeMountNames := make([]string, 0, len(volumeMountsArray))
848+
bundleVolMountCount := 0
849+
var bundleVolMountPath string
826850
for _, vm := range volumeMountsArray {
827-
volumeMountNames = append(volumeMountNames, vm.Get("name").String())
851+
vmName := vm.Get("name").String()
852+
volumeMountNames = append(volumeMountNames, vmName)
853+
if vmName == "bundle-emptydir-vol" {
854+
bundleVolMountCount++
855+
bundleVolMountPath = vm.Get("mountPath").String()
856+
}
828857
}
829858
volumeMountsStr := strings.Join(volumeMountNames, "\n")
830859

831-
// Each container in Pod should have config volumeMounts
832-
o.Expect(volumeMountsStr).To(o.ContainSubstring("config-cm-vol"), fmt.Sprintf("Pod container %d (%s) should have config-cm-vol", i, containerName))
860+
// Each container should have volumeMounts
861+
o.Expect(volumeMountsStr).To(o.ContainSubstring("bundle-emptydir-vol"), fmt.Sprintf("Pod container %d (%s) should have bundle-emptydir-vol", i, containerName))
833862
o.Expect(volumeMountsStr).To(o.ContainSubstring("config-secret-vol"), fmt.Sprintf("Pod container %d (%s) should have config-secret-vol", i, containerName))
834-
e2e.Logf("Pod container %d (%s) has config volumeMounts applied", i, containerName)
863+
864+
// CRITICAL: Verify no duplicates and override path
865+
o.Expect(bundleVolMountCount).To(o.Equal(1), fmt.Sprintf("Container %d (%s) should have exactly 1 bundle-emptydir-vol (no duplicates)", i, containerName))
866+
o.Expect(bundleVolMountPath).To(o.Equal("/config-override"), fmt.Sprintf("Container %d (%s) bundle-emptydir-vol should have override path /config-override", i, containerName))
867+
868+
e2e.Logf("Pod container %d (%s) has volumeMounts with merge-with-override applied (no duplicates, override path verified)", i, containerName)
835869
}
836-
e2e.Logf("Test Point 2 passed: VolumeMounts applied to ALL %d container(s) in actual Pod", containerCount)
870+
e2e.Logf("Test Point 2 passed: VolumeMounts with merge-with-override applied to ALL %d container(s) in actual Pod", containerCount)
837871

838-
e2e.Logf("Test completed successfully - volumeMounts append to all containers mechanism works correctly")
872+
e2e.Logf("Test completed successfully - volumeMounts merge-with-override mechanism works correctly")
839873
})
840874

841875
g.It("PolarionID:87543-[Skipped:Disconnected]deploymentConfig tolerations are appended to operator deployment without duplicates", func() {

0 commit comments

Comments
 (0)