From ca6a9931587baeb49bbecc6f7b259f30e46dab2e Mon Sep 17 00:00:00 2001 From: David Venable Date: Tue, 25 Jul 2023 12:49:46 -0500 Subject: [PATCH] Improves some of the timeouts for the peer forwarder tests to reduce testing time. (#3020) Signed-off-by: David Venable --- .../peerforwarder/PeerForwarderReceiveBufferTest.java | 6 +++--- .../peerforwarder/PeerForwarder_ClientServerIT.java | 2 +- .../peerforwarder/RemotePeerForwarderTest.java | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/data-prepper-core/src/test/java/org/opensearch/dataprepper/peerforwarder/PeerForwarderReceiveBufferTest.java b/data-prepper-core/src/test/java/org/opensearch/dataprepper/peerforwarder/PeerForwarderReceiveBufferTest.java index 372272e416..15555776d6 100644 --- a/data-prepper-core/src/test/java/org/opensearch/dataprepper/peerforwarder/PeerForwarderReceiveBufferTest.java +++ b/data-prepper-core/src/test/java/org/opensearch/dataprepper/peerforwarder/PeerForwarderReceiveBufferTest.java @@ -32,7 +32,7 @@ class PeerForwarderReceiveBufferTest { private static final int TEST_BATCH_SIZE = 3; private static final int TEST_BUFFER_SIZE = 13; private static final int TEST_WRITE_TIMEOUT = 100; - private static final int TEST_BATCH_READ_TIMEOUT = 5_000; + private static final int TEST_BATCH_READ_TIMEOUT = 200; private static final ExecutorService EXECUTOR = Executors.newSingleThreadExecutor(); private static final String PIPELINE_NAME = UUID.randomUUID().toString(); private static final String PLUGIN_ID = UUID.randomUUID().toString(); @@ -204,7 +204,7 @@ void testNonZeroBatchDelayReturnsAllRecords() throws Exception { final Collection> testRecords2 = generateBatchRecords(1); EXECUTOR.submit(() -> { try { - Thread.sleep(1000); + Thread.sleep(TEST_BATCH_READ_TIMEOUT / 5); peerForwarderReceiveBuffer.writeAll(testRecords2, TEST_WRITE_TIMEOUT); } catch (final Exception e) { throw new RuntimeException(e); @@ -229,7 +229,7 @@ void testZeroBatchDelayReturnsAvailableRecords() throws Exception { final Collection> testRecords2 = generateBatchRecords(1); EXECUTOR.submit(() -> { try { - Thread.sleep(1000); + Thread.sleep(TEST_BATCH_READ_TIMEOUT / 5); peerForwarderReceiveBuffer.writeAll(testRecords2, TEST_WRITE_TIMEOUT); } catch (final Exception e) { throw new RuntimeException(e); diff --git a/data-prepper-core/src/test/java/org/opensearch/dataprepper/peerforwarder/PeerForwarder_ClientServerIT.java b/data-prepper-core/src/test/java/org/opensearch/dataprepper/peerforwarder/PeerForwarder_ClientServerIT.java index e132acc813..ea0c018ee4 100644 --- a/data-prepper-core/src/test/java/org/opensearch/dataprepper/peerforwarder/PeerForwarder_ClientServerIT.java +++ b/data-prepper-core/src/test/java/org/opensearch/dataprepper/peerforwarder/PeerForwarder_ClientServerIT.java @@ -151,7 +151,7 @@ private Collection> getServerSideRecords(final PeerForwarderProvid assertThat(pluginBufferMap, notNullValue()); final PeerForwarderReceiveBuffer> receiveBuffer = pluginBufferMap.get(pluginId); - final Map.Entry>, CheckpointState> bufferEntry = receiveBuffer.read(1000); + final Map.Entry>, CheckpointState> bufferEntry = receiveBuffer.read(400); return bufferEntry.getKey(); } diff --git a/data-prepper-core/src/test/java/org/opensearch/dataprepper/peerforwarder/RemotePeerForwarderTest.java b/data-prepper-core/src/test/java/org/opensearch/dataprepper/peerforwarder/RemotePeerForwarderTest.java index 12b13d24dc..64c16ff82b 100644 --- a/data-prepper-core/src/test/java/org/opensearch/dataprepper/peerforwarder/RemotePeerForwarderTest.java +++ b/data-prepper-core/src/test/java/org/opensearch/dataprepper/peerforwarder/RemotePeerForwarderTest.java @@ -66,12 +66,12 @@ class RemotePeerForwarderTest { private static final int TEST_BUFFER_CAPACITY = 20; private static final int TEST_BATCH_SIZE = 20; - private static final int TEST_BATCH_DELAY = 3_000; - private static final int TEST_LOCAL_WRITE_TIMEOUT = 500; - private static final int TEST_TIMEOUT_IN_MILLIS = 500; + private static final int TEST_BATCH_DELAY = 800; + private static final int TEST_LOCAL_WRITE_TIMEOUT = 400; + private static final int TEST_TIMEOUT_IN_MILLIS = 400; private static final int FORWARDING_BATCH_SIZE = 5; private static final int FORWARDING_BATCH_QUEUE_DEPTH = 1; - private static final Duration FORWARDING_BATCH_TIMEOUT = Duration.of(3, ChronoUnit.SECONDS); + private static final Duration FORWARDING_BATCH_TIMEOUT = Duration.of(800, ChronoUnit.MILLIS); private static final int PIPELINE_WORKER_THREADS = 3; private static final String PIPELINE_NAME = UUID.randomUUID().toString(); private static final String PLUGIN_ID = UUID.randomUUID().toString();