Prechádzať zdrojové kódy

ZOOKEEPER-3480: Fix the flaky test in CommitProcessorMetricsTest

This test is pretty flaky on Jenkins, the previous code doesn't wait all requests being processed, which may cause flaky.

Author: Fangmin Lyu <fangmin@apache.org>

Reviewers: Norbert Kalmar <nkalmar@yahoo.com>, maoling <maoling199210191@sina.com>, Michael Han <hanm@apache.org>

Closes #1035 from lvfangmin/ZOOKEEPER-3480
Fangmin Lyu 5 rokov pred
rodič
commit
8fbeec0db8

+ 2 - 0
zookeeper-server/src/test/java/org/apache/zookeeper/server/quorum/CommitProcessorMetricsTest.java

@@ -377,9 +377,11 @@ public class CommitProcessorMetricsTest extends ZKTestCase {
 
 
         //three read requests will be processed in parallel
         //three read requests will be processed in parallel
         commitSeen = new CountDownLatch(1);
         commitSeen = new CountDownLatch(1);
+        requestScheduled = new CountDownLatch(3);
         commitProcessor.processRequest(createReadRequest(1l, 2));
         commitProcessor.processRequest(createReadRequest(1l, 2));
         commitProcessor.processRequest(createReadRequest(1l, 3));
         commitProcessor.processRequest(createReadRequest(1l, 3));
         commitProcessor.processRequest(createReadRequest(1l, 4));
         commitProcessor.processRequest(createReadRequest(1l, 4));
+        requestScheduled.await(5, TimeUnit.SECONDS);
 
 
         //add a commit request to trigger waitForEmptyPool, which will record number of requests being proccessed
         //add a commit request to trigger waitForEmptyPool, which will record number of requests being proccessed
         poolEmpytied = new CountDownLatch(1);
         poolEmpytied = new CountDownLatch(1);