From 12858311ee38c164e7a8fcd741eddb32e940e5d5 Mon Sep 17 00:00:00 2001 From: mariano Date: Fri, 3 Jul 2026 06:07:44 -0500 Subject: [PATCH] test(consumer): give RebalanceAtScaleIntegrationTest a per-method broker to fix CI flake MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit RebalanceAtScaleIntegrationTest was the only class failing on main CI (3 runs: the #221 merge run + both attempts of the #218 run). The signature was identical every time: produce timed out at line 325 (send.get in the produceRecords setup helper) with org.apache.kafka.common.errors.TimeoutException, always in this one class, for its later-ordered methods (cooperativeSticky, revoke) while midFlight passed. Root cause: the class shared ONE static KafkaContainer across its three @Test methods, each of which creates its own 6-partition topic + consumer groups and never tears them down. That state accumulated on the single broker until a later method's producer could not get acks within delivery.timeout.ms, failing at the produce step during setup. It is the only container test class heavy enough (3 methods x 6 partitions) to degrade its own broker this way, which is why it was the only one that flaked — a runner-wide resource problem would have scattered failures across the other five container classes, and it did not. Fix: make the @Container field non-static so JUnit's default per-method lifecycle starts a fresh broker for each test, isolating them. Costs ~2 extra broker startups (~40s) for this one class; leaves the five healthy container classes untouched. Cannot run Testcontainers locally (no Docker); verified it compiles. CI is the confirmation — will re-run the branch a few times to confirm the rebalance tests stay green. --- .../kpipe/consumer/RebalanceAtScaleIntegrationTest.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/kpipe-consumer/src/test/java/io/github/eschizoid/kpipe/consumer/RebalanceAtScaleIntegrationTest.java b/lib/kpipe-consumer/src/test/java/io/github/eschizoid/kpipe/consumer/RebalanceAtScaleIntegrationTest.java index 8977c30a..af3ded11 100644 --- a/lib/kpipe-consumer/src/test/java/io/github/eschizoid/kpipe/consumer/RebalanceAtScaleIntegrationTest.java +++ b/lib/kpipe-consumer/src/test/java/io/github/eschizoid/kpipe/consumer/RebalanceAtScaleIntegrationTest.java @@ -71,8 +71,13 @@ class RebalanceAtScaleIntegrationTest { private static final int PARTITIONS = 6; private static final int RECORD_COUNT = 600; + // Per-method broker (instance field, NOT static). Each of this class's three methods creates its + // own 6-partition topic plus consumer groups and never tears them down; sharing one static broker + // across all three let that state accumulate until a later method's producer could not get acks + // within delivery.timeout.ms and failed at the produce step during setup. A fresh broker per + // method keeps each test isolated. Do not make this static. @Container - static KafkaContainer kafka = new KafkaContainer( + final KafkaContainer kafka = new KafkaContainer( DockerImageName.parse("soldevelo/kafka:%s".formatted(KAFKA_VERSION)).asCompatibleSubstituteFor("apache/kafka") );