Merge pull request #63308 from liggitt/cronjob-set-test

Automatic merge from submit-queue (batch tested with PRs 63335, 63308). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Add set image test for sparse API group resource

Ensures set image works correctly on resources that do not exist in the preferred version of their API group

Tests scenario noticed in review of https://github.com/kubernetes/kubernetes/pull/63206#discussion_r185008596

```release-note
NONE
```
This commit is contained in:
Kubernetes Submit Queue
2018-05-01 19:31:08 -07:00
committed by GitHub

View File

@@ -1318,6 +1318,18 @@ run_kubectl_run_tests() {
kubectl run pi --schedule="*/5 * * * *" --generator=cronjob/v1beta1 "--image=$IMAGE_PERL" --restart=OnFailure -- perl -Mbignum=bpi -wle 'print bpi(20)' "${kube_flags[@]}"
# Post-Condition: CronJob "pi" is created
kube::test::get_object_assert cronjobs "{{range.items}}{{$id_field}}:{{end}}" 'pi:'
# Pre-condition: cronjob has perl image, not custom image
output_message=$(kubectl get cronjob/pi -o jsonpath='{..image}')
kube::test::if_has_not_string "${output_message}" "custom-image"
kube::test::if_has_string "${output_message}" "${IMAGE_PERL}"
# Set cronjob image
kubectl set image cronjob/pi '*=custom-image'
# Post-condition: cronjob has custom image, not perl image
output_message=$(kubectl get cronjob/pi -o jsonpath='{..image}')
kube::test::if_has_string "${output_message}" "custom-image"
kube::test::if_has_not_string "${output_message}" "${IMAGE_PERL}"
# Clean up
kubectl delete cronjobs pi "${kube_flags[@]}"