Skip to content

Commit

Permalink
Remarks after CR applied to DNFOF tests
Browse files Browse the repository at this point in the history
Signed-off-by: Lukasz Soszynski <lukasz.soszynski@eliatra.com>
  • Loading branch information
lukasz-soszynski-eliatra committed Oct 24, 2022
1 parent e1a6920 commit 3636588
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,9 @@

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.aMapWithSize;
import static org.hamcrest.Matchers.arrayContaining;
import static org.hamcrest.Matchers.arrayContainingInAnyOrder;
import static org.hamcrest.Matchers.arrayWithSize;
import static org.hamcrest.Matchers.hasKey;
import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.nullValue;
import static org.opensearch.action.admin.indices.alias.IndicesAliasesRequest.AliasActions.Type.ADD;
import static org.opensearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE;
Expand Down Expand Up @@ -125,13 +123,17 @@ public void shouldPerformSimpleSearch_positive() throws IOException {

SearchResponse searchResponse = restHighLevelClient.search(searchRequest, DEFAULT);

assertThat(searchResponse, isSuccessfulSearchResponse());
assertThat(searchResponse, numberOfTotalHitsIsEqualTo(1));
assertThat(searchResponse, searchHitsContainDocumentWithId(0, MARVELOUS_SONGS, "1"));
assertThat(searchResponse, searchHitContainsFieldWithValue(0, FIELD_TITLE, TITLE_MAGNUM_OPUS));
assertThatContainOneSong(searchResponse, "1", TITLE_MAGNUM_OPUS);
}
}

private static void assertThatContainOneSong(SearchResponse searchResponse, String documentId, String title) {
assertThat(searchResponse, isSuccessfulSearchResponse());
assertThat(searchResponse, numberOfTotalHitsIsEqualTo(1));
assertThat(searchResponse, searchHitsContainDocumentWithId(0, MARVELOUS_SONGS, documentId));
assertThat(searchResponse, searchHitContainsFieldWithValue(0, FIELD_TITLE, title));
}

@Test
public void shouldPerformSimpleSearch_negative() throws IOException {
try (RestHighLevelClient restHighLevelClient = cluster.getRestHighLevelClient(LIMITED_USER)) {
Expand All @@ -148,10 +150,7 @@ public void shouldSearchForDocumentsViaIndexPattern_positive() throws IOExceptio

SearchResponse searchResponse = restHighLevelClient.search(searchRequest, DEFAULT);

assertThat(searchResponse, isSuccessfulSearchResponse());
assertThat(searchResponse, numberOfTotalHitsIsEqualTo(1));
assertThat(searchResponse, searchHitsContainDocumentWithId(0, MARVELOUS_SONGS, "1"));
assertThat(searchResponse, searchHitContainsFieldWithValue(0, FIELD_TITLE, TITLE_MAGNUM_OPUS));
assertThatContainOneSong(searchResponse, "1", TITLE_MAGNUM_OPUS);
}
}

Expand All @@ -171,10 +170,7 @@ public void shouldSearchForDocumentsViaAlias_positive() throws IOException {

SearchResponse searchResponse = restHighLevelClient.search(searchRequest, DEFAULT);

assertThat(searchResponse, isSuccessfulSearchResponse());
assertThat(searchResponse, numberOfTotalHitsIsEqualTo(1));
assertThat(searchResponse, searchHitsContainDocumentWithId(0, MARVELOUS_SONGS, "1"));
assertThat(searchResponse, searchHitContainsFieldWithValue(0, FIELD_TITLE, TITLE_MAGNUM_OPUS));
assertThatContainOneSong(searchResponse, "1", TITLE_MAGNUM_OPUS);
}
}

Expand All @@ -194,10 +190,7 @@ public void shouldSearchForDocumentsViaAll_positive() throws IOException {

SearchResponse searchResponse = restHighLevelClient.search(searchRequest, DEFAULT);

assertThat(searchResponse, isSuccessfulSearchResponse());
assertThat(searchResponse, numberOfTotalHitsIsEqualTo(1));
assertThat(searchResponse, searchHitsContainDocumentWithId(0, MARVELOUS_SONGS, "1"));
assertThat(searchResponse, searchHitContainsFieldWithValue(0, FIELD_TITLE, TITLE_MAGNUM_OPUS));
assertThatContainOneSong(searchResponse, "1", TITLE_MAGNUM_OPUS);
}
}

Expand All @@ -222,13 +215,8 @@ public void shouldMSearchDocument_positive() throws IOException {

MultiSearchResponse response = restHighLevelClient.msearch(request, DEFAULT);

assertThat(response, notNullValue());
MultiSearchResponse.Item[] responses = response.getResponses();
assertThat(responses, Matchers.arrayWithSize(2));
assertThat(responses, arrayContaining(
notNullValue(),
notNullValue()
));
assertThat(responses[0].getFailure(), nullValue());
assertThat(responses[1].getFailure(), nullValue());

Expand Down Expand Up @@ -256,7 +244,6 @@ public void shouldGetFieldCapabilities_positive() throws IOException {

FieldCapabilitiesResponse response = restHighLevelClient.fieldCaps(request, DEFAULT);

assertThat(response, notNullValue());
assertThat(response.get(), aMapWithSize(1));
assertThat(response.getIndices(), arrayWithSize(1));
assertThat(response.getField(FIELD_TITLE), hasKey("text"));
Expand Down
2 changes: 0 additions & 2 deletions src/integrationTest/resources/log4j2-test.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,3 @@ logger.testsecconfig.name=org.opensearch.test.framework.TestSecurityConfig
logger.testsecconfig.level = info
logger.localopensearchcluster.name=org.opensearch.test.framework.cluster.LocalOpenSearchCluster
logger.localopensearchcluster.level = info
logger.eveluator.name=org.opensearch.security.privileges.PrivilegesEvaluator
logger.eveluator.level=debug

0 comments on commit 3636588

Please sign in to comment.