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
f4e6bc29
Commit
f4e6bc29
authored
Oct 28, 2016
by
Jon Cope
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DeleteNS: Add Delete Namespace before PVC & Pod, check PD detach
tweak func name moved initializeGCETestSpec from It() to BeforeEach(), added cleanup
parent
fe366480
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
14 deletions
+33
-14
persistent_volumes.go
test/e2e/persistent_volumes.go
+33
-14
No files found.
test/e2e/persistent_volumes.go
View file @
f4e6bc29
...
@@ -17,6 +17,8 @@ limitations under the License.
...
@@ -17,6 +17,8 @@ limitations under the License.
package
e2e
package
e2e
import
(
import
(
"time"
.
"github.com/onsi/ginkgo"
.
"github.com/onsi/ginkgo"
.
"github.com/onsi/gomega"
.
"github.com/onsi/gomega"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
...
@@ -72,6 +74,17 @@ func completeMultiTest(f *framework.Framework, c clientset.Interface, ns string,
...
@@ -72,6 +74,17 @@ func completeMultiTest(f *framework.Framework, c clientset.Interface, ns string,
deletePVCandValidatePVGroup
(
c
,
ns
,
pvols
,
claims
)
deletePVCandValidatePVGroup
(
c
,
ns
,
pvols
,
claims
)
}
}
// Creates a PV, PVC, and ClientPod that will run until killed by test or clean up.
func
initializeGCETestSpec
(
c
clientset
.
Interface
,
ns
string
,
pvConfig
persistentVolumeConfig
,
isPrebound
bool
)
(
*
v1
.
Pod
,
*
v1
.
PersistentVolume
,
*
v1
.
PersistentVolumeClaim
)
{
By
(
"Creating the PV and PVC"
)
pv
,
pvc
:=
createPVPVC
(
c
,
pvConfig
,
ns
,
isPrebound
)
waitOnPVandPVC
(
c
,
ns
,
pv
,
pvc
)
By
(
"Creating the Client Pod"
)
clientPod
:=
createClientPod
(
c
,
ns
,
pvc
)
return
clientPod
,
pv
,
pvc
}
var
_
=
framework
.
KubeDescribe
(
"PersistentVolumes [Volume][Serial]"
,
func
()
{
var
_
=
framework
.
KubeDescribe
(
"PersistentVolumes [Volume][Serial]"
,
func
()
{
// global vars for the Context()s and It()'s below
// global vars for the Context()s and It()'s below
...
@@ -242,6 +255,7 @@ var _ = framework.KubeDescribe("PersistentVolumes [Volume][Serial]", func() {
...
@@ -242,6 +255,7 @@ var _ = framework.KubeDescribe("PersistentVolumes [Volume][Serial]", func() {
var
(
var
(
diskName
string
diskName
string
node
types
.
NodeName
err
error
err
error
pv
*
v1
.
PersistentVolume
pv
*
v1
.
PersistentVolume
pvc
*
v1
.
PersistentVolumeClaim
pvc
*
v1
.
PersistentVolumeClaim
...
@@ -251,6 +265,7 @@ var _ = framework.KubeDescribe("PersistentVolumes [Volume][Serial]", func() {
...
@@ -251,6 +265,7 @@ var _ = framework.KubeDescribe("PersistentVolumes [Volume][Serial]", func() {
BeforeEach
(
func
()
{
BeforeEach
(
func
()
{
framework
.
SkipUnlessProviderIs
(
"gce"
)
framework
.
SkipUnlessProviderIs
(
"gce"
)
By
(
"Initializing Test Spec"
)
if
diskName
==
""
{
if
diskName
==
""
{
diskName
,
err
=
createPDWithRetry
()
diskName
,
err
=
createPDWithRetry
()
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
...
@@ -266,6 +281,8 @@ var _ = framework.KubeDescribe("PersistentVolumes [Volume][Serial]", func() {
...
@@ -266,6 +281,8 @@ var _ = framework.KubeDescribe("PersistentVolumes [Volume][Serial]", func() {
prebind
:
nil
,
prebind
:
nil
,
}
}
}
}
clientPod
,
pv
,
pvc
=
initializeGCETestSpec
(
c
,
ns
,
pvConfig
,
false
)
node
=
types
.
NodeName
(
clientPod
.
Spec
.
NodeName
)
})
})
AfterEach
(
func
()
{
AfterEach
(
func
()
{
...
@@ -277,6 +294,7 @@ var _ = framework.KubeDescribe("PersistentVolumes [Volume][Serial]", func() {
...
@@ -277,6 +294,7 @@ var _ = framework.KubeDescribe("PersistentVolumes [Volume][Serial]", func() {
pvc
=
nil
pvc
=
nil
pv
=
nil
pv
=
nil
}
}
node
,
clientPod
,
pvc
,
pv
=
""
,
nil
,
nil
,
nil
})
})
AddCleanupAction
(
func
()
{
AddCleanupAction
(
func
()
{
...
@@ -288,13 +306,6 @@ var _ = framework.KubeDescribe("PersistentVolumes [Volume][Serial]", func() {
...
@@ -288,13 +306,6 @@ var _ = framework.KubeDescribe("PersistentVolumes [Volume][Serial]", func() {
// Attach a persistent disk to a pod using a PVC.
// Attach a persistent disk to a pod using a PVC.
// Delete the PVC and then the pod. Expect the pod to succeed in unmounting and detaching PD on delete.
// Delete the PVC and then the pod. Expect the pod to succeed in unmounting and detaching PD on delete.
It
(
"should test that deleting a PVC before the pod does not cause pod deletion to fail on PD detach"
,
func
()
{
It
(
"should test that deleting a PVC before the pod does not cause pod deletion to fail on PD detach"
,
func
()
{
By
(
"Creating the PV and PVC"
)
pv
,
pvc
=
createPVPVC
(
c
,
pvConfig
,
ns
,
false
)
waitOnPVandPVC
(
c
,
ns
,
pv
,
pvc
)
By
(
"Creating the Client Pod"
)
clientPod
=
createClientPod
(
c
,
ns
,
pvc
)
node
:=
types
.
NodeName
(
clientPod
.
Spec
.
NodeName
)
By
(
"Deleting the Claim"
)
By
(
"Deleting the Claim"
)
deletePersistentVolumeClaim
(
c
,
pvc
.
Name
,
ns
)
deletePersistentVolumeClaim
(
c
,
pvc
.
Name
,
ns
)
...
@@ -311,13 +322,6 @@ var _ = framework.KubeDescribe("PersistentVolumes [Volume][Serial]", func() {
...
@@ -311,13 +322,6 @@ var _ = framework.KubeDescribe("PersistentVolumes [Volume][Serial]", func() {
// Attach a persistent disk to a pod using a PVC.
// Attach a persistent disk to a pod using a PVC.
// Delete the PV and then the pod. Expect the pod to succeed in unmounting and detaching PD on delete.
// Delete the PV and then the pod. Expect the pod to succeed in unmounting and detaching PD on delete.
It
(
"should test that deleting the PV before the pod does not cause pod deletion to fail on PD detach"
,
func
()
{
It
(
"should test that deleting the PV before the pod does not cause pod deletion to fail on PD detach"
,
func
()
{
By
(
"Creating the PV and PVC"
)
pv
,
pvc
=
createPVPVC
(
c
,
pvConfig
,
ns
,
false
)
waitOnPVandPVC
(
c
,
ns
,
pv
,
pvc
)
By
(
"Creating the Client Pod"
)
clientPod
=
createClientPod
(
c
,
ns
,
pvc
)
node
:=
types
.
NodeName
(
clientPod
.
Spec
.
NodeName
)
By
(
"Deleting the Persistent Volume"
)
By
(
"Deleting the Persistent Volume"
)
deletePersistentVolume
(
c
,
pv
.
Name
)
deletePersistentVolume
(
c
,
pv
.
Name
)
...
@@ -330,5 +334,20 @@ var _ = framework.KubeDescribe("PersistentVolumes [Volume][Serial]", func() {
...
@@ -330,5 +334,20 @@ var _ = framework.KubeDescribe("PersistentVolumes [Volume][Serial]", func() {
err
=
waitForPDDetach
(
diskName
,
node
)
err
=
waitForPDDetach
(
diskName
,
node
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
})
})
// Test that a Pod and PVC attached to a GCEPD successfully unmounts and detaches when the encompassing Namespace is deleted.
It
(
"should test that deleting the Namespace of a PVC and Pod causes the successful detach of Persistent Disk"
,
func
()
{
By
(
"Deleting the Namespace"
)
err
:=
c
.
Core
()
.
Namespaces
()
.
Delete
(
ns
,
nil
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
err
=
framework
.
WaitForNamespacesDeleted
(
c
,
[]
string
{
ns
},
3
*
time
.
Minute
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
By
(
"Verifying Persistent Disk detaches"
)
err
=
waitForPDDetach
(
diskName
,
node
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
})
})
})
})
})
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