@@ -257,21 +257,60 @@ __EOF__
257
257
# cleanup
258
258
kubectl delete --kustomize hack/testdata/kustomize
259
259
260
- # # kubectl apply multiple resources with initial failure.
260
+ # # kubectl apply multiple resources with one failure during apply phase .
261
261
# Pre-Condition: namepace does not exist and no POD exists
262
262
output_message=$( ! kubectl get namespace multi-resource-ns 2>&1 " ${kube_flags[@]:? } " )
263
263
kube::test::if_has_string " ${output_message} " ' namespaces "multi-resource-ns" not found'
264
264
kube::test::get_object_assert pods " {{range.items}}{{${id_field:? } }}:{{end}}" ' '
265
265
# First pass, namespace is created, but pod is not (since namespace does not exist yet).
266
- output_message=$( ! kubectl apply -f hack/testdata/multi-resource.yaml 2>&1 " ${kube_flags[@]:? } " )
266
+ output_message=$( ! kubectl apply -f hack/testdata/multi-resource-1 .yaml 2>&1 " ${kube_flags[@]:? } " )
267
267
kube::test::if_has_string " ${output_message} " ' namespaces "multi-resource-ns" not found'
268
268
output_message=$( ! kubectl get pods test-pod -n multi-resource-ns 2>&1 " ${kube_flags[@]:? } " )
269
269
kube::test::if_has_string " ${output_message} " ' pods "test-pod" not found'
270
270
# Second pass, pod is created (now that namespace exists).
271
- kubectl apply -f hack/testdata/multi-resource.yaml " ${kube_flags[@]:? } "
271
+ kubectl apply -f hack/testdata/multi-resource-1 .yaml " ${kube_flags[@]:? } "
272
272
kube::test::get_object_assert ' pods test-pod -n multi-resource-ns' " {{${id_field} }}" ' test-pod'
273
273
# cleanup
274
- kubectl delete -f hack/testdata/multi-resource.yaml " ${kube_flags[@]:? } "
274
+ kubectl delete -f hack/testdata/multi-resource-1.yaml " ${kube_flags[@]:? } "
275
+
276
+ # # kubectl apply multiple resources with one failure during builder phase.
277
+ # Pre-Condition: No configmaps
278
+ kube::test::get_object_assert configmaps " {{range.items}}{{${id_field:? } }}:{{end}}" ' '
279
+ # Apply a configmap and a bogus custom resource.
280
+ output_message=$( ! kubectl apply -f hack/testdata/multi-resource-2.yaml 2>&1 " ${kube_flags[@]:? } " )
281
+ # Should be error message from bogus custom resource.
282
+ kube::test::if_has_string " ${output_message} " ' no matches for kind "Bogus" in version "example.com/v1"'
283
+ # ConfigMap should have been created even with custom resource error.
284
+ kube::test::get_object_assert ' configmaps foo' " {{${id_field} }}" ' foo'
285
+ # cleanup
286
+ kubectl delete configmaps foo " ${kube_flags[@]:? } "
287
+
288
+ # # kubectl apply multiple resources with one failure during builder phase.
289
+ # Pre-Condition: No pods exist.
290
+ kube::test::get_object_assert pods " {{range.items}}{{${id_field:? } }}:{{end}}" ' '
291
+ # Applies three pods, one of which is invalid (POD-B), two succeed (pod-a, pod-c).
292
+ output_message=$( ! kubectl apply -f hack/testdata/multi-resource-3.yaml 2>&1 " ${kube_flags[@]:? } " )
293
+ kube::test::if_has_string " ${output_message} " ' The Pod "POD-B" is invalid'
294
+ kube::test::get_object_assert ' pods pod-a' " {{${id_field} }}" ' pod-a'
295
+ kube::test::get_object_assert ' pods pod-c' " {{${id_field} }}" ' pod-c'
296
+ # cleanup
297
+ kubectl delete pod pod-a pod-c " ${kube_flags[@]:? } "
298
+ kube::test::get_object_assert pods " {{range.items}}{{${id_field:? } }}:{{end}}" ' '
299
+
300
+ # # kubectl apply multiple resources with one failure during apply phase.
301
+ # Pre-Condition: crd does not exist, and custom resource does not exist.
302
+ kube::test::get_object_assert crds " {{range.items}}{{${id_field:? } }}:{{end}}" ' '
303
+ # First pass, custom resource fails, but crd apply succeeds.
304
+ output_message=$( ! kubectl apply -f hack/testdata/multi-resource-4.yaml 2>&1 " ${kube_flags[@]:? } " )
305
+ kube::test::if_has_string " ${output_message} " ' no matches for kind "Widget" in version "example.com/v1"'
306
+ output_message=$( ! kubectl get widgets foo 2>&1 " ${kube_flags[@]:? } " )
307
+ kube::test::if_has_string " ${output_message} " ' widgets.example.com "foo" not found'
308
+ kube::test::get_object_assert ' crds widgets.example.com' " {{${id_field} }}" ' widgets.example.com'
309
+ # Second pass, custom resource is created (now that crd exists).
310
+ kubectl apply -f hack/testdata/multi-resource-4.yaml " ${kube_flags[@]:? } "
311
+ kube::test::get_object_assert ' widget foo' " {{${id_field} }}" ' foo'
312
+ # cleanup
313
+ kubectl delete -f hack/testdata/multi-resource-4.yaml " ${kube_flags[@]:? } "
275
314
276
315
set +o nounset
277
316
set +o errexit
0 commit comments