Repository navigation
Add a style check against modifying the server's data directory in stateless tests - #114056
alexey-milovidov wants to merge 1 commit into
Conversation
…ateless tests Stateless tests run against arbitrary server configurations - object storage, shared merge tree, encrypted disks - where the local part layout either does not exist or does not mean what the test assumes, and modifying it corrupts shared state. For example, on a remote disk a plain `cp` of a part directory duplicates metadata files without incrementing blob reference counts, and a later removal deletes blobs still referenced by the live part (test 04630 failed every stress check this way, see #113978). The check flags stateless `.sh` tests that fetch a server-side filesystem path from a system table (`system.parts`, `system.detached_parts`, `system.projection_parts`, `system.tables`, `system.disks`, `system.server_settings`) and also run file-modifying shell commands. The existing offenders are grandfathered until they are converted to integration tests; new ones are rejected. Related: #113978 Co-Authored-By: Claude Fable 5 <[email protected]>
|
Workflow [PR], commit [f4c9a28] Summary: ✅ AI ReviewSummaryThis PR adds a new Findings
Final VerdictChanges requested: close the quoted- |
| continue | ||
|
|
||
| for line_number, line in enumerate(file_content.splitlines(), 1): | ||
| code = line.split("#")[0] |
There was a problem hiding this comment.
This split("#") is not shell-aware, so a quoted # becomes an escape hatch. For example, a new stateless test can still write server metadata with:
echo '# bad metadata' > "${DATA_PATH}columns_substreams.txt"After this split the line becomes just echo ', so neither the redirection rule nor the mutation-command regex fires and CI lets the test through. These tests often corrupt text metadata/checksum files, so # in the payload is realistic rather than contrived. Please only strip # when it starts an actual shell comment, or make this parsing quote-aware.
…ateless tests The check (`server_data_manipulation_in_stateless_tests`) flags stateless `.sh` tests that fetch a server-side filesystem path from a system table (`system.parts`, `system.detached_parts`, `system.projection_parts`, `system.tables`, `system.disks`, `system.server_settings` with `name = 'path'`) and also run file-modifying shell commands. With all offenders converted to integration tests in this PR, the exclusion list holds only one documented false positive and one test whose conversion is pending in #114057. Folds in #114056. Co-Authored-By: Claude Fable 5 <[email protected]>
|
Folded into #114070, which converts all the grandfathered tests to integration tests and ships the check with the exclusion list already pruned. |
…gration tests Stateless tests must not modify the server's data on disk: the suite runs against arbitrary server configurations (object storage, shared merge tree, encrypted disks), where the local part layout either does not exist or does not mean what the test assumes, and modifying it corrupts shared state. 37 stateless tests move to integration tests, grouped by scenario: - test_broken_projections (extended): 02254, 04511 - test_broken_tmp_txn_version_startup (extended): 04104, 04492, 04493, 04507 - test_lost_part (extended): 02369, 02370, 04215 - test_corrupted_part_files (new): 02253, 02255, 02444, 04151, 04235, 04323, 04506 - test_mutations_with_tampered_parts (new): 04401, 04412, 04426, 04427, 04428, 04431 - test_attach_tampered_detached_parts (new): 04063, 04246, 04402, 04403, 04404, 04425 - test_backups_from_disk (new): 04054, 04495, 02864, 03001_restore..., 03214, 03231, replacing helpers/install_predefined_backup.sh; the canned backups move along - test_server_metadata_files (new): 03001_matview..., 04329, 04545 The conversions are faithful: every .reference output became an exact assertion, the explanatory comments are preserved, and DETACH/ATTACH stayed DETACH/ATTACH except where the original explicitly emulated a server restart (02255, 04215). Notable: 02444's `rm -f "$path/*.bin"` never expanded the glob (quoting bug), so its corruption was an accidental no-op; the converted test applies it for real and the assertions still hold. See ClickHouse#113978 (review) Related: ClickHouse#114056 Related: ClickHouse#114057 Co-Authored-By: Claude Fable 5 <[email protected]>
Related: #113978
Stateless tests are not allowed to modify the server's data on disk at all (#113978 (review)). The stateless suite runs against arbitrary server configurations — object storage, shared merge tree, encrypted disks — where the local part layout either does not exist or does not mean what the test assumes, and modifying it corrupts shared state. For example, on a remote disk a plain
cpof a part directory duplicates metadata files without incrementing blob reference counts, and a later removal deletes blobs still referenced by the live part; test04630_merge_over_stale_packed_tmp_dirfailed every stress check this way until #113978. Such scenarios belong in integration tests.This PR adds a style check (
server_data_manipulation_in_stateless_testsinci/jobs/check_style.py) that flags stateless.shtests which fetch a server-side filesystem path from a system table (system.parts,system.detached_parts,system.projection_parts,system.tables,system.disks,system.server_settingswithname = 'path') and also run file-modifying shell commands (rm/cp/mv/dd/truncate/ln/chmod/touch/mkdir/tar,sed -i, output redirection into a variable-derived path,clickhouse-disks write/remove/...).The 35 existing offenders are grandfathered with an explicit list and must be converted to integration tests over time; the list must only shrink. New violations are rejected with a message explaining the policy. Verified locally: the check is clean on the current tree, catches each grandfathered test when its entry is removed (including the tricky cases:
ddafter a pipe in04506, theflags/directory viasystem.server_settingsin04329, and the canned-backup installer helper), and04326_disks_app_read_checksums— which only writes anmktempscratch file underCLICKHOUSE_TMP— is documented as the single known false positive.The conversion of the first offender,
04630_merge_over_stale_packed_tmp_dir, is sent separately.Changelog category (leave one):