From 68f139548b3c15ccfca6b57582461f29f1514141 Mon Sep 17 00:00:00 2001 From: Jan Safranek Date: Thu, 10 Jun 2021 10:40:25 +0200 Subject: [PATCH 1/2] Remove unused parameters from TestConcurrentAccessToRelatedVolumes --- test/e2e/storage/testsuites/multivolume.go | 24 ++++++---------------- 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/test/e2e/storage/testsuites/multivolume.go b/test/e2e/storage/testsuites/multivolume.go index 88a7b808164..39ac58d31a2 100644 --- a/test/e2e/storage/testsuites/multivolume.go +++ b/test/e2e/storage/testsuites/multivolume.go @@ -381,8 +381,7 @@ func (t *multiVolumeTestSuite) DefineTests(driver storageframework.TestDriver, p }() // Test access to both volumes on the same node. - TestConcurrentAccessToRelatedVolumes(l.config.Framework, l.cs, l.ns.Name, - l.config.ClientNodeSelection, pvcs, true /* sameNode */, false /* readOnly */) + TestConcurrentAccessToRelatedVolumes(l.config.Framework, l.cs, l.ns.Name, l.config.ClientNodeSelection, pvcs) }) // This tests below configuration: @@ -426,8 +425,7 @@ func (t *multiVolumeTestSuite) DefineTests(driver storageframework.TestDriver, p }() // Test access to both volumes on the same node. - TestConcurrentAccessToRelatedVolumes(l.config.Framework, l.cs, l.ns.Name, - l.config.ClientNodeSelection, pvcs, true /* sameNode */, false /* readOnly */) + TestConcurrentAccessToRelatedVolumes(l.config.Framework, l.cs, l.ns.Name, l.config.ClientNodeSelection, pvcs) }) // This tests below configuration: @@ -696,8 +694,7 @@ func TestConcurrentAccessToSingleVolume(f *framework.Framework, cs clientset.Int // Each provided PVC is used by a single pod. The test ensures that volumes created from // another volume (=clone) or volume snapshot can be used together with the original volume. func TestConcurrentAccessToRelatedVolumes(f *framework.Framework, cs clientset.Interface, ns string, - node e2epod.NodeSelection, pvcs []*v1.PersistentVolumeClaim, requiresSameNode bool, - readOnly bool) { + node e2epod.NodeSelection, pvcs []*v1.PersistentVolumeClaim) { var pods []*v1.Pod @@ -710,7 +707,7 @@ func TestConcurrentAccessToRelatedVolumes(f *framework.Framework, cs clientset.I PVCs: []*v1.PersistentVolumeClaim{pvcs[i]}, SeLinuxLabel: e2epod.GetLinuxLabel(), NodeSelection: node, - PVCsReadOnly: readOnly, + PVCsReadOnly: false, ImageID: e2epod.GetTestImageID(imageutils.JessieDnsutils), } pod, err := e2epod.CreateSecPodWithNodeSelection(cs, &podConfig, f.Timeouts.PodStart) @@ -721,17 +718,8 @@ func TestConcurrentAccessToRelatedVolumes(f *framework.Framework, cs clientset.I pods = append(pods, pod) actualNodeName := pod.Spec.NodeName - // Set affinity depending on requiresSameNode - if requiresSameNode { - e2epod.SetAffinity(&node, actualNodeName) - } else { - e2epod.SetAntiAffinity(&node, actualNodeName) - } - } - - // Delete the last pod and remove from slice of pods - if len(pods) < len(pvcs) { - framework.Failf("Number of pods shouldn't be less than %d, but got %d", len(pvcs), len(pods)) + // Always run the subsequent pods on the same node. + e2epod.SetAffinity(&node, actualNodeName) } } From 29aa4c0ee81aafbd8a5a1a96163eb97b1f27bc8b Mon Sep 17 00:00:00 2001 From: Jan Safranek Date: Thu, 10 Jun 2021 10:40:06 +0200 Subject: [PATCH 2/2] Check content of volumes in snapshot/clone multivolume tests Check that both original and its restored snapshot / clone have the same content during the test. --- test/e2e/storage/testsuites/multivolume.go | 35 ++++++++++++++++++---- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/test/e2e/storage/testsuites/multivolume.go b/test/e2e/storage/testsuites/multivolume.go index 39ac58d31a2..eedb7c9c25a 100644 --- a/test/e2e/storage/testsuites/multivolume.go +++ b/test/e2e/storage/testsuites/multivolume.go @@ -345,6 +345,12 @@ func (t *multiVolumeTestSuite) DefineTests(driver storageframework.TestDriver, p if pattern.SnapshotType == "" { e2eskipper.Skipf("Driver %q does not support snapshots - skipping", dInfo.Name) } + if pattern.VolMode == v1.PersistentVolumeBlock { + // TODO: refactor prepareSnapshotDataSourceForProvisioning() below to use + // utils.CheckWriteToPath / utils.CheckReadFromPath and remove + // redundant InjectContent(). This will enable block volume tests. + e2eskipper.Skipf("This test does not support block volumes -- skipping") + } // Create a volume testVolumeSizeRange := t.GetTestSuiteInfo().SupportedSizeRange @@ -353,13 +359,14 @@ func (t *multiVolumeTestSuite) DefineTests(driver storageframework.TestDriver, p pvcs := []*v1.PersistentVolumeClaim{resource.Pvc} // Create snapshot of it + expectedContent := fmt.Sprintf("volume content %d", time.Now().UTC().UnixNano()) sDriver, ok := driver.(storageframework.SnapshottableTestDriver) if !ok { framework.Failf("Driver %q has CapSnapshotDataSource but does not implement SnapshottableTestDriver", dInfo.Name) } testConfig := storageframework.ConvertTestConfig(l.config) dc := l.config.Framework.DynamicClient - dataSource, cleanupFunc := prepareSnapshotDataSourceForProvisioning(f, testConfig, l.config, pattern, l.cs, dc, resource.Pvc, resource.Sc, sDriver, pattern.VolMode, "injected content") + dataSource, cleanupFunc := prepareSnapshotDataSourceForProvisioning(f, testConfig, l.config, pattern, l.cs, dc, resource.Pvc, resource.Sc, sDriver, pattern.VolMode, expectedContent) defer cleanupFunc() // Create 2nd PVC for testing @@ -381,7 +388,7 @@ func (t *multiVolumeTestSuite) DefineTests(driver storageframework.TestDriver, p }() // Test access to both volumes on the same node. - TestConcurrentAccessToRelatedVolumes(l.config.Framework, l.cs, l.ns.Name, l.config.ClientNodeSelection, pvcs) + TestConcurrentAccessToRelatedVolumes(l.config.Framework, l.cs, l.ns.Name, l.config.ClientNodeSelection, pvcs, expectedContent) }) // This tests below configuration: @@ -396,14 +403,21 @@ func (t *multiVolumeTestSuite) DefineTests(driver storageframework.TestDriver, p if !l.driver.GetDriverInfo().Capabilities[storageframework.CapPVCDataSource] { e2eskipper.Skipf("Driver %q does not support volume clone - skipping", dInfo.Name) } + if pattern.VolMode == v1.PersistentVolumeBlock { + // TODO: refactor preparePVCDataSourceForProvisioning() below to use + // utils.CheckWriteToPath / utils.CheckReadFromPath and remove + // redundant InjectContent(). This will enable block volume tests. + e2eskipper.Skipf("This test does not support block volumes -- skipping") + } // Create a volume + expectedContent := fmt.Sprintf("volume content %d", time.Now().UTC().UnixNano()) testVolumeSizeRange := t.GetTestSuiteInfo().SupportedSizeRange resource := storageframework.CreateVolumeResource(l.driver, l.config, pattern, testVolumeSizeRange) l.resources = append(l.resources, resource) pvcs := []*v1.PersistentVolumeClaim{resource.Pvc} testConfig := storageframework.ConvertTestConfig(l.config) - dataSource, cleanupFunc := preparePVCDataSourceForProvisioning(f, testConfig, l.cs, resource.Pvc, resource.Sc, pattern.VolMode, "injected content") + dataSource, cleanupFunc := preparePVCDataSourceForProvisioning(f, testConfig, l.cs, resource.Pvc, resource.Sc, pattern.VolMode, expectedContent) defer cleanupFunc() // Create 2nd PVC for testing @@ -425,7 +439,7 @@ func (t *multiVolumeTestSuite) DefineTests(driver storageframework.TestDriver, p }() // Test access to both volumes on the same node. - TestConcurrentAccessToRelatedVolumes(l.config.Framework, l.cs, l.ns.Name, l.config.ClientNodeSelection, pvcs) + TestConcurrentAccessToRelatedVolumes(l.config.Framework, l.cs, l.ns.Name, l.config.ClientNodeSelection, pvcs, expectedContent) }) // This tests below configuration: @@ -694,7 +708,7 @@ func TestConcurrentAccessToSingleVolume(f *framework.Framework, cs clientset.Int // Each provided PVC is used by a single pod. The test ensures that volumes created from // another volume (=clone) or volume snapshot can be used together with the original volume. func TestConcurrentAccessToRelatedVolumes(f *framework.Framework, cs clientset.Interface, ns string, - node e2epod.NodeSelection, pvcs []*v1.PersistentVolumeClaim) { + node e2epod.NodeSelection, pvcs []*v1.PersistentVolumeClaim, expectedContent string) { var pods []*v1.Pod @@ -721,6 +735,17 @@ func TestConcurrentAccessToRelatedVolumes(f *framework.Framework, cs clientset.I // Always run the subsequent pods on the same node. e2epod.SetAffinity(&node, actualNodeName) } + + // Check that all pods the same content + for i, pod := range pods { + fileName := "/mnt/volume1/index.html" + index := i + 1 + + ginkgo.By(fmt.Sprintf("Checking if the volume in pod%d has expected initial content", index)) + commands := e2evolume.GenerateReadFileCmd(fileName) + _, err := framework.LookForStringInPodExec(pod.Namespace, pod.Name, commands, expectedContent, time.Minute) + framework.ExpectNoError(err, "failed: finding the contents of the mounted file %s.", fileName) + } } // getCurrentTopologies() goes through all Nodes and returns unique driver topologies and count of Nodes per topology