Skip to content

Commit

Permalink
make E2E_CLUSTER_PROJECT globally available (knative#692)
Browse files Browse the repository at this point in the history
* make E2E_CLUSTER_PROJECT globally available

* add comment

* export E2E_CLUSTER_PROJECT

* fix CR issues

* remove readonly for two KO vars
  • Loading branch information
chizhg authored and knative-prow-robot committed Apr 19, 2019
1 parent b6b8db7 commit c58f6f9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
5 changes: 3 additions & 2 deletions scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,9 @@ This is a helper script for Knative E2E test scripts. To use it:
1. Write logic for the end-to-end tests. Run all go tests using `go_test_e2e()`
(or `report_go_test()` if you need a more fine-grained control) and call
`fail_test()` or `success()` if any of them failed. The environment variable
`KO_DOCKER_REPO` will be set according to the test cluster. You can also use
the following boolean (0 is false, 1 is true) environment variables for the logic:
`KO_DOCKER_REPO` and `E2E_PROJECT_ID` will be set according to the test cluster.
You can also use the following boolean (0 is false, 1 is true) environment
variables for the logic:

- `EMIT_METRICS`: true if `--emit-metrics` was passed.

Expand Down
11 changes: 8 additions & 3 deletions scripts/e2e-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ function save_metadata() {
geo_key="Zone"
geo_value="${E2E_CLUSTER_REGION}-${E2E_CLUSTER_ZONE}"
fi
local gcloud_project="$(gcloud config get-value project)"
local cluster_version="$(gcloud container clusters list --project=${gcloud_project} --format='value(currentMasterVersion)')"
local cluster_version="$(gcloud container clusters list --project=${E2E_PROJECT_ID} --format='value(currentMasterVersion)')"
cat << EOF > ${ARTIFACTS}/metadata.json
{
"E2E:${geo_key}": "${geo_value}",
Expand Down Expand Up @@ -269,6 +268,11 @@ function setup_test_cluster() {

header "Setting up test cluster"

# Set the actual project the test cluster resides in
# It will be a project assigned by Boskos if test is running on Prow,
# otherwise will be ${GCP_PROJECT} set up by user.
readonly export E2E_PROJECT_ID="$(gcloud config get-value project)"

# Save some metadata about cluster creation for using in prow and testgrid
save_metadata

Expand All @@ -280,9 +284,10 @@ function setup_test_cluster() {
if [[ -z "$(kubectl get clusterrolebinding cluster-admin-binding 2> /dev/null)" ]]; then
acquire_cluster_admin_role ${k8s_user} ${E2E_CLUSTER_NAME} ${E2E_CLUSTER_REGION} ${E2E_CLUSTER_ZONE}
kubectl config set-context ${k8s_cluster} --namespace=default
export KO_DOCKER_REPO=gcr.io/$(gcloud config get-value project)/${E2E_BASE_NAME}-e2e-img
export KO_DOCKER_REPO=gcr.io/${E2E_PROJECT_ID}/${E2E_BASE_NAME}-e2e-img
fi

echo "- Project is ${E2E_PROJECT_ID}"
echo "- Cluster is ${k8s_cluster}"
echo "- User is ${k8s_user}"
echo "- Docker is ${KO_DOCKER_REPO}"
Expand Down

0 comments on commit c58f6f9

Please sign in to comment.