File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Tests that initial failures to not block subsequent applies.
2
+ # Pod must be before namespace, so it initially fails. Second
3
+ # apply of pod should succeed, since namespace finally exists.
4
+ apiVersion : v1
5
+ kind : Pod
6
+ metadata :
7
+ name : test-pod
8
+ namespace : multi-resource-ns
9
+ labels :
10
+ name : test-pod-label
11
+ spec :
12
+ containers :
13
+ - name : kubernetes-pause
14
+ image : k8s.gcr.io/pause:2.0
15
+ ---
16
+ apiVersion : v1
17
+ kind : Namespace
18
+ metadata :
19
+ name : multi-resource-ns
Original file line number Diff line number Diff line change @@ -274,6 +274,19 @@ __EOF__
274
274
# cleanup
275
275
kubectl delete --kustomize hack/testdata/kustomize
276
276
277
+ # # kubectl apply multiple resources with initial failure.
278
+ # Pre-Condition: no POD exists
279
+ kube::test::get_object_assert pods " {{range.items}}{{${id_field:? } }}:{{end}}" ' '
280
+ # First pass, namespace is created, but pod is not (since namespace does not exist yet).
281
+ kubectl apply -f hack/testdata/multi-resource.yaml " ${kube_flags[@]:? } "
282
+ output_message=$( ! kubectl get pods test-pod 2>&1 " ${kube_flags[@]:? } " )
283
+ kube::test::if_has_string " ${output_message} " ' pods "test-pod" not found'
284
+ # Second pass, pod is created (now that namespace exists).
285
+ kubectl apply -f hack/testdata/multi-resource.yaml " ${kube_flags[@]:? } "
286
+ kube::test::get_object_assert ' pod test-pod' " {{${id_field} }}" ' test-pod'
287
+ # cleanup
288
+ kubectl delete -f hack/testdata/multi-resource.yaml
289
+
277
290
set +o nounset
278
291
set +o errexit
279
292
}
You can’t perform that action at this time.
0 commit comments