Skip to content

Commit

Permalink
Revisit tests and new version options (#298)
Browse files Browse the repository at this point in the history
* Switch to OpenSearch: updating references and imports ES -> OS

* OpenSearch upgrade: minor code clean up updates

* OpenSearch upgrade: comments and variable names updates

* OpenSearch upgrade: comment updates

* Code cleanup tweaks

* OpenSearch: added OpenSearchRunner for integration tests

* Fix test class name so test are executed when building

* Revisit tests and new search options
  • Loading branch information
jmendeza authored Apr 24, 2023
1 parent caea471 commit 3c344cb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,6 @@ public SearchRequestWrapper(SearchRequest request, Map<String, Object> parameter
maxConcurrentShardRequests(request.maxConcurrentShardRequests());
minCompatibleShardNode(request.minCompatibleShardNode());
minScore(request.minScore());
// TODO: JM: Review
// pit(request.pit());
postFilter(request.postFilter());
preFilterShardSize(request.preFilterShardSize());
preference(request.preference());
Expand All @@ -258,8 +256,6 @@ public SearchRequestWrapper(SearchRequest request, Map<String, Object> parameter
timeout(request.timeout());
trackScores(request.trackScores());
trackTotalHits(request.trackTotalHits());
// TODO: JM: Review
// type(request.type());
version(request.version());

// override values
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,9 @@
import java.util.List;
import java.util.Map;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.*;
import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.*;

/**
* Unit tests for {@link OpenSearchBinaryFileWithMetadataBatchIndexer}.
Expand Down Expand Up @@ -112,7 +110,7 @@ public void testUpdateMetadataWithRemovedBinaries() {


// TODO: JM: Revisit test case
// @Test
@Test
public void testUpdateBinary() {
setupMetadataSearchResult();

Expand All @@ -121,24 +119,24 @@ public void testUpdateBinary() {

batchIndexer.updateIndex(INDEX_ID, SITE_NAME, contentStoreService, context, updateSet, updateStatus);

assertEquals(1, updateStatus.getAttemptedUpdatesAndDeletes());
assertTrue(updateStatus.getSuccessfulUpdates().contains(BINARY_FILENAME1));
verify(searchService).indexBinary(
eq(INDEX_ID), eq(SITE_NAME), eq(BINARY_FILENAME1), any(Content.class), eq(getExpectedMetadata()));
// Binary files are no longer processed by AbstractBinaryFileWithMetadataBatchIndexer
assertEquals(0, updateStatus.getAttemptedUpdatesAndDeletes());
assertFalse(updateStatus.getSuccessfulUpdates().contains(BINARY_FILENAME1));
verify(searchService, times(0)).indexBinary(
eq(INDEX_ID), eq(SITE_NAME), eq(BINARY_FILENAME1), any(Content.class), eq(getExpectedMetadata()));
}


// TODO: JM: Revisit test case
// @Test
@Test
public void testDeleteBinary() {
UpdateSet updateSet = new UpdateSet(Collections.emptyList(), Collections.singletonList(BINARY_FILENAME1));
UpdateStatus updateStatus = new UpdateStatus();

batchIndexer.updateIndex(INDEX_ID, SITE_NAME, contentStoreService, context, updateSet, updateStatus);

assertEquals(1, updateStatus.getAttemptedUpdatesAndDeletes());
assertTrue(updateStatus.getSuccessfulDeletes().contains(BINARY_FILENAME1));
verify(searchService).delete(eq(INDEX_ID), eq(SITE_NAME), eq(BINARY_FILENAME1));
// Binary files are no longer processed by AbstractBinaryFileWithMetadataBatchIndexer
assertEquals(0, updateStatus.getAttemptedUpdatesAndDeletes());
assertFalse(updateStatus.getSuccessfulDeletes().contains(BINARY_FILENAME1));
verify(searchService, times(0)).delete(eq(INDEX_ID), eq(SITE_NAME), eq(BINARY_FILENAME1));
}

@Test
Expand All @@ -165,7 +163,7 @@ protected void setupBinariesSearchResults() {
}

protected void setupMetadataSearchResult() {
when(searchService.searchField(eq(INDEX_ID), eq("metadataPath"), any()))
lenient().when(searchService.searchField(eq(INDEX_ID), eq("metadataPath"), any()))
.thenReturn(List.of(getExpectedMetadata().get("metadataPath").toString()));
}

Expand Down

0 comments on commit 3c344cb

Please sign in to comment.