This is an automated email from the ASF dual-hosted git repository. siddteotia pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/pinot.git
The following commit(s) were added to refs/heads/master by this push: new 2c38d292ea fix flaky QueryLoggerTest (#9759) 2c38d292ea is described below commit 2c38d292ea85d86a166addea9c8e85b11654217f Author: Almog Gavra <almog.ga...@gmail.com> AuthorDate: Wed Nov 9 15:17:13 2022 -0800 fix flaky QueryLoggerTest (#9759) --- .../pinot/broker/querylog/QueryLoggerTest.java | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/pinot-broker/src/test/java/org/apache/pinot/broker/querylog/QueryLoggerTest.java b/pinot-broker/src/test/java/org/apache/pinot/broker/querylog/QueryLoggerTest.java index 797999cdf1..bf173f615b 100644 --- a/pinot-broker/src/test/java/org/apache/pinot/broker/querylog/QueryLoggerTest.java +++ b/pinot-broker/src/test/java/org/apache/pinot/broker/querylog/QueryLoggerTest.java @@ -190,8 +190,6 @@ public class QueryLoggerTest { public void shouldHandleRaceConditionsWithDroppedQueries() throws InterruptedException { // Given: - // first and third request get dropped - final CountDownLatch dropLogLatch = new CountDownLatch(1); final CountDownLatch logLatch = new CountDownLatch(1); Mockito.when(_logRateLimiter.tryAcquire()) .thenReturn(false) @@ -201,10 +199,12 @@ public class QueryLoggerTest { // this one will unblock the tryAcquire, but only after // the first thread has reached _droppedRateLimiter#tryAcquire() logLatch.await(); - dropLogLatch.countDown(); return true; }); + // ensure that the tryAcquire only succeeds after three other + // logs have went through (see logAndDecrement) + final CountDownLatch dropLogLatch = new CountDownLatch(3); Mockito.when(_droppedRateLimiter.tryAcquire()) .thenAnswer(invocation -> { logLatch.countDown(); @@ -219,10 +219,17 @@ public class QueryLoggerTest { // When: try { - executorService.submit(() -> queryLogger.log(params)); // this one gets dropped - executorService.submit(() -> queryLogger.log(params)); // this one succeeds, but blocks - executorService.submit(() -> queryLogger.log(params)); // this one gets dropped - executorService.submit(() -> queryLogger.log(params)); // this one succeeds, and unblocks (2) + // use logAndDecrement on all invocations since any one of them could + // be the one that blocks + Runnable logAndDecrement = () -> { + queryLogger.log(params); + dropLogLatch.countDown(); + }; + + executorService.submit(logAndDecrement); // 1 this one gets dropped + executorService.submit(logAndDecrement); // 2 this one succeeds, but blocks + executorService.submit(logAndDecrement); // 3 this one gets dropped + executorService.submit(logAndDecrement); // 4 this one succeeds, and unblocks (2) } finally { executorService.shutdown(); Assert.assertTrue(executorService.awaitTermination(10, TimeUnit.SECONDS), "expected shutdown to complete"); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org