From 4ca6b1bd7c3bf7108a1818afa28519a04526dbc9 Mon Sep 17 00:00:00 2001 From: Chase Engelbrecht Date: Fri, 6 Oct 2023 14:56:01 -0500 Subject: [PATCH] Move getDrainTimeout to default method in the interface, add test for it, disable SNS sink Signed-off-by: Chase Engelbrecht --- .gitignore | 2 -- .../model/buffer/AbstractBuffer.java | 6 ----- .../dataprepper/model/buffer/Buffer.java | 4 ++- .../model/buffer/AbstractBufferTest.java | 8 ------ .../dataprepper/model/buffer/BufferTest.java | 25 +++++++++++++++++++ .../plugins/buffer/TestBuffer.java | 5 ---- settings.gradle | 2 +- 7 files changed, 29 insertions(+), 23 deletions(-) create mode 100644 data-prepper-api/src/test/java/org/opensearch/dataprepper/model/buffer/BufferTest.java diff --git a/.gitignore b/.gitignore index 409d1def28..086c830d15 100644 --- a/.gitignore +++ b/.gitignore @@ -13,5 +13,3 @@ gradle/tools # Ignore config file generated by test data-prepper-main/src/test/resources/logstash-filter.yaml data-prepper-main/src/test/resources/logstash-conf/logstash-filter.yaml -data-prepper-plugins/sns-sink/C:\\Work\\dlq.txt -data-prepper-plugins/sns-sink/local_dlq_file diff --git a/data-prepper-api/src/main/java/org/opensearch/dataprepper/model/buffer/AbstractBuffer.java b/data-prepper-api/src/main/java/org/opensearch/dataprepper/model/buffer/AbstractBuffer.java index 323eb3f2a5..d3523af5a7 100644 --- a/data-prepper-api/src/main/java/org/opensearch/dataprepper/model/buffer/AbstractBuffer.java +++ b/data-prepper-api/src/main/java/org/opensearch/dataprepper/model/buffer/AbstractBuffer.java @@ -13,7 +13,6 @@ import org.opensearch.dataprepper.model.configuration.PluginSetting; import org.opensearch.dataprepper.model.record.Record; -import java.time.Duration; import java.util.Collection; import java.util.Map; import java.util.concurrent.TimeUnit; @@ -181,9 +180,4 @@ protected int getRecordsInFlight() { public void postProcess(final Long recordsInBuffer) { } - - @Override - public Duration getDrainTimeout() { - return Duration.ZERO; - } } diff --git a/data-prepper-api/src/main/java/org/opensearch/dataprepper/model/buffer/Buffer.java b/data-prepper-api/src/main/java/org/opensearch/dataprepper/model/buffer/Buffer.java index 694a4f5de5..50c1085bd7 100644 --- a/data-prepper-api/src/main/java/org/opensearch/dataprepper/model/buffer/Buffer.java +++ b/data-prepper-api/src/main/java/org/opensearch/dataprepper/model/buffer/Buffer.java @@ -55,5 +55,7 @@ public interface Buffer> { boolean isEmpty(); - Duration getDrainTimeout(); + default Duration getDrainTimeout() { + return Duration.ZERO; + } } diff --git a/data-prepper-api/src/test/java/org/opensearch/dataprepper/model/buffer/AbstractBufferTest.java b/data-prepper-api/src/test/java/org/opensearch/dataprepper/model/buffer/AbstractBufferTest.java index 6ba6210040..17f13e4ae8 100644 --- a/data-prepper-api/src/test/java/org/opensearch/dataprepper/model/buffer/AbstractBufferTest.java +++ b/data-prepper-api/src/test/java/org/opensearch/dataprepper/model/buffer/AbstractBufferTest.java @@ -16,7 +16,6 @@ import org.opensearch.dataprepper.model.configuration.PluginSetting; import org.opensearch.dataprepper.model.record.Record; -import java.time.Duration; import java.util.AbstractMap; import java.util.ArrayList; import java.util.Arrays; @@ -260,13 +259,6 @@ public void testWriteAllRuntimeException() { Assert.assertThrows(NullPointerException.class, () -> abstractBuffer.writeAll(testRecords, 1000)); } - @Test - public void testGetDrainTimeout() { - final AbstractBuffer> abstractBuffer = new AbstractBufferImpl(testPluginSetting); - - Assert.assertEquals(Duration.ZERO, abstractBuffer.getDrainTimeout()); - } - public static class AbstractBufferImpl extends AbstractBuffer> { private final Queue> queue; public AbstractBufferImpl(PluginSetting pluginSetting) { diff --git a/data-prepper-api/src/test/java/org/opensearch/dataprepper/model/buffer/BufferTest.java b/data-prepper-api/src/test/java/org/opensearch/dataprepper/model/buffer/BufferTest.java new file mode 100644 index 0000000000..293a9d67bb --- /dev/null +++ b/data-prepper-api/src/test/java/org/opensearch/dataprepper/model/buffer/BufferTest.java @@ -0,0 +1,25 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.opensearch.dataprepper.model.buffer; + +import org.junit.Assert; +import org.junit.jupiter.api.Test; +import org.opensearch.dataprepper.model.event.Event; +import org.opensearch.dataprepper.model.record.Record; + +import java.time.Duration; + +import static org.mockito.Mockito.spy; + +public class BufferTest { + + @Test + public void testGetDrainTimeout() { + final Buffer> buffer = spy(Buffer.class); + + Assert.assertEquals(Duration.ZERO, buffer.getDrainTimeout()); + } +} diff --git a/data-prepper-plugins/common/src/test/java/org/opensearch/dataprepper/plugins/buffer/TestBuffer.java b/data-prepper-plugins/common/src/test/java/org/opensearch/dataprepper/plugins/buffer/TestBuffer.java index 6215a6d78e..9cf365c2e7 100644 --- a/data-prepper-plugins/common/src/test/java/org/opensearch/dataprepper/plugins/buffer/TestBuffer.java +++ b/data-prepper-plugins/common/src/test/java/org/opensearch/dataprepper/plugins/buffer/TestBuffer.java @@ -12,7 +12,6 @@ import org.opensearch.dataprepper.model.event.Event; import org.opensearch.dataprepper.model.record.Record; -import java.time.Duration; import java.util.AbstractMap; import java.util.ArrayList; import java.util.Collection; @@ -93,8 +92,4 @@ public int size() { return buffer.size(); } - @Override - public Duration getDrainTimeout() { - return Duration.ZERO; - } } diff --git a/settings.gradle b/settings.gradle index 7575153b68..efa0a507db 100644 --- a/settings.gradle +++ b/settings.gradle @@ -139,7 +139,7 @@ include 'data-prepper-plugins:buffer-common' include 'data-prepper-plugins:sqs-source' include 'data-prepper-plugins:cloudwatch-logs' include 'data-prepper-plugins:http-sink' -include 'data-prepper-plugins:sns-sink' +//include 'data-prepper-plugins:sns-sink' include 'data-prepper-plugins:prometheus-sink' include 'data-prepper-plugins:dissect-processor' include 'data-prepper-plugins:dynamodb-source'