TESTS: Remove Dead Code in Test Infra. (#34548)
* None of this infrastructure is used * Some redundant throws and resulting catch code removed
This commit is contained in:
parent
b0e98cbce2
commit
08d4bf6e84
|
@ -213,11 +213,7 @@ public class TransportClientNodesServiceTests extends ESTestCase {
|
|||
transport.endConnectMode();
|
||||
transportService.stop();
|
||||
transportClientNodesService.close();
|
||||
try {
|
||||
terminate(threadPool);
|
||||
} catch (InterruptedException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -69,11 +69,7 @@ public class TransportActionProxyTests extends ESTestCase {
|
|||
public void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
IOUtils.close(serviceA, serviceB, serviceC, () -> {
|
||||
try {
|
||||
terminate(threadPool);
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,6 @@ import org.elasticsearch.action.admin.indices.segments.ShardSegments;
|
|||
import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequestBuilder;
|
||||
import org.elasticsearch.action.bulk.BulkRequestBuilder;
|
||||
import org.elasticsearch.action.bulk.BulkResponse;
|
||||
import org.elasticsearch.action.get.GetResponse;
|
||||
import org.elasticsearch.action.index.IndexRequestBuilder;
|
||||
import org.elasticsearch.action.index.IndexResponse;
|
||||
import org.elasticsearch.action.search.ClearScrollResponse;
|
||||
|
@ -183,7 +182,6 @@ import java.util.Set;
|
|||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
@ -382,8 +380,6 @@ public abstract class ESIntegTestCase extends ESTestCase {
|
|||
case TEST:
|
||||
currentCluster = buildAndPutCluster(currentClusterScope, randomLong());
|
||||
break;
|
||||
default:
|
||||
fail("Unknown Scope: [" + currentClusterScope + "]");
|
||||
}
|
||||
cluster().beforeTest(random(), getPerTestTransportClientRatio());
|
||||
cluster().wipe(excludeTemplates());
|
||||
|
@ -402,7 +398,7 @@ public abstract class ESIntegTestCase extends ESTestCase {
|
|||
* Creates a randomized index template. This template is used to pass in randomized settings on a
|
||||
* per index basis. Allows to enable/disable the randomization for number of shards and replicas
|
||||
*/
|
||||
public void randomIndexTemplate() throws IOException {
|
||||
public void randomIndexTemplate() {
|
||||
|
||||
// TODO move settings for random directory etc here into the index based randomized settings.
|
||||
if (cluster().size() > 0) {
|
||||
|
@ -798,12 +794,12 @@ public abstract class ESIntegTestCase extends ESTestCase {
|
|||
|
||||
if (numNodes > 0) {
|
||||
internalCluster().ensureAtLeastNumDataNodes(numNodes);
|
||||
getExcludeSettings(index, numNodes, builder);
|
||||
getExcludeSettings(numNodes, builder);
|
||||
}
|
||||
return client().admin().indices().prepareCreate(index).setSettings(builder.build());
|
||||
}
|
||||
|
||||
private Settings.Builder getExcludeSettings(String index, int num, Settings.Builder builder) {
|
||||
private Settings.Builder getExcludeSettings(int num, Settings.Builder builder) {
|
||||
String exclude = String.join(",", internalCluster().allDataNodesButN(num));
|
||||
builder.put("index.routing.allocation.exclude._name", exclude);
|
||||
return builder;
|
||||
|
@ -896,7 +892,7 @@ public abstract class ESIntegTestCase extends ESTestCase {
|
|||
internalCluster().ensureAtLeastNumDataNodes(n);
|
||||
Settings.Builder builder = Settings.builder();
|
||||
if (n > 0) {
|
||||
getExcludeSettings(index, n, builder);
|
||||
getExcludeSettings(n, builder);
|
||||
}
|
||||
Settings build = builder.build();
|
||||
if (!build.isEmpty()) {
|
||||
|
@ -1296,16 +1292,6 @@ public abstract class ESIntegTestCase extends ESTestCase {
|
|||
return client().prepareIndex(index, type, id).setSource(source).execute().actionGet();
|
||||
}
|
||||
|
||||
/**
|
||||
* Syntactic sugar for:
|
||||
* <pre>
|
||||
* client().prepareGet(index, type, id).execute().actionGet();
|
||||
* </pre>
|
||||
*/
|
||||
protected final GetResponse get(String index, String type, String id) {
|
||||
return client().prepareGet(index, type, id).execute().actionGet();
|
||||
}
|
||||
|
||||
/**
|
||||
* Syntactic sugar for:
|
||||
* <pre>
|
||||
|
@ -1418,12 +1404,12 @@ public abstract class ESIntegTestCase extends ESTestCase {
|
|||
/**
|
||||
* Convenience method that forwards to {@link #indexRandom(boolean, List)}.
|
||||
*/
|
||||
public void indexRandom(boolean forceRefresh, IndexRequestBuilder... builders) throws InterruptedException, ExecutionException {
|
||||
public void indexRandom(boolean forceRefresh, IndexRequestBuilder... builders) throws InterruptedException {
|
||||
indexRandom(forceRefresh, Arrays.asList(builders));
|
||||
}
|
||||
|
||||
public void indexRandom(boolean forceRefresh, boolean dummyDocuments, IndexRequestBuilder... builders)
|
||||
throws InterruptedException, ExecutionException {
|
||||
throws InterruptedException {
|
||||
indexRandom(forceRefresh, dummyDocuments, Arrays.asList(builders));
|
||||
}
|
||||
|
||||
|
@ -1442,7 +1428,7 @@ public abstract class ESIntegTestCase extends ESTestCase {
|
|||
* @param builders the documents to index.
|
||||
* @see #indexRandom(boolean, boolean, java.util.List)
|
||||
*/
|
||||
public void indexRandom(boolean forceRefresh, List<IndexRequestBuilder> builders) throws InterruptedException, ExecutionException {
|
||||
public void indexRandom(boolean forceRefresh, List<IndexRequestBuilder> builders) throws InterruptedException {
|
||||
indexRandom(forceRefresh, forceRefresh, builders);
|
||||
}
|
||||
|
||||
|
@ -1459,7 +1445,7 @@ public abstract class ESIntegTestCase extends ESTestCase {
|
|||
* @param builders the documents to index.
|
||||
*/
|
||||
public void indexRandom(boolean forceRefresh, boolean dummyDocuments, List<IndexRequestBuilder> builders)
|
||||
throws InterruptedException, ExecutionException {
|
||||
throws InterruptedException {
|
||||
indexRandom(forceRefresh, dummyDocuments, true, builders);
|
||||
}
|
||||
|
||||
|
@ -1477,7 +1463,7 @@ public abstract class ESIntegTestCase extends ESTestCase {
|
|||
* @param builders the documents to index.
|
||||
*/
|
||||
public void indexRandom(boolean forceRefresh, boolean dummyDocuments, boolean maybeFlush, List<IndexRequestBuilder> builders)
|
||||
throws InterruptedException, ExecutionException {
|
||||
throws InterruptedException {
|
||||
Random random = random();
|
||||
Map<String, Set<String>> indicesAndTypes = new HashMap<>();
|
||||
for (IndexRequestBuilder builder : builders) {
|
||||
|
|
|
@ -250,7 +250,6 @@ public abstract class ESTestCase extends LuceneTestCase {
|
|||
}
|
||||
|
||||
protected final Logger logger = Loggers.getLogger(getClass());
|
||||
protected final DeprecationLogger deprecationLogger = new DeprecationLogger(logger);
|
||||
private ThreadContext threadContext;
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
|
@ -370,7 +369,7 @@ public abstract class ESTestCase extends LuceneTestCase {
|
|||
return "[" + name.substring(start + 1, end) + "] ";
|
||||
}
|
||||
|
||||
private void ensureNoWarnings() throws IOException {
|
||||
private void ensureNoWarnings() {
|
||||
//Check that there are no unaccounted warning headers. These should be checked with {@link #assertWarnings(String...)} in the
|
||||
//appropriate test
|
||||
try {
|
||||
|
@ -510,7 +509,7 @@ public abstract class ESTestCase extends LuceneTestCase {
|
|||
checkIndexFailed = false;
|
||||
}
|
||||
|
||||
public final void ensureCheckIndexPassed() throws Exception {
|
||||
public final void ensureCheckIndexPassed() {
|
||||
assertFalse("at least one shard failed CheckIndex", checkIndexFailed);
|
||||
}
|
||||
|
||||
|
@ -878,7 +877,7 @@ public abstract class ESTestCase extends LuceneTestCase {
|
|||
return breakSupplier.getAsBoolean();
|
||||
}
|
||||
|
||||
public static boolean terminate(ExecutorService... services) throws InterruptedException {
|
||||
public static boolean terminate(ExecutorService... services) {
|
||||
boolean terminated = true;
|
||||
for (ExecutorService service : services) {
|
||||
if (service != null) {
|
||||
|
@ -888,7 +887,7 @@ public abstract class ESTestCase extends LuceneTestCase {
|
|||
return terminated;
|
||||
}
|
||||
|
||||
public static boolean terminate(ThreadPool threadPool) throws InterruptedException {
|
||||
public static boolean terminate(ThreadPool threadPool) {
|
||||
return ThreadPool.terminate(threadPool, 10, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
|
@ -943,23 +942,6 @@ public abstract class ESTestCase extends LuceneTestCase {
|
|||
return builder;
|
||||
}
|
||||
|
||||
private static String threadName(Thread t) {
|
||||
return "Thread[" +
|
||||
"id=" + t.getId() +
|
||||
", name=" + t.getName() +
|
||||
", state=" + t.getState() +
|
||||
", group=" + groupName(t.getThreadGroup()) +
|
||||
"]";
|
||||
}
|
||||
|
||||
private static String groupName(ThreadGroup threadGroup) {
|
||||
if (threadGroup == null) {
|
||||
return "{null group}";
|
||||
} else {
|
||||
return threadGroup.getName();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns size random values
|
||||
*/
|
||||
|
|
|
@ -696,13 +696,6 @@ public final class InternalTestCluster extends TestCluster {
|
|||
return suffix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the common node name prefix for this test cluster.
|
||||
*/
|
||||
public String nodePrefix() {
|
||||
return nodePrefix;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized Client client() {
|
||||
ensureOpen();
|
||||
|
@ -804,21 +797,6 @@ public final class InternalTestCluster extends TestCluster {
|
|||
return null; // can't happen
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a random node that applies to the given predicate.
|
||||
* The predicate can filter nodes based on the nodes settings.
|
||||
* If all nodes are filtered out this method will return <code>null</code>
|
||||
*/
|
||||
public synchronized Client client(final Predicate<Settings> filterPredicate) {
|
||||
ensureOpen();
|
||||
final NodeAndClient randomNodeAndClient =
|
||||
getRandomNodeAndClient(nodeAndClient -> filterPredicate.test(nodeAndClient.node.settings()));
|
||||
if (randomNodeAndClient != null) {
|
||||
return randomNodeAndClient.client(random);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void close() {
|
||||
if (this.open.compareAndSet(true, false)) {
|
||||
|
@ -914,7 +892,7 @@ public final class InternalTestCluster extends TestCluster {
|
|||
return clientWrapper.apply(transportClient);
|
||||
}
|
||||
|
||||
void resetClient() throws IOException {
|
||||
void resetClient() {
|
||||
if (closed.get() == false) {
|
||||
Releasables.close(nodeClient, transportClient);
|
||||
nodeClient = null;
|
||||
|
@ -1388,7 +1366,7 @@ public final class InternalTestCluster extends TestCluster {
|
|||
});
|
||||
}
|
||||
|
||||
private void randomlyResetClients() throws IOException {
|
||||
private void randomlyResetClients() {
|
||||
// only reset the clients on nightly tests, it causes heavy load...
|
||||
if (RandomizedTest.isNightly() && rarely(random)) {
|
||||
final Collection<NodeAndClient> nodesAndClients = nodes.values();
|
||||
|
@ -1654,20 +1632,6 @@ public final class InternalTestCluster extends TestCluster {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Restarts a random node in the cluster
|
||||
*/
|
||||
public void restartRandomNode() throws Exception {
|
||||
restartRandomNode(EMPTY_CALLBACK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Restarts a random node in the cluster and calls the callback during restart.
|
||||
*/
|
||||
public void restartRandomNode(RestartCallback callback) throws Exception {
|
||||
restartRandomNode(nc -> true, callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Restarts a random data node in the cluster
|
||||
*/
|
||||
|
@ -1718,13 +1682,6 @@ public final class InternalTestCluster extends TestCluster {
|
|||
fullRestart(EMPTY_CALLBACK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Restarts all nodes in a rolling restart fashion ie. only restarts on node a time.
|
||||
*/
|
||||
public void rollingRestart() throws Exception {
|
||||
rollingRestart(EMPTY_CALLBACK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Restarts all nodes in a rolling restart fashion ie. only restarts on node a time.
|
||||
*/
|
||||
|
|
|
@ -186,11 +186,7 @@ public abstract class AbstractSimpleTransportTestCase extends ESTestCase {
|
|||
assertNoPendingHandshakes(serviceB.getOriginalTransport());
|
||||
} finally {
|
||||
IOUtils.close(serviceA, serviceB, () -> {
|
||||
try {
|
||||
terminate(threadPool);
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -247,10 +247,7 @@ public class MockWebServer implements Closeable {
|
|||
latches.forEach(CountDownLatch::countDown);
|
||||
|
||||
if (server.getExecutor() instanceof ExecutorService) {
|
||||
try {
|
||||
terminate((ExecutorService) server.getExecutor());
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
}
|
||||
server.stop(0);
|
||||
}
|
||||
|
|
|
@ -125,11 +125,7 @@ public class SamlAuthenticationIT extends ESRestTestCase {
|
|||
public static void shutdownHttpServer() {
|
||||
final Executor executor = httpServer.getExecutor();
|
||||
if (executor instanceof ExecutorService) {
|
||||
try {
|
||||
terminate((ExecutorService) executor);
|
||||
} catch (InterruptedException e) {
|
||||
// oh well
|
||||
}
|
||||
}
|
||||
httpServer.stop(0);
|
||||
httpServer = null;
|
||||
|
|
Loading…
Reference in New Issue