Skip to content

Commit 76c6cdf

Browse files
dakroneweizijun
authored andcommitted
Wrap accounting breaker check in assertBusy (elastic#39211)
There may be situations where indices have not yet been closed from a Lucene perspective, causing the breaker to not immediately be at 0 Relates to elastic#30290
1 parent b09ef84 commit 76c6cdf

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2413,9 +2413,15 @@ public void ensureEstimatedStats() {
24132413
final CircuitBreakerService breakerService = getInstanceFromNode(CircuitBreakerService.class, nodeAndClient.node);
24142414
CircuitBreaker fdBreaker = breakerService.getBreaker(CircuitBreaker.FIELDDATA);
24152415
assertThat("Fielddata breaker not reset to 0 on node: " + name, fdBreaker.getUsed(), equalTo(0L));
2416-
CircuitBreaker acctBreaker = breakerService.getBreaker(CircuitBreaker.ACCOUNTING);
2417-
assertThat("Accounting breaker not reset to 0 on node: " + name + ", are there still Lucene indices around?",
2418-
acctBreaker.getUsed(), equalTo(0L));
2416+
try {
2417+
assertBusy(() -> {
2418+
CircuitBreaker acctBreaker = breakerService.getBreaker(CircuitBreaker.ACCOUNTING);
2419+
assertThat("Accounting breaker not reset to 0 on node: " + name + ", are there still Lucene indices around?",
2420+
acctBreaker.getUsed(), equalTo(0L));
2421+
});
2422+
} catch (Exception e) {
2423+
throw new AssertionError("Exception during check for accounting breaker reset to 0", e);
2424+
}
24192425
// Anything that uses transport or HTTP can increase the
24202426
// request breaker (because they use bigarrays), because of
24212427
// that the breaker can sometimes be incremented from ping
@@ -2430,7 +2436,7 @@ public void ensureEstimatedStats() {
24302436
assertThat("Request breaker not reset to 0 on node: " + name, reqBreaker.getUsed(), equalTo(0L));
24312437
});
24322438
} catch (Exception e) {
2433-
fail("Exception during check for request breaker reset to 0: " + e);
2439+
throw new AssertionError("Exception during check for request breaker reset to 0", e);
24342440
}
24352441

24362442
NodeService nodeService = getInstanceFromNode(NodeService.class, nodeAndClient.node);

0 commit comments

Comments
 (0)