Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
dcc284bf
Commit
dcc284bf
authored
Oct 16, 2017
by
divyenpatel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adding E2E test to verify workflow for deleting PVC when PVC is in use
addressed gnufied's review comments addressed Michelle Au's review comments
parent
1213f911
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
0 deletions
+57
-0
pv_reclaimpolicy.go
test/e2e/storage/pv_reclaimpolicy.go
+57
-0
No files found.
test/e2e/storage/pv_reclaimpolicy.go
View file @
dcc284bf
...
@@ -25,6 +25,7 @@ import (
...
@@ -25,6 +25,7 @@ import (
"k8s.io/api/core/v1"
"k8s.io/api/core/v1"
apierrs
"k8s.io/apimachinery/pkg/api/errors"
apierrs
"k8s.io/apimachinery/pkg/api/errors"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
clientset
"k8s.io/client-go/kubernetes"
clientset
"k8s.io/client-go/kubernetes"
vsphere
"k8s.io/kubernetes/pkg/cloudprovider/providers/vsphere"
vsphere
"k8s.io/kubernetes/pkg/cloudprovider/providers/vsphere"
"k8s.io/kubernetes/test/e2e/framework"
"k8s.io/kubernetes/test/e2e/framework"
...
@@ -91,6 +92,62 @@ var _ = SIGDescribe("PersistentVolumes [Feature:ReclaimPolicy]", func() {
...
@@ -91,6 +92,62 @@ var _ = SIGDescribe("PersistentVolumes [Feature:ReclaimPolicy]", func() {
})
})
/*
/*
Test Steps:
1. Create vmdk
2. Create PV Spec with volume path set to VMDK file created in Step-1, and PersistentVolumeReclaimPolicy is set to Delete
3. Create PVC with the storage request set to PV's storage capacity.
4. Wait for PV and PVC to bound.
5. Delete PVC.
6. Verify volume is attached to the node and volume is accessible in the pod.
7. Verify PV status should be failed.
8. Delete the pod.
9. Verify PV should be detached from the node and automatically deleted.
*/
It
(
"should not detach and unmount PV when associated pvc with delete as reclaimPolicy is deleted when it is in use by the pod"
,
func
()
{
vsp
,
err
:=
vsphere
.
GetVSphere
()
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
volumePath
,
pv
,
pvc
,
err
=
testSetupVSpherePersistentVolumeReclaim
(
vsp
,
c
,
ns
,
v1
.
PersistentVolumeReclaimDelete
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
// Wait for PV and PVC to Bind
framework
.
ExpectNoError
(
framework
.
WaitOnPVandPVC
(
c
,
ns
,
pv
,
pvc
))
By
(
"Creating the Pod"
)
pod
,
err
:=
framework
.
CreateClientPod
(
c
,
ns
,
pvc
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
node
:=
types
.
NodeName
(
pod
.
Spec
.
NodeName
)
By
(
"Deleting the Claim"
)
framework
.
ExpectNoError
(
framework
.
DeletePersistentVolumeClaim
(
c
,
pvc
.
Name
,
ns
),
"Failed to delete PVC "
,
pvc
.
Name
)
pvc
=
nil
// Verify PV is Present, after PVC is deleted and PV status should be Failed.
pv
,
err
:=
c
.
CoreV1
()
.
PersistentVolumes
()
.
Get
(
pv
.
Name
,
metav1
.
GetOptions
{})
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
framework
.
WaitForPersistentVolumePhase
(
v1
.
VolumeFailed
,
c
,
pv
.
Name
,
1
*
time
.
Second
,
60
*
time
.
Second
))
.
NotTo
(
HaveOccurred
())
By
(
"Verify the volume is attached to the node"
)
isVolumeAttached
,
verifyDiskAttachedError
:=
verifyVSphereDiskAttached
(
vsp
,
pv
.
Spec
.
VsphereVolume
.
VolumePath
,
node
)
Expect
(
verifyDiskAttachedError
)
.
NotTo
(
HaveOccurred
())
Expect
(
isVolumeAttached
)
.
To
(
BeTrue
())
By
(
"Verify the volume is accessible and available in the pod"
)
verifyVSphereVolumesAccessible
(
pod
,
[]
*
v1
.
PersistentVolume
{
pv
},
vsp
)
framework
.
Logf
(
"Verified that Volume is accessible in the POD after deleting PV claim"
)
By
(
"Deleting the Pod"
)
framework
.
ExpectNoError
(
framework
.
DeletePodWithWait
(
f
,
c
,
pod
),
"Failed to delete pod "
,
pod
.
Name
)
By
(
"Verify PV is detached from the node after Pod is deleted"
)
Expect
(
waitForVSphereDiskToDetach
(
vsp
,
pv
.
Spec
.
VsphereVolume
.
VolumePath
,
types
.
NodeName
(
pod
.
Spec
.
NodeName
)))
.
NotTo
(
HaveOccurred
())
By
(
"Verify PV should be deleted automatically"
)
framework
.
ExpectNoError
(
framework
.
WaitForPersistentVolumeDeleted
(
c
,
pv
.
Name
,
1
*
time
.
Second
,
30
*
time
.
Second
))
pv
=
nil
volumePath
=
""
})
/*
This test Verify persistent volume should be retained when reclaimPolicy on the PV is set to retain
This test Verify persistent volume should be retained when reclaimPolicy on the PV is set to retain
and associated claim is deleted
and associated claim is deleted
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment