From 904a9665c695a1c0269bc984a7a91cc70f499423 Mon Sep 17 00:00:00 2001 From: Darshit Chanpura <35282393+DarshitChanpura@users.noreply.github.com> Date: Mon, 16 Oct 2023 22:26:29 -0400 Subject: [PATCH] Revert "Refactors CrossClusterSearchTests to fix flaky behavior" (#3552) Reverts opensearch-project/security#3526 as the exit criteria was not satisfied. --- .../security/CrossClusterSearchTests.java | 50 ++++++++++--------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/src/integrationTest/java/org/opensearch/security/CrossClusterSearchTests.java b/src/integrationTest/java/org/opensearch/security/CrossClusterSearchTests.java index b45cb8143a..d9e4d2b5f3 100644 --- a/src/integrationTest/java/org/opensearch/security/CrossClusterSearchTests.java +++ b/src/integrationTest/java/org/opensearch/security/CrossClusterSearchTests.java @@ -12,7 +12,6 @@ import java.io.IOException; import java.util.List; import java.util.Map; -import java.util.Arrays; import com.carrotsearch.randomizedtesting.annotations.ParametersFactory; import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope; @@ -246,17 +245,18 @@ public void shouldSearchForDocumentOnBothClustersWhenIndexOnBothClusterArePointe SearchRequest searchRequest = SearchRequestFactory.searchAll(REMOTE_SONG_INDEX, SONG_INDEX_NAME); searchRequest.setCcsMinimizeRoundtrips(ccsMinimizeRoundtrips); - List> documentIdsList = Arrays.asList( - Pair.of(SONG_INDEX_NAME, SONG_ID_1R), - Pair.of(SONG_INDEX_NAME, SONG_ID_2L), - Pair.of(SONG_INDEX_NAME, SONG_ID_6R) - ); - SearchResponse response = restHighLevelClient.search(searchRequest, DEFAULT); assertThat(response, isSuccessfulSearchResponse()); assertThat(response, numberOfTotalHitsIsEqualTo(3)); - assertThat(response, searchHitsContainDocumentsInAnyOrder(documentIdsList)); + assertThat( + response, + searchHitsContainDocumentsInAnyOrder( + Pair.of(SONG_INDEX_NAME, SONG_ID_1R), + Pair.of(SONG_INDEX_NAME, SONG_ID_2L), + Pair.of(SONG_INDEX_NAME, SONG_ID_6R) + ) + ); } } @@ -286,18 +286,19 @@ public void shouldSearchViaAllAliasOnRemoteCluster_positive() throws IOException try (RestHighLevelClient restHighLevelClient = cluster.getRestHighLevelClient(ADMIN_USER)) { SearchRequest searchRequest = searchAll(REMOTE_CLUSTER_NAME + ":_all"); - List> documentIdsList = Arrays.asList( - Pair.of(SONG_INDEX_NAME, SONG_ID_1R), - Pair.of(SONG_INDEX_NAME, SONG_ID_6R), - Pair.of(PROHIBITED_SONG_INDEX_NAME, SONG_ID_3R), - Pair.of(LIMITED_USER_INDEX_NAME, SONG_ID_5R) - ); - SearchResponse response = restHighLevelClient.search(searchRequest, DEFAULT); assertThat(response, isSuccessfulSearchResponse()); assertThat(response, numberOfTotalHitsIsEqualTo(4)); - assertThat(response, searchHitsContainDocumentsInAnyOrder(documentIdsList)); + assertThat( + response, + searchHitsContainDocumentsInAnyOrder( + Pair.of(SONG_INDEX_NAME, SONG_ID_1R), + Pair.of(SONG_INDEX_NAME, SONG_ID_6R), + Pair.of(PROHIBITED_SONG_INDEX_NAME, SONG_ID_3R), + Pair.of(LIMITED_USER_INDEX_NAME, SONG_ID_5R) + ) + ); } } @@ -315,18 +316,19 @@ public void shouldSearchAllIndexOnRemoteClusterWhenStarIsUsedAsIndexName_positiv try (RestHighLevelClient restHighLevelClient = cluster.getRestHighLevelClient(ADMIN_USER)) { SearchRequest searchRequest = searchAll(REMOTE_CLUSTER_NAME + ":*"); - List> documentIdsList = Arrays.asList( - Pair.of(SONG_INDEX_NAME, SONG_ID_1R), - Pair.of(SONG_INDEX_NAME, SONG_ID_6R), - Pair.of(PROHIBITED_SONG_INDEX_NAME, SONG_ID_3R), - Pair.of(LIMITED_USER_INDEX_NAME, SONG_ID_5R) - ); - SearchResponse response = restHighLevelClient.search(searchRequest, DEFAULT); assertThat(response, isSuccessfulSearchResponse()); assertThat(response, numberOfTotalHitsIsEqualTo(4)); - assertThat(response, searchHitsContainDocumentsInAnyOrder(documentIdsList)); + assertThat( + response, + searchHitsContainDocumentsInAnyOrder( + Pair.of(SONG_INDEX_NAME, SONG_ID_1R), + Pair.of(SONG_INDEX_NAME, SONG_ID_6R), + Pair.of(PROHIBITED_SONG_INDEX_NAME, SONG_ID_3R), + Pair.of(LIMITED_USER_INDEX_NAME, SONG_ID_5R) + ) + ); } }