mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 02:41:25 +00:00
test(apply): deflake run_kubectl_apply_tests
Signed-off-by: knight42 <anonymousknight96@gmail.com>
This commit is contained in:
parent
3eb90c19d0
commit
57619aa9d7
@ -159,7 +159,7 @@ __EOF__
|
|||||||
# Dry-run create the CR
|
# Dry-run create the CR
|
||||||
kubectl "${kube_flags[@]:?}" apply --dry-run=server -f hack/testdata/CRD/resource.yaml "${kube_flags[@]:?}"
|
kubectl "${kube_flags[@]:?}" apply --dry-run=server -f hack/testdata/CRD/resource.yaml "${kube_flags[@]:?}"
|
||||||
# Make sure that the CR doesn't exist
|
# Make sure that the CR doesn't exist
|
||||||
! kubectl "${kube_flags[@]:?}" get resource/myobj || exit 1
|
! kubectl "${kube_flags[@]:?}" get resource/myobj 2>/dev/null || exit 1
|
||||||
|
|
||||||
# clean-up
|
# clean-up
|
||||||
kubectl "${kube_flags[@]:?}" delete customresourcedefinition resources.mygroup.example.com
|
kubectl "${kube_flags[@]:?}" delete customresourcedefinition resources.mygroup.example.com
|
||||||
@ -173,11 +173,8 @@ __EOF__
|
|||||||
kube::test::get_object_assert 'pods a -n nsb' "{{${id_field:?}}}" 'a'
|
kube::test::get_object_assert 'pods a -n nsb' "{{${id_field:?}}}" 'a'
|
||||||
# apply b with namespace
|
# apply b with namespace
|
||||||
kubectl apply --namespace nsb --prune -l prune-group=true -f hack/testdata/prune/b.yaml "${kube_flags[@]:?}"
|
kubectl apply --namespace nsb --prune -l prune-group=true -f hack/testdata/prune/b.yaml "${kube_flags[@]:?}"
|
||||||
# check right pod exists
|
# check right pod exists and wrong pod doesn't exist
|
||||||
kube::test::get_object_assert 'pods b -n nsb' "{{${id_field:?}}}" 'b'
|
kube::test::wait_object_assert 'pods -n nsb' "{{range.items}}{{${id_field:?}}}:{{end}}" 'b:'
|
||||||
# check wrong pod doesn't exist
|
|
||||||
output_message=$(! kubectl get pods a -n nsb 2>&1 "${kube_flags[@]:?}")
|
|
||||||
kube::test::if_has_string "${output_message}" 'pods "a" not found'
|
|
||||||
|
|
||||||
# cleanup
|
# cleanup
|
||||||
kubectl delete pods b -n nsb
|
kubectl delete pods b -n nsb
|
||||||
@ -191,8 +188,7 @@ __EOF__
|
|||||||
# check right pod exists
|
# check right pod exists
|
||||||
kube::test::get_object_assert 'pods a' "{{${id_field:?}}}" 'a'
|
kube::test::get_object_assert 'pods a' "{{${id_field:?}}}" 'a'
|
||||||
# check wrong pod doesn't exist
|
# check wrong pod doesn't exist
|
||||||
output_message=$(! kubectl get pods b -n nsb 2>&1 "${kube_flags[@]:?}")
|
kube::test::wait_object_assert 'pods -n nsb' "{{range.items}}{{${id_field:?}}}:{{end}}" ''
|
||||||
kube::test::if_has_string "${output_message}" 'pods "b" not found'
|
|
||||||
|
|
||||||
# apply b
|
# apply b
|
||||||
kubectl apply -l prune-group=true -f hack/testdata/prune/b.yaml "${kube_flags[@]:?}"
|
kubectl apply -l prune-group=true -f hack/testdata/prune/b.yaml "${kube_flags[@]:?}"
|
||||||
@ -254,11 +250,8 @@ __EOF__
|
|||||||
kube::test::get_object_assert 'pods b -n nsb' "{{${id_field:?}}}" 'b'
|
kube::test::get_object_assert 'pods b -n nsb' "{{${id_field:?}}}" 'b'
|
||||||
# apply --prune must prune a
|
# apply --prune must prune a
|
||||||
kubectl apply --prune --all -f hack/testdata/prune/b.yaml
|
kubectl apply --prune --all -f hack/testdata/prune/b.yaml
|
||||||
# check wrong pod doesn't exist
|
# check wrong pod doesn't exist and right pod exists
|
||||||
output_message=$(! kubectl get pods a -n nsb 2>&1 "${kube_flags[@]:?}")
|
kube::test::wait_object_assert 'pods -n nsb' "{{range.items}}{{${id_field:?}}}:{{end}}" 'b:'
|
||||||
kube::test::if_has_string "${output_message}" 'pods "a" not found'
|
|
||||||
# check right pod exists
|
|
||||||
kube::test::get_object_assert 'pods b -n nsb' "{{${id_field:?}}}" 'b'
|
|
||||||
|
|
||||||
# cleanup
|
# cleanup
|
||||||
kubectl delete ns nsb
|
kubectl delete ns nsb
|
||||||
@ -471,7 +464,7 @@ __EOF__
|
|||||||
# Dry-run create the CR
|
# Dry-run create the CR
|
||||||
kubectl "${kube_flags[@]:?}" apply --server-side --dry-run=server -f hack/testdata/CRD/resource.yaml "${kube_flags[@]:?}"
|
kubectl "${kube_flags[@]:?}" apply --server-side --dry-run=server -f hack/testdata/CRD/resource.yaml "${kube_flags[@]:?}"
|
||||||
# Make sure that the CR doesn't exist
|
# Make sure that the CR doesn't exist
|
||||||
! kubectl "${kube_flags[@]:?}" get resource/myobj || exit 1
|
! kubectl "${kube_flags[@]:?}" get resource/myobj 2>/dev/null || exit 1
|
||||||
|
|
||||||
# clean-up
|
# clean-up
|
||||||
kubectl "${kube_flags[@]:?}" delete customresourcedefinition resources.mygroup.example.com
|
kubectl "${kube_flags[@]:?}" delete customresourcedefinition resources.mygroup.example.com
|
||||||
|
Loading…
Reference in New Issue
Block a user