mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-10 21:50:05 +00:00
add a test to test-cmd.sh for apply -f with label selector
This commit is contained in:
@@ -988,6 +988,21 @@ __EOF__
|
||||
# Clean up
|
||||
kubectl delete pods test-pod "${kube_flags[@]}"
|
||||
|
||||
|
||||
## kubectl apply -f with label selector should only apply matching objects
|
||||
# Pre-Condition: no POD exists
|
||||
kube::test::get_object_assert pods "{{range.items}}{{$id_field}}:{{end}}" ''
|
||||
# apply
|
||||
kubectl apply -l unique-label=bingbang -f hack/testdata/filter "${kube_flags[@]}"
|
||||
# check right pod exists
|
||||
kube::test::get_object_assert 'pods selector-test-pod' "{{${labels_field}.name}}" 'selector-test-pod'
|
||||
# check wrong pod doesn't exist
|
||||
output_message=$(! kubectl get pods selector-test-pod-dont-apply 2>&1 "${kube_flags[@]}")
|
||||
kube::test::if_has_string "${output_message}" 'pods "selector-test-pod-dont-apply" not found'
|
||||
# cleanup
|
||||
kubectl delete pods selector-test-pod
|
||||
|
||||
|
||||
## kubectl run should create deployments or jobs
|
||||
# Pre-Condition: no Job exists
|
||||
kube::test::get_object_assert jobs "{{range.items}}{{$id_field}}:{{end}}" ''
|
||||
|
Reference in New Issue
Block a user