Skip to content

Commit 93b284a

Browse files
author
Christoph Büscher
authored
Enable silent FollowersCheckerTest (#38851)
One of the test methods wasn't run because it was private. Making this method public and fixing some issues around mocking the threadpool that otherwise would lead to an NPE.
1 parent 89eae89 commit 93b284a

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

server/src/test/java/org/elasticsearch/cluster/coordination/FollowersCheckerTests.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
import org.elasticsearch.test.EqualsHashCodeTestUtils.CopyFunction;
3434
import org.elasticsearch.test.transport.CapturingTransport;
3535
import org.elasticsearch.test.transport.MockTransport;
36-
import org.elasticsearch.threadpool.ThreadPool;
3736
import org.elasticsearch.threadpool.ThreadPool.Names;
3837
import org.elasticsearch.transport.ConnectTransportException;
3938
import org.elasticsearch.transport.TransportException;
@@ -73,7 +72,6 @@
7372
import static org.hamcrest.Matchers.not;
7473
import static org.hamcrest.Matchers.nullValue;
7574
import static org.hamcrest.core.IsInstanceOf.instanceOf;
76-
import static org.mockito.Mockito.mock;
7775

7876
public class FollowersCheckerTests extends ESTestCase {
7977

@@ -548,14 +546,16 @@ public String executor() {
548546
}
549547
}
550548

551-
private void testPreferMasterNodes() {
549+
public void testPreferMasterNodes() {
552550
List<DiscoveryNode> nodes = randomNodes(10);
553551
DiscoveryNodes.Builder discoNodesBuilder = DiscoveryNodes.builder();
554552
nodes.forEach(dn -> discoNodesBuilder.add(dn));
555553
DiscoveryNodes discoveryNodes = discoNodesBuilder.localNodeId(nodes.get(0).getId()).build();
556554
CapturingTransport capturingTransport = new CapturingTransport();
557-
TransportService transportService = capturingTransport.createTransportService(Settings.EMPTY, mock(ThreadPool.class),
558-
TransportService.NOOP_TRANSPORT_INTERCEPTOR, x -> nodes.get(0), null, emptySet());
555+
final Settings settings = Settings.builder().put(NODE_NAME_SETTING.getKey(), nodes.get(0).getName()).build();
556+
final DeterministicTaskQueue deterministicTaskQueue = new DeterministicTaskQueue(settings, random());
557+
TransportService transportService = capturingTransport.createTransportService(Settings.EMPTY,
558+
deterministicTaskQueue.getThreadPool(), TransportService.NOOP_TRANSPORT_INTERCEPTOR, x -> nodes.get(0), null, emptySet());
559559
final FollowersChecker followersChecker = new FollowersChecker(Settings.EMPTY, transportService, fcr -> {
560560
assert false : fcr;
561561
}, (node, reason) -> {

0 commit comments

Comments
 (0)