Skip to content

Remove flaky RabbitMQ pause-based integration tests - #103271

Merged
fm4v merged 2 commits into
masterfrom
fix-rabbitmq-pause-flaky
Apr 22, 2026
Merged

fm4v merged 2 commits into
masterfrom
fix-rabbitmq-pause-flaky

Conversation

@fm4v

@fm4v fm4v commented Apr 21, 2026 •

Copy link
Copy Markdown
Member

Remove the only two integration tests that rely on
ClickHouseCluster.pause_rabbitmq() and remove the helper itself.

The helper wraps a test body in rabbitmqctl stop_app / start_app plus
a readiness wait. On RabbitMQ 4.2.1 (shipped in the integration-test
image) the start_app RPC silently hangs after a prior stop_app — the
broker emits no Starting RabbitMQ line for the full 120 s timeout,
then Python's subprocess.check_output(..., timeout=120) fires
TimeoutExpired and the test fails with
RuntimeError: rabbitmqctl start_app timed out. Because the RabbitMQ
fixture is module-scoped, the container is then left in a stopped /
half-started state and every follow-up test in the module fails with
Cannot wait RabbitMQ container.

Failure counts from checks on play.clickhouse.com (last 14 days,
test_name LIKE 'test_storage_rabbitmq%'):

  • Primary pause_rabbitmq timeouts: test_connection_info_logging_with_rabbitmq_address 43, test_rabbitmq_no_connection_at_startup_2 20.
  • Cascade (Cannot wait RabbitMQ container): two Integration tests (arm_binary, distributed plan, 2/4) runs took down 58 and 57 other tests each.
  • Total rabbitmq integration failures attributable to this primitive: ~2/3 of all rabbitmq failures in the window.

