Skip to content

Commit

Permalink
Remove Dead Code Test Infrastructure (#39192) (#39436)
Browse files Browse the repository at this point in the history
* Just removing some obviously unused things
  • Loading branch information
original-brownbear authored Feb 27, 2019
1 parent 542e2c5 commit 28b771f
Show file tree
Hide file tree
Showing 14 changed files with 12 additions and 184 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public void setup() {
ConnectionManager innerConnectionManager
= new ConnectionManager(settings, capturingTransport);
StubbableConnectionManager connectionManager
= new StubbableConnectionManager(innerConnectionManager, settings, capturingTransport, deterministicTaskQueue.getThreadPool());
= new StubbableConnectionManager(innerConnectionManager, settings, capturingTransport);
connectionManager.setDefaultNodeConnectedBehavior((cm, discoveryNode) -> {
final boolean isConnected = connectedNodes.contains(discoveryNode);
final boolean isDisconnected = disconnectedNodes.contains(discoveryNode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class SearchSlowLogTests extends ESSingleNodeTestCase {
protected SearchContext createSearchContext(IndexService indexService) {
BigArrays bigArrays = indexService.getBigArrays();
ThreadPool threadPool = indexService.getThreadPool();
return new TestSearchContext(threadPool, bigArrays, indexService) {
return new TestSearchContext(bigArrays, indexService) {
final ShardSearchRequest request = new ShardSearchRequest() {
private SearchSourceBuilder searchSourceBuilder;
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -508,8 +508,7 @@ public void sendRequest(long requestId, String action, TransportRequest request,
};

ConnectionManager delegate = new ConnectionManager(Settings.EMPTY, service.transport);
StubbableConnectionManager connectionManager = new StubbableConnectionManager(delegate, Settings.EMPTY, service.transport,
threadPool);
StubbableConnectionManager connectionManager = new StubbableConnectionManager(delegate, Settings.EMPTY, service.transport);

connectionManager.addConnectBehavior(seedNode.getAddress(), (cm, discoveryNode) -> {
if (discoveryNode == seedNode) {
Expand Down Expand Up @@ -1162,8 +1161,7 @@ public void sendRequest(long requestId, String action, TransportRequest request,
};

ConnectionManager delegate = new ConnectionManager(Settings.EMPTY, service.transport);
StubbableConnectionManager connectionManager = new StubbableConnectionManager(delegate, Settings.EMPTY, service.transport,
threadPool);
StubbableConnectionManager connectionManager = new StubbableConnectionManager(delegate, Settings.EMPTY, service.transport);

connectionManager.addNodeConnectedBehavior(connectedNode.getAddress(), (cm, discoveryNode)
-> discoveryNode.equals(connectedNode));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ protected Query rewrite(Query query) throws IOException {
return query;
}

protected QueryBuilder rewriteAndFetch(QueryBuilder builder, QueryRewriteContext context) throws IOException {
protected QueryBuilder rewriteAndFetch(QueryBuilder builder, QueryRewriteContext context) {
PlainActionFuture<QueryBuilder> future = new PlainActionFuture<>();
Rewriteable.rewriteAndFetch(builder, context, future);
return future.actionGet();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,6 @@ public class BackgroundIndexer implements AutoCloseable {
volatile int minFieldSize = 10;
volatile int maxFieldSize = 140;

/**
* Start indexing in the background using a random number of threads.
*
* @param index index name to index into
* @param type document type
* @param client client to use
*/
public BackgroundIndexer(String index, String type, Client client) {
this(index, type, client, -1);
}

/**
* Start indexing in the background using a random number of threads. Indexing will be paused after numOfDocs docs has
* been indexed.
Expand Down Expand Up @@ -239,11 +228,6 @@ private void setBudget(int numOfDocs) {

}

/** Start indexing with no limit to the number of documents */
public void start() {
start(-1);
}

/**
* Start indexing
*
Expand All @@ -261,11 +245,6 @@ public void pauseIndexing() {
setBudget(0);
}

/** Continue indexing after it has paused. No new document limit will be set */
public void continueIndexing() {
continueIndexing(-1);
}

/**
* Continue indexing after it has paused.
*
Expand Down Expand Up @@ -299,16 +278,6 @@ public void assertNoFailures() {
Assert.assertThat(failures, emptyIterable());
}

/** the minimum size in code points of a payload field in the indexed documents */
public void setMinFieldSize(int fieldSize) {
minFieldSize = fieldSize;
}

/** the minimum size in code points of a payload field in the indexed documents */
public void setMaxFieldSize(int fieldSize) {
maxFieldSize = fieldSize;
}

public void setAssertNoFailuresOnStop(final boolean assertNoFailuresOnStop) {
this.assertNoFailuresOnStop = assertNoFailuresOnStop;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.script.ScriptService;
import org.elasticsearch.search.internal.SearchContext;
import org.elasticsearch.threadpool.ThreadPool;
import org.junit.AfterClass;
import org.junit.BeforeClass;

Expand Down Expand Up @@ -312,8 +311,7 @@ public Index resolveIndex(String index) {
*/
protected SearchContext createSearchContext(IndexService indexService) {
BigArrays bigArrays = indexService.getBigArrays();
ThreadPool threadPool = indexService.getThreadPool();
return new TestSearchContext(threadPool, bigArrays, indexService);
return new TestSearchContext(bigArrays, indexService);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import org.elasticsearch.common.util.BigArrays;
import org.elasticsearch.index.IndexService;
import org.elasticsearch.index.cache.bitset.BitsetFilterCache;
import org.elasticsearch.index.engine.Engine;
import org.elasticsearch.index.fielddata.IndexFieldData;
import org.elasticsearch.index.mapper.MappedFieldType;
import org.elasticsearch.index.mapper.MapperService;
Expand Down Expand Up @@ -57,7 +56,6 @@
import org.elasticsearch.search.rescore.RescoreContext;
import org.elasticsearch.search.sort.SortAndFormats;
import org.elasticsearch.search.suggest.SuggestionSearchContext;
import org.elasticsearch.threadpool.ThreadPool;

import java.util.Collections;
import java.util.HashMap;
Expand All @@ -69,7 +67,6 @@ public class TestSearchContext extends SearchContext {
final BigArrays bigArrays;
final IndexService indexService;
final BitsetFilterCache fixedBitSetFilterCache;
final ThreadPool threadPool;
final Map<Class<?>, Collector> queryCollectors = new HashMap<>();
final IndexShard indexShard;
final QuerySearchResult queryResult = new QuerySearchResult();
Expand All @@ -92,11 +89,10 @@ public class TestSearchContext extends SearchContext {
private final long originNanoTime = System.nanoTime();
private final Map<String, SearchExtBuilder> searchExtBuilders = new HashMap<>();

public TestSearchContext(ThreadPool threadPool, BigArrays bigArrays, IndexService indexService) {
public TestSearchContext(BigArrays bigArrays, IndexService indexService) {
this.bigArrays = bigArrays.withCircuitBreaking();
this.indexService = indexService;
this.fixedBitSetFilterCache = indexService.cache().bitsetFilterCache();
this.threadPool = threadPool;
this.indexShard = indexService.getShardOrNull(0);
queryShardContext = indexService.newQueryShardContext(0, null, () -> 0L, null);
}
Expand All @@ -108,7 +104,6 @@ public TestSearchContext(QueryShardContext queryShardContext) {
public TestSearchContext(QueryShardContext queryShardContext, IndexShard indexShard) {
this.bigArrays = null;
this.indexService = null;
this.threadPool = null;
this.fixedBitSetFilterCache = null;
this.indexShard = indexShard;
this.queryShardContext = queryShardContext;
Expand Down Expand Up @@ -267,10 +262,6 @@ public ContextIndexSearcher searcher() {
return searcher;
}

public void setSearcher(Engine.Searcher searcher) {
this.searcher = new ContextIndexSearcher(searcher, indexService.cache().query(), indexShard.getQueryCachingPolicy());
}

@Override
public IndexShard indexShard() {
return indexShard;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,7 @@

public class BlockClusterStateProcessing extends SingleNodeDisruption {

AtomicReference<CountDownLatch> disruptionLatch = new AtomicReference<>();


public BlockClusterStateProcessing(Random random) {
this(null, random);
}
private final AtomicReference<CountDownLatch> disruptionLatch = new AtomicReference<>();

public BlockClusterStateProcessing(String disruptedNode, Random random) {
super(random);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,6 @@ public static void assertFourthHit(SearchResponse searchResponse, Matcher<Search
assertSearchHit(searchResponse, 4, matcher);
}

public static void assertFifthHit(SearchResponse searchResponse, Matcher<SearchHit> matcher) {
assertSearchHit(searchResponse, 5, matcher);
}

public static void assertSearchHit(SearchResponse searchResponse, int number, Matcher<SearchHit> matcher) {
assertThat(number, greaterThan(0));
assertThat("SearchHit number must be greater than 0", number, greaterThan(0));
Expand Down Expand Up @@ -657,14 +653,6 @@ public static void assertFileNotExists(Path file) {
assertThat("file/dir [" + file + "] should not exist.", Files.exists(file), is(false));
}

/**
* Check if a directory exists
*/
public static void assertDirectoryExists(Path dir) {
assertFileExists(dir);
assertThat("file [" + dir + "] should be a directory.", Files.isDirectory(dir), is(true));
}

/**
* Asserts that the provided {@link BytesReference}s created through
* {@link org.elasticsearch.common.xcontent.ToXContent#toXContent(XContentBuilder, ToXContent.Params)} hold the same content.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public synchronized void crash() throws IOException {
}
}

final class CloseableDirectory implements Closeable {
static final class CloseableDirectory implements Closeable {
private final BaseDirectoryWrapper dir;
private final TestRuleMarkFailure failureMarker;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public TransportService createTransportService(Settings settings, ThreadPool thr
Function<BoundTransportAddress, DiscoveryNode> localNodeFactory,
@Nullable ClusterSettings clusterSettings, Set<String> taskHeaders) {
StubbableConnectionManager connectionManager = new StubbableConnectionManager(new ConnectionManager(settings, this),
settings, this, threadPool);
settings, this);
connectionManager.setDefaultNodeConnectedBehavior((cm, discoveryNode) -> nodeConnected(discoveryNode));
connectionManager.setDefaultGetConnectionBehavior((cm, discoveryNode) -> createConnection(discoveryNode));
return new TransportService(settings, this, threadPool, interceptor, localNodeFactory, clusterSettings, taskHeaders,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ private MockTransportService(Settings settings, StubbableTransport transport, Th
Function<BoundTransportAddress, DiscoveryNode> localNodeFactory,
@Nullable ClusterSettings clusterSettings, Set<String> taskHeaders) {
super(settings, transport, threadPool, interceptor, localNodeFactory, clusterSettings, taskHeaders,
new StubbableConnectionManager(new ConnectionManager(settings, transport), settings, transport, threadPool));
new StubbableConnectionManager(new ConnectionManager(settings, transport), settings, transport));
this.original = transport.getDelegate();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.elasticsearch.common.CheckedBiConsumer;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.ConnectTransportException;
import org.elasticsearch.transport.ConnectionManager;
import org.elasticsearch.transport.ConnectionProfile;
Expand All @@ -41,7 +40,7 @@ public class StubbableConnectionManager extends ConnectionManager {
private volatile GetConnectionBehavior defaultGetConnectionBehavior = ConnectionManager::getConnection;
private volatile NodeConnectedBehavior defaultNodeConnectedBehavior = ConnectionManager::nodeConnected;

public StubbableConnectionManager(ConnectionManager delegate, Settings settings, Transport transport, ThreadPool threadPool) {
public StubbableConnectionManager(ConnectionManager delegate, Settings settings, Transport transport) {
super(settings, transport);
this.delegate = delegate;
this.getConnectionBehaviors = new ConcurrentHashMap<>();
Expand Down

0 comments on commit 28b771f

Please sign in to comment.