Skip to content

Restore test_storage_rabbitmq integration tests - #101967

Merged
alexey-milovidov merged 3 commits into
masterfrom
revert-rabbitmq-test-removal
Apr 8, 2026
Merged

alexey-milovidov merged 3 commits into
masterfrom
revert-rabbitmq-test-removal

Conversation

@fm4v

@fm4v fm4v commented Apr 7, 2026 •

Copy link
Copy Markdown
Member

Reverts the test removal from #93107, bringing back the comprehensive RabbitMQ integration test suite (~50 tests covering exchanges, formats, materialized views, virtual columns, named collections, etc.).

The test_failed_connection.py file is excluded as it relies on pausing/restarting the RabbitMQ container.

Existing shutdown and virtual-column tests (from #92154) are preserved in a separate test_shutdown.py.

Changelog category (leave one):

  • Build/Testing/Packaging Improvement

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.684

Reverts the test removal from #93107, bringing back the comprehensive
RabbitMQ integration test suite (~50 tests). The `test_failed_connection.py`
file is excluded as it relies on pausing the RabbitMQ container.

Existing shutdown/virtual-column tests are preserved in `test_shutdown.py`.
@clickhouse-gh

clickhouse-gh Bot commented Apr 7, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [ed37ca6]

Summary: ✅


AI Review

Summary

This PR restores and parallelizes test_storage_rabbitmq integration coverage (plus split-out shutdown tests). High-level direction is good, but there are still correctness/reliability issues in the new parallel-safety wiring and metadata quality that should be addressed before merge.

PR Metadata
  • Changelog category: ✅ Build/Testing/Packaging Improvement matches the change.
  • Changelog entry: ❌ Required for this category and currently set to ..., which is not user-readable.
  • Suggested replacement:
    • Restore and parallelize RabbitMQ integration tests by introducing per-test database/exchange isolation and re-enabling broad RabbitMQ engine coverage.
Missing context
  • ⚠️ Most CI checks are still pending, so this review is based on code inspection and current PR state.
Findings

⚠️ Majors

  • [tests/integration/test_storage_rabbitmq/test.py:52] unique uses request.node.originalname, which drops parametrization suffixes and can collide between parametrized cases (test_x[0], test_x[1]), reintroducing cross-test RabbitMQ exchange/queue collisions under parallel execution.
    Suggested fix: derive from request.node.name (or include explicit param ID) so names stay unique per parametrized instance.

💡 Nits

  • [tests/integration/test_storage_rabbitmq/clickhouse_path/format_schemas/rabbitmq.proto:1] File mode is executable (100755) but this is a schema file; it should be non-executable (100644).
  • PR body changelog entry is placeholder ...; replace with concrete user-facing text (see above).
ClickHouse Rules
Item Status Notes
Deletion logging ➖
Serialization versioning ➖
Core-area scrutiny ✅
No test removal ✅
Experimental gate ➖
No magic constants ✅
Backward compatibility ✅
SettingsChangesHistory.cpp ➖
PR metadata quality ⚠️ Changelog entry is required for selected category but currently ....
Safe rollout ✅
Compilation time ✅
Final Verdict
  • Status: ⚠️ Request changes
  • Minimum required actions:
    • Fix per-param uniqueness in unique fixture naming.
    • Make rabbitmq.proto non-executable (100644).
    • Replace placeholder changelog entry with a concrete user-facing sentence.

@clickhouse-gh clickhouse-gh Bot added the pr-build Pull request with build/testing/packaging improvement label Apr 7, 2026
logging.debug("RabbitMQ is available - running test")
instance.query("CREATE DATABASE test")
yield # run test
instance.query("DROP DATABASE test SYNC")

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.

rabbitmq_setup_teardown can skip cluster.reset_rabbitmq if DROP DATABASE test SYNC throws (e.g. after a prior exception/restart), which leaves broker state dirty for subsequent tests and causes cascading flakes.

Please wrap teardown in try/finally so cluster.reset_rabbitmq always runs, and consider DROP DATABASE IF EXISTS test SYNC for idempotent cleanup.

@@ -0,0 +1,6 @@
syntax = "proto3";

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 .proto file is added with executable permissions (100755). Could we make it non-executable (100644) to avoid unnecessary mode-only diffs and packaging noise?

- Add `db` fixture: creates a per-test unique database, drops it on teardown
- Add `unique` fixture: provides per-test prefix for exchange/queue names
- Remove the autouse fixture that created/dropped a shared `test` database
  and called `reset_rabbitmq` (which destroys state for other parallel tests)
- Replace all hardcoded `test.` database references with `{db}.`
- Replace all hardcoded exchange names with `{unique}_<name>` in both
  SQL settings and pika publish calls
- Replace hardcoded queue names in pika calls with unique-prefixed versions
- Mark `test_storage_rabbitmq/` as parallel (is_sequential=False) in config

def _test_unique(request):
"""Generate a unique prefix for exchange/queue names."""
name = request.node.originalname or request.node.name

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.

unique uses request.node.originalname, which is identical for all parametrized variants of the same test (e.g. test_rabbitmq_select[0] and test_rabbitmq_select[1] both become test_rabbitmq_select).

Because exchange/queue names are derived from unique, parametrized cases can still collide when distributed to different workers, which undermines the parallel-safety goal and can cause flaky cross-consumption.

Please derive unique from request.node.name (or include the parametrization ID explicitly), similarly to the DB fixture.

- Virtual columns tests: update expected `_exchange_name` values to
  include the `{unique}_` prefix (exchange name is now dynamic)
- Flush tests: replace hardcoded `database = 'test'` with `{db}` in
  `system.parts` queries
@alexey-milovidov alexey-milovidov self-assigned this Apr 8, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Apr 8, 2026
Merged via the queue into master with commit 59df85c Apr 8, 2026
159 checks passed
@alexey-milovidov
alexey-milovidov deleted the revert-rabbitmq-test-removal branch April 8, 2026 21:09
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Apr 8, 2026
huldarchen pushed a commit to huldarchen/ClickHouse that referenced this pull request May 7, 2026
The three tests in `tests/integration/test_storage_rabbitmq/test_shutdown.py`
have been failing in CI:

- `test_shutdown_rabbitmq_with_materialized_view`
- `test_idle_loop_shutdown_completes_promptly`
- `test_rabbitmq_virtual_column_table`

The fourth test in the file (`test_attach_detach_rabbitmq_with_materialized_view`)
was already marked as `pytest.mark.skip` due to a known data race in
`StorageRabbitMQ` shutdown.

Per @alexey-milovidov's directive on PR ClickHouse#104253:
> "remove (or, optionally, fix) failed RabbitMQ tests and send a PR.
>  Tag the author who tried to resurrect RabbitMQ tests recently,
>  as it was a bad idea."

Removing the entire `test_shutdown.py` file rather than skipping its
contents, since the only non-skipped tests in it are flaky and the
remaining test was already non-runnable.

Context:
- The `test_storage_rabbitmq` suite was originally removed in PR ClickHouse#93107
  due to chronic flakiness, then restored in PR ClickHouse#101967 (2026-04-07).
- `test_shutdown.py` was added shortly after in PR ClickHouse#102711 (2026-04-21).

cc @alexey-milovidov @fm4v @jaapieaapie1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-build Pull request with build/testing/packaging improvement 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.

3 participants