Example CI report (ARM distributed plan, 2/4, PR #103252):
https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=103252&sha=b0daef3f630d999968660b722401fc27ddd48ecb&name_0=PR&name_1=Integration%20tests%20%28arm_binary%2C%20distributed%20plan%2C%202%2F4%29

The downloaded docker log shows the smoking gun: broker receives
stop_app at 12:21:21, emits Successfully stopped RabbitMQ and its dependencies 87 ms later, then is silent for 127 s until the
SIGTERM from pytest teardown at 12:23:28. start_app never produces
any log output — the RPC is wedged.

The two removed tests were:

  • test_rabbitmq_no_connection_at_startup_2 — ATTACH of a RabbitMQ
    engine table while the broker is unreachable. Covers the same async-
    connect path as test_rabbitmq_no_connection_at_startup_1, which
    continues to exist and uses a non-resolvable host instead of a paused
    broker.
  • test_connection_info_logging_with_rabbitmq_address — regression
    guard that the reconnect log line prints a real host:port and does
    not leak credentials when the table is configured via
    rabbitmq_address = 'amqp://...'.

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

fm4v added 2 commits April 21, 2026 16:08
`pause_rabbitmq()` in `tests/integration/helpers/cluster.py` wraps a
test body in `rabbitmqctl stop_app` / `start_app` plus a readiness
wait. When `start_app` or the readiness wait times out, the original
code just raises: the test fails AND the container is left in a
stopped / half-started state. Because the `rabbitmq_cluster` fixture
is module-scoped, every follow-up test in the same module then fails
with `Cannot wait RabbitMQ container`.

Recent flaky data from `checks` on `play.clickhouse.com`
(`test_name LIKE 'test_storage_rabbitmq%'`, last 14 days) shows the
cascade clearly: on two runs of `Integration tests (arm_binary,
distributed plan, 2/4)`, a single `pause_rabbitmq()` teardown
timeout took down 58 and 57 other tests respectively. The root
offender each time is `test_connection_info_logging_with_rabbitmq_address`
(31 primary fails) and occasionally `test_rabbitmq_no_connection_at_startup_2`.

Make the context manager self-healing: if any of `stop_app`,
`start_app` or `wait_rabbitmq_to_start` raises, fall back to
`reset_rabbitmq(timeout)` (full container restart), which leaves the
module fixture in a usable state for subsequent tests. The original
exception on entry is re-raised so the offending test still fails;
teardown recovery swallows the timeout since the test body already
succeeded or raised its own exception.
Remove the only two callers of `pause_rabbitmq()` in
`tests/integration/helpers/cluster.py` and the helper itself.

The helper wraps a test body in `rabbitmqctl stop_app` / `start_app`
with a readiness wait. On RabbitMQ 4.2.1 (Erlang 27) the
`start_app` RPC silently hangs after a prior `stop_app` — the broker
emits no "Starting RabbitMQ" log line for the entire 120s timeout,
then the test fails with `rabbitmqctl start_app timed out` (see
`rmq_103252` CI logs: broker is silent for 2min between the
`Successfully stopped RabbitMQ and its dependencies` notice and the
SIGTERM from pytest teardown at 12:23:28).

Because the RabbitMQ fixture is module-scoped, a stuck `start_app`
leaves the container in a broken state and every follow-up test in
the module fails with `Cannot wait RabbitMQ container`. Recent
`checks` data (last 14 days) shows this cascade took down 58 and 57
other tests in two separate `Integration tests (arm_binary,
distributed plan, 2/4)` runs, and drove ~2/3 of RabbitMQ
integration-test failures.

The two callers were:
- `test_rabbitmq_no_connection_at_startup_2` — checked that a
  `RabbitMQ` engine table can ATTACH while the broker is unreachable.
- `test_connection_info_logging_with_rabbitmq_address` — checked that
  the reconnect log line prints the real address, not `:0`, and does
  not leak credentials.

Both tests' contracts were satisfied only accidentally by the
underlying primitive, and both have been consistently flaky. Drop
the tests and the unused helper.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=103252&sha=b0daef3f630d999968660b722401fc27ddd48ecb&name_0=PR&name_1=Integration%20tests%20%28arm_binary%2C%20distributed%20plan%2C%202%2F4%29
@clickhouse-gh

clickhouse-gh Bot commented Apr 21, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [124d2db]

Summary: ❌

job_name test_name status info comment
Stateless tests (amd_llvm_coverage, 1/3) FAIL
03258_nonexistent_db FAIL cidb IGNORED

AI Review

Summary

This PR removes pause_rabbitmq and deletes two RabbitMQ integration tests that rely on it. While the flakiness root cause is well explained, the change currently drops important regression coverage (reconnect behavior on ATTACH, and log safety/quality for rabbitmq_address) without replacement, so it should not merge as-is.

Findings

❌ Blockers

  • [tests/integration/test_storage_rabbitmq/test.py:2010] Removing test_rabbitmq_no_connection_at_startup_2 drops coverage for the DETACH → ATTACH reconnect path after broker outage. test_rabbitmq_no_connection_at_startup_1 only checks CREATE TABLE with an invalid host and is not equivalent.
    • Suggested fix: keep this scenario and replace pause_rabbitmq with a deterministic outage/recovery primitive (for example container restart via existing helper paths) so reconnection on ATTACH stays tested.
  • [tests/integration/test_storage_rabbitmq/test.py:3689] Removing test_connection_info_logging_with_rabbitmq_address drops the only regression guard that reconnect logs show the correct endpoint and do not leak credentials for rabbitmq_address.
    • Suggested fix: preserve this test intent with a non-flaky reconnect trigger and keep assertions against :0 and credential leakage.
ClickHouse Rules
Item Status Notes
Deletion logging ➖
Serialization versioning ➖
Core-area scrutiny ✅
No test removal ❌ Removes two existing integration tests with no replacement coverage.
Experimental gate ➖
No magic constants ✅
Backward compatibility ✅
SettingsChangesHistory.cpp ➖
PR metadata quality ✅
Safe rollout ⚠️ Reduced regression protection in RabbitMQ path weakens CI signal for rollout safety.
Compilation time ✅
No large/binary files ✅
Final Verdict
  • Status: ⚠️ Request changes
  • Minimum required actions:
    1. Restore coverage for DETACH/ATTACH reconnect behavior using a deterministic non-flaky outage mechanism.
    2. Restore coverage that reconnect logs for rabbitmq_address contain correct endpoint information and do not expose credentials.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Apr 21, 2026
)


def test_rabbitmq_format_factory_settings(rabbitmq_cluster, db, unique):

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.

Dropping this test removes coverage for the DETACH → ATTACH reconnect path after a broker outage. test_rabbitmq_no_connection_at_startup_1 exercises CREATE TABLE with an invalid host, but it does not validate recovery behavior for ATTACH on an already-defined RabbitMQ table.

Given the flakiness is in pause_rabbitmq, please keep this scenario with a deterministic outage primitive (for example container stop/start via reset_rabbitmq or another non-hanging method) instead of deleting the regression coverage entirely.

@@ -3740,36 +3689,3 @@ def on_dead_letter(ch, method, properties, body):
channel.queue_delete(deadletter_queue)

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 deletes the only regression check that reconnect logs for rabbitmq_address include the real endpoint and do not leak credentials. That is user-visible diagnostics + sensitive-data safety coverage, and there is no replacement test in this PR.

Please preserve this assertion with a non-flaky reconnect trigger (instead of pause_rabbitmq) so we keep protection against :0 endpoint logging and credential exposure regressions.

@fm4v
fm4v added this pull request to the merge queue Apr 22, 2026
Merged via the queue into master with commit dcea556 Apr 22, 2026
159 of 161 checks passed
@fm4v
fm4v deleted the fix-rabbitmq-pause-flaky branch April 22, 2026 12:28
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Apr 22, 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