This is an automated email from the ASF dual-hosted git repository. sijie pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-pulsar.git
The following commit(s) were added to refs/heads/master by this push: new e8c8c37 Resolve the flaky test ReplicatorTest.testCloseReplicatorStartProducer (#1815) e8c8c37 is described below commit e8c8c3744c31ac3a1166a3eb07bbe7d2d77faf3f Author: Matteo Merli <mme...@apache.org> AuthorDate: Wed May 23 11:12:38 2018 -0700 Resolve the flaky test ReplicatorTest.testCloseReplicatorStartProducer (#1815) ### Motivation Fixed the flaky behavior by ensuring the read operation completes with the expected failure instead of throwing assertion error in background. --- .../pulsar/broker/service/ReplicatorTest.java | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/ReplicatorTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/ReplicatorTest.java index b5413c5..de49925 100644 --- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/ReplicatorTest.java +++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/ReplicatorTest.java @@ -796,7 +796,6 @@ public class ReplicatorTest extends ReplicatorTestBase { */ @Test(timeOut = 15000) public void testCloseReplicatorStartProducer() throws Exception { - TopicName dest = TopicName.get("persistent://pulsar/ns1/closeCursor"); // Producer on r1 MessageProducer producer1 = new MessageProducer(url1, dest); @@ -815,27 +814,20 @@ public class ReplicatorTest extends ReplicatorTestBase { ManagedCursor cursor = (ManagedCursor) cursorField.get(replicator); cursor.close(); // try to read entries - CountDownLatch latch = new CountDownLatch(1); producer1.produce(10); - cursor.asyncReadEntriesOrWait(10, new ReadEntriesCallback() { - @Override - public void readEntriesComplete(List<Entry> entries, Object ctx) { - latch.countDown(); - fail("it should have been failed"); - } - @Override - public void readEntriesFailed(ManagedLedgerException exception, Object ctx) { - latch.countDown(); - assertTrue(exception instanceof CursorAlreadyClosedException); - } - }, null); + try { + cursor.readEntriesOrWait(10); + fail("It should have failed"); + } catch (Exception e) { + assertEquals(e.getClass(), CursorAlreadyClosedException.class); + } // replicator-readException: cursorAlreadyClosed replicator.readEntriesFailed(new CursorAlreadyClosedException("Cursor already closed exception"), null); // wait replicator producer to be closed - Thread.sleep(1000); + Thread.sleep(100); // Replicator producer must be closed Field producerField = AbstractReplicator.class.getDeclaredField("producer"); -- To stop receiving notification emails like this one, please contact si...@apache.org.