mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 15:05:27 +00:00
Include PV wait confirmation for Disruptive PV tests
This commit is contained in:
parent
36f658aada
commit
44be42c196
@ -507,6 +507,9 @@ func testPodSuccessOrFail(c clientset.Interface, ns string, pod *v1.Pod) error {
|
||||
// Deletes the passed-in pod and waits for the pod to be terminated. Resilient to the pod
|
||||
// not existing.
|
||||
func DeletePodWithWait(f *Framework, c clientset.Interface, pod *v1.Pod) error {
|
||||
if pod == nil {
|
||||
return nil
|
||||
}
|
||||
return DeletePodWithWaitByName(f, c, pod.GetName(), pod.GetNamespace())
|
||||
}
|
||||
|
||||
|
@ -61,10 +61,11 @@ var _ = utils.SIGDescribe("GenericPersistentVolume[Disruptive]", func() {
|
||||
var (
|
||||
clientPod *v1.Pod
|
||||
pvc *v1.PersistentVolumeClaim
|
||||
pv *v1.PersistentVolume
|
||||
)
|
||||
BeforeEach(func() {
|
||||
framework.Logf("Initializing pod and pvcs for test")
|
||||
clientPod, pvc = createPodPVCFromSC(f, c, ns)
|
||||
clientPod, pvc, pv = createPodPVCFromSC(f, c, ns)
|
||||
})
|
||||
for _, test := range disruptiveTestTable {
|
||||
func(t disruptiveTest) {
|
||||
@ -76,13 +77,13 @@ var _ = utils.SIGDescribe("GenericPersistentVolume[Disruptive]", func() {
|
||||
}
|
||||
AfterEach(func() {
|
||||
framework.Logf("Tearing down test spec")
|
||||
tearDownTestCase(c, f, ns, clientPod, pvc, nil)
|
||||
tearDownTestCase(c, f, ns, clientPod, pvc, pv, false)
|
||||
pvc, clientPod = nil, nil
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
func createPodPVCFromSC(f *framework.Framework, c clientset.Interface, ns string) (*v1.Pod, *v1.PersistentVolumeClaim) {
|
||||
func createPodPVCFromSC(f *framework.Framework, c clientset.Interface, ns string) (*v1.Pod, *v1.PersistentVolumeClaim, *v1.PersistentVolume) {
|
||||
var err error
|
||||
test := storageClassTest{
|
||||
name: "default",
|
||||
@ -99,5 +100,5 @@ func createPodPVCFromSC(f *framework.Framework, c clientset.Interface, ns string
|
||||
By("Creating a pod with dynamically provisioned volume")
|
||||
pod, err := framework.CreateNginxPod(c, ns, nil, pvcClaims)
|
||||
Expect(err).NotTo(HaveOccurred(), "While creating pods for kubelet restart test")
|
||||
return pod, pvc
|
||||
return pod, pvc, pvs[0]
|
||||
}
|
||||
|
@ -208,7 +208,7 @@ var _ = utils.SIGDescribe("NFSPersistentVolumes[Disruptive][Flaky]", func() {
|
||||
|
||||
AfterEach(func() {
|
||||
framework.Logf("Tearing down test spec")
|
||||
tearDownTestCase(c, f, ns, clientPod, pvc, pv)
|
||||
tearDownTestCase(c, f, ns, clientPod, pvc, pv, true /* force PV delete */)
|
||||
pv, pvc, clientPod = nil, nil, nil
|
||||
})
|
||||
|
||||
@ -277,11 +277,14 @@ func initTestCase(f *framework.Framework, c clientset.Interface, pvConfig framew
|
||||
}
|
||||
|
||||
// tearDownTestCase destroy resources created by initTestCase.
|
||||
func tearDownTestCase(c clientset.Interface, f *framework.Framework, ns string, client *v1.Pod, pvc *v1.PersistentVolumeClaim, pv *v1.PersistentVolume) {
|
||||
func tearDownTestCase(c clientset.Interface, f *framework.Framework, ns string, client *v1.Pod, pvc *v1.PersistentVolumeClaim, pv *v1.PersistentVolume, forceDeletePV bool) {
|
||||
// Ignore deletion errors. Failing on them will interrupt test cleanup.
|
||||
framework.DeletePodWithWait(f, c, client)
|
||||
framework.DeletePersistentVolumeClaim(c, pvc.Name, ns)
|
||||
if pv != nil {
|
||||
if forceDeletePV {
|
||||
framework.DeletePersistentVolume(c, pv.Name)
|
||||
return
|
||||
}
|
||||
err := framework.WaitForPersistentVolumeDeleted(c, pv.Name, 5*time.Second, 5*time.Minute)
|
||||
framework.ExpectNoError(err, "Persistent Volume %v not deleted by dynamic provisioner", pv.Name)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user