Skip to content

Commit

Permalink
Merge pull request #38844 from nikhiljindal/fednewkubectlTests
Browse files Browse the repository at this point in the history
Automatic merge from submit-queue

Adding test-federation-cmd.sh to test kubectl with federation apiserver

There are 2 parts to the PR:
* Adding ability to run kubectl tests for a subset of resources.
* Adding test-federation-cmd.sh that runs kubectl tests for resources that are supported by federation-apiserver.

cc @kubernetes/sig-federation @kubernetes/sig-api-machinery 

```release-note
Adding kubectl tests for federation
```
  • Loading branch information
Kubernetes Submit Queue committed Jan 4, 2017
2 parents 5ee52e8 + 5424d50 commit 6b70211
Show file tree
Hide file tree
Showing 6 changed files with 3,326 additions and 2,959 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ else
test-cmd: generated_files
hack/make-rules/test-kubeadm-cmd.sh
hack/make-rules/test-cmd.sh
hack/make-rules/test-federation-cmd.sh
endif

define CLEAN_HELP_INFO
Expand Down
25 changes: 24 additions & 1 deletion hack/lib/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ readonly red=$(tput setaf 1)
readonly green=$(tput setaf 2)

kube::test::clear_all() {
kubectl delete "${kube_flags[@]}" rc,pods --all --grace-period=0 --force
if kube::test::if_supports_resource "rc" ; then
kubectl delete "${kube_flags[@]}" rc --all --grace-period=0 --force
fi
if kube::test::if_supports_resource "pods" ; then
kubectl delete "${kube_flags[@]}" pods --all --grace-period=0 --force
fi
}

# Force exact match of a returned result for a object query. Wrap this with || to support multiple
Expand Down Expand Up @@ -223,3 +228,21 @@ kube::test::if_has_string() {
return 1
fi
}

# Returns true if the required resource is part of supported resources.
# Expects env vars:
# SUPPORTED_RESOURCES: Array of all resources supported by the apiserver. "*"
# means it supports all resources. For ex: ("*") or ("rc" "*") both mean that
# all resources are supported.
# $1: Name of the resource to be tested.
kube::test::if_supports_resource() {
SUPPORTED_RESOURCES=${SUPPORTED_RESOURCES:-""}
REQUIRED_RESOURCE=${1:-""}

for r in "${SUPPORTED_RESOURCES[@]}"; do
if [[ "${r}" == "*" || "${r}" == "${REQUIRED_RESOURCE}" ]]; then
return 0
fi
done
return 1
}

0 comments on commit 6b70211

Please sign in to comment.