eolivelli commented on a change in pull request #11638:
URL: https://github.com/apache/pulsar/pull/11638#discussion_r686740178



##########
File path: 
pulsar-io/elastic-search/src/test/java/org/apache/pulsar/io/elasticsearch/ElasticSearchClientTests.java
##########
@@ -212,39 +229,49 @@ public void testBulkBlocking() throws Exception {
                 .setRetryBackoffInMs(100)
                 .setBulkFlushIntervalInMs(10000);
         ElasticSearchClient client = new ElasticSearchClient(config);
-        client.createIndexIfNeeded(index);
-
-        MockRecord<GenericObject> mockRecord = new MockRecord<>();
-        for(int i = 1; i <= 5; i++) {
-            client.bulkIndex(mockRecord, Pair.of(Integer.toString(i), 
"{\"a\":"+i+"}"));
-        }
-        // wait bulk flush interval
-        Awaitility.await().untilAsserted( () -> {
-            assertEquals(mockRecord.acked, 5);
+        assertTrue(client.createIndexIfNeeded(index));
+
+        try {
+            MockRecord<GenericObject> mockRecord = new MockRecord<>();
+            for (int i = 1; i <= 5; i++) {
+                client.bulkIndex(mockRecord, Pair.of(Integer.toString(i), 
"{\"a\":" + i + "}"));
+            }
+
+            Awaitility.await().untilAsserted(() -> {
+                assertThat("acked record", mockRecord.acked, 
greaterThanOrEqualTo(4));
+                assertEquals(mockRecord.failed, 0);
+                assertThat("totalHits", client.totalHits(index), 
greaterThanOrEqualTo(4L));
+            });
+            client.flush();
+            Awaitility.await().untilAsserted(() -> {
+                assertEquals(mockRecord.acked, 5);
+                assertEquals(mockRecord.failed, 0);
+                assertEquals(client.totalHits(index), 5);
+            });
+
+            ChaosContainer<?> chaosContainer = new 
ChaosContainer<>(container.getContainerName(), "30s");
+            chaosContainer.start();
+            Thread.sleep(1000L);
+
+            // 11th bulkIndex is blocking because we have 2 pending requests, 
and the 3rd request is blocked.
+            long start = System.currentTimeMillis();
+            for (int i = 6; i <= 15; i++) {
+                client.bulkIndex(mockRecord, Pair.of(Integer.toString(i), 
"{\"a\":" + i + "}"));
+                log.info("{} index [}", System.currentTimeMillis(), i);
+            }
+            long elapsed = System.currentTimeMillis() - start;
+            log.info("elapsed = {}", elapsed);
+            assertTrue(elapsed > 29000); // bulkIndex was blocking while 
elasticsearch was down or busy

Review comment:
       so this test is taking more than 30 seconds?
   if we cannot do better then I am fine with it




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to