Skip to content

Commit bf68fc4

Browse files
committed
Use bundled tar kubectl for integration tests. Add log verbosity args.
1 parent 8dee70a commit bf68fc4

File tree

5 files changed

+25
-9
lines changed

5 files changed

+25
-9
lines changed

deploy/common.sh

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
# Common variables
44
readonly KUSTOMIZE_PATH="${PKGDIR}/bin/kustomize"
5+
readonly VERBOSITY="${GCE_PD_VERBOSITY:-2}"
6+
readonly KUBECTL="${GCE_PD_KUBECTL:-kubectl}"
57

68
# Common functions
79

deploy/kubernetes/delete-driver.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ source "${PKGDIR}/deploy/common.sh"
1616

1717
ensure_kustomize
1818

19-
${KUSTOMIZE_PATH} build ${PKGDIR}/deploy/kubernetes/overlays/${DEPLOY_VERSION} | kubectl delete --ignore-not-found -f -
20-
kubectl delete secret cloud-sa --ignore-not-found
19+
${KUSTOMIZE_PATH} build ${PKGDIR}/deploy/kubernetes/overlays/${DEPLOY_VERSION} | ${KUBECTL} delete -v="${VERBOSITY}" --ignore-not-found -f -
20+
${KUBECTL} delete secret cloud-sa -v="${VERBOSITY}" --ignore-not-found

deploy/kubernetes/deploy-driver.sh

+8-7
Original file line numberDiff line numberDiff line change
@@ -76,20 +76,21 @@ if [ "$skip_sa_check" != true ]; then
7676
check_service_account
7777
fi
7878

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

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

90-
# Debug log: print kubectl version
91-
kubectl version
90+
# Debug log: print ${KUBECTL} version
91+
${KUBECTL} version
9292

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

test/k8s-integration/main.go

+12
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,18 @@ func handle() error {
148148
return fmt.Errorf("failed to build Kubernetes: %v", err)
149149
}
150150

151+
kshPath := filepath.Join(k8sDir, "cluster", "kubectl.sh")
152+
_, err = os.Stat(kshPath)
153+
if err == nil {
154+
// Set kubectl to the one bundled in the k8s tar for versioning
155+
err = os.Setenv("GCE_PD_KUBECTL", kshPath)
156+
if err != nil {
157+
return fmt.Errorf("failed to set cluster specific kubectl: %v", err)
158+
}
159+
} else {
160+
glog.Errorf("could not find cluster kubectl at %s, falling back to default kubectl", kshPath)
161+
}
162+
151163
err = clusterUp(k8sDir)
152164
if err != nil {
153165
return fmt.Errorf("failed to cluster up: %v", err)

test/run-k8s-integration.sh

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ readonly PKGDIR=${GOPATH}/src/sigs.k8s.io/gcp-compute-persistent-disk-csi-driver
1313
readonly overlay_name="${GCE_PD_OVERLAY_NAME:-prow-head-template}"
1414
readonly boskos_resource_type="${GCE_PD_BOSKOS_RESOURCE_TYPE:-gce-project}"
1515
readonly do_driver_build="${GCE_PD_DO_DRIVER_BUILD:-true}"
16+
export GCE_PD_VERBOSITY=9
1617

1718
make -C ${PKGDIR} test-k8s-integration
1819
${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}

0 commit comments

Comments
 (0)