mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-03-01 00:19:11 +00:00
Remove usages of MockTcpTransport
from zen tests (#36579)
We are attempting to replace the usage of the `MockTcpTransport` with the `MockNioTransport`. This commit replaces usages of `MockTcpTransport` in two zen test cases.
This commit is contained in:
parent
2afa7faefd
commit
f998e04c34
@ -32,7 +32,7 @@ import org.elasticsearch.common.network.NetworkService;
|
|||||||
import org.elasticsearch.common.settings.ClusterSettings;
|
import org.elasticsearch.common.settings.ClusterSettings;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.unit.ByteSizeValue;
|
import org.elasticsearch.common.unit.ByteSizeValue;
|
||||||
import org.elasticsearch.common.util.BigArrays;
|
import org.elasticsearch.common.util.PageCacheRecycler;
|
||||||
import org.elasticsearch.discovery.zen.FaultDetection;
|
import org.elasticsearch.discovery.zen.FaultDetection;
|
||||||
import org.elasticsearch.discovery.zen.MasterFaultDetection;
|
import org.elasticsearch.discovery.zen.MasterFaultDetection;
|
||||||
import org.elasticsearch.discovery.zen.NodesFaultDetection;
|
import org.elasticsearch.discovery.zen.NodesFaultDetection;
|
||||||
@ -43,10 +43,10 @@ import org.elasticsearch.test.ESTestCase;
|
|||||||
import org.elasticsearch.test.transport.MockTransportService;
|
import org.elasticsearch.test.transport.MockTransportService;
|
||||||
import org.elasticsearch.threadpool.TestThreadPool;
|
import org.elasticsearch.threadpool.TestThreadPool;
|
||||||
import org.elasticsearch.threadpool.ThreadPool;
|
import org.elasticsearch.threadpool.ThreadPool;
|
||||||
import org.elasticsearch.transport.MockTcpTransport;
|
|
||||||
import org.elasticsearch.transport.TransportConnectionListener;
|
import org.elasticsearch.transport.TransportConnectionListener;
|
||||||
import org.elasticsearch.transport.TransportRequestOptions;
|
import org.elasticsearch.transport.TransportRequestOptions;
|
||||||
import org.elasticsearch.transport.TransportService;
|
import org.elasticsearch.transport.TransportService;
|
||||||
|
import org.elasticsearch.transport.nio.MockNioTransport;
|
||||||
import org.hamcrest.Matcher;
|
import org.hamcrest.Matcher;
|
||||||
import org.hamcrest.Matchers;
|
import org.hamcrest.Matchers;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
@ -138,8 +138,8 @@ public class ZenFaultDetectionTests extends ESTestCase {
|
|||||||
// trace zenfd actions but keep the default otherwise
|
// trace zenfd actions but keep the default otherwise
|
||||||
.putList(TransportService.TRACE_LOG_EXCLUDE_SETTING.getKey(), TransportLivenessAction.NAME)
|
.putList(TransportService.TRACE_LOG_EXCLUDE_SETTING.getKey(), TransportLivenessAction.NAME)
|
||||||
.build(),
|
.build(),
|
||||||
new MockTcpTransport(settings, threadPool, BigArrays.NON_RECYCLING_INSTANCE, circuitBreakerService,
|
new MockNioTransport(settings, version, threadPool, new NetworkService(Collections.emptyList()),
|
||||||
namedWriteableRegistry, new NetworkService(Collections.emptyList()), version),
|
PageCacheRecycler.NON_RECYCLING_INSTANCE, namedWriteableRegistry, circuitBreakerService),
|
||||||
threadPool,
|
threadPool,
|
||||||
TransportService.NOOP_TRANSPORT_INTERCEPTOR,
|
TransportService.NOOP_TRANSPORT_INTERCEPTOR,
|
||||||
(boundAddress) ->
|
(boundAddress) ->
|
||||||
|
@ -38,6 +38,7 @@ import org.elasticsearch.common.transport.BoundTransportAddress;
|
|||||||
import org.elasticsearch.common.transport.TransportAddress;
|
import org.elasticsearch.common.transport.TransportAddress;
|
||||||
import org.elasticsearch.common.unit.TimeValue;
|
import org.elasticsearch.common.unit.TimeValue;
|
||||||
import org.elasticsearch.common.util.BigArrays;
|
import org.elasticsearch.common.util.BigArrays;
|
||||||
|
import org.elasticsearch.common.util.PageCacheRecycler;
|
||||||
import org.elasticsearch.common.util.concurrent.AbstractRunnable;
|
import org.elasticsearch.common.util.concurrent.AbstractRunnable;
|
||||||
import org.elasticsearch.common.util.concurrent.ConcurrentCollections;
|
import org.elasticsearch.common.util.concurrent.ConcurrentCollections;
|
||||||
import org.elasticsearch.common.util.concurrent.EsExecutors;
|
import org.elasticsearch.common.util.concurrent.EsExecutors;
|
||||||
@ -56,6 +57,7 @@ import org.elasticsearch.transport.TransportException;
|
|||||||
import org.elasticsearch.transport.TransportRequestOptions;
|
import org.elasticsearch.transport.TransportRequestOptions;
|
||||||
import org.elasticsearch.transport.TransportResponseHandler;
|
import org.elasticsearch.transport.TransportResponseHandler;
|
||||||
import org.elasticsearch.transport.TransportService;
|
import org.elasticsearch.transport.TransportService;
|
||||||
|
import org.elasticsearch.transport.nio.MockNioTransport;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.mockito.Matchers;
|
import org.mockito.Matchers;
|
||||||
@ -143,14 +145,14 @@ public class UnicastZenPingTests extends ESTestCase {
|
|||||||
|
|
||||||
NetworkService networkService = new NetworkService(Collections.emptyList());
|
NetworkService networkService = new NetworkService(Collections.emptyList());
|
||||||
|
|
||||||
final BiFunction<Settings, Version, Transport> supplier = (s, v) -> new MockTcpTransport(
|
final BiFunction<Settings, Version, Transport> supplier = (s, v) -> new MockNioTransport(
|
||||||
s,
|
s,
|
||||||
|
v,
|
||||||
threadPool,
|
threadPool,
|
||||||
BigArrays.NON_RECYCLING_INSTANCE,
|
|
||||||
new NoneCircuitBreakerService(),
|
|
||||||
new NamedWriteableRegistry(Collections.emptyList()),
|
|
||||||
networkService,
|
networkService,
|
||||||
v);
|
PageCacheRecycler.NON_RECYCLING_INSTANCE,
|
||||||
|
new NamedWriteableRegistry(Collections.emptyList()),
|
||||||
|
new NoneCircuitBreakerService());
|
||||||
|
|
||||||
NetworkHandle handleA = startServices(settings, threadPool, "UZP_A", Version.CURRENT, supplier);
|
NetworkHandle handleA = startServices(settings, threadPool, "UZP_A", Version.CURRENT, supplier);
|
||||||
closeables.push(handleA.transportService);
|
closeables.push(handleA.transportService);
|
||||||
@ -268,14 +270,14 @@ public class UnicastZenPingTests extends ESTestCase {
|
|||||||
final NetworkService networkService = new NetworkService(Collections.emptyList());
|
final NetworkService networkService = new NetworkService(Collections.emptyList());
|
||||||
|
|
||||||
final Map<String, TransportAddress[]> addresses = new HashMap<>();
|
final Map<String, TransportAddress[]> addresses = new HashMap<>();
|
||||||
final BiFunction<Settings, Version, Transport> supplier = (s, v) -> new MockTcpTransport(
|
final BiFunction<Settings, Version, Transport> supplier = (s, v) -> new MockNioTransport(
|
||||||
s,
|
s,
|
||||||
|
v,
|
||||||
threadPool,
|
threadPool,
|
||||||
BigArrays.NON_RECYCLING_INSTANCE,
|
|
||||||
new NoneCircuitBreakerService(),
|
|
||||||
new NamedWriteableRegistry(Collections.emptyList()),
|
|
||||||
networkService,
|
networkService,
|
||||||
v) {
|
PageCacheRecycler.NON_RECYCLING_INSTANCE,
|
||||||
|
new NamedWriteableRegistry(Collections.emptyList()),
|
||||||
|
new NoneCircuitBreakerService()) {
|
||||||
@Override
|
@Override
|
||||||
public TransportAddress[] addressesFromString(String address, int perAddressLimit) throws UnknownHostException {
|
public TransportAddress[] addressesFromString(String address, int perAddressLimit) throws UnknownHostException {
|
||||||
final TransportAddress[] transportAddresses = addresses.get(address);
|
final TransportAddress[] transportAddresses = addresses.get(address);
|
||||||
@ -634,14 +636,14 @@ public class UnicastZenPingTests extends ESTestCase {
|
|||||||
|
|
||||||
NetworkService networkService = new NetworkService(Collections.emptyList());
|
NetworkService networkService = new NetworkService(Collections.emptyList());
|
||||||
|
|
||||||
final BiFunction<Settings, Version, Transport> supplier = (s, v) -> new MockTcpTransport(
|
final BiFunction<Settings, Version, Transport> supplier = (s, v) -> new MockNioTransport(
|
||||||
s,
|
s,
|
||||||
|
v,
|
||||||
threadPool,
|
threadPool,
|
||||||
BigArrays.NON_RECYCLING_INSTANCE,
|
|
||||||
new NoneCircuitBreakerService(),
|
|
||||||
new NamedWriteableRegistry(Collections.emptyList()),
|
|
||||||
networkService,
|
networkService,
|
||||||
v);
|
PageCacheRecycler.NON_RECYCLING_INSTANCE,
|
||||||
|
new NamedWriteableRegistry(Collections.emptyList()),
|
||||||
|
new NoneCircuitBreakerService());
|
||||||
|
|
||||||
NetworkHandle handleA = startServices(settings, threadPool, "UZP_A", Version.CURRENT, supplier, EnumSet.allOf(Role.class));
|
NetworkHandle handleA = startServices(settings, threadPool, "UZP_A", Version.CURRENT, supplier, EnumSet.allOf(Role.class));
|
||||||
closeables.push(handleA.transportService);
|
closeables.push(handleA.transportService);
|
||||||
@ -689,15 +691,14 @@ public class UnicastZenPingTests extends ESTestCase {
|
|||||||
|
|
||||||
public void testInvalidHosts() throws InterruptedException {
|
public void testInvalidHosts() throws InterruptedException {
|
||||||
final Logger logger = mock(Logger.class);
|
final Logger logger = mock(Logger.class);
|
||||||
final NetworkService networkService = new NetworkService(Collections.emptyList());
|
final Transport transport = new MockNioTransport(
|
||||||
final Transport transport = new MockTcpTransport(
|
|
||||||
Settings.EMPTY,
|
Settings.EMPTY,
|
||||||
|
Version.CURRENT,
|
||||||
threadPool,
|
threadPool,
|
||||||
BigArrays.NON_RECYCLING_INSTANCE,
|
new NetworkService(Collections.emptyList()),
|
||||||
new NoneCircuitBreakerService(),
|
PageCacheRecycler.NON_RECYCLING_INSTANCE,
|
||||||
new NamedWriteableRegistry(Collections.emptyList()),
|
new NamedWriteableRegistry(Collections.emptyList()),
|
||||||
networkService,
|
new NoneCircuitBreakerService()) {
|
||||||
Version.CURRENT) {
|
|
||||||
@Override
|
@Override
|
||||||
public BoundTransportAddress boundAddress() {
|
public BoundTransportAddress boundAddress() {
|
||||||
return new BoundTransportAddress(
|
return new BoundTransportAddress(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user