build: watch for sauce service failures when waiting for it to start (#36109)
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 PR Close #36109
This commit is contained in:
parent
22be967104
commit
02281281a8
|
@ -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 = [
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
;;
|
||||
|
|
Loading…
Reference in New Issue