Skip to content

Use bundled tar kubectl for integration tests. Add log verbosity args. #234

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

Merged
merged 1 commit into from
Mar 14, 2019
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions deploy/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

# Common variables
readonly KUSTOMIZE_PATH="${PKGDIR}/bin/kustomize"
readonly VERBOSITY="${GCE_PD_VERBOSITY:-2}"
readonly KUBECTL="${GCE_PD_KUBECTL:-kubectl}"

# Common functions

Expand Down
4 changes: 2 additions & 2 deletions deploy/kubernetes/delete-driver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ source "${PKGDIR}/deploy/common.sh"

ensure_kustomize

${KUSTOMIZE_PATH} build ${PKGDIR}/deploy/kubernetes/overlays/${DEPLOY_VERSION} | kubectl delete --ignore-not-found -f -
kubectl delete secret cloud-sa --ignore-not-found
${KUSTOMIZE_PATH} build ${PKGDIR}/deploy/kubernetes/overlays/${DEPLOY_VERSION} | ${KUBECTL} delete -v="${VERBOSITY}" --ignore-not-found -f -
${KUBECTL} delete secret cloud-sa -v="${VERBOSITY}" --ignore-not-found
15 changes: 8 additions & 7 deletions deploy/kubernetes/deploy-driver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,20 +76,21 @@ if [ "$skip_sa_check" != true ]; then
check_service_account
fi

if ! kubectl get secret cloud-sa -n ${NAMESPACE};
if ! ${KUBECTL} get secret cloud-sa -v="${VERBOSITY}" -n ${NAMESPACE};
then
kubectl create secret generic cloud-sa --from-file="${GCE_PD_SA_DIR}/cloud-sa.json" -n ${NAMESPACE}
${KUBECTL} create secret generic cloud-sa -v="${VERBOSITY}" --from-file="${GCE_PD_SA_DIR}/cloud-sa.json" -n ${NAMESPACE}
fi

# GKE Required Setup
if ! kubectl get clusterrolebinding cluster-admin-binding;
if ! ${KUBECTL} get clusterrolebinding -v="${VERBOSITY}" cluster-admin-binding;
then
kubectl create clusterrolebinding cluster-admin-binding --clusterrole cluster-admin --user $(gcloud config get-value account)
${KUBECTL} create clusterrolebinding cluster-admin-binding -v="${VERBOSITY}" --clusterrole cluster-admin --user $(gcloud config get-value account)
fi

# Debug log: print kubectl version
kubectl version
# Debug log: print ${KUBECTL} version
${KUBECTL} version

readonly tmp_spec=/tmp/gcp-compute-persistent-disk-csi-driver-specs-generated.yaml
${KUSTOMIZE_PATH} build ${PKGDIR}/deploy/kubernetes/overlays/${DEPLOY_VERSION} | tee $tmp_spec
kubectl apply -v=9 -f $tmp_spec
${KUBECTL} apply -v="${VERBOSITY}" -f $tmp_spec

12 changes: 12 additions & 0 deletions test/k8s-integration/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,18 @@ func handle() error {
return fmt.Errorf("failed to build Kubernetes: %v", err)
}

kshPath := filepath.Join(k8sDir, "cluster", "kubectl.sh")
_, err = os.Stat(kshPath)
if err == nil {
// Set kubectl to the one bundled in the k8s tar for versioning
err = os.Setenv("GCE_PD_KUBECTL", kshPath)
if err != nil {
return fmt.Errorf("failed to set cluster specific kubectl: %v", err)
}
} else {
glog.Errorf("could not find cluster kubectl at %s, falling back to default kubectl", kshPath)
}

err = clusterUp(k8sDir)
if err != nil {
return fmt.Errorf("failed to cluster up: %v", err)
Expand Down
1 change: 1 addition & 0 deletions test/run-k8s-integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ readonly PKGDIR=${GOPATH}/src/sigs.k8s.io/gcp-compute-persistent-disk-csi-driver
readonly overlay_name="${GCE_PD_OVERLAY_NAME:-prow-head-template}"
readonly boskos_resource_type="${GCE_PD_BOSKOS_RESOURCE_TYPE:-gce-project}"
readonly do_driver_build="${GCE_PD_DO_DRIVER_BUILD:-true}"
export GCE_PD_VERBOSITY=9

Choose a reason for hiding this comment

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

should this also be configureable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

for integration tests we always want to just set it to max. noisy logs for our tests is fine and helps with debugging


make -C ${PKGDIR} test-k8s-integration
${PKGDIR}/bin/k8s-integration-test --kube-version=master --run-in-prow=true --deploy-overlay-name=${overlay_name} --service-account-file=${E2E_GOOGLE_APPLICATION_CREDENTIALS} --do-driver-build=${do_driver_build} --boskos-resource-type=${boskos_resource_type}