Skip to content

Commit

Permalink
run/logging-manual: stabilize tests (#1515)
Browse files Browse the repository at this point in the history
* run/logging-manual: confirm environment

* hello-broken: extend test timeout

* run/kokoro: use kokoro build id in service name

* e2e: fix service URL derivation and remove beta component

Co-authored-by: F. Hinkelmann <[email protected]>
  • Loading branch information
grayside and fhinkel authored Jan 27, 2020
1 parent 82e75e0 commit c7f523a
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .kokoro/build-with-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ gcloud config set project $GOOGLE_CLOUD_PROJECT
# to run them concurrently.
export SAMPLE_VERSION="${KOKORO_GIT_COMMIT:-latest}"
export SAMPLE_NAME="$(basename $(pwd))"

# Builds not triggered by a PR will fall back to the commit hash then "latest".
SUFFIX=${KOKORO_GITHUB_PULL_REQUEST_NUMBER:-${SAMPLE_VERSION:0:12}}
SUFFIX=${KOKORO_BUILD_ID}
export SERVICE_NAME="${SAMPLE_NAME}-${SUFFIX}"
export CONTAINER_IMAGE="gcr.io/${GOOGLE_CLOUD_PROJECT}/run-${SAMPLE_NAME}:${SAMPLE_VERSION}"

Expand Down
2 changes: 1 addition & 1 deletion run/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
| Sample | Description | Deploy |
| --------------------------------------- | ------------------------ | ------------- |
|[Hello World][helloworld]&nbsp;&#10149; | Quickstart | [<img src="https://storage.googleapis.com/cloudrun/button.svg" alt="Run on Google Cloud" height="30"/>][run_button_helloworld] |
|[System Packages][system_package] | Use system-installed binaries in your service. | [<img src="https://storage.googleapis.com/cloudrun/button.svg" alt="Run on Google Cloud" height="30">][run_button_system_package] |
|[System Packages][system_package] | Use system-installed binaries in your service. | [<img src="https://storage.googleapis.com/cloudrun/button.svg" alt="Run on Google Cloud" height="30">][run_button_system_package] |
|[Pub/Sub][pubsub] | Event-driven service with a Pub/Sub push subscription | [<img src="https://storage.googleapis.com/cloudrun/button.svg" alt="Run on Google Cloud" height="30"/>][run_button_pubsub] |
|[Image Processing][image_processing] | Event-driven image analysis & transformation | [<img src="https://storage.googleapis.com/cloudrun/button.svg" alt="Run on Google Cloud" height="30"/>][run_button_image_processing] |
|[Manual Logging][manual_logging] | Structured logging without client library | [<img src="https://storage.googleapis.com/cloudrun/button.svg" alt="Run on Google Cloud" height="30"/>][run_button_manual_logging] |
Expand Down
2 changes: 1 addition & 1 deletion run/hello-broken/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"scripts": {
"start": "node index.js",
"test": "echo \"Error: no test specified\" && exit 0",
"e2e-test": "NAME=Cloud test/runner.sh mocha test/system.test.js --timeout=20000",
"e2e-test": "NAME=Cloud test/runner.sh mocha test/system.test.js --timeout=30000",
"lint": "eslint '**/*.js'",
"fix": "eslint --fix '**/*.js'"
},
Expand Down
4 changes: 4 additions & 0 deletions run/hello-broken/test/runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,9 @@ trap cleanup EXIT
export ID_TOKEN=$(gcloud auth print-identity-token)
export BASE_URL=$(test/url.sh)
export BASE_URL_OVERRIDE=$(SERVICE_NAME=${SERVICE_OVERRIDE} test/url.sh)

test -z "$BASE_URL" && echo "BASE_URL value is empty" && exit 1
test -z "$BASE_URL_OVERRIDE" && echo "BASE_URL_OVERRIDE value is empty" && exit 1

# Do not use exec to preserve trap behavior.
"$@"
2 changes: 1 addition & 1 deletion run/hello-broken/test/url.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ set -x
gcloud run services \
describe "${SERVICE_NAME}" \
--region="${REGION:-us-central1}" \
--format='value(status.domain)' \
--format='value(status.url)' \
--platform=managed
3 changes: 3 additions & 0 deletions run/logging-manual/test/runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,8 @@ trap cleanup EXIT
# TODO: Perform authentication inside the test.
export ID_TOKEN=$(gcloud auth print-identity-token)
export BASE_URL=$(test/url.sh)

test -z "$BASE_URL" && echo "BASE_URL value is empty" && exit 1

# Do not use exec to preserve trap behavior.
"$@"
2 changes: 1 addition & 1 deletion run/logging-manual/test/url.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ set -x
gcloud run services \
describe "${SERVICE_NAME}" \
--region="${REGION:-us-central1}" \
--format='value(status.domain)' \
--format='value(status.url)' \
--platform=managed

0 comments on commit c7f523a

Please sign in to comment.