Skip to content

Commit

Permalink
Adding test-federation-cmd.sh to test kubectl with federation apiserver
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhiljindal committed Jan 4, 2017
1 parent d12d012 commit 5424d50
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
}
Loading

0 comments on commit 5424d50

Please sign in to comment.