You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2018/05/23 18:12:40 UTC

[GitHub] sijie closed pull request #1815: Resolve the flaky test ReplicatorTest.testCloseReplicatorStartProducer

sijie closed pull request #1815: Resolve the flaky test ReplicatorTest.testCloseReplicatorStartProducer
URL: https://github.com/apache/incubator-pulsar/pull/1815
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

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 b5413c57ff..de4992594d 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 void testResumptionAfterBacklogRelaxed() throws Exception {
      */
     @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 void testCloseReplicatorStartProducer() throws Exception {
         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");


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services