Repository navigation
CI: fix Bugfix validation after stop-testing rename - #105298
Conversation
ClickHouse#104081 renamed the `server_died` event to `stop_testing` in `clickhouse-test` and replaced the parent-side print `Server died, terminating all processes...` with `Stopping tests, terminating all processes...`. The functional-tests results parser still searched for the old string, so when a Bugfix validation run actually killed the server it failed to emit the synthetic `Server died` leaf that the inversion step in `ci/jobs/functional_tests.py` flips to OK — and the job reported `Failed to reproduce the bug` even though the bug had reproduced. Realign the two SIGN constants to the wording the runner now emits and rename the carried variable/field to `stop_testing` to match. Observed on the `Bugfix validation (functional tests)` job of ClickHouse#105286 (server crashed under the test, log: `Stopping tests, terminating all processes...`). Refs ClickHouse#104081
|
Workflow [PR], commit [bfb9a67] Summary: ✅ AI ReviewSummaryThis PR updates Final Verdict
|
| HUNG_SIGN = "Found hung queries in processlist" | ||
| SERVER_DIED_SIGN = "Server died, terminating all processes" | ||
| SERVER_DIED_SIGN2 = "Server does not respond to health check" | ||
| STOP_TESTING_SIGN = "Stopping tests, terminating all processes" |
There was a problem hiding this comment.
We should put this in a common file and use them in clickhouse-test. Otherwise this will happen again
There was a problem hiding this comment.
+1
And also this looks fragile, maybe we need to use constants from clickhouse-test directly here?
Also can't bugfix simply consider any error as the bug is reproduced?
There was a problem hiding this comment.
I will fix this with the next PR. Let me know what do you think is better - having a clear automation marker in the report text, e.g. STOP_TESTING or ###STOP_TESTING###; or maybe just using exit code 2 for clickhouse-test to signal this situation. @azat @Algunenano
There was a problem hiding this comment.
The point why I want to commit this now is this affects some of CI checks
There was a problem hiding this comment.
exit code 2 for clickhouse-test to signal this situation
I like this one
Another option is to add proper reports into clickhouse-test that will be more or standardized and will not require that complex parsing
Follow-up to PR ClickHouse#105298 (ClickHouse#105298 (comment)) and PR ClickHouse#104081 (ClickHouse#104081). Previously the job-side parser detected the stop_testing condition (server died, hung check failed, --max-failures reached, etc.) by matching specific strings in `test_result.txt`. Every wording change in `clickhouse-test` risked silently breaking bugfix validation - exactly what happened when PR ClickHouse#104081 renamed `Server died, terminating all processes...` to `Stopping tests, terminating all processes...`. Replace that fragile log-line matching with a stable contract: an exit code. `clickhouse-test` now exits with `STOP_TESTING_EXIT_CODE = 2` when the run is aborted via a new `StopTesting` exception (renamed from `TestRunAbort`, mirroring `StopIteration`). All paths that previously set the `stop_testing` event now raise `StopTesting` and unwind to a single outer handler that exits with the new code - including the parent-side hung-check path (which used to `break` after killing workers) and the `create_common_database` failure path (which used to re-raise the original exception, bypassing the handler entirely). The job-side parser (`functional_tests_results.py`) treats `runner_exit_code == STOP_TESTING_EXIT_CODE` as the authoritative stop_testing signal - no more `STOP_TESTING_SIGN` / `STOP_TESTING_SIGN2` matching. The constant itself is read straight from `tests/clickhouse-test` via `runpy.run_path`, so there is a single source of truth. `ClickHouseProc.run_test` (used by `fast_test.py`) now returns the integer exit code instead of a bool so this signal reaches the parser for the fast-test invocation too. Behavioural change worth noting: when `StopTesting` unwinds from `do_run_tests` in the parent-side hung-check path, the end-of-main cleanup steps (final hung check, restarted-tests printing, coverage flush, trace log analysis) are skipped. This is acceptable since the server is unresponsive in that path anyway; the diagnostics would fail. ### Changelog category (leave one): - CI Fix or Improvement (changelog entry is not required) ### Changelog entry: ...
…rser Follow-up to PR ClickHouse#105298 (commit fc45ec9) which introduced `STOP_TESTING_EXIT_CODE = 2` as the stable signal from `clickhouse-test` to the job-side parser for "the run was aborted mid-flight (server died, hung-check tripped, etc.)". The parser uses that signal to attach a synthetic `Server died` leaf and demote ambiguous per-test failures to `UNKNOWN`. The contract holds when `clickhouse-test` reaches `sys.exit(STOP_TESTING_EXIT_CODE)` through the `except StopTesting` handler. It does *not* hold in the parent-side hung-check path, which is the most common abort scenario: when the parent terminates a worker via `p.terminate()`, the worker's `signal_handler` raises `Terminated` (subclass of `KeyboardInterrupt`), `run_tests_array`'s `except KeyboardInterrupt` calls `stop_tests()`, which `killpg`s the entire process group - hitting the parent before it can exit through `StopTesting`. The parent's own `signal_handler` then raises `Terminated` and `__main__` exits `128 + SIGTERM = 143`. Concrete failure mode on PR ClickHouse#105041 (https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=105041&sha=68cd608314c8187b7813ab0317a528ec6aff3409&name_0=PR&name_1=Bugfix%20validation%20%28functional%20tests%29): master hung running the PR's new tests, `clickhouse-test` was killed with exit code 143, no per-test result lines reached `test_result.txt`, the parser fell through to `not s.success_finish` (state = `ERROR`, `results = []`), and the bugfix-validation inverter then overwrote that honest ERROR with `set_failed().set_info("Failed to reproduce the bug")` - exactly the opposite of what happened. Replace the singleton `runner_exit_code == STOP_TESTING_EXIT_CODE` check with a `frozenset` that also matches `128 + SIGTERM` (143) and `128 + SIGKILL` (137). All three carry the same semantics: the run was aborted mid-flight, partial per-test results are incomplete, the `Server died` leaf is appropriate. Exit code 1 is deliberately *not* in the set. It is set by end-of-run post-checks (final hung-check, `runner_process_killed`, `total_tests_run == 0`) that run after every test has finished - per-test results are authoritative in that case and must not be demoted. The existing tail handler at the bottom of `FTResultsProcessor.run` already handles exit 1 by appending a generic `clickhouse-test exited with code N` leaf without touching per-test results. This commit does not fix the underlying `worker -> parent` SIGTERM feedback loop in `tests/clickhouse-test`. That root-cause fix (mask SIGTERM on the parent during the worker-cleanup block, or stop `Terminated` from triggering `stop_tests` in workers) is left for a separate change. Adding the kill codes here is defence-in-depth that makes the parser robust to the loop without depending on whether it ever gets fixed - and also covers external kills (job-level timeout, runner shutdown) which would otherwise fall through to the same incorrect ERROR path. A second bug surfaced by the same CI report - the bugfix-validation inverter overwriting `status=ERROR` with `set_failed("Failed to reproduce the bug")` when `test_result.results` is empty - is a separate change. ### Changelog category (leave one): - CI Fix or Improvement (changelog entry is not required) ### Changelog entry (a [user-readable short description](https://github.com/ClickHouse/ClickHouse/blob/master/docs/changelog_entry_guidelines.md) of the changes that goes into CHANGELOG.md): ... ### Documentation entry for user-facing changes - [ ] Documentation is written (mandatory for new features)
Follow-up to PR ClickHouse#105298 (ClickHouse#105298 (comment)) and PR ClickHouse#104081 (ClickHouse#104081). Previously the job-side parser detected the stop_testing condition (server died, hung check failed, --max-failures reached, etc.) by matching specific strings in `test_result.txt`. Every wording change in `clickhouse-test` risked silently breaking bugfix validation - exactly what happened when PR ClickHouse#104081 renamed `Server died, terminating all processes...` to `Stopping tests, terminating all processes...`. Replace that fragile log-line matching with a stable contract: an exit code. `clickhouse-test` now exits with `STOP_TESTING_EXIT_CODE = 2` when the run is aborted via a new `StopTesting` exception (renamed from `TestRunAbort`, mirroring `StopIteration`). All paths that previously set the `stop_testing` event now raise `StopTesting` and unwind to a single outer handler that exits with the new code - including the parent-side hung-check path (which used to `break` after killing workers) and the `create_common_database` failure path (which used to re-raise the original exception, bypassing the handler entirely). The job-side parser (`functional_tests_results.py`) treats `runner_exit_code == STOP_TESTING_EXIT_CODE` as the authoritative stop_testing signal - no more `STOP_TESTING_SIGN` / `STOP_TESTING_SIGN2` matching. The constant itself is read straight from `tests/clickhouse-test` via `runpy.run_path`, so there is a single source of truth. `ClickHouseProc.run_test` (used by `fast_test.py`) now returns the integer exit code instead of a bool so this signal reaches the parser for the fast-test invocation too. Behavioural change worth noting: when `StopTesting` unwinds from `do_run_tests` in the parent-side hung-check path, the end-of-main cleanup steps (final hung check, restarted-tests printing, coverage flush, trace log analysis) are skipped. This is acceptable since the server is unresponsive in that path anyway; the diagnostics would fail. ### Changelog category (leave one): - CI Fix or Improvement (changelog entry is not required) ### Changelog entry: ...
#104081 renamed the
server_diedevent tostop_testinginclickhouse-testand replaced the parent-side printwith
The functional-tests results parser in
ci/jobs/scripts/functional_tests_results.pystill searched for the old string, so when a Bugfix validation run actually killed the server it never emitted the syntheticServer diedleaf that the inversion step inci/jobs/functional_tests.pyflips to OK — and the job reportedFailed to reproduce the bugeven though the bug had reproduced.This PR realigns the two SIGN constants to the wording the runner now emits and renames the carried variable /
Summaryfield tostop_testingto match.Observed on the
Bugfix validation (functional tests)job of #105286 (server crashed under the test; log lineStopping tests, terminating all processes...).Refs #104081.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Version info
26.5.1.856