mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-17 02:14:54 +00:00
Disambiguate TestCluster implementation since Client is now also Closeable and if we call IOUtils it might interpret it as a Iterable<Closeable>
This commit is contained in:
parent
0bcee2df37
commit
15841081f6
@ -279,7 +279,7 @@ public class MinimumMasterNodesIT extends ESIntegTestCase {
|
||||
setMinimumMasterNodes(2);
|
||||
|
||||
// make sure it has been processed on all nodes (master node spawns a secondary cluster state update task)
|
||||
for (Client client : internalCluster()) {
|
||||
for (Client client : internalCluster().getClients()) {
|
||||
assertThat(client.admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setLocal(true).get().isTimedOut(),
|
||||
equalTo(false));
|
||||
}
|
||||
@ -303,7 +303,7 @@ public class MinimumMasterNodesIT extends ESIntegTestCase {
|
||||
assertTrue(awaitBusy(
|
||||
() -> {
|
||||
boolean success = true;
|
||||
for (Client client : internalCluster()) {
|
||||
for (Client client : internalCluster().getClients()) {
|
||||
boolean clientHasNoMasterBlock = hasNoMasterBlock.test(client);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Checking for NO_MASTER_BLOCK on client: {} NO_MASTER_BLOCK: [{}]", client, clientHasNoMasterBlock);
|
||||
|
@ -167,7 +167,7 @@ public class UpdateMappingOnClusterIT extends ESIntegTestCase {
|
||||
|
||||
private void compareMappingOnNodes(GetMappingsResponse previousMapping) {
|
||||
// make sure all nodes have same cluster state
|
||||
for (Client client : cluster()) {
|
||||
for (Client client : cluster().getClients()) {
|
||||
GetMappingsResponse currentMapping = client.admin().indices().prepareGetMappings(INDEX).addTypes(TYPE).setLocal(true).get();
|
||||
assertThat(previousMapping.getMappings().get(INDEX).get(TYPE).source(), equalTo(currentMapping.getMappings().get(INDEX).get(TYPE).source()));
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ public class SimpleValidateQueryIT extends ESIntegTestCase {
|
||||
|
||||
refresh();
|
||||
|
||||
for (Client client : internalCluster()) {
|
||||
for (Client client : internalCluster().getClients()) {
|
||||
ValidateQueryResponse response = client.admin().indices().prepareValidateQuery("test")
|
||||
.setQuery(QueryBuilders.wrapperQuery("foo".getBytes(StandardCharsets.UTF_8)))
|
||||
.setExplain(true)
|
||||
@ -104,7 +104,7 @@ public class SimpleValidateQueryIT extends ESIntegTestCase {
|
||||
|
||||
}
|
||||
|
||||
for (Client client : internalCluster()) {
|
||||
for (Client client : internalCluster().getClients()) {
|
||||
ValidateQueryResponse response = client.admin().indices().prepareValidateQuery("test")
|
||||
.setQuery(QueryBuilders.queryStringQuery("foo"))
|
||||
.setExplain(true)
|
||||
|
@ -241,8 +241,8 @@ public class CompositeTestCluster extends TestCluster {
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized Iterator<Client> iterator() {
|
||||
return Collections.singleton(client()).iterator();
|
||||
public synchronized Iterable<Client> getClients() {
|
||||
return Collections.singleton(client());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -129,6 +129,7 @@ import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.annotation.Annotation;
|
||||
@ -675,7 +676,7 @@ public abstract class ESIntegTestCase extends ESTestCase {
|
||||
}
|
||||
|
||||
public static Iterable<Client> clients() {
|
||||
return cluster();
|
||||
return cluster().getClients();
|
||||
}
|
||||
|
||||
protected int minimumNumberOfShards() {
|
||||
@ -1099,7 +1100,7 @@ public abstract class ESIntegTestCase extends ESTestCase {
|
||||
Map<String, Object> masterStateMap = convertToMap(masterClusterState);
|
||||
int masterClusterStateSize = masterClusterState.toString().length();
|
||||
String masterId = masterClusterState.nodes().masterNodeId();
|
||||
for (Client client : cluster()) {
|
||||
for (Client client : cluster().getClients()) {
|
||||
ClusterState localClusterState = client.admin().cluster().prepareState().all().setLocal(true).get().getState();
|
||||
byte[] localClusterStateBytes = ClusterState.Builder.toBytes(localClusterState);
|
||||
// remove local node reference
|
||||
|
@ -167,8 +167,8 @@ public final class ExternalTestCluster extends TestCluster {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Client> iterator() {
|
||||
return Collections.singleton(client).iterator();
|
||||
public Iterable<Client> getClients() {
|
||||
return Collections.singleton(client);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1720,27 +1720,29 @@ public final class InternalTestCluster extends TestCluster {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized Iterator<Client> iterator() {
|
||||
public synchronized Iterable<Client> getClients() {
|
||||
ensureOpen();
|
||||
final Iterator<NodeAndClient> iterator = nodes.values().iterator();
|
||||
return new Iterator<Client>() {
|
||||
return () -> {
|
||||
ensureOpen();
|
||||
final Iterator<NodeAndClient> iterator = nodes.values().iterator();
|
||||
return new Iterator<Client>() {
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return iterator.hasNext();
|
||||
}
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return iterator.hasNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Client next() {
|
||||
return iterator.next().client(random);
|
||||
}
|
||||
@Override
|
||||
public Client next() {
|
||||
return iterator.next().client(random);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException("");
|
||||
}
|
||||
@Override
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException("");
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcke
|
||||
* Base test cluster that exposes the basis to run tests against any elasticsearch cluster, whose layout
|
||||
* (e.g. number of nodes) is predefined and cannot be changed during the tests execution
|
||||
*/
|
||||
public abstract class TestCluster implements Iterable<Client>, Closeable {
|
||||
public abstract class TestCluster implements Closeable {
|
||||
|
||||
protected final ESLogger logger = Loggers.getLogger(getClass());
|
||||
private final long seed;
|
||||
@ -228,5 +228,10 @@ public abstract class TestCluster implements Iterable<Client>, Closeable {
|
||||
*/
|
||||
public abstract String getClusterName();
|
||||
|
||||
/**
|
||||
* Returns an {@link Iterable} over all clients in this test cluster
|
||||
*/
|
||||
public abstract Iterable<Client> getClients();
|
||||
|
||||
|
||||
}
|
||||
|
@ -130,8 +130,8 @@ public class InternalTestClusterTests extends ESTestCase {
|
||||
cluster1.beforeTest(random, random.nextDouble());
|
||||
}
|
||||
assertArrayEquals(cluster0.getNodeNames(), cluster1.getNodeNames());
|
||||
Iterator<Client> iterator1 = cluster1.iterator();
|
||||
for (Client client : cluster0) {
|
||||
Iterator<Client> iterator1 = cluster1.getClients().iterator();
|
||||
for (Client client : cluster0.getClients()) {
|
||||
assertTrue(iterator1.hasNext());
|
||||
Client other = iterator1.next();
|
||||
assertSettings(client.settings(), other.settings(), false);
|
||||
|
Loading…
x
Reference in New Issue
Block a user