Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

e2e: wait for the provisioner to clean up PV resources #416

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions test/pod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ func (p *PodTestSuite) SetupSuite() {
cmds := []string{
fmt.Sprintf("kind create cluster --config=%s --wait=120s", testdataFile("kind-cluster.yaml")),
fmt.Sprintf("kind load docker-image %s", p.config.IMAGE),
// We'll be replacing this, but applying particular labels to it.
"kubectl -n local-path-storage delete deployment local-path-provisioner --wait",
}
for _, cmd := range cmds {
_, err = runCmd(
Expand Down
4 changes: 2 additions & 2 deletions test/testdata/custom-path-pattern/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../../deploy
- ../labelled-deploy
- storage-class.yaml
- pod.yaml
- pvc.yaml
Expand All @@ -11,4 +11,4 @@ commonLabels:
app: local-path-provisioner
images:
- name: rancher/local-path-provisioner
newTag: dev
newTag: dev
6 changes: 6 additions & 0 deletions test/testdata/labelled-deploy/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../../deploy
commonLabels:
system-component: "true"
2 changes: 1 addition & 1 deletion test/testdata/multiple-storage-classes/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../../deploy
- ../labelled-deploy
- storage-class-shared.yaml
- pod.yaml
- pvc.yaml
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../../deploy
- ../labelled-deploy
- ../../../examples/pod
patches:
- path: patch.yaml
Expand Down
2 changes: 1 addition & 1 deletion test/testdata/pod-with-local-volume/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../../deploy
- ../labelled-deploy
- ../../../examples/pod-with-local-volume
commonLabels:
app: local-path-provisioner
Expand Down
2 changes: 1 addition & 1 deletion test/testdata/pod-with-node-affinity/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../../deploy
- ../labelled-deploy
- ../../../examples/pod-with-node-affinity
patches:
- path: patch.yaml
Expand Down
2 changes: 1 addition & 1 deletion test/testdata/pod-with-rwop-volume/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../../deploy
- ../labelled-deploy
- ../../../examples/pod-with-rwop-volume
commonLabels:
app: local-path-provisioner
Expand Down
2 changes: 1 addition & 1 deletion test/testdata/pod-with-security-context/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../../deploy
- ../labelled-deploy
- ../../../examples/pod-with-security-context
commonLabels:
app: local-path-provisioner
Expand Down
2 changes: 1 addition & 1 deletion test/testdata/pod-with-subpath/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../../deploy
- ../labelled-deploy
- ../../../examples/pod-with-subpath
commonLabels:
app: local-path-provisioner
Expand Down
2 changes: 1 addition & 1 deletion test/testdata/pod/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../../deploy
- ../labelled-deploy
- ../../../examples/pod
commonLabels:
app: local-path-provisioner
Expand Down
30 changes: 22 additions & 8 deletions test/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,28 @@ func testdataFile(fields ...string) string {
}

func deleteKustomizeDeployment(t *testing.T, kustomizeDir string, envs []string) error {
_, err := runCmd(
t,
"kustomize build | kubectl delete --timeout=180s -f -",
testdataFile(kustomizeDir),
envs,
nil,
)
return err
cmds := []string{
// Begin by deleting everything except the provisioner.
// This gives the local-path provider a chance to kick in and kill the pv.
"kustomize build | kubectl delete --timeout=180s -f - -l 'system-component!=true'",
// Wait on the provisioner
"kubectl wait --for=delete pv --all",
// Clean up everything else
"kustomize build | kubectl delete --timeout=180s -f - -l 'system-component=true' --wait",
}
for _, cmd := range cmds {
_, err := runCmd(
t,
cmd,
testdataFile(kustomizeDir),
envs,
nil,
)
if err != nil {
return err
}
}
return nil
}

func deleteCluster(t *testing.T, envs []string) error {
Expand Down