Skip to content

Commit

Permalink
add a test for kubectl apply --prune
Browse files Browse the repository at this point in the history
  • Loading branch information
mikedanese committed Oct 7, 2016
1 parent ea5ecc4 commit 62960aa
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
25 changes: 24 additions & 1 deletion hack/make-rules/test-cmd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1052,6 +1052,29 @@ __EOF__
kubectl delete pods selector-test-pod


## kubectl apply --prune
# Pre-Condition: no POD exists
kube::test::get_object_assert pods "{{range.items}}{{$id_field}}:{{end}}" ''

# apply a
kubectl apply --prune -l prune-group=true -f hack/testdata/prune/a.yaml "${kube_flags[@]}"
# check right pod exists
kube::test::get_object_assert 'pods a' "{{${id_field}}}" 'a'
# check wrong pod doesn't exist
output_message=$(! kubectl get pods b 2>&1 "${kube_flags[@]}")
kube::test::if_has_string "${output_message}" 'pods "b" not found'

# apply b
kubectl apply --prune -l prune-group=true -f hack/testdata/prune/b.yaml "${kube_flags[@]}"
# check right pod exists
kube::test::get_object_assert 'pods b' "{{${id_field}}}" 'b'
# check wrong pod doesn't exist
output_message=$(! kubectl get pods a 2>&1 "${kube_flags[@]}")
kube::test::if_has_string "${output_message}" 'pods "a" not found'

# cleanup
kubectl delete pods b

## kubectl run should create deployments or jobs
# Pre-Condition: no Job exists
kube::test::get_object_assert jobs "{{range.items}}{{$id_field}}:{{end}}" ''
Expand Down Expand Up @@ -1161,7 +1184,7 @@ __EOF__
]
}
__EOF__

# Post-Condition: assertion object exist
kube::test::get_object_assert thirdpartyresources "{{range.items}}{{$id_field}}:{{end}}" 'bar.company.com:foo.company.com:'

Expand Down
10 changes: 10 additions & 0 deletions hack/testdata/prune/a.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: Pod
metadata:
name: a
labels:
prune-group: "true"
spec:
containers:
- name: kubernetes-pause
image: gcr.io/google-containers/pause:2.0
10 changes: 10 additions & 0 deletions hack/testdata/prune/b.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: Pod
metadata:
name: b
labels:
prune-group: "true"
spec:
containers:
- name: kubernetes-pause
image: gcr.io/google-containers/pause:2.0

0 comments on commit 62960aa

Please sign in to comment.