Skip to content
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

build: watch for sauce service failures when waiting for it to start #36109

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions .circleci/config.yml
Expand Up @@ -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
Expand All @@ -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
Expand Down
14 changes: 14 additions & 0 deletions tools/saucelabs/BUILD.bazel
Expand Up @@ -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 = [
Expand Down
14 changes: 11 additions & 3 deletions tools/saucelabs/README.md
Expand Up @@ -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.
Expand All @@ -43,15 +51,15 @@ 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}
```

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}
```

Expand Down
38 changes: 34 additions & 4 deletions tools/saucelabs/sauce-service.sh
Expand Up @@ -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}:"
gregmagolan marked this conversation as resolved.
Show resolved Hide resolved
echo "--------------------------------------------------------------------------------"
tail "${SERVICE_LOG_FILE}"
echo "--------------------------------------------------------------------------------"
echo "^^^^^ ${SERVICE_LOG_FILE} ^^^^^"
fi
}

Expand Down Expand Up @@ -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
}
Expand All @@ -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
Expand Down Expand Up @@ -419,6 +446,9 @@ case "${1:-}" in
${SERVICE_COMMAND}
)
;;
log)
@serviceLog
;;
tail)
@serviceTail
;;
Expand Down