From 6739a560fee456d1108f93c06c27e169d092c33d Mon Sep 17 00:00:00 2001 From: kranthikirang Date: Fri, 15 Nov 2024 15:24:29 +0000 Subject: [PATCH] fixed integration tests with indexAlias Signed-off-by: kranthikirang --- .../opensearch/index/DefaultIndexManagerTests.java | 6 +++--- .../opensearch/index/IsmPolicyManagementTests.java | 10 +++++----- .../opensearch/index/NoIsmPolicyManagementTests.java | 2 +- .../index/TraceAnalyticsRawIndexManagerTests.java | 4 ++-- .../TraceAnalyticsServiceMapIndexManagerTests.java | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/data-prepper-plugins/opensearch/src/test/java/org/opensearch/dataprepper/plugins/sink/opensearch/index/DefaultIndexManagerTests.java b/data-prepper-plugins/opensearch/src/test/java/org/opensearch/dataprepper/plugins/sink/opensearch/index/DefaultIndexManagerTests.java index 82b8f1b757..3729c4e8eb 100644 --- a/data-prepper-plugins/opensearch/src/test/java/org/opensearch/dataprepper/plugins/sink/opensearch/index/DefaultIndexManagerTests.java +++ b/data-prepper-plugins/opensearch/src/test/java/org/opensearch/dataprepper/plugins/sink/opensearch/index/DefaultIndexManagerTests.java @@ -412,7 +412,7 @@ void checkAndCreatePolicy_Normal() throws IOException { defaultIndexManager = indexManagerFactory.getIndexManager( IndexType.CUSTOM, openSearchClient, restHighLevelClient, openSearchSinkConfiguration, templateStrategy); when(restHighLevelClient.getLowLevelClient()).thenReturn(restClient); - assertEquals(Optional.empty(), defaultIndexManager.checkAndCreatePolicy()); + assertEquals(Optional.empty(), defaultIndexManager.checkAndCreatePolicy(INDEX_ALIAS)); verify(restHighLevelClient).getLowLevelClient(); verify(restClient).performRequest(any()); verify(openSearchSinkConfiguration, times(4)).getIndexConfiguration(); @@ -428,7 +428,7 @@ void checkAndCreatePolicy_Exception() throws IOException { when(restHighLevelClient.getLowLevelClient()).thenReturn(restClient); when(restClient.performRequest(any())).thenThrow(responseException); when(responseException.getMessage()).thenReturn("Invalid field: [ism_template]"); - assertThrows(ResponseException.class, () -> defaultIndexManager.checkAndCreatePolicy()); + assertThrows(ResponseException.class, () -> defaultIndexManager.checkAndCreatePolicy(INDEX_ALIAS)); verify(restHighLevelClient, times(2)).getLowLevelClient(); verify(restClient, times(2)).performRequest(any()); verify(openSearchSinkConfiguration, times(2)).getIndexConfiguration(); @@ -441,7 +441,7 @@ void checkAndCreatePolicy_Exception() throws IOException { void checkAndCreatePolicy() throws IOException { defaultIndexManager = indexManagerFactory.getIndexManager( IndexType.CUSTOM, openSearchClient, restHighLevelClient, openSearchSinkConfiguration, templateStrategy); - assertEquals(Optional.empty(), defaultIndexManager.checkAndCreatePolicy()); + assertEquals(Optional.empty(), defaultIndexManager.checkAndCreatePolicy(INDEX_ALIAS)); verify(indexConfiguration).getIndexAlias(); verify(openSearchSinkConfiguration, times(2)).getIndexConfiguration(); verify(indexConfiguration).getIsmPolicyFile(); diff --git a/data-prepper-plugins/opensearch/src/test/java/org/opensearch/dataprepper/plugins/sink/opensearch/index/IsmPolicyManagementTests.java b/data-prepper-plugins/opensearch/src/test/java/org/opensearch/dataprepper/plugins/sink/opensearch/index/IsmPolicyManagementTests.java index fba0604b3a..b80e423212 100644 --- a/data-prepper-plugins/opensearch/src/test/java/org/opensearch/dataprepper/plugins/sink/opensearch/index/IsmPolicyManagementTests.java +++ b/data-prepper-plugins/opensearch/src/test/java/org/opensearch/dataprepper/plugins/sink/opensearch/index/IsmPolicyManagementTests.java @@ -99,7 +99,7 @@ public void constructor_NullRestClient() { @Test public void checkAndCreatePolicy_Normal() throws IOException { when(restHighLevelClient.getLowLevelClient()).thenReturn(restClient); - assertEquals(Optional.empty(), ismPolicyManagementStrategy.checkAndCreatePolicy()); + assertEquals(Optional.empty(), ismPolicyManagementStrategy.checkAndCreatePolicy(INDEX_ALIAS)); verify(restHighLevelClient).getLowLevelClient(); verify(restClient).performRequest(any()); } @@ -114,7 +114,7 @@ public void checkAndCreatePolicy_OnlyOnePolicyFile_TwoExceptions() throws IOExce when(restHighLevelClient.getLowLevelClient()).thenReturn(restClient); when(restClient.performRequest(any())).thenThrow(responseException); when(responseException.getMessage()).thenReturn("Invalid field: [ism_template]"); - assertThrows(ResponseException.class, () -> ismPolicyManagementStrategy.checkAndCreatePolicy()); + assertThrows(ResponseException.class, () -> ismPolicyManagementStrategy.checkAndCreatePolicy(INDEX_ALIAS)); verify(restHighLevelClient, times(2)).getLowLevelClient(); verify(restClient, times(2)).performRequest(any()); } @@ -129,7 +129,7 @@ public void checkAndCreatePolicy_OnlyOnePolicyFile_FirstExceptionThenSucceeds() when(restHighLevelClient.getLowLevelClient()).thenReturn(restClient); when(restClient.performRequest(any())).thenThrow(responseException).thenReturn(null); when(responseException.getMessage()).thenReturn("Invalid field: [ism_template]"); - assertEquals(Optional.of(POLICY_NAME), ismPolicyManagementStrategy.checkAndCreatePolicy()); + assertEquals(Optional.of(POLICY_NAME), ismPolicyManagementStrategy.checkAndCreatePolicy(INDEX_ALIAS)); verify(restHighLevelClient, times(2)).getLowLevelClient(); verify(restClient, times(2)).performRequest(any()); } @@ -156,7 +156,7 @@ public void checkAndCreatePolicy_with_custom_ism_policy_from_s3() throws IOExcep when(restHighLevelClient.getLowLevelClient()).thenReturn(restClient); when(restClient.performRequest(any())).thenThrow(responseException).thenReturn(null); when(responseException.getMessage()).thenReturn("Invalid field: [ism_template]"); - assertEquals(Optional.of(POLICY_NAME), ismPolicyManagementStrategyWithTemplate.checkAndCreatePolicy()); + assertEquals(Optional.of(POLICY_NAME), ismPolicyManagementStrategyWithTemplate.checkAndCreatePolicy(INDEX_ALIAS)); verify(restHighLevelClient, times(2)).getLowLevelClient(); verify(restClient, times(2)).performRequest(any()); } @@ -166,7 +166,7 @@ public void checkAndCreatePolicy_ExceptionFirstThenSucceed() throws IOException when(restHighLevelClient.getLowLevelClient()).thenReturn(restClient); when(restClient.performRequest(any())).thenThrow(responseException).thenReturn(null); when(responseException.getMessage()).thenReturn("Invalid field: [ism_template]"); - assertEquals(Optional.of(POLICY_NAME), ismPolicyManagementStrategy.checkAndCreatePolicy()); + assertEquals(Optional.of(POLICY_NAME), ismPolicyManagementStrategy.checkAndCreatePolicy(INDEX_ALIAS)); verify(restHighLevelClient, times(2)).getLowLevelClient(); verify(restClient, times(2)).performRequest(any()); } diff --git a/data-prepper-plugins/opensearch/src/test/java/org/opensearch/dataprepper/plugins/sink/opensearch/index/NoIsmPolicyManagementTests.java b/data-prepper-plugins/opensearch/src/test/java/org/opensearch/dataprepper/plugins/sink/opensearch/index/NoIsmPolicyManagementTests.java index eeb1d1c1fc..2c531ed321 100644 --- a/data-prepper-plugins/opensearch/src/test/java/org/opensearch/dataprepper/plugins/sink/opensearch/index/NoIsmPolicyManagementTests.java +++ b/data-prepper-plugins/opensearch/src/test/java/org/opensearch/dataprepper/plugins/sink/opensearch/index/NoIsmPolicyManagementTests.java @@ -55,7 +55,7 @@ public void constructor_NullRestClient() { @Test public void checkAndCreatePolicy() throws IOException { - assertEquals(Optional.empty(), ismPolicyManagementStrategy.checkAndCreatePolicy()); + assertEquals(Optional.empty(), ismPolicyManagementStrategy.checkAndCreatePolicy(INDEX_ALIAS)); } @ParameterizedTest diff --git a/data-prepper-plugins/opensearch/src/test/java/org/opensearch/dataprepper/plugins/sink/opensearch/index/TraceAnalyticsRawIndexManagerTests.java b/data-prepper-plugins/opensearch/src/test/java/org/opensearch/dataprepper/plugins/sink/opensearch/index/TraceAnalyticsRawIndexManagerTests.java index c711aa7d96..075d26656b 100644 --- a/data-prepper-plugins/opensearch/src/test/java/org/opensearch/dataprepper/plugins/sink/opensearch/index/TraceAnalyticsRawIndexManagerTests.java +++ b/data-prepper-plugins/opensearch/src/test/java/org/opensearch/dataprepper/plugins/sink/opensearch/index/TraceAnalyticsRawIndexManagerTests.java @@ -177,7 +177,7 @@ void checkISMEnabled_False() throws IOException { @Test void checkAndCreatePolicy_Normal() throws IOException { when(restHighLevelClient.getLowLevelClient()).thenReturn(restClient); - assertEquals(Optional.empty(), traceAnalyticsRawIndexManager.checkAndCreatePolicy()); + assertEquals(Optional.empty(), traceAnalyticsRawIndexManager.checkAndCreatePolicy(INDEX_ALIAS)); verify(openSearchSinkConfiguration).getIndexConfiguration(); verify(indexConfiguration).getIndexAlias(); verify(restHighLevelClient).getLowLevelClient(); @@ -189,7 +189,7 @@ void checkAndCreatePolicy_ExceptionFirstThenSucceeds() throws IOException { when(restHighLevelClient.getLowLevelClient()).thenReturn(restClient); when(restClient.performRequest(any())).thenThrow(responseException).thenReturn(null); when(responseException.getMessage()).thenReturn("Invalid field: [ism_template]"); - assertEquals(Optional.of("raw-span-policy"), traceAnalyticsRawIndexManager.checkAndCreatePolicy()); + assertEquals(Optional.of("raw-span-policy"), traceAnalyticsRawIndexManager.checkAndCreatePolicy(INDEX_ALIAS)); verify(restHighLevelClient, times(2)).getLowLevelClient(); verify(restClient, times(2)).performRequest(any()); verify(openSearchSinkConfiguration).getIndexConfiguration(); diff --git a/data-prepper-plugins/opensearch/src/test/java/org/opensearch/dataprepper/plugins/sink/opensearch/index/TraceAnalyticsServiceMapIndexManagerTests.java b/data-prepper-plugins/opensearch/src/test/java/org/opensearch/dataprepper/plugins/sink/opensearch/index/TraceAnalyticsServiceMapIndexManagerTests.java index 442218eec4..d928a67ac1 100644 --- a/data-prepper-plugins/opensearch/src/test/java/org/opensearch/dataprepper/plugins/sink/opensearch/index/TraceAnalyticsServiceMapIndexManagerTests.java +++ b/data-prepper-plugins/opensearch/src/test/java/org/opensearch/dataprepper/plugins/sink/opensearch/index/TraceAnalyticsServiceMapIndexManagerTests.java @@ -169,7 +169,7 @@ void checkISMEnabledByDefault_False() throws IOException { @Test void checkAndCreatePolicy() throws IOException { - assertEquals(Optional.empty(), traceAnalyticsServiceMapIndexManager.checkAndCreatePolicy()); + assertEquals(Optional.empty(), traceAnalyticsServiceMapIndexManager.checkAndCreatePolicy(INDEX_ALIAS)); verify(openSearchSinkConfiguration).getIndexConfiguration(); verify(indexConfiguration).getIndexAlias(); }