use of com.yelp.nrtsearch.server.luceneserver.IndexState in project nrtsearch by Yelp.
the class WarmerTest method testWarmFromS3_parallel.
@Test
public void testWarmFromS3_parallel() throws IOException, SearchHandler.SearchHandlerException, InterruptedException {
Path warmingQueriesDir = folder.newFolder("warming_queries").toPath();
int warmingCountPerQuery = 10;
try (BufferedWriter writer = Files.newBufferedWriter(warmingQueriesDir.resolve("warming_queries.txt"))) {
List<String> testSearchRequestsJson = getTestSearchRequestsAsJsonStrings();
List<String> moreTestSearchRequestsJson = new ArrayList<>();
for (int i = 0; i < warmingCountPerQuery; i++) {
moreTestSearchRequestsJson.addAll(testSearchRequestsJson);
}
for (String line : moreTestSearchRequestsJson) {
writer.write(line);
writer.newLine();
}
writer.flush();
}
String versionHash = archiver.upload(service, resource, warmingQueriesDir, List.of(), List.of(), false);
archiver.blessVersion(service, resource, versionHash);
IndexState mockIndexState = mock(IndexState.class);
SearchHandler mockSearchHandler = mock(SearchHandler.class);
warmer.warmFromS3(mockIndexState, 3, mockSearchHandler);
for (SearchRequest testRequest : getTestSearchRequests()) {
verify(mockSearchHandler, times(warmingCountPerQuery)).handle(mockIndexState, testRequest);
}
verifyNoMoreInteractions(mockSearchHandler);
}
use of com.yelp.nrtsearch.server.luceneserver.IndexState in project nrtsearch by Yelp.
the class WarmerTest method testWarmFromS3.
@Test
public void testWarmFromS3() throws IOException, SearchHandler.SearchHandlerException, InterruptedException {
Path warmingQueriesDir = folder.newFolder("warming_queries").toPath();
try (BufferedWriter writer = Files.newBufferedWriter(warmingQueriesDir.resolve("warming_queries.txt"))) {
List<String> testSearchRequestsJson = getTestSearchRequestsAsJsonStrings();
for (String line : testSearchRequestsJson) {
writer.write(line);
writer.newLine();
}
writer.flush();
}
String versionHash = archiver.upload(service, resource, warmingQueriesDir, List.of(), List.of(), false);
archiver.blessVersion(service, resource, versionHash);
IndexState mockIndexState = mock(IndexState.class);
SearchHandler mockSearchHandler = mock(SearchHandler.class);
warmer.warmFromS3(mockIndexState, 0, mockSearchHandler);
for (SearchRequest testRequest : getTestSearchRequests()) {
verify(mockSearchHandler).handle(mockIndexState, testRequest);
}
verifyNoMoreInteractions(mockSearchHandler);
}
use of com.yelp.nrtsearch.server.luceneserver.IndexState in project nrtsearch by Yelp.
the class WarmerTest method testWarmFromS3_multiple.
@Test
public void testWarmFromS3_multiple() throws IOException, SearchHandler.SearchHandlerException, InterruptedException {
Path warmingQueriesDir = folder.newFolder("warming_queries").toPath();
try (BufferedWriter writer = Files.newBufferedWriter(warmingQueriesDir.resolve("warming_queries.txt"))) {
List<String> testSearchRequestsJson = getTestSearchRequestsAsJsonStrings();
for (String line : testSearchRequestsJson) {
writer.write(line);
writer.newLine();
}
writer.flush();
}
String versionHash = archiver.upload(service, resource, warmingQueriesDir, List.of(), List.of(), false);
archiver.blessVersion(service, resource, versionHash);
IndexState mockIndexState = mock(IndexState.class);
SearchHandler mockSearchHandler = mock(SearchHandler.class);
warmer.warmFromS3(mockIndexState, 0, mockSearchHandler);
warmer.warmFromS3(mockIndexState, 0, mockSearchHandler);
for (SearchRequest testRequest : getTestSearchRequests()) {
verify(mockSearchHandler, times(2)).handle(mockIndexState, testRequest);
}
verifyNoMoreInteractions(mockSearchHandler);
}
use of com.yelp.nrtsearch.server.luceneserver.IndexState in project nrtsearch by Yelp.
the class DocCollectorTest method testOverrideDefaultTerminateAfter.
@Test
public void testOverrideDefaultTerminateAfter() {
IndexState indexState = Mockito.mock(IndexState.class);
when(indexState.getDefaultTerminateAfter()).thenReturn(100);
SearchRequest request = SearchRequest.newBuilder().setTopHits(10).setTerminateAfter(75).build();
TestDocCollector docCollector = new TestDocCollector(request, indexState);
assertTrue(docCollector.getManager() instanceof TestDocCollector.TestCollectorManager);
assertTrue(docCollector.getWrappedManager() instanceof TerminateAfterWrapper);
assertEquals(75, ((TerminateAfterWrapper<?>) docCollector.getWrappedManager()).getTerminateAfter());
}
use of com.yelp.nrtsearch.server.luceneserver.IndexState in project nrtsearch by Yelp.
the class DocCollectorTest method testUsesDefaultTerminateAfter.
@Test
public void testUsesDefaultTerminateAfter() {
IndexState indexState = Mockito.mock(IndexState.class);
when(indexState.getDefaultTerminateAfter()).thenReturn(100);
SearchRequest request = SearchRequest.newBuilder().setTopHits(10).build();
TestDocCollector docCollector = new TestDocCollector(request, indexState);
assertTrue(docCollector.getManager() instanceof TestDocCollector.TestCollectorManager);
assertTrue(docCollector.getWrappedManager() instanceof TerminateAfterWrapper);
assertEquals(100, ((TerminateAfterWrapper<?>) docCollector.getWrappedManager()).getTerminateAfter());
}
Aggregations