|
204 | 204 | # is not used.
|
205 | 205 | suite_args+=(--report-complete-ginkgo --report-complete-junit)
|
206 | 206 |
|
| 207 | +# When SIGTERM doesn't reach the E2E test suite binaries, ginkgo will exit |
| 208 | +# without collecting information from about the currently running and |
| 209 | +# potentially stuck tests. This seems to happen when Prow shuts down a test |
| 210 | +# job because of a timeout. |
| 211 | +# |
| 212 | +# It's useful to print one final progress report in that case, |
| 213 | +# so GINKGO_PROGRESS_REPORT_ON_SIGTERM (enabled by default when CI=true) |
| 214 | +# catches SIGTERM and forwards it to all processes spawned by ginkgo. |
| 215 | +# |
| 216 | +# Manual invocations can trigger a similar report with `killall -USR1 e2e.test` |
| 217 | +# without having to kill the test run. |
| 218 | +GINKGO_CLI_PID= |
| 219 | +signal_handler() { |
| 220 | + if [ -n "${GINKGO_CLI_PID}" ]; then |
| 221 | + cat <<EOF |
| 222 | +
|
| 223 | +*** $0: received $1 signal -> asking Ginkgo to stop. |
| 224 | +*** |
| 225 | +*** Beware that a timeout may have been caused by some earlier test, |
| 226 | +*** not necessarily the one which gets interrupted now. |
| 227 | +*** See the "Spec runtime" for information about how long the |
| 228 | +*** interrupted test was running. |
| 229 | +
|
| 230 | +EOF |
| 231 | + # This goes to the process group, which is important because we |
| 232 | + # need to reach the e2e.test processes forked by the Ginkgo CLI. |
| 233 | + kill -TERM "-${GINKGO_CLI_PID}" || true |
| 234 | + |
| 235 | + echo "Waiting for Ginkgo with pid ${GINKGO_CLI_PID}..." |
| 236 | + wait "{$GINKGO_CLI_PID}" |
| 237 | + echo "Ginkgo terminated." |
| 238 | + fi |
| 239 | +} |
| 240 | +case "${GINKGO_PROGRESS_REPORT_ON_SIGTERM:-${CI:-no}}" in |
| 241 | + y|yes|true) |
| 242 | + kube::util::trap_add "signal_handler INT" INT |
| 243 | + kube::util::trap_add "signal_handler TERM" TERM |
| 244 | + # Job control is needed to make the Ginkgo CLI and all workers run |
| 245 | + # in their own process group. |
| 246 | + set -m |
| 247 | + ;; |
| 248 | +esac |
| 249 | + |
207 | 250 | # The following invocation is fairly complex. Let's dump it to simplify
|
208 | 251 | # determining what the final options are. Enabled by default in CI
|
209 | 252 | # environments like Prow.
|
@@ -236,4 +279,8 @@ case "${GINKGO_SHOW_COMMAND:-${CI:-no}}" in y|yes|true) set -x ;; esac
|
236 | 279 | ${E2E_REPORT_DIR:+"--report-dir=${E2E_REPORT_DIR}"} \
|
237 | 280 | ${E2E_REPORT_PREFIX:+"--report-prefix=${E2E_REPORT_PREFIX}"} \
|
238 | 281 | "${suite_args[@]:+${suite_args[@]}}" \
|
239 |
| - "${@}" |
| 282 | + "${@}" & |
| 283 | + |
| 284 | +set +x |
| 285 | +GINKGO_CLI_PID=$! |
| 286 | +wait "${GINKGO_CLI_PID}" |
0 commit comments