diff --git a/data-prepper-api/src/test/java/com/amazon/dataprepper/model/buffer/AbstractBufferTest.java b/data-prepper-api/src/test/java/com/amazon/dataprepper/model/buffer/AbstractBufferTest.java index d85c29a578..3054ab4550 100644 --- a/data-prepper-api/src/test/java/com/amazon/dataprepper/model/buffer/AbstractBufferTest.java +++ b/data-prepper-api/src/test/java/com/amazon/dataprepper/model/buffer/AbstractBufferTest.java @@ -64,8 +64,8 @@ public void testWriteMetrics() throws TimeoutException { Assert.assertTrue( MetricsTestUtil.isBetween( MetricsTestUtil.getMeasurementFromList(writeTimeMeasurements, Statistic.TOTAL_TIME).getValue(), - 0.5, - 0.6)); + 0.45, + 0.65)); } @Test @@ -91,8 +91,8 @@ public void testWriteAllMetrics() throws Exception { Assert.assertTrue( MetricsTestUtil.isBetween( MetricsTestUtil.getMeasurementFromList(writeTimeMeasurements, Statistic.TOTAL_TIME).getValue(), - 0.1, - 0.2)); + 0.05, + 0.25)); } @Test @@ -129,8 +129,8 @@ public void testReadMetrics() throws Exception { Assert.assertEquals(1.0, MetricsTestUtil.getMeasurementFromList(readTimeMeasurements, Statistic.COUNT).getValue(), 0); Assert.assertTrue(MetricsTestUtil.isBetween( MetricsTestUtil.getMeasurementFromList(readTimeMeasurements, Statistic.TOTAL_TIME).getValue(), - 0.1, - 0.2)); + 0.05, + 0.25)); } @Test diff --git a/data-prepper-api/src/test/java/com/amazon/dataprepper/model/configuration/PipelinesDataFlowModelTest.java b/data-prepper-api/src/test/java/com/amazon/dataprepper/model/configuration/PipelinesDataFlowModelTest.java index 760b356227..c16dd5a31a 100644 --- a/data-prepper-api/src/test/java/com/amazon/dataprepper/model/configuration/PipelinesDataFlowModelTest.java +++ b/data-prepper-api/src/test/java/com/amazon/dataprepper/model/configuration/PipelinesDataFlowModelTest.java @@ -31,6 +31,7 @@ class PipelinesDataFlowModelTest { void setup() { objectMapper = new ObjectMapper(YAMLFactory.builder() .disable(YAMLGenerator.Feature.WRITE_DOC_START_MARKER) + .enable(YAMLGenerator.Feature.USE_PLATFORM_LINE_BREAKS) .build()); } diff --git a/data-prepper-api/src/test/java/com/amazon/dataprepper/model/configuration/PluginModelTests.java b/data-prepper-api/src/test/java/com/amazon/dataprepper/model/configuration/PluginModelTests.java index 5d31ad4928..5adac42868 100644 --- a/data-prepper-api/src/test/java/com/amazon/dataprepper/model/configuration/PluginModelTests.java +++ b/data-prepper-api/src/test/java/com/amazon/dataprepper/model/configuration/PluginModelTests.java @@ -10,6 +10,7 @@ import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; +import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator; import org.junit.jupiter.api.Test; import java.io.BufferedReader; @@ -64,7 +65,7 @@ public final void testSerializingPluginModel_noExceptions() throws JsonGeneratio public final void testSerialization_empty_plugin_to_YAML() throws JsonGenerationException, JsonMappingException, IOException { final PluginModel pluginModel = new PluginModel("customPlugin", new HashMap<>()); - final ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); + final ObjectMapper mapper = new ObjectMapper(new YAMLFactory().enable(YAMLGenerator.Feature.USE_PLATFORM_LINE_BREAKS)); final String serialized = mapper.writeValueAsString(pluginModel); @@ -78,7 +79,7 @@ public final void testSerialization_empty_plugin_to_YAML() throws JsonGeneration public final void testUsingCustomSerializerWithPluginSettings_noExceptions() throws JsonGenerationException, JsonMappingException, IOException { final PluginModel pluginModel = new PluginModel("customPlugin", validPluginSettings()); - final ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); + final ObjectMapper mapper = new ObjectMapper(new YAMLFactory().enable(YAMLGenerator.Feature.USE_PLATFORM_LINE_BREAKS)); final String serialized = mapper.writeValueAsString(pluginModel); diff --git a/data-prepper-api/src/test/java/com/amazon/dataprepper/model/event/DefaultEventMetadataTest.java b/data-prepper-api/src/test/java/com/amazon/dataprepper/model/event/DefaultEventMetadataTest.java index a8b0887596..7b92eb6453 100644 --- a/data-prepper-api/src/test/java/com/amazon/dataprepper/model/event/DefaultEventMetadataTest.java +++ b/data-prepper-api/src/test/java/com/amazon/dataprepper/model/event/DefaultEventMetadataTest.java @@ -20,8 +20,8 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.anEmptyMap; import static org.hamcrest.Matchers.emptyOrNullString; -import static org.hamcrest.Matchers.greaterThan; -import static org.hamcrest.Matchers.lessThan; +import static org.hamcrest.Matchers.greaterThanOrEqualTo; +import static org.hamcrest.Matchers.lessThanOrEqualTo; import static org.junit.jupiter.api.Assertions.assertThrows; public class DefaultEventMetadataTest { @@ -92,8 +92,8 @@ public void testBuild_withoutTimeReceived() { assertThat(result, notNullValue()); final Instant timeReceived = result.getTimeReceived(); assertThat(timeReceived, notNullValue()); - assertThat(timeReceived, is(greaterThan(before))); - assertThat(timeReceived, is(lessThan(Instant.now()))); + assertThat(timeReceived, is(greaterThanOrEqualTo(before))); + assertThat(timeReceived, is(lessThanOrEqualTo(Instant.now()))); } @Test diff --git a/data-prepper-api/src/test/java/com/amazon/dataprepper/model/event/JacksonEventTest.java b/data-prepper-api/src/test/java/com/amazon/dataprepper/model/event/JacksonEventTest.java index 5e4d5a1930..0150496366 100644 --- a/data-prepper-api/src/test/java/com/amazon/dataprepper/model/event/JacksonEventTest.java +++ b/data-prepper-api/src/test/java/com/amazon/dataprepper/model/event/JacksonEventTest.java @@ -385,7 +385,7 @@ public void testBuild_withAttributes() { @Test public void testBuild_withAllMetadataFields() { - final Instant now = Instant.now(); + final Instant now = Instant.now().minusSeconds(1); final Map testAttributes = new HashMap<>(); testAttributes.put(UUID.randomUUID().toString(), UUID.randomUUID()); testAttributes.put(UUID.randomUUID().toString(), UUID.randomUUID().toString()); diff --git a/data-prepper-core/src/test/java/com/amazon/dataprepper/parser/config/DataPrepperArgsTest.java b/data-prepper-core/src/test/java/com/amazon/dataprepper/parser/config/DataPrepperArgsTest.java index 31bfbf844b..6eb908a214 100644 --- a/data-prepper-core/src/test/java/com/amazon/dataprepper/parser/config/DataPrepperArgsTest.java +++ b/data-prepper-core/src/test/java/com/amazon/dataprepper/parser/config/DataPrepperArgsTest.java @@ -9,6 +9,8 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.junit.jupiter.MockitoExtension; +import java.nio.file.Paths; + import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.endsWith; import static org.hamcrest.Matchers.is; @@ -65,10 +67,12 @@ public void testGivenNullArgumentThenThrowException() { public void testGivenLogstashConfigPathThenPipelineConfigCreated() { final DataPrepperArgs args = new DataPrepperArgs(LOGSTASH_PIPELINE_FILE_PATH, DP_CONFIG_YAML_FILE_PATH); + final String configFileEnding = Paths.get("src", "test", "resources", "logstash-filter.yaml").toString(); + assertThat(args, is(notNullValue())); assertThat( args.getPipelineConfigFileLocation(), - endsWith("src/test/resources/logstash-filter.yaml")); + endsWith(configFileEnding)); assertThat(args.getDataPrepperConfigFileLocation(), is(DP_CONFIG_YAML_FILE_PATH)); } diff --git a/data-prepper-logstash-configuration/src/main/java/org/opensearch/dataprepper/logstash/LogstashConfigConverter.java b/data-prepper-logstash-configuration/src/main/java/org/opensearch/dataprepper/logstash/LogstashConfigConverter.java index c8508a04ff..f7ff034cf4 100644 --- a/data-prepper-logstash-configuration/src/main/java/org/opensearch/dataprepper/logstash/LogstashConfigConverter.java +++ b/data-prepper-logstash-configuration/src/main/java/org/opensearch/dataprepper/logstash/LogstashConfigConverter.java @@ -51,6 +51,7 @@ public String convertLogstashConfigurationToPipeline(String logstashConfiguratio ObjectMapper mapper = new ObjectMapper(YAMLFactory.builder() .disable(YAMLGenerator.Feature.WRITE_DOC_START_MARKER) .enable(YAMLGenerator.Feature.INDENT_ARRAYS_WITH_INDICATOR) + .enable(YAMLGenerator.Feature.USE_PLATFORM_LINE_BREAKS) .disable(YAMLGenerator.Feature.SPLIT_LINES) .enable(YAMLGenerator.Feature.LITERAL_BLOCK_STYLE) .build());