Skip to content

Commit 1bfd383

Browse files
author
Yecheng Fu
committed
Add new e2e test for local PV "Pods sharing a single local PV [Serial]"
1 parent 3c92a6d commit 1bfd383

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

test/e2e/storage/persistent_volumes-local.go

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,69 @@ var _ = utils.SIGDescribe("PersistentVolumes-local ", func() {
613613
Expect(err).ToNot(HaveOccurred())
614614
})
615615
})
616+
617+
Context("Pods sharing a single local PV [Serial]", func() {
618+
var (
619+
pv *v1.PersistentVolume
620+
)
621+
622+
BeforeEach(func() {
623+
localVolume := &localTestVolume{
624+
node: config.node0,
625+
hostDir: "/tmp",
626+
localVolumeType: DirectoryLocalVolumeType,
627+
}
628+
pvConfig := makeLocalPVConfig(config, localVolume)
629+
var err error
630+
pv, err = framework.CreatePV(config.client, framework.MakePersistentVolume(pvConfig))
631+
framework.ExpectNoError(err)
632+
})
633+
634+
AfterEach(func() {
635+
if pv == nil {
636+
return
637+
}
638+
By(fmt.Sprintf("Clean PV %s", pv.Name))
639+
err := config.client.CoreV1().PersistentVolumes().Delete(pv.Name, &metav1.DeleteOptions{})
640+
framework.ExpectNoError(err)
641+
})
642+
643+
It("all pods should be running", func() {
644+
var (
645+
pvc *v1.PersistentVolumeClaim
646+
pods = map[string]*v1.Pod{}
647+
count = 50
648+
err error
649+
)
650+
pvc = framework.MakePersistentVolumeClaim(makeLocalPVCConfig(config, DirectoryLocalVolumeType), config.ns)
651+
By(fmt.Sprintf("Create a PVC %s", pvc.Name))
652+
pvc, err = framework.CreatePVC(config.client, config.ns, pvc)
653+
framework.ExpectNoError(err)
654+
By(fmt.Sprintf("Create %d pods to use this PVC", count))
655+
for i := 0; i < count; i++ {
656+
pod := framework.MakeSecPod(config.ns, []*v1.PersistentVolumeClaim{pvc}, false, "", false, false, selinuxLabel, nil)
657+
pod, err := config.client.CoreV1().Pods(config.ns).Create(pod)
658+
Expect(err).NotTo(HaveOccurred())
659+
pods[pod.Name] = pod
660+
}
661+
By("Wait for all pods are running")
662+
err = wait.PollImmediate(time.Second, 5*time.Minute, func() (done bool, err error) {
663+
podsList, err := config.client.CoreV1().Pods(config.ns).List(metav1.ListOptions{})
664+
if err != nil {
665+
return false, err
666+
}
667+
runningPods := 0
668+
for _, pod := range podsList.Items {
669+
switch pod.Status.Phase {
670+
case v1.PodRunning:
671+
runningPods++
672+
}
673+
}
674+
return runningPods == count, nil
675+
})
676+
Expect(err).ToNot(HaveOccurred())
677+
})
678+
})
616679
})
617680

618681
func deletePodAndPVCs(config *localTestConfig, pod *v1.Pod) error {

0 commit comments

Comments
 (0)