Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration test to verify controller pods status #811

Merged
merged 1 commit into from
Mar 8, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 34 additions & 5 deletions scripts/ci-integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ CRD_YAML="crd.yaml"
BOOTSTRAP_CLUSTER_NAME="clusterapi-bootstrap"
CONTROLLER_REPO="controller-ci" # use arbitrary repo name since we don't need to publish it
EXAMPLE_PROVIDER_REPO="example-provider-ci"
INTEGRATION_TEST_DIR="./test/integration"

install_kustomize() {
go get sigs.k8s.io/kustomize
Expand Down Expand Up @@ -67,12 +68,33 @@ delete_bootstrap() {
kind delete cluster --name "${BOOTSTRAP_CLUSTER_NAME}"
}

verify_cluster_api() {
echo "not implemented"
#TODO: verify cluster-api CRD on bootstrap cluster
wait_pod_running() {
retry=30
INTERVAL=6
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason these vars are in different cases?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, no strong reason, thanks

until kubectl get pods "$1" -n "$2" --no-headers | awk -F" " '{s+=($3!="Running")} END {exit s}'
do
sleep ${INTERVAL};
retry=$((retry - 1))
if [ $retry -lt 0 ];
then
kubectl describe pod "$1" -n "$2"
kubectl logs "$1" -n "$2"
exit 1
fi;
kubectl get pods "$1" -n "$2" --no-headers;
done;
}

ensure_docker_in_docker() {
if [ -z "${PROW_JOB_ID}" ] ; then
# start docker service in setup other than Prow
service docker start
fi
# DinD is configured at Prow
}

main() {
ensure_docker_in_docker
build_containers

install_kustomize
Expand All @@ -81,9 +103,16 @@ main() {
install_kubectl
create_bootstrap

"${KUBECTL}" create -f "${CRD_YAML}"
"${KUBECTL}" create -f "${CRD_YAML}"

set +e
wait_pod_running "cluster-api-controller-manager-0" "cluster-api-system"
wait_pod_running "provider-controller-manager-0" "provider-system"
set -e

verify_cluster_api
if [ -d "${INTEGRATION_TEST_DIR}" ] ; then
go test -v "${INTEGRATION_TEST_DIR}"/...
fi

delete_bootstrap

Expand Down