From 584aba0417113ed93a382dce357cdbc3f7713c0a Mon Sep 17 00:00:00 2001 From: David Venable Date: Mon, 14 Aug 2023 10:18:04 -0500 Subject: [PATCH] Fixes two unit tests that have failed and are probably flaky. The ParseTreeEvaluatorListenerTest appears to be using negative values sometimes, which seems to be unsupported. The OTelLogsSourceTest test failed as well, but it appears this code may not always be executed because it was mixing Hamcrest and Mockito. Signed-off-by: David Venable --- .../expression/ParseTreeEvaluatorListenerTest.java | 4 ++-- .../plugins/source/otellogs/OTelLogsSourceTest.java | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/data-prepper-expression/src/test/java/org/opensearch/dataprepper/expression/ParseTreeEvaluatorListenerTest.java b/data-prepper-expression/src/test/java/org/opensearch/dataprepper/expression/ParseTreeEvaluatorListenerTest.java index 9b517d8ae0..f0e1fdb9f4 100644 --- a/data-prepper-expression/src/test/java/org/opensearch/dataprepper/expression/ParseTreeEvaluatorListenerTest.java +++ b/data-prepper-expression/src/test/java/org/opensearch/dataprepper/expression/ParseTreeEvaluatorListenerTest.java @@ -193,7 +193,7 @@ void testSimpleRelationalOperatorExpressionWithInValidLiteralType() { @Test void testSimpleRelationalOperatorExpressionWithJsonPointerTypeValidValue() { final String testKey = "testKey"; - final int testValue = random.nextInt(1000); + final int testValue = random.nextInt(1000) + 2; final Map data = Map.of(testKey, testValue); final Event testEvent = createTestEvent(data); final String greaterThanStatement = String.format(" /%s > %d", testKey, testValue - 1); @@ -207,7 +207,7 @@ void testSimpleRelationalOperatorExpressionWithJsonPointerTypeValidValue() { } @Test - void testSimpleRelationalOperatorExpressionWithJsonPointerTypeInValidValue() { + void testSimpleRelationalOperatorExpressionWithJsonPointerTypeInValidValueWithPositiveInteger() { final String testKey = "testKey"; final boolean testValue = true; final Map data = Map.of(testKey, testValue); diff --git a/data-prepper-plugins/otel-logs-source/src/test/java/org/opensearch/dataprepper/plugins/source/otellogs/OTelLogsSourceTest.java b/data-prepper-plugins/otel-logs-source/src/test/java/org/opensearch/dataprepper/plugins/source/otellogs/OTelLogsSourceTest.java index eee926a698..64a7f341cf 100644 --- a/data-prepper-plugins/otel-logs-source/src/test/java/org/opensearch/dataprepper/plugins/source/otellogs/OTelLogsSourceTest.java +++ b/data-prepper-plugins/otel-logs-source/src/test/java/org/opensearch/dataprepper/plugins/source/otellogs/OTelLogsSourceTest.java @@ -89,6 +89,7 @@ import java.util.stream.Stream; import java.util.zip.GZIPOutputStream; +import static org.hamcrest.Matchers.hasItem; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.opensearch.dataprepper.plugins.source.otellogs.OTelLogsSourceConfig.DEFAULT_PORT; import static org.opensearch.dataprepper.plugins.source.otellogs.OTelLogsSourceConfig.DEFAULT_REQUEST_TIMEOUT_MS; @@ -800,8 +801,9 @@ private void assertSecureResponseWithStatusCode(final AggregatedHttpResponse res .stream() .map(Map.Entry::getKey) .map(AsciiString::toString) + .map(String::toLowerCase) .collect(Collectors.toList()); - assertThat("Response Header Keys", headerKeys, not(contains("server"))); + assertThat("Response Header Keys", headerKeys, not(hasItem("server"))); } private byte[] createGZipCompressedPayload(final String payload) throws IOException {