Fix compilation issues for tests. (#29)
Some of the tests that use the x-pack code are failing compilation. This PR cleans up the references to fix the issue. Signed-off-by: Peter Nied <petern@amazon.com>
This commit is contained in:
parent
38e9c9750a
commit
171ce992e4
|
@ -85,7 +85,6 @@ import org.elasticsearch.search.sort.SortOrder;
|
|||
import org.elasticsearch.search.suggest.Suggest;
|
||||
import org.elasticsearch.search.suggest.SuggestBuilder;
|
||||
import org.elasticsearch.search.suggest.phrase.PhraseSuggestionBuilder;
|
||||
import org.elasticsearch.xpack.core.index.query.PinnedQueryBuilder;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Before;
|
||||
|
||||
|
@ -1385,8 +1384,6 @@ public class SearchIT extends ESRestHighLevelClientTestCase {
|
|||
public void testSearchWithBasicLicensedQuery() throws IOException {
|
||||
SearchRequest searchRequest = new SearchRequest("index");
|
||||
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
|
||||
PinnedQueryBuilder pinnedQuery = new PinnedQueryBuilder(new MatchAllQueryBuilder(), "2", "1");
|
||||
searchSourceBuilder.query(pinnedQuery);
|
||||
searchRequest.source(searchSourceBuilder);
|
||||
SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync);
|
||||
assertSearchHeader(searchResponse);
|
||||
|
|
|
@ -20,8 +20,6 @@
|
|||
package org.elasticsearch.client.documentation;
|
||||
|
||||
import org.apache.http.HttpHost;
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.LatchedActionListener;
|
||||
import org.elasticsearch.client.ESRestHighLevelClientTestCase;
|
||||
import org.elasticsearch.client.RequestOptions;
|
||||
import org.elasticsearch.client.RestClient;
|
||||
|
@ -29,14 +27,6 @@ import org.elasticsearch.client.RestHighLevelClient;
|
|||
import org.elasticsearch.client.core.MainResponse;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.Instant;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.hamcrest.Matchers.greaterThan;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
|
||||
/**
|
||||
* Documentation for miscellaneous APIs in the high level java client.
|
||||
|
|
|
@ -1,112 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.client.indices;
|
||||
|
||||
import org.elasticsearch.action.support.DefaultShardOperationFailedException;
|
||||
import org.elasticsearch.client.AbstractResponseTestCase;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.index.seqno.RetentionLeaseNotFoundException;
|
||||
import org.elasticsearch.xpack.core.action.ReloadAnalyzersResponse.ReloadDetails;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.hasSize;
|
||||
import static org.hamcrest.Matchers.in;
|
||||
|
||||
public class ReloadAnalyzersResponseTests
|
||||
extends AbstractResponseTestCase<org.elasticsearch.xpack.core.action.ReloadAnalyzersResponse, ReloadAnalyzersResponse> {
|
||||
|
||||
private String index;
|
||||
private String id;
|
||||
private Set<Integer> shardIds;
|
||||
|
||||
@Override
|
||||
protected org.elasticsearch.xpack.core.action.ReloadAnalyzersResponse createServerTestInstance(XContentType xContentType) {
|
||||
index = randomAlphaOfLength(8);
|
||||
id = randomAlphaOfLength(8);
|
||||
final int total = randomIntBetween(1, 16);
|
||||
final int successful = total - scaledRandomIntBetween(0, total);
|
||||
final int failed = scaledRandomIntBetween(0, total - successful);
|
||||
final List<DefaultShardOperationFailedException> failures = new ArrayList<>();
|
||||
shardIds = new HashSet<>();
|
||||
for (int i = 0; i < failed; i++) {
|
||||
final DefaultShardOperationFailedException failure = new DefaultShardOperationFailedException(
|
||||
index,
|
||||
randomValueOtherThanMany(shardIds::contains, () -> randomIntBetween(0, total - 1)),
|
||||
new RetentionLeaseNotFoundException(id));
|
||||
failures.add(failure);
|
||||
shardIds.add(failure.shardId());
|
||||
}
|
||||
Map<String, ReloadDetails> reloadedDetailsMap = new HashMap<>();
|
||||
int randomIndices = randomIntBetween(0, 5);
|
||||
for (int i = 0; i < randomIndices; i++) {
|
||||
String indexName = randomAlphaOfLengthBetween(5, 10);
|
||||
Set<String> randomNodeIds = new HashSet<>(Arrays.asList(generateRandomStringArray(5, 5, false, true)));
|
||||
Set<String> randomAnalyzers = new HashSet<>(Arrays.asList(generateRandomStringArray(5, 5, false, true)));
|
||||
|
||||
ReloadDetails reloadedDetails = new ReloadDetails(indexName, randomNodeIds, randomAnalyzers);
|
||||
reloadedDetailsMap.put(indexName, reloadedDetails);
|
||||
}
|
||||
return new org.elasticsearch.xpack.core.action.ReloadAnalyzersResponse(total, successful, failed, failures, reloadedDetailsMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReloadAnalyzersResponse doParseToClientInstance(XContentParser parser) throws IOException {
|
||||
return ReloadAnalyzersResponse.fromXContent(parser);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void assertInstances(org.elasticsearch.xpack.core.action.ReloadAnalyzersResponse serverTestInstance,
|
||||
ReloadAnalyzersResponse clientInstance) {
|
||||
assertThat(clientInstance.shards().total(), equalTo(serverTestInstance.getTotalShards()));
|
||||
assertThat(clientInstance.shards().successful(), equalTo(serverTestInstance.getSuccessfulShards()));
|
||||
assertThat(clientInstance.shards().skipped(), equalTo(0));
|
||||
assertThat(clientInstance.shards().failed(), equalTo(serverTestInstance.getFailedShards()));
|
||||
assertThat(clientInstance.shards().failures(), hasSize(clientInstance.shards().failed() == 0 ? 0 : 1)); // failures are grouped
|
||||
if (clientInstance.shards().failed() > 0) {
|
||||
final DefaultShardOperationFailedException groupedFailure = clientInstance.shards().failures().iterator().next();
|
||||
assertThat(groupedFailure.index(), equalTo(index));
|
||||
assertThat(groupedFailure.shardId(), in(shardIds));
|
||||
assertThat(groupedFailure.reason(), containsString("reason=retention lease with ID [" + id + "] not found"));
|
||||
}
|
||||
Map<String, ReloadDetails> serverDetails = serverTestInstance.getReloadDetails();
|
||||
assertThat(clientInstance.getReloadedDetails().size(), equalTo(serverDetails.size()));
|
||||
for (Entry<String, org.elasticsearch.client.indices.ReloadAnalyzersResponse.ReloadDetails> entry : clientInstance
|
||||
.getReloadedDetails().entrySet()) {
|
||||
String indexName = entry.getKey();
|
||||
assertTrue(serverDetails.keySet().contains(indexName));
|
||||
assertEquals(serverDetails.get(indexName).getIndexName(), entry.getValue().getIndexName());
|
||||
assertEquals(serverDetails.get(indexName).getReloadedAnalyzers(), entry.getValue().getReloadedAnalyzers());
|
||||
assertEquals(serverDetails.get(indexName).getReloadedIndicesNodes(), entry.getValue().getReloadedIndicesNodes());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue