Skip to content

Make tests with access entities parallel-safe - #102131

Merged
alexey-milovidov merged 11 commits into
masterfrom
fix-parallel-access-entity-tests
Apr 10, 2026
Merged

alexey-milovidov merged 11 commits into
masterfrom
fix-parallel-access-entity-tests

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Apr 8, 2026 •

Copy link
Copy Markdown
Member

Convert stateless tests that create global access entities (USER, ROLE, SETTINGS PROFILE) with hardcoded names to use unique names via CLICKHOUSE_TEST_UNIQUE_NAME, making them safe for parallel execution.

Tests converted from .sql to .sh with unique entity names:

  • 01605_drop_settings_profile_while_assigned — unique USER and SETTINGS PROFILE
  • 01418_custom_settings — unique SETTINGS PROFILE names, uses --ignore-error to preserve session state across expected errors
  • 03920_formatting_consistency — unique USER and ROLE names
  • 03172_bcrypt_validation — unique USER name for invalid bcrypt hash test
  • 03532_create_user_query_on_wrong_parametric_grantees — unique USER name for syntax error test

Updated existing .sh test:

  • 02015_async_inserts_4 — replaced hardcoded role_02015/u_02015_* with unique names

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

...

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Version info

  • Merged into: 26.4.1.758

alexey-milovidov and others added 2 commits April 8, 2026 22:38
Convert SQL tests that create global access entities (USER, ROLE,
SETTINGS PROFILE) with hardcoded names to .sh tests using
`CLICKHOUSE_TEST_UNIQUE_NAME` for unique entity names.

Tests converted:
- `01605_drop_settings_profile_while_assigned`: SQL to .sh, unique USER/PROFILE
- `01418_custom_settings`: SQL to .sh, unique SETTINGS PROFILE names
- `03920_formatting_consistency`: SQL to .sh, unique USER/ROLE names
- `02015_async_inserts_4`: updated .sh to use unique USER/ROLE names

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Convert SQL tests that reference global USER entities to .sh tests
using `CLICKHOUSE_TEST_UNIQUE_NAME`:

- `03172_bcrypt_validation`: unique user name for invalid bcrypt hash test
- `03532_create_user_query_on_wrong_parametric_grantees`: unique user name
  for parametric grantees syntax error test

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Both branches made the same fix (unique access entity names).
Keep `CLICKHOUSE_TEST_UNIQUE_NAME` variant with `DROP ... IF EXISTS`.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Apr 8, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [409674a]

Summary: ✅


AI Review

Summary

This PR converts several stateless access-entity tests to .sh and uses CLICKHOUSE_TEST_UNIQUE_NAME to reduce cross-test collisions in parallel runs. I found one new correctness issue and posted it inline: identifier-safe substitution was regressed in 03920_formatting_consistency.sh. I also observed previously-reported assertion-strictness risks in 01418_custom_settings.sh that still need to be addressed. Verdict: request changes.

PR Metadata
  • ⚠️ Changelog category is correct (CI Fix or Improvement).
  • ⚠️ Changelog entry is optional for this category.
  • ⚠️ PR description mentions 02015_async_inserts_4 as updated, but that file is not in this PR head diff.
Missing context
  • ⚠️ No CI report/log links were provided in this request, so review was based on static diff analysis.
Findings

❌ Blockers

  • [tests/queries/0_stateless/03920_formatting_consistency.sh:281-282] Replacing {CLICKHOUSE_DATABASE_1:Identifier} with ${CLICKHOUSE_DATABASE}_1 removes identifier-safe substitution. If the database name contains non-identifier characters, these statements may parse incorrectly or refer to unintended identifiers.
    Suggested fix: restore identifier-safe passing (query parameters / proper identifier quoting), as in the previous .sql version.

⚠️ Majors

  • [tests/queries/0_stateless/01418_custom_settings.sh:39,49,69] (already reported inline) Converted negative-path checks are grep-based and can weaken strict { serverError ... } semantics unless all assertion paths are unambiguously fail-fast.

  • [tests/queries/0_stateless/01418_custom_settings.sh:53-70] (already reported inline) custom_f non-persistence verification now relies on stderr scraping in a multi-query block, which is more fragile than the original direct error assertion style.

