-
Notifications
You must be signed in to change notification settings - Fork 91
Stop CTST gracefully at a cucumber-level time budget #2457
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
base: development/2.15
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,17 @@ cd "$FUNCTIONAL_TESTS_DIR" | |
| mkdir -p ctst/reports | ||
|
|
||
| export SDK=true # Cli-testing also has a cli mode, not really used in practice | ||
|
|
||
| # Gracefully stop before the GitHub step timeout hard-kills the process: | ||
| # scenarios that start after this deadline are skipped (see the time-budget | ||
| # Before hook), so Cucumber finishes normally and writes its reports. The hook | ||
| # drops a marker file; we fail the run if it is present. | ||
| CTST_MAX_RUNTIME_MIN=${CTST_MAX_RUNTIME_MIN:-180} | ||
| export CTST_DEADLINE_EPOCH_MS=$(( $(date +%s%3N) + CTST_MAX_RUNTIME_MIN * 60 * 1000 )) | ||
| export CTST_TIMEOUT_MARKER="/tmp/ctst-timeout.marker" | ||
| rm -f "$CTST_TIMEOUT_MARKER" | ||
|
|
||
| rc=0 | ||
| yarn cucumber-js \ | ||
| --config ctst/cucumber.config.cjs \ | ||
| --tags "${TAGS}" \ | ||
|
|
@@ -33,4 +44,13 @@ yarn cucumber-js \ | |
| --format pretty \ | ||
| --format html:ctst/reports/report.html \ | ||
| --format junit:ctst/reports/report.xml \ | ||
| --format message:ctst/reports/report.ndjson | ||
| --format message:ctst/reports/report.ndjson || rc=$? | ||
|
|
||
| if [ -f "$CTST_TIMEOUT_MARKER" ]; then | ||
| echo "::error::CTST exceeded its ${CTST_MAX_RUNTIME_MIN}-minute time budget; remaining scenarios were skipped." | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we need to display a log here ?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no need imo, I would display a log in the hook, for each test skipped, we can access the name of the scenario and just write "scenario xxx skipped because of global timeout" |
||
| if [ "$rc" -eq 0 ]; then | ||
| rc=1 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. instead of wrapper script, there is already some code to "tweak" the return code (and make it pass always), c.f. tests/functional/ctst/cucumber.config.cjs : → instead of this, you could thus tweak the result to actually return something other than 0 if we want to skip further analysis (e.g. test results merging...) |
||
| fi | ||
| fi | ||
|
|
||
| exit "$rc" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| import fs from 'fs'; | ||
| import { | ||
| Before, | ||
| After, | ||
|
|
@@ -53,6 +54,23 @@ AfterAll(async function () { | |
| await stopDLQConsumer(); | ||
| }); | ||
|
|
||
| // Time budget: scenarios that start after the deadline are skipped so Cucumber | ||
| // finishes normally (writing its reports) before the GitHub step timeout would | ||
| // hard-kill the process. The marker file lets the runner script fail the run. | ||
| Before(() => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would simplify this :
|
||
| const deadline = Number(process.env.CTST_DEADLINE_EPOCH_MS); | ||
| if (deadline && Date.now() > deadline) { | ||
| const marker = process.env.CTST_TIMEOUT_MARKER; | ||
| if (marker) { | ||
| try { | ||
| fs.writeFileSync(marker, 'timeout'); | ||
| } catch { /* best-effort: marker is advisory */ } | ||
| } | ||
| return 'skipped'; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what does this "skipped" do?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's an official cucumber keyword, but yeah this should probably use fail instead 🤔 |
||
| } | ||
| return undefined; | ||
| }); | ||
|
|
||
| Before(async function (this: Zenko, scenario: ITestCaseHookParameter) { | ||
| this.resetSaved(); | ||
| Identity.resetIdentity(); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
best to minimize content of wrapper script : should do this computation in javascript
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
even CTST_MAX_RUNTIME_MIN default value could be set directly in the javascript code?