From cd58da221da17e9cde0b5527e04828823123cc76 Mon Sep 17 00:00:00 2001 From: Greg Magolan Date: Tue, 17 Mar 2020 11:31:00 -0500 Subject: [PATCH 1/2] build: watch for sauce service failures when waiting for it to start Also add two targets to make it more convienent to tail & dump the sauce service logs: //tools/saucelabs:sauce_service_tail & //tools/saucelabs:sauce_service_log --- tools/saucelabs/BUILD.bazel | 14 ++++++++++++ tools/saucelabs/README.md | 10 ++++++++- tools/saucelabs/sauce-service.sh | 38 ++++++++++++++++++++++++++++---- 3 files changed, 57 insertions(+), 5 deletions(-) diff --git a/tools/saucelabs/BUILD.bazel b/tools/saucelabs/BUILD.bazel index 5cfca5be42853..da7dd957b569d 100644 --- a/tools/saucelabs/BUILD.bazel +++ b/tools/saucelabs/BUILD.bazel @@ -37,6 +37,20 @@ sh_binary( data = ["@npm//sauce-connect"], ) +sh_binary( + name = "sauce_service_tail", + srcs = ["sauce-service.sh"], + args = ["tail"], + data = ["@npm//sauce-connect"], +) + +sh_binary( + name = "sauce_service_log", + srcs = ["sauce-service.sh"], + args = ["log"], + data = ["@npm//sauce-connect"], +) + nodejs_binary( name = "karma-saucelabs", data = [ diff --git a/tools/saucelabs/README.md b/tools/saucelabs/README.md index f3ec9cf586a64..25fdda31c6aa3 100644 --- a/tools/saucelabs/README.md +++ b/tools/saucelabs/README.md @@ -27,11 +27,19 @@ yarn bazel run //tools/saucelabs:sauce_service_setup For example, `packages/core/test:test_web` becomes `packages/core/test:saucelabs_test_web`. ``` -yarn bazel test //path/to/target:saucelabs_target1 --config=saucelabs --config=ivy +yarn bazel test //packages/core/test:saucelabs_test_web --config=saucelabs --config=ivy ``` Remove the `--config=ivy` if you want to run through View Engine instead. +5. Sauce service log may be tailed or dumped with the following targets: + +``` bash +yarn bazel run //tools/saucelabs:sauce_service_tail +yarn bazel run //tools/saucelabs:sauce_service_log +``` + + ## Additional test features To see the test output while the tests are running (as these are long tests), add the `--test_output=streamed` option. diff --git a/tools/saucelabs/sauce-service.sh b/tools/saucelabs/sauce-service.sh index 9f70183be76b9..3bb2058ba5fc5 100755 --- a/tools/saucelabs/sauce-service.sh +++ b/tools/saucelabs/sauce-service.sh @@ -191,16 +191,32 @@ service-pre-start() { # Called after service is started service-post-start() { - @wait_for "Waiting for Sauce Connect Proxy process" "${SAUCE_PID_FILE}" + if [[ ! -f "${SAUCE_PID_FILE}" ]]; then + printf "# Waiting for Sauce Connect Proxy process (${SAUCE_PID_FILE})" + while [[ ! -f "${SAUCE_PID_FILE}" ]]; do + if ! @serviceStatus >/dev/null 2>&1; then + printf "\n" + @serviceStop + @echo "Service failed to start!" + service-failed-setup + exit 1 + fi + printf "." + sleep 0.5 + done + printf "\n" + fi @echo "Sauce Connect Proxy started (pid $(cat "${SAUCE_PID_FILE}"))" } # Called if service fails to start service-failed-setup() { if [[ -f "${SERVICE_LOG_FILE}" ]]; then - echo "================================================================================" - echo "${SERVICE_LOG_FILE}:" - echo $(cat "${SERVICE_LOG_FILE}") + @echo "tail ${SERVICE_LOG_FILE}:" + echo "--------------------------------------------------------------------------------" + tail "${SERVICE_LOG_FILE}" + echo "--------------------------------------------------------------------------------" + echo "^^^^^ ${SERVICE_LOG_FILE} ^^^^^" fi } @@ -359,6 +375,8 @@ service-post-stop() { return 0 else @warn "Service is not running" + @remove "${SERVICE_PID_FILE}" + @remove "${SERVICE_START_FILE}" service-post-stop fi } @@ -378,9 +396,18 @@ service-post-stop() { } @serviceTail() { + @echo "tail ${SERVICE_LOG_FILE}:" tail -f "${SERVICE_LOG_FILE}" } +@serviceLog() { + @echo "cat ${SERVICE_LOG_FILE}:" + echo "--------------------------------------------------------------------------------" + cat "${SERVICE_LOG_FILE}" + echo "--------------------------------------------------------------------------------" + echo "^^^^^ ${SERVICE_LOG_FILE} ^^^^^" +} + case "${1:-}" in setup) @serviceLock @@ -419,6 +446,9 @@ case "${1:-}" in ${SERVICE_COMMAND} ) ;; + log) + @serviceLog + ;; tail) @serviceTail ;; From 369d42bdd43d2139ee5e7490319d826f067b028d Mon Sep 17 00:00:00 2001 From: Greg Magolan Date: Tue, 17 Mar 2020 12:00:16 -0500 Subject: [PATCH 2/2] build: fix saucelabs jobs that were broken by bazelisk change --- .circleci/config.yml | 4 ++-- tools/saucelabs/README.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 3464a00f7e4f7..a625395acb0f1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -347,7 +347,7 @@ jobs: # See /tools/saucelabs/README.md for more info command: | yarn bazel run //tools/saucelabs:sauce_service_setup - TESTS=$(./node_modules/.bin/bazel query --output label '(kind(karma_web_test, ...) intersect attr("tags", "saucelabs", ...)) except attr("tags", "ivy-only", ...) except attr("tags", "fixme-saucelabs-ve", ...)') + TESTS=$(./node_modules/.bin/bazelisk query --output label '(kind(karma_web_test, ...) intersect attr("tags", "saucelabs", ...)) except attr("tags", "ivy-only", ...) except attr("tags", "fixme-saucelabs-ve", ...)') yarn bazel test --config=saucelabs ${TESTS} yarn bazel run //tools/saucelabs:sauce_service_stop no_output_timeout: 40m @@ -371,7 +371,7 @@ jobs: # See /tools/saucelabs/README.md for more info command: | yarn bazel run //tools/saucelabs:sauce_service_setup - TESTS=$(./node_modules/.bin/bazel query --output label '(kind(karma_web_test, ...) intersect attr("tags", "saucelabs", ...)) except attr("tags", "no-ivy-aot", ...) except attr("tags", "fixme-saucelabs-ivy", ...)') + TESTS=$(./node_modules/.bin/bazelisk query --output label '(kind(karma_web_test, ...) intersect attr("tags", "saucelabs", ...)) except attr("tags", "no-ivy-aot", ...) except attr("tags", "fixme-saucelabs-ivy", ...)') yarn bazel test --config=saucelabs --config=ivy ${TESTS} yarn bazel run //tools/saucelabs:sauce_service_stop no_output_timeout: 40m diff --git a/tools/saucelabs/README.md b/tools/saucelabs/README.md index 25fdda31c6aa3..9ade6aa1166b6 100644 --- a/tools/saucelabs/README.md +++ b/tools/saucelabs/README.md @@ -51,7 +51,7 @@ Running all ViewEngine karma tests in Saucelabs: ``` bash yarn bazel run //tools/saucelabs:sauce_service_setup -TESTS=$(./node_modules/.bin/bazel query --output label '(kind(karma_web_test, ...) intersect attr("tags", "saucelabs", ...)) except attr("tags", "ivy-only", ...) except attr("tags", "fixme-saucelabs-ve", ...)') +TESTS=$(./node_modules/.bin/bazelisk query --output label '(kind(karma_web_test, ...) intersect attr("tags", "saucelabs", ...)) except attr("tags", "ivy-only", ...) except attr("tags", "fixme-saucelabs-ve", ...)') yarn bazel test --config=saucelabs ${TESTS} ``` @@ -59,7 +59,7 @@ Running all Ivy karma tests in Saucelabs: ``` bash yarn bazel run //tools/saucelabs:sauce_service_setup -TESTS=$(./node_modules/.bin/bazel query --output label '(kind(karma_web_test, ...) intersect attr("tags", "saucelabs", ...)) except attr("tags", "no-ivy-aot", ...) except attr("tags", "fixme-saucelabs-ivy", ...)') +TESTS=$(./node_modules/.bin/bazelisk query --output label '(kind(karma_web_test, ...) intersect attr("tags", "saucelabs", ...)) except attr("tags", "no-ivy-aot", ...) except attr("tags", "fixme-saucelabs-ivy", ...)') yarn bazel test --config=saucelabs --config=ivy ${TESTS} ```