ClickHouse Rules
Item Status Notes
Deletion logging ➖
Serialization versioning ➖
Core-area scrutiny ✅
No test removal ✅
Experimental gate ➖
No magic constants ✅
Backward compatibility ⚠️ Identifier-safe substitution for DB name regressed in one test.
SettingsChangesHistory.cpp ➖
PR metadata quality ⚠️ PR body lists one file (02015_async_inserts_4) that is not in the diff.
Safe rollout ✅
Compilation time ✅
No large/binary files ✅
Final Verdict
  • Status: ⚠️ Request changes
  • Minimum required actions:
    • Restore identifier-safe database-name substitution in 03920_formatting_consistency.sh.
    • Address strictness/semantics issues already flagged inline for 01418_custom_settings.sh.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Apr 8, 2026
Consolidate consecutive CLICKHOUSE_CLIENT invocations into single
multi-query (-n) calls. Separate calls are kept only where output
is piped through sed/grep.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Address review: replace `--ignore-error` in 01418 with separate
client calls at each expected-error point. Re-SET session variables
where needed across the split boundaries.

Also restore original entity names in sed replacements so reference
files stay closer to the original test output.

Accept master's version of 02015 using CLICKHOUSE_DATABASE.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
USER="u_${CLICKHOUSE_TEST_UNIQUE_NAME}"

# Parametric grantees syntax is not supported
${CLICKHOUSE_CLIENT} -q "CREATE USER ${USER} GRANTEES {grantees:Identifier}" 2>&1 | grep -m1 -o 'SYNTAX_ERROR'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This script can produce a false pass because assertion failures are not fatal here.

grep on line 10 is intended to assert SYNTAX_ERROR, but if it fails (e.g. error code/message changed), the script still continues, and a successful second check on line 12 can make the whole script exit with 0.

Please make each assertion fail-fast (for example by enabling set -euo pipefail, or chaining checks with &&) so the first failed expectation cannot be masked by later commands.

alexey-milovidov and others added 2 commits April 9, 2026 00:50
The `value` column in `system.settings` escapes single quotes as `\'`
when output via the client. Update reference to match.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
- 01418: replace `2>/dev/null` with `grep -m1 -o 'UNKNOWN_SETTING'`
  to explicitly verify the expected error code at each error point
- 03532, 03172: add `set -e` so a failed grep assertion aborts
  the script immediately (without `pipefail` since the client is
  expected to exit nonzero in the pipeline)

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

The MSan stress test failure (MemorySanitizer: use-of-uninitialized-value, STID 4179-5154 or 4148-3044) is a known pre-existing issue unrelated to this PR. Fix: #102158

alexey-milovidov and others added 3 commits April 9, 2026 03:48
- `03532_create_user_query_on_wrong_parametric_grantees.sh`: use `set -eo pipefail`
  and capture output before grepping to make assertions fail-fast.
- `01418_custom_settings.sh`: keep `getSetting('custom_f')` in the same session
  as the `SETTINGS custom_f` queries to verify query-level settings don't leak
  into session scope.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
"

# Expected error: custom_e is not yet defined
${CLICKHOUSE_CLIENT} -q "SELECT getSetting('custom_e') as v, toTypeName(v)" 2>&1 | grep -m1 -o 'UNKNOWN_SETTING'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

grep-based checks in this script are currently non-fatal because the script does not enable set -e and these commands are not guarded with explicit || exit 1. If an expected UNKNOWN_SETTING exception is not produced, grep exits non-zero but the test still continues and may pass.

Please make these assertions fail hard (for example, enable set -eo pipefail and capture expected-failure output with ... || true, then grep it), so the test cannot silently pass when behavior regresses.

-- Database
CREATE DATABASE IF NOT EXISTS {CLICKHOUSE_DATABASE_1:Identifier};
DROP DATABASE IF EXISTS {CLICKHOUSE_DATABASE_1:Identifier};
CREATE DATABASE IF NOT EXISTS ${CLICKHOUSE_DATABASE}_1;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switching from {CLICKHOUSE_DATABASE_1:Identifier} to direct interpolation ${CLICKHOUSE_DATABASE}_1 drops identifier escaping provided by ClickHouse query parameters.

If CLICKHOUSE_DATABASE ever contains non-identifier characters, this statement can fail to parse (or target a different identifier than intended). Please keep identifier-safe substitution, e.g. via query parameters / proper identifier quoting, to preserve the previous behavior.

@alexey-milovidov alexey-milovidov self-assigned this Apr 10, 2026
@alexey-milovidov
alexey-milovidov merged commit c1f0fad into master Apr 10, 2026
162 of 163 checks passed
@alexey-milovidov
alexey-milovidov deleted the fix-parallel-access-entity-tests branch April 10, 2026 00:19
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Apr 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-ci pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants