Skip to content
Snippets Groups Projects
Commit 0efb5e92 authored by Derek Su's avatar Derek Su Committed by Derek
Browse files

Revert "e2e: confirm the cleanup of PVs with legacy affinity attributes"

This reverts commit 59a15da2.
parent 750309a6
No related branches found
No related tags found
No related merge requests found
...@@ -82,38 +82,38 @@ func TestPVCTestSuite(t *testing.T) { ...@@ -82,38 +82,38 @@ func TestPVCTestSuite(t *testing.T) {
func (p *PodTestSuite) TestPodWithHostPathVolume() { func (p *PodTestSuite) TestPodWithHostPathVolume() {
p.kustomizeDir = "pod" p.kustomizeDir = "pod"
runTest(p, []string{p.config.IMAGE}, waitCondition("ready"), hostPathVolumeType) runTest(p, []string{p.config.IMAGE}, "ready", hostPathVolumeType)
} }
func (p *PodTestSuite) TestPodWithLocalVolume() { func (p *PodTestSuite) TestPodWithLocalVolume() {
p.kustomizeDir = "pod-with-local-volume" p.kustomizeDir = "pod-with-local-volume"
runTest(p, []string{p.config.IMAGE}, waitCondition("ready"), localVolumeType) runTest(p, []string{p.config.IMAGE}, "ready", localVolumeType)
} }
func (p *PodTestSuite) TestPodWithLocalVolumeDefault() { func (p *PodTestSuite) TestPodWithLocalVolumeDefault() {
p.kustomizeDir = "pod-with-default-local-volume" p.kustomizeDir = "pod-with-default-local-volume"
runTest(p, []string{p.config.IMAGE}, waitCondition("ready"), localVolumeType) runTest(p, []string{p.config.IMAGE}, "ready", localVolumeType)
} }
func (p *PodTestSuite) TestPodWithNodeAffinity() { func (p *PodTestSuite) TestPodWithNodeAffinity() {
p.kustomizeDir = "pod-with-node-affinity" p.kustomizeDir = "pod-with-node-affinity"
runTest(p, []string{p.config.IMAGE}, waitCondition("ready"), hostPathVolumeType) runTest(p, []string{p.config.IMAGE}, "ready", hostPathVolumeType)
} }
func (p *PodTestSuite) TestPodWithRWOPVolume() { func (p *PodTestSuite) TestPodWithRWOPVolume() {
p.kustomizeDir = "pod-with-rwop-volume" p.kustomizeDir = "pod-with-rwop-volume"
runTest(p, []string{p.config.IMAGE}, waitCondition("ready"), localVolumeType) runTest(p, []string{p.config.IMAGE}, "ready", localVolumeType)
} }
func (p *PodTestSuite) TestPodWithSecurityContext() { func (p *PodTestSuite) TestPodWithSecurityContext() {
p.kustomizeDir = "pod-with-security-context" p.kustomizeDir = "pod-with-security-context"
kustomizeDir := testdataFile(p.kustomizeDir) kustomizeDir := testdataFile(p.kustomizeDir)
runTest(p, []string{p.config.IMAGE}, waitCondition("podscheduled"), hostPathVolumeType) runTest(p, []string{p.config.IMAGE}, "podscheduled", hostPathVolumeType)
cmd := fmt.Sprintf(`kubectl get pod -l %s=%s -o=jsonpath='{.items[0].status.conditions[?(@.type=="Ready")].reason}'`, LabelKey, LabelValue) cmd := fmt.Sprintf(`kubectl get pod -l %s=%s -o=jsonpath='{.items[0].status.conditions[?(@.type=="Ready")].reason}'`, LabelKey, LabelValue)
...@@ -142,33 +142,22 @@ loop: ...@@ -142,33 +142,22 @@ loop:
func (p *PodTestSuite) TestPodWithSubpath() { func (p *PodTestSuite) TestPodWithSubpath() {
p.kustomizeDir = "pod-with-subpath" p.kustomizeDir = "pod-with-subpath"
runTest(p, []string{p.config.IMAGE}, waitCondition("ready"), hostPathVolumeType) runTest(p, []string{p.config.IMAGE}, "ready", hostPathVolumeType)
} }
func (p *PodTestSuite) xxTestPodWithMultipleStorageClasses() { func (p *PodTestSuite) xxTestPodWithMultipleStorageClasses() {
p.kustomizeDir = "multiple-storage-classes" p.kustomizeDir = "multiple-storage-classes"
runTest(p, []string{p.config.IMAGE}, waitCondition("ready"), hostPathVolumeType) runTest(p, []string{p.config.IMAGE}, "ready", hostPathVolumeType)
} }
func (p *PodTestSuite) TestPodWithCustomPathPatternStorageClasses() { func (p *PodTestSuite) TestPodWithCustomPathPatternStorageClasses() {
p.kustomizeDir = "custom-path-pattern" p.kustomizeDir = "custom-path-pattern"
runTest(p, []string{p.config.IMAGE}, waitCondition("ready"), hostPathVolumeType) runTest(p, []string{p.config.IMAGE}, "ready", hostPathVolumeType)
} }
func (p *PodTestSuite) TestPodWithLegacyAffinityConstraint() { func runTest(p *PodTestSuite, images []string, waitCondition, volumeType string) {
// The helper pod should be correctly scheduled
p.kustomizeDir = "pv-with-legacy-affinity"
runTest(p, []string{p.config.IMAGE}, "kubectl wait pv pvc-to-clean-up --for delete --timeout=120s", "")
}
func waitCondition(waitCondition string) string {
return fmt.Sprintf("kubectl wait pod -l %s=%s --for condition=%s --timeout=120s", LabelKey, LabelValue, waitCondition)
}
func runTest(p *PodTestSuite, images []string, waitCmd, volumeType string) {
kustomizeDir := testdataFile(p.kustomizeDir) kustomizeDir := testdataFile(p.kustomizeDir)
var cmds []string var cmds []string
...@@ -182,7 +171,7 @@ func runTest(p *PodTestSuite, images []string, waitCmd, volumeType string) { ...@@ -182,7 +171,7 @@ func runTest(p *PodTestSuite, images []string, waitCmd, volumeType string) {
cmds, cmds,
fmt.Sprintf("kustomize edit add label %s:%s -f", LabelKey, LabelValue), fmt.Sprintf("kustomize edit add label %s:%s -f", LabelKey, LabelValue),
"kustomize build | kubectl apply -f -", "kustomize build | kubectl apply -f -",
waitCmd, fmt.Sprintf("kubectl wait pod -l %s=%s --for condition=%s --timeout=120s", LabelKey, LabelValue, waitCondition),
) )
for _, cmd := range cmds { for _, cmd := range cmds {
...@@ -199,7 +188,6 @@ func runTest(p *PodTestSuite, images []string, waitCmd, volumeType string) { ...@@ -199,7 +188,6 @@ func runTest(p *PodTestSuite, images []string, waitCmd, volumeType string) {
} }
} }
if volumeType != "" {
typeCheckCmd := fmt.Sprintf("kubectl get pv $(%s) -o jsonpath='{.spec.%s}'", "kubectl get pv -o jsonpath='{.items[0].metadata.name}'", volumeType) typeCheckCmd := fmt.Sprintf("kubectl get pv $(%s) -o jsonpath='{.spec.%s}'", "kubectl get pv -o jsonpath='{.items[0].metadata.name}'", volumeType)
c := createCmd(p.T(), typeCheckCmd, kustomizeDir, p.config.envs(), nil) c := createCmd(p.T(), typeCheckCmd, kustomizeDir, p.config.envs(), nil)
typeCheckOutput, err := c.CombinedOutput() typeCheckOutput, err := c.CombinedOutput()
...@@ -210,4 +198,3 @@ func runTest(p *PodTestSuite, images []string, waitCmd, volumeType string) { ...@@ -210,4 +198,3 @@ func runTest(p *PodTestSuite, images []string, waitCmd, volumeType string) {
p.FailNow("volume Type not correct") p.FailNow("volume Type not correct")
} }
} }
}
...@@ -3,8 +3,4 @@ kind: Cluster ...@@ -3,8 +3,4 @@ kind: Cluster
nodes: nodes:
- role: control-plane - role: control-plane
- role: worker - role: worker
labels:
kubernetes.io/hostname: kind-worker1.hostname
- role: worker - role: worker
labels:
kubernetes.io/hostname: kind-worker2.hostname
...@@ -11,4 +11,4 @@ spec: ...@@ -11,4 +11,4 @@ spec:
- key: kubernetes.io/hostname - key: kubernetes.io/hostname
operator: In operator: In
values: values:
- kind-worker1.hostname - kind-worker
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../../deploy
- pv.yaml
commonLabels:
app: local-path-provisioner
images:
- name: rancher/local-path-provisioner
newTag: dev
\ No newline at end of file
apiVersion: v1
kind: PersistentVolume
metadata:
annotations:
local.path.provisioner/selected-node: kind-worker
pv.kubernetes.io/provisioned-by: rancher.io/local-path
finalizers:
- kubernetes.io/pv-protection
labels:
test/avoid-cleanup: "true"
name: pvc-to-clean-up
spec:
accessModes:
- ReadWriteOnce
capacity:
storage: 100Mi
hostPath:
path: /opt/local-path-provisioner/default/local-path-pvc
type: DirectoryOrCreate
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- kind-worker1.hostname
claimRef:
apiVersion: v1
kind: PersistentVolumeClaim
name: no-such-pvc
namespace: default
# The PVC "definitely doesn't exist any more"
resourceVersion: "1"
uid: 12345678-1234-5678-9abc-123456789abc
persistentVolumeReclaimPolicy: Delete
storageClassName: local-path-custom-path-pattern
volumeMode: Filesystem
...@@ -78,7 +78,7 @@ func testdataFile(fields ...string) string { ...@@ -78,7 +78,7 @@ func testdataFile(fields ...string) string {
func deleteKustomizeDeployment(t *testing.T, kustomizeDir string, envs []string) error { func deleteKustomizeDeployment(t *testing.T, kustomizeDir string, envs []string) error {
_, err := runCmd( _, err := runCmd(
t, t,
"kustomize build | kubectl delete --timeout=180s -f - -l 'test/avoid-cleanup!=true'", "kustomize build | kubectl delete --timeout=180s -f -",
testdataFile(kustomizeDir), testdataFile(kustomizeDir),
envs, envs,
nil, nil,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment