Cut over to MockTcpTransport since LocalTransport is remove in core (elastic/elasticsearch#3684)
This is a followup commit to elastic/elasticsearchelastic/elasticsearch#20695 Original commit: elastic/x-pack-elasticsearch@27cd454ba6
This commit is contained in:
parent
f9aba3944e
commit
2f70ae92b6
|
@ -434,8 +434,8 @@ public class XPackPlugin extends Plugin implements ScriptPlugin, ActionPlugin, I
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<TransportInterceptor> getTransportInterceptors() {
|
public List<TransportInterceptor> getTransportInterceptors(NamedWriteableRegistry namedWriteableRegistry) {
|
||||||
return security.getTransportInterceptors();
|
return security.getTransportInterceptors(namedWriteableRegistry);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -677,7 +677,7 @@ public class Security implements ActionPlugin, IngestPlugin, NetworkPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<TransportInterceptor> getTransportInterceptors() {
|
public List<TransportInterceptor> getTransportInterceptors(NamedWriteableRegistry namedWriteableRegistry) {
|
||||||
if (transportClientMode || enabled == false) { // don't register anything if we are not enabled
|
if (transportClientMode || enabled == false) { // don't register anything if we are not enabled
|
||||||
// interceptors are not installed if we are running on the transport client
|
// interceptors are not installed if we are running on the transport client
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
|
|
|
@ -36,7 +36,6 @@ import org.elasticsearch.common.network.NetworkAddress;
|
||||||
import org.elasticsearch.common.settings.Setting;
|
import org.elasticsearch.common.settings.Setting;
|
||||||
import org.elasticsearch.common.settings.Setting.Property;
|
import org.elasticsearch.common.settings.Setting.Property;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.transport.InetSocketTransportAddress;
|
|
||||||
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.concurrent.AbstractRunnable;
|
import org.elasticsearch.common.util.concurrent.AbstractRunnable;
|
||||||
|
@ -707,12 +706,8 @@ public class IndexAuditTrail extends AbstractComponent implements AuditTrail, Cl
|
||||||
TransportAddress address = message.remoteAddress();
|
TransportAddress address = message.remoteAddress();
|
||||||
if (address != null) {
|
if (address != null) {
|
||||||
builder.field(Field.ORIGIN_TYPE, "transport");
|
builder.field(Field.ORIGIN_TYPE, "transport");
|
||||||
if (address instanceof InetSocketTransportAddress) {
|
builder.field(Field.ORIGIN_ADDRESS,
|
||||||
builder.field(Field.ORIGIN_ADDRESS,
|
NetworkAddress.format(address.address().getAddress()));
|
||||||
NetworkAddress.format(((InetSocketTransportAddress) address).address().getAddress()));
|
|
||||||
} else {
|
|
||||||
builder.field(Field.ORIGIN_ADDRESS, address);
|
|
||||||
}
|
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -771,7 +766,7 @@ public class IndexAuditTrail extends AbstractComponent implements AuditTrail, Cl
|
||||||
.put(theClientSetting).build(), Settings.EMPTY, Collections.singletonList(XPackPlugin.class)) {};
|
.put(theClientSetting).build(), Settings.EMPTY, Collections.singletonList(XPackPlugin.class)) {};
|
||||||
for (Tuple<String, Integer> pair : hostPortPairs) {
|
for (Tuple<String, Integer> pair : hostPortPairs) {
|
||||||
try {
|
try {
|
||||||
transportClient.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(pair.v1()), pair.v2()));
|
transportClient.addTransportAddress(new TransportAddress(InetAddress.getByName(pair.v1()), pair.v2()));
|
||||||
} catch (UnknownHostException e) {
|
} catch (UnknownHostException e) {
|
||||||
throw new ElasticsearchException("could not find host {}", e, pair.v1());
|
throw new ElasticsearchException("could not find host {}", e, pair.v1());
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,6 @@ import org.elasticsearch.common.network.NetworkAddress;
|
||||||
import org.elasticsearch.common.settings.Setting;
|
import org.elasticsearch.common.settings.Setting;
|
||||||
import org.elasticsearch.common.settings.Setting.Property;
|
import org.elasticsearch.common.settings.Setting.Property;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.transport.InetSocketTransportAddress;
|
|
||||||
import org.elasticsearch.common.transport.TransportAddress;
|
import org.elasticsearch.common.transport.TransportAddress;
|
||||||
import org.elasticsearch.common.util.concurrent.ThreadContext;
|
import org.elasticsearch.common.util.concurrent.ThreadContext;
|
||||||
import org.elasticsearch.rest.RestRequest;
|
import org.elasticsearch.rest.RestRequest;
|
||||||
|
@ -408,13 +407,9 @@ public class LoggingAuditTrail extends AbstractComponent implements AuditTrail {
|
||||||
TransportAddress address = message.remoteAddress();
|
TransportAddress address = message.remoteAddress();
|
||||||
if (address != null) {
|
if (address != null) {
|
||||||
builder.append("origin_type=[transport], ");
|
builder.append("origin_type=[transport], ");
|
||||||
if (address instanceof InetSocketTransportAddress) {
|
builder.append("origin_address=[").
|
||||||
builder.append("origin_address=[").
|
append(NetworkAddress.format(address.address().getAddress())).
|
||||||
append(NetworkAddress.format(((InetSocketTransportAddress) address).address().getAddress())).
|
|
||||||
append("]");
|
append("]");
|
||||||
} else {
|
|
||||||
builder.append("origin_address=[").append(address).append("]");
|
|
||||||
}
|
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,6 @@ package org.elasticsearch.xpack.security.transport.filter;
|
||||||
import org.elasticsearch.ElasticsearchException;
|
import org.elasticsearch.ElasticsearchException;
|
||||||
import org.elasticsearch.common.network.InetAddresses;
|
import org.elasticsearch.common.network.InetAddresses;
|
||||||
import org.elasticsearch.common.network.NetworkAddress;
|
import org.elasticsearch.common.network.NetworkAddress;
|
||||||
import org.elasticsearch.common.transport.InetSocketTransportAddress;
|
|
||||||
import org.elasticsearch.common.transport.TransportAddress;
|
import org.elasticsearch.common.transport.TransportAddress;
|
||||||
import org.jboss.netty.handler.ipfilter.IpFilterRule;
|
import org.jboss.netty.handler.ipfilter.IpFilterRule;
|
||||||
import org.jboss.netty.handler.ipfilter.IpSubnetFilterRule;
|
import org.jboss.netty.handler.ipfilter.IpSubnetFilterRule;
|
||||||
|
@ -154,8 +153,7 @@ public class SecurityIpFilterRule implements IpFilterRule {
|
||||||
firstAdded = true;
|
firstAdded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert transportAddress instanceof InetSocketTransportAddress;
|
ruleSpec.append(NetworkAddress.format(transportAddress.address().getAddress()));
|
||||||
ruleSpec.append(NetworkAddress.format(((InetSocketTransportAddress) transportAddress).address().getAddress()));
|
|
||||||
}
|
}
|
||||||
return ruleSpec.toString();
|
return ruleSpec.toString();
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ public class ExecutionService extends AbstractComponent {
|
||||||
private final TimeValue maxStopTimeout;
|
private final TimeValue maxStopTimeout;
|
||||||
private final ThreadPool threadPool;
|
private final ThreadPool threadPool;
|
||||||
|
|
||||||
private volatile CurrentExecutions currentExecutions = null;
|
private volatile CurrentExecutions currentExecutions;
|
||||||
private final AtomicBoolean started = new AtomicBoolean(false);
|
private final AtomicBoolean started = new AtomicBoolean(false);
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
|
|
@ -15,7 +15,6 @@ import org.elasticsearch.cluster.node.DiscoveryNodes;
|
||||||
import org.elasticsearch.cluster.service.ClusterService;
|
import org.elasticsearch.cluster.service.ClusterService;
|
||||||
import org.elasticsearch.common.component.Lifecycle;
|
import org.elasticsearch.common.component.Lifecycle;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
|
||||||
import org.elasticsearch.env.Environment;
|
import org.elasticsearch.env.Environment;
|
||||||
import org.elasticsearch.test.ESTestCase;
|
import org.elasticsearch.test.ESTestCase;
|
||||||
import org.elasticsearch.watcher.ResourceWatcherService;
|
import org.elasticsearch.watcher.ResourceWatcherService;
|
||||||
|
@ -59,7 +58,7 @@ public abstract class AbstractLicenseServiceTestCase extends ESTestCase {
|
||||||
MetaData metaData = mock(MetaData.class);
|
MetaData metaData = mock(MetaData.class);
|
||||||
when(metaData.custom(LicensesMetaData.TYPE)).thenReturn(new LicensesMetaData(license));
|
when(metaData.custom(LicensesMetaData.TYPE)).thenReturn(new LicensesMetaData(license));
|
||||||
when(state.metaData()).thenReturn(metaData);
|
when(state.metaData()).thenReturn(metaData);
|
||||||
final DiscoveryNode mockNode = new DiscoveryNode("b", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT);
|
final DiscoveryNode mockNode = new DiscoveryNode("b", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT);
|
||||||
when(discoveryNodes.getMasterNode()).thenReturn(mockNode);
|
when(discoveryNodes.getMasterNode()).thenReturn(mockNode);
|
||||||
when(discoveryNodes.isLocalNodeElectedMaster()).thenReturn(false);
|
when(discoveryNodes.isLocalNodeElectedMaster()).thenReturn(false);
|
||||||
when(state.nodes()).thenReturn(discoveryNodes);
|
when(state.nodes()).thenReturn(discoveryNodes);
|
||||||
|
|
|
@ -13,7 +13,6 @@ import org.elasticsearch.cluster.ClusterStateUpdateTask;
|
||||||
import org.elasticsearch.cluster.metadata.MetaData;
|
import org.elasticsearch.cluster.metadata.MetaData;
|
||||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||||
import org.elasticsearch.cluster.node.DiscoveryNodes;
|
import org.elasticsearch.cluster.node.DiscoveryNodes;
|
||||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
|
||||||
import org.elasticsearch.common.unit.TimeValue;
|
import org.elasticsearch.common.unit.TimeValue;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
@ -64,7 +63,7 @@ public class LicenseClusterChangeTests extends AbstractLicenseServiceTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testTrialLicenseGeneration() throws Exception {
|
public void testTrialLicenseGeneration() throws Exception {
|
||||||
DiscoveryNode master = new DiscoveryNode("b", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT);
|
DiscoveryNode master = new DiscoveryNode("b", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT);
|
||||||
ClusterState oldState = ClusterState.builder(new ClusterName("a"))
|
ClusterState oldState = ClusterState.builder(new ClusterName("a"))
|
||||||
.nodes(DiscoveryNodes.builder().masterNodeId(master.getId()).add(master)).build();
|
.nodes(DiscoveryNodes.builder().masterNodeId(master.getId()).add(master)).build();
|
||||||
when(discoveryNodes.isLocalNodeElectedMaster()).thenReturn(true);
|
when(discoveryNodes.isLocalNodeElectedMaster()).thenReturn(true);
|
||||||
|
|
|
@ -21,6 +21,8 @@ import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.transport.TransportAddress;
|
import org.elasticsearch.common.transport.TransportAddress;
|
||||||
import org.elasticsearch.discovery.DiscoveryModule;
|
import org.elasticsearch.discovery.DiscoveryModule;
|
||||||
import org.elasticsearch.discovery.zen.ping.unicast.UnicastZenPing;
|
import org.elasticsearch.discovery.zen.ping.unicast.UnicastZenPing;
|
||||||
|
import org.elasticsearch.node.MockNode;
|
||||||
|
import org.elasticsearch.transport.MockTcpTransportPlugin;
|
||||||
import org.elasticsearch.xpack.XPackPlugin;
|
import org.elasticsearch.xpack.XPackPlugin;
|
||||||
import org.elasticsearch.xpack.XPackSettings;
|
import org.elasticsearch.xpack.XPackSettings;
|
||||||
import org.elasticsearch.node.Node;
|
import org.elasticsearch.node.Node;
|
||||||
|
@ -54,7 +56,7 @@ public abstract class TribeTransportTestCase extends ESIntegTestCase {
|
||||||
protected final Settings nodeSettings(int nodeOrdinal) {
|
protected final Settings nodeSettings(int nodeOrdinal) {
|
||||||
final Settings.Builder builder = Settings.builder()
|
final Settings.Builder builder = Settings.builder()
|
||||||
.put(NetworkModule.HTTP_ENABLED.getKey(), false)
|
.put(NetworkModule.HTTP_ENABLED.getKey(), false)
|
||||||
.put("transport.type", "local")
|
.put("transport.type", MockTcpTransportPlugin.MOCK_TCP_TRANSPORT_NAME)
|
||||||
.put(DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey(), "local");
|
.put(DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey(), "local");
|
||||||
List<String> enabledFeatures = enabledFeatures();
|
List<String> enabledFeatures = enabledFeatures();
|
||||||
builder.put(XPackSettings.SECURITY_ENABLED.getKey(), enabledFeatures.contains(XPackPlugin.SECURITY));
|
builder.put(XPackSettings.SECURITY_ENABLED.getKey(), enabledFeatures.contains(XPackPlugin.SECURITY));
|
||||||
|
@ -128,8 +130,8 @@ public abstract class TribeTransportTestCase extends ESIntegTestCase {
|
||||||
Settings merged = Settings.builder()
|
Settings merged = Settings.builder()
|
||||||
.put("tribe.t1.cluster.name", internalCluster().getClusterName())
|
.put("tribe.t1.cluster.name", internalCluster().getClusterName())
|
||||||
.put("tribe.t2.cluster.name", cluster2.getClusterName())
|
.put("tribe.t2.cluster.name", cluster2.getClusterName())
|
||||||
.put("tribe.t1.transport.type", "local")
|
.put("tribe.t1.transport.type", MockTcpTransportPlugin.MOCK_TCP_TRANSPORT_NAME)
|
||||||
.put("tribe.t2.transport.type", "local")
|
.put("tribe.t2.transport.type", MockTcpTransportPlugin.MOCK_TCP_TRANSPORT_NAME)
|
||||||
.put("tribe.t1.discovery.type", "local")
|
.put("tribe.t1.discovery.type", "local")
|
||||||
.put("tribe.t2.discovery.type", "local")
|
.put("tribe.t2.discovery.type", "local")
|
||||||
.put("tribe.blocks.write", false)
|
.put("tribe.blocks.write", false)
|
||||||
|
@ -138,10 +140,10 @@ public abstract class TribeTransportTestCase extends ESIntegTestCase {
|
||||||
.put(NetworkModule.HTTP_ENABLED.getKey(), false)
|
.put(NetworkModule.HTTP_ENABLED.getKey(), false)
|
||||||
.put(internalCluster().getDefaultSettings())
|
.put(internalCluster().getDefaultSettings())
|
||||||
.put("node.name", "tribe_node") // make sure we can identify threads from this node
|
.put("node.name", "tribe_node") // make sure we can identify threads from this node
|
||||||
.put("transport.type", "local")
|
.put("transport.type", MockTcpTransportPlugin.MOCK_TCP_TRANSPORT_NAME)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
final Node tribeNode = new Node(merged).start();
|
final Node tribeNode = new MockNode(merged, Collections.singleton(MockTcpTransportPlugin.class)).start();
|
||||||
Client tribeClient = tribeNode.client();
|
Client tribeClient = tribeNode.client();
|
||||||
|
|
||||||
logger.info("wait till tribe has the same nodes as the 2 clusters");
|
logger.info("wait till tribe has the same nodes as the 2 clusters");
|
||||||
|
|
|
@ -14,7 +14,6 @@ import org.elasticsearch.client.node.NodeClient;
|
||||||
import org.elasticsearch.cluster.health.ClusterHealthStatus;
|
import org.elasticsearch.cluster.health.ClusterHealthStatus;
|
||||||
import org.elasticsearch.common.network.NetworkAddress;
|
import org.elasticsearch.common.network.NetworkAddress;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.transport.InetSocketTransportAddress;
|
|
||||||
import org.elasticsearch.common.transport.TransportAddress;
|
import org.elasticsearch.common.transport.TransportAddress;
|
||||||
import org.elasticsearch.plugins.Plugin;
|
import org.elasticsearch.plugins.Plugin;
|
||||||
import org.elasticsearch.xpack.XPackSettings;
|
import org.elasticsearch.xpack.XPackSettings;
|
||||||
|
@ -22,7 +21,6 @@ import org.elasticsearch.xpack.security.InternalClient;
|
||||||
import org.elasticsearch.xpack.security.Security;
|
import org.elasticsearch.xpack.security.Security;
|
||||||
import org.elasticsearch.xpack.security.authc.support.SecuredString;
|
import org.elasticsearch.xpack.security.authc.support.SecuredString;
|
||||||
import org.elasticsearch.xpack.security.client.SecurityClient;
|
import org.elasticsearch.xpack.security.client.SecurityClient;
|
||||||
import org.elasticsearch.test.ESIntegTestCase.SuppressLocalMode;
|
|
||||||
import org.elasticsearch.xpack.XPackClient;
|
import org.elasticsearch.xpack.XPackClient;
|
||||||
import org.elasticsearch.xpack.XPackPlugin;
|
import org.elasticsearch.xpack.XPackPlugin;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
|
@ -51,7 +49,6 @@ import static org.hamcrest.core.IsCollectionContaining.hasItem;
|
||||||
*
|
*
|
||||||
* @see SecuritySettingsSource
|
* @see SecuritySettingsSource
|
||||||
*/
|
*/
|
||||||
@SuppressLocalMode
|
|
||||||
public abstract class SecurityIntegTestCase extends ESIntegTestCase {
|
public abstract class SecurityIntegTestCase extends ESIntegTestCase {
|
||||||
|
|
||||||
private static SecuritySettingsSource SECURITY_DEFAULT_SETTINGS;
|
private static SecuritySettingsSource SECURITY_DEFAULT_SETTINGS;
|
||||||
|
@ -394,8 +391,7 @@ public abstract class SecurityIntegTestCase extends ESIntegTestCase {
|
||||||
NodeInfo ni = randomFrom(nodes);
|
NodeInfo ni = randomFrom(nodes);
|
||||||
boolean useSSL = XPackSettings.HTTP_SSL_ENABLED.get(ni.getSettings());
|
boolean useSSL = XPackSettings.HTTP_SSL_ENABLED.get(ni.getSettings());
|
||||||
TransportAddress publishAddress = ni.getHttp().address().publishAddress();
|
TransportAddress publishAddress = ni.getHttp().address().publishAddress();
|
||||||
assertEquals(1, publishAddress.uniqueAddressTypeId());
|
InetSocketAddress address = publishAddress.address();
|
||||||
InetSocketAddress address = ((InetSocketTransportAddress) publishAddress).address();
|
|
||||||
return (useSSL ? "https://" : "http://") + NetworkAddress.format(address.getAddress()) + ":" + address.getPort();
|
return (useSSL ? "https://" : "http://") + NetworkAddress.format(address.getAddress()) + ":" + address.getPort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ package org.elasticsearch.xpack;
|
||||||
import org.elasticsearch.client.transport.TransportClient;
|
import org.elasticsearch.client.transport.TransportClient;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.plugins.Plugin;
|
import org.elasticsearch.plugins.Plugin;
|
||||||
|
import org.elasticsearch.transport.MockTcpTransportPlugin;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -24,6 +25,6 @@ public class TestXPackTransportClient extends TransportClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
public TestXPackTransportClient(Settings settings, Collection<Class<? extends Plugin>> plugins) {
|
public TestXPackTransportClient(Settings settings, Collection<Class<? extends Plugin>> plugins) {
|
||||||
super(settings, Settings.EMPTY, addPlugins(plugins, XPackPlugin.class));
|
super(settings, Settings.EMPTY, addPlugins(plugins, XPackPlugin.class, MockTcpTransportPlugin.class));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,6 @@ import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse;
|
||||||
import org.elasticsearch.action.search.SearchResponse;
|
import org.elasticsearch.action.search.SearchResponse;
|
||||||
import org.elasticsearch.common.network.NetworkModule;
|
import org.elasticsearch.common.network.NetworkModule;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.transport.InetSocketTransportAddress;
|
|
||||||
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.index.IndexNotFoundException;
|
import org.elasticsearch.index.IndexNotFoundException;
|
||||||
|
@ -91,8 +90,7 @@ public class OldMonitoringIndicesBackwardsCompatibilityIT extends AbstractOldXPa
|
||||||
// If we're using the http exporter we need feed it the port and enable it
|
// If we're using the http exporter we need feed it the port and enable it
|
||||||
NodesInfoResponse nodeInfos = client().admin().cluster().prepareNodesInfo().get();
|
NodesInfoResponse nodeInfos = client().admin().cluster().prepareNodesInfo().get();
|
||||||
TransportAddress publishAddress = nodeInfos.getNodes().get(0).getHttp().address().publishAddress();
|
TransportAddress publishAddress = nodeInfos.getNodes().get(0).getHttp().address().publishAddress();
|
||||||
assertEquals(1, publishAddress.uniqueAddressTypeId());
|
InetSocketAddress address = publishAddress.address();
|
||||||
InetSocketAddress address = ((InetSocketTransportAddress) publishAddress).address();
|
|
||||||
Settings.Builder settings = Settings.builder();
|
Settings.Builder settings = Settings.builder();
|
||||||
setupHttpExporter(settings, address.getPort());
|
setupHttpExporter(settings, address.getPort());
|
||||||
client().admin().cluster().prepareUpdateSettings().setTransientSettings(settings).get();
|
client().admin().cluster().prepareUpdateSettings().setTransientSettings(settings).get();
|
||||||
|
|
|
@ -20,7 +20,6 @@ import org.elasticsearch.cluster.service.ClusterService;
|
||||||
import org.elasticsearch.common.settings.ClusterSettings;
|
import org.elasticsearch.common.settings.ClusterSettings;
|
||||||
import org.elasticsearch.common.settings.Setting;
|
import org.elasticsearch.common.settings.Setting;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
|
||||||
import org.elasticsearch.common.util.concurrent.ConcurrentCollections;
|
import org.elasticsearch.common.util.concurrent.ConcurrentCollections;
|
||||||
import org.elasticsearch.discovery.DiscoverySettings;
|
import org.elasticsearch.discovery.DiscoverySettings;
|
||||||
import org.elasticsearch.test.ESTestCase;
|
import org.elasticsearch.test.ESTestCase;
|
||||||
|
@ -96,7 +95,7 @@ public class TransportMonitoringBulkActionTests extends ESTestCase {
|
||||||
clusterService = new ClusterService(Settings.builder().put("cluster.name",
|
clusterService = new ClusterService(Settings.builder().put("cluster.name",
|
||||||
TransportMonitoringBulkActionTests.class.getName()).build(),
|
TransportMonitoringBulkActionTests.class.getName()).build(),
|
||||||
new ClusterSettings(Settings.EMPTY, clusterSettings), threadPool);
|
new ClusterSettings(Settings.EMPTY, clusterSettings), threadPool);
|
||||||
clusterService.setLocalNode(new DiscoveryNode("node", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(),
|
clusterService.setLocalNode(new DiscoveryNode("node", buildNewFakeTransportAddress(), emptyMap(), emptySet(),
|
||||||
Version.CURRENT));
|
Version.CURRENT));
|
||||||
clusterService.setNodeConnectionsService(new NodeConnectionsService(Settings.EMPTY, null, null) {
|
clusterService.setNodeConnectionsService(new NodeConnectionsService(Settings.EMPTY, null, null) {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -9,7 +9,6 @@ import org.elasticsearch.Version;
|
||||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||||
import org.elasticsearch.common.io.stream.BytesStreamOutput;
|
import org.elasticsearch.common.io.stream.BytesStreamOutput;
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
|
||||||
import org.elasticsearch.test.ESTestCase;
|
import org.elasticsearch.test.ESTestCase;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -130,7 +129,7 @@ public class MonitoringDocTests extends ESTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Set<DiscoveryNode.Role> roles = new HashSet<>(randomSubsetOf(Arrays.asList(DiscoveryNode.Role.values())));
|
Set<DiscoveryNode.Role> roles = new HashSet<>(randomSubsetOf(Arrays.asList(DiscoveryNode.Role.values())));
|
||||||
return new DiscoveryNode(randomAsciiOfLength(5), randomAsciiOfLength(3), LocalTransportAddress.buildUnique(),
|
return new DiscoveryNode(randomAsciiOfLength(5), randomAsciiOfLength(3), buildNewFakeTransportAddress(),
|
||||||
attributes, roles, randomVersion(random()));
|
attributes, roles, randomVersion(random()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,6 @@ import org.elasticsearch.common.Nullable;
|
||||||
import org.elasticsearch.common.bytes.BytesArray;
|
import org.elasticsearch.common.bytes.BytesArray;
|
||||||
import org.elasticsearch.common.collect.Tuple;
|
import org.elasticsearch.common.collect.Tuple;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentHelper;
|
import org.elasticsearch.common.xcontent.XContentHelper;
|
||||||
import org.elasticsearch.common.xcontent.XContentType;
|
import org.elasticsearch.common.xcontent.XContentType;
|
||||||
|
@ -495,14 +494,14 @@ public class HttpExporterIT extends MonitoringIntegTestCase {
|
||||||
IndexRecoveryMonitoringDoc doc = new IndexRecoveryMonitoringDoc(MonitoredSystem.ES.getSystem(), Version.CURRENT.toString());
|
IndexRecoveryMonitoringDoc doc = new IndexRecoveryMonitoringDoc(MonitoredSystem.ES.getSystem(), Version.CURRENT.toString());
|
||||||
doc.setClusterUUID(internalCluster().getClusterName());
|
doc.setClusterUUID(internalCluster().getClusterName());
|
||||||
doc.setTimestamp(System.currentTimeMillis());
|
doc.setTimestamp(System.currentTimeMillis());
|
||||||
doc.setSourceNode(new DiscoveryNode("id", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT));
|
doc.setSourceNode(new DiscoveryNode("id", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT));
|
||||||
doc.setRecoveryResponse(new RecoveryResponse());
|
doc.setRecoveryResponse(new RecoveryResponse());
|
||||||
return doc;
|
return doc;
|
||||||
} else {
|
} else {
|
||||||
ClusterStateMonitoringDoc doc = new ClusterStateMonitoringDoc(MonitoredSystem.ES.getSystem(), Version.CURRENT.toString());
|
ClusterStateMonitoringDoc doc = new ClusterStateMonitoringDoc(MonitoredSystem.ES.getSystem(), Version.CURRENT.toString());
|
||||||
doc.setClusterUUID(internalCluster().getClusterName());
|
doc.setClusterUUID(internalCluster().getClusterName());
|
||||||
doc.setTimestamp(System.currentTimeMillis());
|
doc.setTimestamp(System.currentTimeMillis());
|
||||||
doc.setSourceNode(new DiscoveryNode("id", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT));
|
doc.setSourceNode(new DiscoveryNode("id", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT));
|
||||||
doc.setClusterState(ClusterState.PROTO);
|
doc.setClusterState(ClusterState.PROTO);
|
||||||
doc.setStatus(ClusterHealthStatus.GREEN);
|
doc.setStatus(ClusterHealthStatus.GREEN);
|
||||||
return doc;
|
return doc;
|
||||||
|
|
|
@ -13,7 +13,6 @@ import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.cluster.health.ClusterHealthStatus;
|
import org.elasticsearch.cluster.health.ClusterHealthStatus;
|
||||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
|
||||||
import org.elasticsearch.search.SearchHit;
|
import org.elasticsearch.search.SearchHit;
|
||||||
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
|
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
|
||||||
import org.elasticsearch.test.ESIntegTestCase.Scope;
|
import org.elasticsearch.test.ESIntegTestCase.Scope;
|
||||||
|
@ -198,14 +197,14 @@ public class LocalExporterTests extends MonitoringIntegTestCase {
|
||||||
IndexRecoveryMonitoringDoc doc = new IndexRecoveryMonitoringDoc(MonitoredSystem.ES.getSystem(), Version.CURRENT.toString());
|
IndexRecoveryMonitoringDoc doc = new IndexRecoveryMonitoringDoc(MonitoredSystem.ES.getSystem(), Version.CURRENT.toString());
|
||||||
doc.setClusterUUID(internalCluster().getClusterName());
|
doc.setClusterUUID(internalCluster().getClusterName());
|
||||||
doc.setTimestamp(System.currentTimeMillis());
|
doc.setTimestamp(System.currentTimeMillis());
|
||||||
doc.setSourceNode(new DiscoveryNode("id", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT));
|
doc.setSourceNode(new DiscoveryNode("id", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT));
|
||||||
doc.setRecoveryResponse(new RecoveryResponse());
|
doc.setRecoveryResponse(new RecoveryResponse());
|
||||||
return doc;
|
return doc;
|
||||||
} else {
|
} else {
|
||||||
ClusterStateMonitoringDoc doc = new ClusterStateMonitoringDoc(MonitoredSystem.ES.getSystem(), Version.CURRENT.toString());
|
ClusterStateMonitoringDoc doc = new ClusterStateMonitoringDoc(MonitoredSystem.ES.getSystem(), Version.CURRENT.toString());
|
||||||
doc.setClusterUUID(internalCluster().getClusterName());
|
doc.setClusterUUID(internalCluster().getClusterName());
|
||||||
doc.setTimestamp(System.currentTimeMillis());
|
doc.setTimestamp(System.currentTimeMillis());
|
||||||
doc.setSourceNode(new DiscoveryNode("id", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT));
|
doc.setSourceNode(new DiscoveryNode("id", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT));
|
||||||
doc.setClusterState(ClusterState.PROTO);
|
doc.setClusterState(ClusterState.PROTO);
|
||||||
doc.setStatus(ClusterHealthStatus.GREEN);
|
doc.setStatus(ClusterHealthStatus.GREEN);
|
||||||
return doc;
|
return doc;
|
||||||
|
|
|
@ -7,7 +7,6 @@ package org.elasticsearch.xpack.monitoring.resolver;
|
||||||
|
|
||||||
import org.elasticsearch.Version;
|
import org.elasticsearch.Version;
|
||||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContent;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.xpack.monitoring.exporter.MonitoringDoc;
|
import org.elasticsearch.xpack.monitoring.exporter.MonitoringDoc;
|
||||||
|
@ -31,7 +30,7 @@ public class DataResolverTests extends MonitoringIndexNameResolverTestCase {
|
||||||
MonitoringDoc doc = new MonitoringDoc(randomMonitoringId(), randomAsciiOfLength(2));
|
MonitoringDoc doc = new MonitoringDoc(randomMonitoringId(), randomAsciiOfLength(2));
|
||||||
doc.setClusterUUID(randomAsciiOfLength(5));
|
doc.setClusterUUID(randomAsciiOfLength(5));
|
||||||
doc.setTimestamp(Math.abs(randomLong()));
|
doc.setTimestamp(Math.abs(randomLong()));
|
||||||
doc.setSourceNode(new DiscoveryNode("id", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT));
|
doc.setSourceNode(new DiscoveryNode("id", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT));
|
||||||
return doc;
|
return doc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,6 @@ package org.elasticsearch.xpack.monitoring.resolver;
|
||||||
import org.elasticsearch.Version;
|
import org.elasticsearch.Version;
|
||||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContent;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.xpack.monitoring.MonitoredSystem;
|
import org.elasticsearch.xpack.monitoring.MonitoredSystem;
|
||||||
|
@ -40,7 +39,7 @@ public class TimestampedResolverTests extends MonitoringIndexNameResolverTestCas
|
||||||
MonitoringDoc doc = new MonitoringDoc(randomMonitoringId(), randomAsciiOfLength(2));
|
MonitoringDoc doc = new MonitoringDoc(randomMonitoringId(), randomAsciiOfLength(2));
|
||||||
doc.setClusterUUID(randomAsciiOfLength(5));
|
doc.setClusterUUID(randomAsciiOfLength(5));
|
||||||
doc.setTimestamp(Math.abs(randomLong()));
|
doc.setTimestamp(Math.abs(randomLong()));
|
||||||
doc.setSourceNode(new DiscoveryNode(randomAsciiOfLength(5), LocalTransportAddress.buildUnique(),
|
doc.setSourceNode(new DiscoveryNode(randomAsciiOfLength(5), buildNewFakeTransportAddress(),
|
||||||
emptyMap(), emptySet(), Version.CURRENT));
|
emptyMap(), emptySet(), Version.CURRENT));
|
||||||
return doc;
|
return doc;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,6 @@ package org.elasticsearch.xpack.monitoring.resolver.bulk;
|
||||||
import org.elasticsearch.Version;
|
import org.elasticsearch.Version;
|
||||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||||
import org.elasticsearch.common.bytes.BytesArray;
|
import org.elasticsearch.common.bytes.BytesArray;
|
||||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
|
||||||
import org.elasticsearch.common.util.set.Sets;
|
import org.elasticsearch.common.util.set.Sets;
|
||||||
import org.elasticsearch.common.xcontent.XContentType;
|
import org.elasticsearch.common.xcontent.XContentType;
|
||||||
import org.elasticsearch.xpack.monitoring.MonitoredSystem;
|
import org.elasticsearch.xpack.monitoring.MonitoredSystem;
|
||||||
|
@ -41,7 +40,7 @@ public class MonitoringBulkDataResolverTests extends MonitoringIndexNameResolver
|
||||||
|
|
||||||
doc.setClusterUUID(randomAsciiOfLength(5));
|
doc.setClusterUUID(randomAsciiOfLength(5));
|
||||||
doc.setTimestamp(Math.abs(randomLong()));
|
doc.setTimestamp(Math.abs(randomLong()));
|
||||||
doc.setSourceNode(new DiscoveryNode("id", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT));
|
doc.setSourceNode(new DiscoveryNode("id", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT));
|
||||||
return doc;
|
return doc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,6 @@ package org.elasticsearch.xpack.monitoring.resolver.bulk;
|
||||||
import org.elasticsearch.Version;
|
import org.elasticsearch.Version;
|
||||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||||
import org.elasticsearch.common.bytes.BytesArray;
|
import org.elasticsearch.common.bytes.BytesArray;
|
||||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
|
||||||
import org.elasticsearch.common.util.set.Sets;
|
import org.elasticsearch.common.util.set.Sets;
|
||||||
import org.elasticsearch.common.xcontent.XContentType;
|
import org.elasticsearch.common.xcontent.XContentType;
|
||||||
import org.elasticsearch.xpack.monitoring.MonitoredSystem;
|
import org.elasticsearch.xpack.monitoring.MonitoredSystem;
|
||||||
|
@ -43,7 +42,7 @@ public class MonitoringBulkTimestampedResolverTests
|
||||||
}
|
}
|
||||||
|
|
||||||
doc.setClusterUUID(randomAsciiOfLength(5));
|
doc.setClusterUUID(randomAsciiOfLength(5));
|
||||||
doc.setSourceNode(new DiscoveryNode("id", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT));
|
doc.setSourceNode(new DiscoveryNode("id", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT));
|
||||||
return doc;
|
return doc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,6 @@ import org.elasticsearch.action.admin.cluster.stats.ClusterStatsResponse;
|
||||||
import org.elasticsearch.cluster.ClusterName;
|
import org.elasticsearch.cluster.ClusterName;
|
||||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
|
||||||
import org.elasticsearch.common.unit.TimeValue;
|
import org.elasticsearch.common.unit.TimeValue;
|
||||||
import org.elasticsearch.common.util.set.Sets;
|
import org.elasticsearch.common.util.set.Sets;
|
||||||
import org.elasticsearch.common.xcontent.XContentType;
|
import org.elasticsearch.common.xcontent.XContentType;
|
||||||
|
@ -44,7 +43,7 @@ public class ClusterInfoResolverTests extends MonitoringIndexNameResolverTestCas
|
||||||
ClusterInfoMonitoringDoc doc = new ClusterInfoMonitoringDoc(randomMonitoringId(), randomAsciiOfLength(2));
|
ClusterInfoMonitoringDoc doc = new ClusterInfoMonitoringDoc(randomMonitoringId(), randomAsciiOfLength(2));
|
||||||
doc.setClusterUUID(randomAsciiOfLength(5));
|
doc.setClusterUUID(randomAsciiOfLength(5));
|
||||||
doc.setTimestamp(Math.abs(randomLong()));
|
doc.setTimestamp(Math.abs(randomLong()));
|
||||||
doc.setSourceNode(new DiscoveryNode("id", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT));
|
doc.setSourceNode(new DiscoveryNode("id", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT));
|
||||||
doc.setVersion(randomFrom(Version.V_2_0_0, Version.CURRENT).toString());
|
doc.setVersion(randomFrom(Version.V_2_0_0, Version.CURRENT).toString());
|
||||||
doc.setLicense(licenseBuilder.build());
|
doc.setLicense(licenseBuilder.build());
|
||||||
doc.setClusterName(randomAsciiOfLength(5));
|
doc.setClusterName(randomAsciiOfLength(5));
|
||||||
|
|
|
@ -7,7 +7,6 @@ package org.elasticsearch.xpack.monitoring.resolver.cluster;
|
||||||
|
|
||||||
import org.elasticsearch.Version;
|
import org.elasticsearch.Version;
|
||||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
|
||||||
import org.elasticsearch.common.util.set.Sets;
|
import org.elasticsearch.common.util.set.Sets;
|
||||||
import org.elasticsearch.common.xcontent.XContentType;
|
import org.elasticsearch.common.xcontent.XContentType;
|
||||||
import org.elasticsearch.xpack.monitoring.collector.cluster.ClusterStateNodeMonitoringDoc;
|
import org.elasticsearch.xpack.monitoring.collector.cluster.ClusterStateNodeMonitoringDoc;
|
||||||
|
@ -29,7 +28,7 @@ public class ClusterStateNodeResolverTests extends
|
||||||
ClusterStateNodeMonitoringDoc doc = new ClusterStateNodeMonitoringDoc(randomMonitoringId(), randomAsciiOfLength(2));
|
ClusterStateNodeMonitoringDoc doc = new ClusterStateNodeMonitoringDoc(randomMonitoringId(), randomAsciiOfLength(2));
|
||||||
doc.setClusterUUID(randomAsciiOfLength(5));
|
doc.setClusterUUID(randomAsciiOfLength(5));
|
||||||
doc.setTimestamp(Math.abs(randomLong()));
|
doc.setTimestamp(Math.abs(randomLong()));
|
||||||
doc.setSourceNode(new DiscoveryNode("id", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT));
|
doc.setSourceNode(new DiscoveryNode("id", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT));
|
||||||
doc.setNodeId(UUID.randomUUID().toString());
|
doc.setNodeId(UUID.randomUUID().toString());
|
||||||
doc.setStateUUID(UUID.randomUUID().toString());
|
doc.setStateUUID(UUID.randomUUID().toString());
|
||||||
return doc;
|
return doc;
|
||||||
|
|
|
@ -11,7 +11,6 @@ import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.cluster.health.ClusterHealthStatus;
|
import org.elasticsearch.cluster.health.ClusterHealthStatus;
|
||||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||||
import org.elasticsearch.cluster.node.DiscoveryNodes;
|
import org.elasticsearch.cluster.node.DiscoveryNodes;
|
||||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
|
||||||
import org.elasticsearch.common.util.set.Sets;
|
import org.elasticsearch.common.util.set.Sets;
|
||||||
import org.elasticsearch.common.xcontent.XContentType;
|
import org.elasticsearch.common.xcontent.XContentType;
|
||||||
import org.elasticsearch.xpack.monitoring.collector.cluster.ClusterStateMonitoringDoc;
|
import org.elasticsearch.xpack.monitoring.collector.cluster.ClusterStateMonitoringDoc;
|
||||||
|
@ -32,12 +31,12 @@ public class ClusterStateResolverTests extends MonitoringIndexNameResolverTestCa
|
||||||
ClusterStateMonitoringDoc doc = new ClusterStateMonitoringDoc(randomMonitoringId(), randomAsciiOfLength(2));
|
ClusterStateMonitoringDoc doc = new ClusterStateMonitoringDoc(randomMonitoringId(), randomAsciiOfLength(2));
|
||||||
doc.setClusterUUID(randomAsciiOfLength(5));
|
doc.setClusterUUID(randomAsciiOfLength(5));
|
||||||
doc.setTimestamp(Math.abs(randomLong()));
|
doc.setTimestamp(Math.abs(randomLong()));
|
||||||
doc.setSourceNode(new DiscoveryNode("id", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT));
|
doc.setSourceNode(new DiscoveryNode("id", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT));
|
||||||
doc.setStatus(randomFrom(ClusterHealthStatus.values()));
|
doc.setStatus(randomFrom(ClusterHealthStatus.values()));
|
||||||
|
|
||||||
DiscoveryNode masterNode = new DiscoveryNode("master", new LocalTransportAddress("master"),
|
DiscoveryNode masterNode = new DiscoveryNode("master", buildNewFakeTransportAddress(),
|
||||||
emptyMap(), emptySet(), Version.CURRENT);
|
emptyMap(), emptySet(), Version.CURRENT);
|
||||||
DiscoveryNode otherNode = new DiscoveryNode("other", new LocalTransportAddress("other"), emptyMap(), emptySet(), Version.CURRENT);
|
DiscoveryNode otherNode = new DiscoveryNode("other", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT);
|
||||||
DiscoveryNodes discoveryNodes = DiscoveryNodes.builder().add(masterNode).add(otherNode).masterNodeId(masterNode.getId()).build();
|
DiscoveryNodes discoveryNodes = DiscoveryNodes.builder().add(masterNode).add(otherNode).masterNodeId(masterNode.getId()).build();
|
||||||
ClusterState clusterState = ClusterState.builder(new ClusterName("test")).nodes(discoveryNodes).build();
|
ClusterState clusterState = ClusterState.builder(new ClusterName("test")).nodes(discoveryNodes).build();
|
||||||
doc.setClusterState(clusterState);
|
doc.setClusterState(clusterState);
|
||||||
|
|
|
@ -22,7 +22,6 @@ import org.elasticsearch.cluster.routing.ShardRouting;
|
||||||
import org.elasticsearch.cluster.routing.UnassignedInfo;
|
import org.elasticsearch.cluster.routing.UnassignedInfo;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.transport.BoundTransportAddress;
|
import org.elasticsearch.common.transport.BoundTransportAddress;
|
||||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
|
||||||
import org.elasticsearch.common.transport.TransportAddress;
|
import org.elasticsearch.common.transport.TransportAddress;
|
||||||
import org.elasticsearch.common.unit.ByteSizeValue;
|
import org.elasticsearch.common.unit.ByteSizeValue;
|
||||||
import org.elasticsearch.common.util.set.Sets;
|
import org.elasticsearch.common.util.set.Sets;
|
||||||
|
@ -65,7 +64,7 @@ public class ClusterStatsResolverTests extends MonitoringIndexNameResolverTestCa
|
||||||
ClusterStatsMonitoringDoc doc = new ClusterStatsMonitoringDoc(randomMonitoringId(), randomAsciiOfLength(2));
|
ClusterStatsMonitoringDoc doc = new ClusterStatsMonitoringDoc(randomMonitoringId(), randomAsciiOfLength(2));
|
||||||
doc.setClusterUUID(randomAsciiOfLength(5));
|
doc.setClusterUUID(randomAsciiOfLength(5));
|
||||||
doc.setTimestamp(Math.abs(randomLong()));
|
doc.setTimestamp(Math.abs(randomLong()));
|
||||||
doc.setSourceNode(new DiscoveryNode("id", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT));
|
doc.setSourceNode(new DiscoveryNode("id", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT));
|
||||||
doc.setClusterStats(randomClusterStats());
|
doc.setClusterStats(randomClusterStats());
|
||||||
return doc;
|
return doc;
|
||||||
}
|
}
|
||||||
|
@ -97,7 +96,7 @@ public class ClusterStatsResolverTests extends MonitoringIndexNameResolverTestCa
|
||||||
*/
|
*/
|
||||||
private ClusterStatsResponse randomClusterStats() {
|
private ClusterStatsResponse randomClusterStats() {
|
||||||
List<ClusterStatsNodeResponse> responses = Collections.singletonList(
|
List<ClusterStatsNodeResponse> responses = Collections.singletonList(
|
||||||
new ClusterStatsNodeResponse(new DiscoveryNode("node_0", LocalTransportAddress.buildUnique(),
|
new ClusterStatsNodeResponse(new DiscoveryNode("node_0", buildNewFakeTransportAddress(),
|
||||||
emptyMap(), emptySet(), Version.CURRENT),
|
emptyMap(), emptySet(), Version.CURRENT),
|
||||||
ClusterHealthStatus.GREEN, randomNodeInfo(), randomNodeStats(), randomShardStats())
|
ClusterHealthStatus.GREEN, randomNodeInfo(), randomNodeStats(), randomShardStats())
|
||||||
);
|
);
|
||||||
|
@ -109,10 +108,10 @@ public class ClusterStatsResolverTests extends MonitoringIndexNameResolverTestCa
|
||||||
* @return a random {@link NodeInfo} used to resolve a monitoring document.
|
* @return a random {@link NodeInfo} used to resolve a monitoring document.
|
||||||
*/
|
*/
|
||||||
private NodeInfo randomNodeInfo() {
|
private NodeInfo randomNodeInfo() {
|
||||||
BoundTransportAddress transportAddress = new BoundTransportAddress(new TransportAddress[]{LocalTransportAddress.buildUnique()},
|
BoundTransportAddress transportAddress = new BoundTransportAddress(new TransportAddress[]{buildNewFakeTransportAddress()},
|
||||||
LocalTransportAddress.buildUnique());
|
buildNewFakeTransportAddress());
|
||||||
return new NodeInfo(Version.CURRENT, org.elasticsearch.Build.CURRENT,
|
return new NodeInfo(Version.CURRENT, org.elasticsearch.Build.CURRENT,
|
||||||
new DiscoveryNode("node_0", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT), Settings.EMPTY,
|
new DiscoveryNode("node_0", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT), Settings.EMPTY,
|
||||||
DummyOsInfo.INSTANCE, new ProcessInfo(randomInt(), randomBoolean(), randomPositiveLong()), JvmInfo.jvmInfo(),
|
DummyOsInfo.INSTANCE, new ProcessInfo(randomInt(), randomBoolean(), randomPositiveLong()), JvmInfo.jvmInfo(),
|
||||||
new ThreadPoolInfo(Collections.singletonList(new ThreadPool.Info("test_threadpool", ThreadPool.ThreadPoolType.FIXED, 5))),
|
new ThreadPoolInfo(Collections.singletonList(new ThreadPool.Info("test_threadpool", ThreadPool.ThreadPoolType.FIXED, 5))),
|
||||||
new TransportInfo(transportAddress, Collections.emptyMap()), new HttpInfo(transportAddress, randomLong()),
|
new TransportInfo(transportAddress, Collections.emptyMap()), new HttpInfo(transportAddress, randomLong()),
|
||||||
|
@ -131,7 +130,7 @@ public class ClusterStatsResolverTests extends MonitoringIndexNameResolverTestCa
|
||||||
};
|
};
|
||||||
Map<Index, List<IndexShardStats>> statsByShard = new HashMap<>();
|
Map<Index, List<IndexShardStats>> statsByShard = new HashMap<>();
|
||||||
statsByShard.put(index, Collections.singletonList(new IndexShardStats(new ShardId(index, 0), randomShardStats())));
|
statsByShard.put(index, Collections.singletonList(new IndexShardStats(new ShardId(index, 0), randomShardStats())));
|
||||||
return new NodeStats(new DiscoveryNode("node_0", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT), 0,
|
return new NodeStats(new DiscoveryNode("node_0", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT), 0,
|
||||||
new NodeIndicesStats(new CommonStats(), statsByShard), null, null, null, null,
|
new NodeIndicesStats(new CommonStats(), statsByShard), null, null, null, null,
|
||||||
new FsInfo(0, null, pathInfo), null, null, null, null, null, null);
|
new FsInfo(0, null, pathInfo), null, null, null, null, null, null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,6 @@ import org.elasticsearch.cluster.routing.RecoverySource;
|
||||||
import org.elasticsearch.cluster.routing.ShardRouting;
|
import org.elasticsearch.cluster.routing.ShardRouting;
|
||||||
import org.elasticsearch.cluster.routing.ShardRoutingState;
|
import org.elasticsearch.cluster.routing.ShardRoutingState;
|
||||||
import org.elasticsearch.cluster.routing.TestShardRouting;
|
import org.elasticsearch.cluster.routing.TestShardRouting;
|
||||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
|
||||||
import org.elasticsearch.common.util.set.Sets;
|
import org.elasticsearch.common.util.set.Sets;
|
||||||
import org.elasticsearch.common.xcontent.XContentType;
|
import org.elasticsearch.common.xcontent.XContentType;
|
||||||
import org.elasticsearch.index.shard.ShardId;
|
import org.elasticsearch.index.shard.ShardId;
|
||||||
|
@ -37,9 +36,9 @@ public class IndexRecoveryResolverTests extends MonitoringIndexNameResolverTestC
|
||||||
IndexRecoveryMonitoringDoc doc = new IndexRecoveryMonitoringDoc(randomMonitoringId(), randomAsciiOfLength(2));
|
IndexRecoveryMonitoringDoc doc = new IndexRecoveryMonitoringDoc(randomMonitoringId(), randomAsciiOfLength(2));
|
||||||
doc.setClusterUUID(randomAsciiOfLength(5));
|
doc.setClusterUUID(randomAsciiOfLength(5));
|
||||||
doc.setTimestamp(Math.abs(randomLong()));
|
doc.setTimestamp(Math.abs(randomLong()));
|
||||||
doc.setSourceNode(new DiscoveryNode("id", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT));
|
doc.setSourceNode(new DiscoveryNode("id", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT));
|
||||||
|
|
||||||
DiscoveryNode localNode = new DiscoveryNode("foo", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT);
|
DiscoveryNode localNode = new DiscoveryNode("foo", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT);
|
||||||
Map<String, java.util.List<RecoveryState>> shardRecoveryStates = new HashMap<>();
|
Map<String, java.util.List<RecoveryState>> shardRecoveryStates = new HashMap<>();
|
||||||
ShardRouting shardRouting = TestShardRouting.newShardRouting(new ShardId("test", "uuid", 0), localNode.getId(), true,
|
ShardRouting shardRouting = TestShardRouting.newShardRouting(new ShardId("test", "uuid", 0), localNode.getId(), true,
|
||||||
ShardRoutingState.INITIALIZING, RecoverySource.StoreRecoverySource.EXISTING_STORE_INSTANCE);
|
ShardRoutingState.INITIALIZING, RecoverySource.StoreRecoverySource.EXISTING_STORE_INSTANCE);
|
||||||
|
|
|
@ -13,7 +13,6 @@ import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||||
import org.elasticsearch.cluster.routing.RecoverySource;
|
import org.elasticsearch.cluster.routing.RecoverySource;
|
||||||
import org.elasticsearch.cluster.routing.ShardRouting;
|
import org.elasticsearch.cluster.routing.ShardRouting;
|
||||||
import org.elasticsearch.cluster.routing.UnassignedInfo;
|
import org.elasticsearch.cluster.routing.UnassignedInfo;
|
||||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
|
||||||
import org.elasticsearch.common.util.set.Sets;
|
import org.elasticsearch.common.util.set.Sets;
|
||||||
import org.elasticsearch.common.xcontent.XContentType;
|
import org.elasticsearch.common.xcontent.XContentType;
|
||||||
import org.elasticsearch.index.Index;
|
import org.elasticsearch.index.Index;
|
||||||
|
@ -48,7 +47,7 @@ public class IndexStatsResolverTests extends MonitoringIndexNameResolverTestCase
|
||||||
IndexStatsMonitoringDoc doc = new IndexStatsMonitoringDoc(randomMonitoringId(), randomAsciiOfLength(2));
|
IndexStatsMonitoringDoc doc = new IndexStatsMonitoringDoc(randomMonitoringId(), randomAsciiOfLength(2));
|
||||||
doc.setClusterUUID(randomAsciiOfLength(5));
|
doc.setClusterUUID(randomAsciiOfLength(5));
|
||||||
doc.setTimestamp(Math.abs(randomLong()));
|
doc.setTimestamp(Math.abs(randomLong()));
|
||||||
doc.setSourceNode(new DiscoveryNode("id", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT));
|
doc.setSourceNode(new DiscoveryNode("id", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT));
|
||||||
doc.setIndexStats(randomIndexStats());
|
doc.setIndexStats(randomIndexStats());
|
||||||
return doc;
|
return doc;
|
||||||
}
|
}
|
||||||
|
@ -61,7 +60,7 @@ public class IndexStatsResolverTests extends MonitoringIndexNameResolverTestCase
|
||||||
public void testIndexStatsResolver() throws Exception {
|
public void testIndexStatsResolver() throws Exception {
|
||||||
IndexStatsMonitoringDoc doc = newMonitoringDoc();
|
IndexStatsMonitoringDoc doc = newMonitoringDoc();
|
||||||
doc.setTimestamp(1437580442979L);
|
doc.setTimestamp(1437580442979L);
|
||||||
doc.setSourceNode(new DiscoveryNode("id", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT));
|
doc.setSourceNode(new DiscoveryNode("id", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT));
|
||||||
|
|
||||||
IndexStatsResolver resolver = newResolver();
|
IndexStatsResolver resolver = newResolver();
|
||||||
assertThat(resolver.index(doc), equalTo(".monitoring-es-" + MonitoringTemplateUtils.TEMPLATE_VERSION + "-2015.07.22"));
|
assertThat(resolver.index(doc), equalTo(".monitoring-es-" + MonitoringTemplateUtils.TEMPLATE_VERSION + "-2015.07.22"));
|
||||||
|
|
|
@ -14,7 +14,6 @@ import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||||
import org.elasticsearch.cluster.routing.RecoverySource;
|
import org.elasticsearch.cluster.routing.RecoverySource;
|
||||||
import org.elasticsearch.cluster.routing.ShardRouting;
|
import org.elasticsearch.cluster.routing.ShardRouting;
|
||||||
import org.elasticsearch.cluster.routing.UnassignedInfo;
|
import org.elasticsearch.cluster.routing.UnassignedInfo;
|
||||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
|
||||||
import org.elasticsearch.common.util.set.Sets;
|
import org.elasticsearch.common.util.set.Sets;
|
||||||
import org.elasticsearch.common.xcontent.XContentType;
|
import org.elasticsearch.common.xcontent.XContentType;
|
||||||
import org.elasticsearch.index.Index;
|
import org.elasticsearch.index.Index;
|
||||||
|
@ -51,7 +50,7 @@ public class IndicesStatsResolverTests extends MonitoringIndexNameResolverTestCa
|
||||||
IndicesStatsMonitoringDoc doc = new IndicesStatsMonitoringDoc(randomMonitoringId(), randomAsciiOfLength(2));
|
IndicesStatsMonitoringDoc doc = new IndicesStatsMonitoringDoc(randomMonitoringId(), randomAsciiOfLength(2));
|
||||||
doc.setClusterUUID(randomAsciiOfLength(5));
|
doc.setClusterUUID(randomAsciiOfLength(5));
|
||||||
doc.setTimestamp(Math.abs(randomLong()));
|
doc.setTimestamp(Math.abs(randomLong()));
|
||||||
doc.setSourceNode(new DiscoveryNode("id", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT));
|
doc.setSourceNode(new DiscoveryNode("id", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT));
|
||||||
doc.setIndicesStats(randomIndicesStats());
|
doc.setIndicesStats(randomIndicesStats());
|
||||||
return doc;
|
return doc;
|
||||||
}
|
}
|
||||||
|
@ -65,7 +64,7 @@ public class IndicesStatsResolverTests extends MonitoringIndexNameResolverTestCa
|
||||||
IndicesStatsMonitoringDoc doc = newMonitoringDoc();
|
IndicesStatsMonitoringDoc doc = newMonitoringDoc();
|
||||||
doc.setClusterUUID(randomAsciiOfLength(5));
|
doc.setClusterUUID(randomAsciiOfLength(5));
|
||||||
doc.setTimestamp(1437580442979L);
|
doc.setTimestamp(1437580442979L);
|
||||||
doc.setSourceNode(new DiscoveryNode("id", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT));
|
doc.setSourceNode(new DiscoveryNode("id", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT));
|
||||||
|
|
||||||
IndicesStatsResolver resolver = newResolver();
|
IndicesStatsResolver resolver = newResolver();
|
||||||
assertThat(resolver.index(doc), equalTo(".monitoring-es-" + MonitoringTemplateUtils.TEMPLATE_VERSION + "-2015.07.22"));
|
assertThat(resolver.index(doc), equalTo(".monitoring-es-" + MonitoringTemplateUtils.TEMPLATE_VERSION + "-2015.07.22"));
|
||||||
|
|
|
@ -7,7 +7,6 @@ package org.elasticsearch.xpack.monitoring.resolver.node;
|
||||||
|
|
||||||
import org.elasticsearch.Version;
|
import org.elasticsearch.Version;
|
||||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
|
||||||
import org.elasticsearch.common.util.set.Sets;
|
import org.elasticsearch.common.util.set.Sets;
|
||||||
import org.elasticsearch.common.xcontent.XContentType;
|
import org.elasticsearch.common.xcontent.XContentType;
|
||||||
import org.elasticsearch.test.VersionUtils;
|
import org.elasticsearch.test.VersionUtils;
|
||||||
|
@ -29,9 +28,9 @@ public class DiscoveryNodeResolverTests extends MonitoringIndexNameResolverTestC
|
||||||
DiscoveryNodeMonitoringDoc doc = new DiscoveryNodeMonitoringDoc(randomMonitoringId(), randomAsciiOfLength(2));
|
DiscoveryNodeMonitoringDoc doc = new DiscoveryNodeMonitoringDoc(randomMonitoringId(), randomAsciiOfLength(2));
|
||||||
doc.setClusterUUID(randomAsciiOfLength(5));
|
doc.setClusterUUID(randomAsciiOfLength(5));
|
||||||
doc.setTimestamp(Math.abs(randomLong()));
|
doc.setTimestamp(Math.abs(randomLong()));
|
||||||
doc.setSourceNode(new DiscoveryNode("id", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT));
|
doc.setSourceNode(new DiscoveryNode("id", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT));
|
||||||
doc.setNode(new DiscoveryNode(randomAsciiOfLength(3), UUID.randomUUID().toString(),
|
doc.setNode(new DiscoveryNode(randomAsciiOfLength(3), UUID.randomUUID().toString(),
|
||||||
LocalTransportAddress.buildUnique(), emptyMap(), emptySet(),
|
buildNewFakeTransportAddress(), emptyMap(), emptySet(),
|
||||||
VersionUtils.randomVersionBetween(random(), VersionUtils.getFirstVersion(), Version.CURRENT)));
|
VersionUtils.randomVersionBetween(random(), VersionUtils.getFirstVersion(), Version.CURRENT)));
|
||||||
return doc;
|
return doc;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,6 @@ import org.elasticsearch.cluster.routing.RecoverySource;
|
||||||
import org.elasticsearch.cluster.routing.ShardRouting;
|
import org.elasticsearch.cluster.routing.ShardRouting;
|
||||||
import org.elasticsearch.cluster.routing.UnassignedInfo;
|
import org.elasticsearch.cluster.routing.UnassignedInfo;
|
||||||
import org.elasticsearch.common.Nullable;
|
import org.elasticsearch.common.Nullable;
|
||||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
|
||||||
import org.elasticsearch.common.util.set.Sets;
|
import org.elasticsearch.common.util.set.Sets;
|
||||||
import org.elasticsearch.common.xcontent.XContentType;
|
import org.elasticsearch.common.xcontent.XContentType;
|
||||||
import org.elasticsearch.index.Index;
|
import org.elasticsearch.index.Index;
|
||||||
|
@ -63,7 +62,7 @@ public class NodeStatsResolverTests extends MonitoringIndexNameResolverTestCase<
|
||||||
NodeStatsMonitoringDoc doc = new NodeStatsMonitoringDoc(randomMonitoringId(), randomAsciiOfLength(2));
|
NodeStatsMonitoringDoc doc = new NodeStatsMonitoringDoc(randomMonitoringId(), randomAsciiOfLength(2));
|
||||||
doc.setClusterUUID(randomAsciiOfLength(5));
|
doc.setClusterUUID(randomAsciiOfLength(5));
|
||||||
doc.setTimestamp(Math.abs(randomLong()));
|
doc.setTimestamp(Math.abs(randomLong()));
|
||||||
doc.setSourceNode(new DiscoveryNode("id", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT));
|
doc.setSourceNode(new DiscoveryNode("id", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT));
|
||||||
doc.setNodeMaster(randomBoolean());
|
doc.setNodeMaster(randomBoolean());
|
||||||
doc.setNodeId(UUID.randomUUID().toString());
|
doc.setNodeId(UUID.randomUUID().toString());
|
||||||
doc.setMlockall(randomBoolean());
|
doc.setMlockall(randomBoolean());
|
||||||
|
@ -150,7 +149,7 @@ public class NodeStatsResolverTests extends MonitoringIndexNameResolverTestCase<
|
||||||
new ThreadPoolStats.Stats(ThreadPool.Names.SEARCH, 0, 0, 0, 0, 0, 0),
|
new ThreadPoolStats.Stats(ThreadPool.Names.SEARCH, 0, 0, 0, 0, 0, 0),
|
||||||
new ThreadPoolStats.Stats(InternalWatchExecutor.THREAD_POOL_NAME, 0, 0, 0, 0, 0, 0)
|
new ThreadPoolStats.Stats(InternalWatchExecutor.THREAD_POOL_NAME, 0, 0, 0, 0, 0, 0)
|
||||||
);
|
);
|
||||||
return new NodeStats(new DiscoveryNode("node_0", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT), 0,
|
return new NodeStats(new DiscoveryNode("node_0", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT), 0,
|
||||||
new NodeIndicesStats(new CommonStats(), statsByShard), OsProbe.getInstance().osStats(),
|
new NodeIndicesStats(new CommonStats(), statsByShard), OsProbe.getInstance().osStats(),
|
||||||
ProcessProbe.getInstance().processStats(), JvmStats.jvmStats(),
|
ProcessProbe.getInstance().processStats(), JvmStats.jvmStats(),
|
||||||
new ThreadPoolStats(threadPoolStats),
|
new ThreadPoolStats(threadPoolStats),
|
||||||
|
|
|
@ -12,7 +12,6 @@ import org.elasticsearch.cluster.routing.ShardRouting;
|
||||||
import org.elasticsearch.cluster.routing.ShardRoutingState;
|
import org.elasticsearch.cluster.routing.ShardRoutingState;
|
||||||
import org.elasticsearch.cluster.routing.TestShardRouting;
|
import org.elasticsearch.cluster.routing.TestShardRouting;
|
||||||
import org.elasticsearch.cluster.routing.UnassignedInfo;
|
import org.elasticsearch.cluster.routing.UnassignedInfo;
|
||||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
|
||||||
import org.elasticsearch.common.util.set.Sets;
|
import org.elasticsearch.common.util.set.Sets;
|
||||||
import org.elasticsearch.common.xcontent.XContentType;
|
import org.elasticsearch.common.xcontent.XContentType;
|
||||||
import org.elasticsearch.index.Index;
|
import org.elasticsearch.index.Index;
|
||||||
|
@ -35,7 +34,7 @@ public class ShardsResolverTests extends MonitoringIndexNameResolverTestCase<Sha
|
||||||
doc.setClusterUUID(randomAsciiOfLength(5));
|
doc.setClusterUUID(randomAsciiOfLength(5));
|
||||||
doc.setTimestamp(Math.abs(randomLong()));
|
doc.setTimestamp(Math.abs(randomLong()));
|
||||||
doc.setClusterStateUUID(UUID.randomUUID().toString());
|
doc.setClusterStateUUID(UUID.randomUUID().toString());
|
||||||
doc.setSourceNode(new DiscoveryNode("id", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT));
|
doc.setSourceNode(new DiscoveryNode("id", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT));
|
||||||
|
|
||||||
ShardRouting shardRouting = TestShardRouting.newShardRouting(
|
ShardRouting shardRouting = TestShardRouting.newShardRouting(
|
||||||
new ShardId(new Index(randomAsciiOfLength(5), UUID.randomUUID().toString()), randomIntBetween(0, 5)),
|
new ShardId(new Index(randomAsciiOfLength(5), UUID.randomUUID().toString()), randomIntBetween(0, 5)),
|
||||||
|
@ -53,7 +52,7 @@ public class ShardsResolverTests extends MonitoringIndexNameResolverTestCase<Sha
|
||||||
|
|
||||||
final String clusterStateUUID = UUID.randomUUID().toString();
|
final String clusterStateUUID = UUID.randomUUID().toString();
|
||||||
doc.setClusterStateUUID(clusterStateUUID);
|
doc.setClusterStateUUID(clusterStateUUID);
|
||||||
doc.setSourceNode(new DiscoveryNode("id", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT));
|
doc.setSourceNode(new DiscoveryNode("id", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT));
|
||||||
|
|
||||||
ShardsResolver resolver = newResolver();
|
ShardsResolver resolver = newResolver();
|
||||||
assertThat(resolver.index(doc), equalTo(".monitoring-es-" + MonitoringTemplateUtils.TEMPLATE_VERSION + "-2015.07.22"));
|
assertThat(resolver.index(doc), equalTo(".monitoring-es-" + MonitoringTemplateUtils.TEMPLATE_VERSION + "-2015.07.22"));
|
||||||
|
|
|
@ -24,7 +24,6 @@ import org.elasticsearch.plugins.Plugin;
|
||||||
import org.elasticsearch.test.ESIntegTestCase;
|
import org.elasticsearch.test.ESIntegTestCase;
|
||||||
import org.elasticsearch.test.TestCluster;
|
import org.elasticsearch.test.TestCluster;
|
||||||
import org.elasticsearch.test.store.MockFSIndexStore;
|
import org.elasticsearch.test.store.MockFSIndexStore;
|
||||||
import org.elasticsearch.test.transport.AssertingLocalTransport;
|
|
||||||
import org.elasticsearch.test.transport.MockTransportService;
|
import org.elasticsearch.test.transport.MockTransportService;
|
||||||
import org.elasticsearch.xpack.XPackClient;
|
import org.elasticsearch.xpack.XPackClient;
|
||||||
import org.elasticsearch.xpack.XPackPlugin;
|
import org.elasticsearch.xpack.XPackPlugin;
|
||||||
|
@ -141,7 +140,6 @@ public abstract class MonitoringIntegTestCase extends ESIntegTestCase {
|
||||||
protected Collection<Class<? extends Plugin>> getMockPlugins() {
|
protected Collection<Class<? extends Plugin>> getMockPlugins() {
|
||||||
Set<Class<? extends Plugin>> plugins = new HashSet<>(super.getMockPlugins());
|
Set<Class<? extends Plugin>> plugins = new HashSet<>(super.getMockPlugins());
|
||||||
plugins.remove(MockTransportService.TestPlugin.class); // security has its own transport service
|
plugins.remove(MockTransportService.TestPlugin.class); // security has its own transport service
|
||||||
plugins.remove(AssertingLocalTransport.TestPlugin.class); // security has its own transport
|
|
||||||
plugins.add(MockFSIndexStore.TestPlugin.class);
|
plugins.add(MockFSIndexStore.TestPlugin.class);
|
||||||
return plugins;
|
return plugins;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,6 @@ import org.elasticsearch.cluster.node.DiscoveryNodes;
|
||||||
import org.elasticsearch.cluster.service.ClusterService;
|
import org.elasticsearch.cluster.service.ClusterService;
|
||||||
import org.elasticsearch.common.collect.ImmutableOpenMap;
|
import org.elasticsearch.common.collect.ImmutableOpenMap;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
|
||||||
import org.elasticsearch.test.ESTestCase;
|
import org.elasticsearch.test.ESTestCase;
|
||||||
import org.elasticsearch.threadpool.TestThreadPool;
|
import org.elasticsearch.threadpool.TestThreadPool;
|
||||||
import org.elasticsearch.threadpool.ThreadPool;
|
import org.elasticsearch.threadpool.ThreadPool;
|
||||||
|
@ -62,7 +61,7 @@ public class SecurityTemplateServiceTests extends ESTestCase {
|
||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void setup() {
|
||||||
DiscoveryNode localNode = mock(DiscoveryNode.class);
|
DiscoveryNode localNode = mock(DiscoveryNode.class);
|
||||||
when(localNode.getHostAddress()).thenReturn(LocalTransportAddress.buildUnique().toString());
|
when(localNode.getHostAddress()).thenReturn(buildNewFakeTransportAddress().toString());
|
||||||
clusterService = mock(ClusterService.class);
|
clusterService = mock(ClusterService.class);
|
||||||
when(clusterService.localNode()).thenReturn(localNode);
|
when(clusterService.localNode()).thenReturn(localNode);
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,6 @@ import org.elasticsearch.client.transport.TransportClient;
|
||||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||||
import org.elasticsearch.cluster.service.ClusterService;
|
import org.elasticsearch.cluster.service.ClusterService;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
|
||||||
import org.elasticsearch.rest.RestRequest;
|
import org.elasticsearch.rest.RestRequest;
|
||||||
import org.elasticsearch.test.ESTestCase;
|
import org.elasticsearch.test.ESTestCase;
|
||||||
import org.elasticsearch.threadpool.TestThreadPool;
|
import org.elasticsearch.threadpool.TestThreadPool;
|
||||||
|
@ -55,7 +54,7 @@ public class IndexAuditTrailMutedTests extends ESTestCase {
|
||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void setup() {
|
||||||
DiscoveryNode localNode = mock(DiscoveryNode.class);
|
DiscoveryNode localNode = mock(DiscoveryNode.class);
|
||||||
when(localNode.getHostAddress()).thenReturn(LocalTransportAddress.buildUnique().toString());
|
when(localNode.getHostAddress()).thenReturn(buildNewFakeTransportAddress().toString());
|
||||||
clusterService = mock(ClusterService.class);
|
clusterService = mock(ClusterService.class);
|
||||||
when(clusterService.localNode()).thenReturn(localNode);
|
when(clusterService.localNode()).thenReturn(localNode);
|
||||||
|
|
||||||
|
|
|
@ -32,8 +32,7 @@ import org.elasticsearch.common.Priority;
|
||||||
import org.elasticsearch.common.network.NetworkAddress;
|
import org.elasticsearch.common.network.NetworkAddress;
|
||||||
import org.elasticsearch.common.network.NetworkModule;
|
import org.elasticsearch.common.network.NetworkModule;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.transport.InetSocketTransportAddress;
|
import org.elasticsearch.common.transport.TransportAddress;
|
||||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
|
||||||
import org.elasticsearch.plugins.Plugin;
|
import org.elasticsearch.plugins.Plugin;
|
||||||
import org.elasticsearch.rest.RestRequest;
|
import org.elasticsearch.rest.RestRequest;
|
||||||
import org.elasticsearch.search.SearchHit;
|
import org.elasticsearch.search.SearchHit;
|
||||||
|
@ -77,9 +76,6 @@ import static org.hamcrest.Matchers.nullValue;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@ESIntegTestCase.ClusterScope(scope = SUITE, supportsDedicatedMasters = false, numDataNodes = 1)
|
@ESIntegTestCase.ClusterScope(scope = SUITE, supportsDedicatedMasters = false, numDataNodes = 1)
|
||||||
public class IndexAuditTrailTests extends SecurityIntegTestCase {
|
public class IndexAuditTrailTests extends SecurityIntegTestCase {
|
||||||
public static final String SECOND_CLUSTER_NODE_PREFIX = "remote_" + SUITE_CLUSTER_NODE_PREFIX;
|
public static final String SECOND_CLUSTER_NODE_PREFIX = "remote_" + SUITE_CLUSTER_NODE_PREFIX;
|
||||||
|
@ -89,6 +85,8 @@ public class IndexAuditTrailTests extends SecurityIntegTestCase {
|
||||||
private static Settings remoteSettings;
|
private static Settings remoteSettings;
|
||||||
private static byte[] systemKey;
|
private static byte[] systemKey;
|
||||||
|
|
||||||
|
private TransportAddress remoteAddress = buildNewFakeTransportAddress();
|
||||||
|
private TransportAddress localAddress = new TransportAddress(InetAddress.getLoopbackAddress(), 0);
|
||||||
private IndexNameResolver.Rollover rollover;
|
private IndexNameResolver.Rollover rollover;
|
||||||
private IndexAuditTrail auditor;
|
private IndexAuditTrail auditor;
|
||||||
private SetOnce<Message> enqueuedMessage;
|
private SetOnce<Message> enqueuedMessage;
|
||||||
|
@ -160,7 +158,7 @@ public class IndexAuditTrailTests extends SecurityIntegTestCase {
|
||||||
|
|
||||||
NodesInfoResponse response = remoteCluster.client().admin().cluster().prepareNodesInfo().execute().actionGet();
|
NodesInfoResponse response = remoteCluster.client().admin().cluster().prepareNodesInfo().execute().actionGet();
|
||||||
TransportInfo info = response.getNodes().get(0).getTransport();
|
TransportInfo info = response.getNodes().get(0).getTransport();
|
||||||
InetSocketTransportAddress inet = (InetSocketTransportAddress) info.address().publishAddress();
|
TransportAddress inet = info.address().publishAddress();
|
||||||
|
|
||||||
Settings.Builder builder = Settings.builder()
|
Settings.Builder builder = Settings.builder()
|
||||||
.put(XPackSettings.SECURITY_ENABLED.getKey(), useSecurity)
|
.put(XPackSettings.SECURITY_ENABLED.getKey(), useSecurity)
|
||||||
|
@ -266,8 +264,8 @@ public class IndexAuditTrailTests extends SecurityIntegTestCase {
|
||||||
Settings settings = builder.put(settings(rollover, includes, excludes)).build();
|
Settings settings = builder.put(settings(rollover, includes, excludes)).build();
|
||||||
logger.info("--> settings: [{}]", settings.getAsMap().toString());
|
logger.info("--> settings: [{}]", settings.getAsMap().toString());
|
||||||
DiscoveryNode localNode = mock(DiscoveryNode.class);
|
DiscoveryNode localNode = mock(DiscoveryNode.class);
|
||||||
when(localNode.getHostAddress()).thenReturn(remoteHostAddress().getAddress());
|
when(localNode.getHostAddress()).thenReturn(remoteAddress.getAddress());
|
||||||
when(localNode.getHostName()).thenReturn(remoteHostAddress().getHost());
|
when(localNode.getHostName()).thenReturn(remoteAddress.getHost());
|
||||||
ClusterService clusterService = mock(ClusterService.class);
|
ClusterService clusterService = mock(ClusterService.class);
|
||||||
when(clusterService.localNode()).thenReturn(localNode);
|
when(clusterService.localNode()).thenReturn(localNode);
|
||||||
threadPool = new TestThreadPool("index audit trail tests");
|
threadPool = new TestThreadPool("index audit trail tests");
|
||||||
|
@ -291,9 +289,9 @@ public class IndexAuditTrailTests extends SecurityIntegTestCase {
|
||||||
assertAuditMessage(hit, "transport", "anonymous_access_denied");
|
assertAuditMessage(hit, "transport", "anonymous_access_denied");
|
||||||
Map<String, Object> sourceMap = hit.sourceAsMap();
|
Map<String, Object> sourceMap = hit.sourceAsMap();
|
||||||
if (message instanceof RemoteHostMockMessage) {
|
if (message instanceof RemoteHostMockMessage) {
|
||||||
assertEquals(remoteHostAddress().toString(), sourceMap.get("origin_address"));
|
assertEquals(remoteAddress.getAddress(), sourceMap.get("origin_address"));
|
||||||
} else {
|
} else {
|
||||||
assertEquals("local[local_host]", sourceMap.get("origin_address"));
|
assertEquals(localAddress.getAddress(), sourceMap.get("origin_address"));
|
||||||
}
|
}
|
||||||
|
|
||||||
assertEquals("_action", sourceMap.get("action"));
|
assertEquals("_action", sourceMap.get("action"));
|
||||||
|
@ -328,9 +326,9 @@ public class IndexAuditTrailTests extends SecurityIntegTestCase {
|
||||||
assertAuditMessage(hit, "transport", "authentication_failed");
|
assertAuditMessage(hit, "transport", "authentication_failed");
|
||||||
|
|
||||||
if (message instanceof RemoteHostMockMessage) {
|
if (message instanceof RemoteHostMockMessage) {
|
||||||
assertEquals(remoteHostAddress().toString(), sourceMap.get("origin_address"));
|
assertEquals(remoteAddress.getAddress(), sourceMap.get("origin_address"));
|
||||||
} else {
|
} else {
|
||||||
assertEquals("local[local_host]", sourceMap.get("origin_address"));
|
assertEquals(localAddress.getAddress(), sourceMap.get("origin_address"));
|
||||||
}
|
}
|
||||||
|
|
||||||
assertEquals("_principal", sourceMap.get("principal"));
|
assertEquals("_principal", sourceMap.get("principal"));
|
||||||
|
@ -348,9 +346,9 @@ public class IndexAuditTrailTests extends SecurityIntegTestCase {
|
||||||
assertAuditMessage(hit, "transport", "authentication_failed");
|
assertAuditMessage(hit, "transport", "authentication_failed");
|
||||||
Map<String, Object> sourceMap = hit.sourceAsMap();
|
Map<String, Object> sourceMap = hit.sourceAsMap();
|
||||||
if (message instanceof RemoteHostMockMessage) {
|
if (message instanceof RemoteHostMockMessage) {
|
||||||
assertEquals(remoteHostAddress().toString(), sourceMap.get("origin_address"));
|
assertEquals(remoteAddress.getAddress(), sourceMap.get("origin_address"));
|
||||||
} else {
|
} else {
|
||||||
assertEquals("local[local_host]", sourceMap.get("origin_address"));
|
assertEquals(localAddress.getAddress(), sourceMap.get("origin_address"));
|
||||||
}
|
}
|
||||||
|
|
||||||
assertThat(sourceMap.get("principal"), nullValue());
|
assertThat(sourceMap.get("principal"), nullValue());
|
||||||
|
@ -403,9 +401,9 @@ public class IndexAuditTrailTests extends SecurityIntegTestCase {
|
||||||
Map<String, Object> sourceMap = hit.sourceAsMap();
|
Map<String, Object> sourceMap = hit.sourceAsMap();
|
||||||
|
|
||||||
if (message instanceof RemoteHostMockMessage) {
|
if (message instanceof RemoteHostMockMessage) {
|
||||||
assertEquals(remoteHostAddress().toString(), sourceMap.get("origin_address"));
|
assertEquals(remoteAddress.getAddress(), sourceMap.get("origin_address"));
|
||||||
} else {
|
} else {
|
||||||
assertEquals("local[local_host]", sourceMap.get("origin_address"));
|
assertEquals(localAddress.getAddress(), sourceMap.get("origin_address"));
|
||||||
}
|
}
|
||||||
|
|
||||||
assertEquals("transport", sourceMap.get("origin_type"));
|
assertEquals("transport", sourceMap.get("origin_type"));
|
||||||
|
@ -688,8 +686,8 @@ public class IndexAuditTrailTests extends SecurityIntegTestCase {
|
||||||
DateTime dateTime = ISODateTimeFormat.dateTimeParser().withZoneUTC().parseDateTime((String) sourceMap.get("@timestamp"));
|
DateTime dateTime = ISODateTimeFormat.dateTimeParser().withZoneUTC().parseDateTime((String) sourceMap.get("@timestamp"));
|
||||||
assertThat(dateTime.isBefore(DateTime.now(DateTimeZone.UTC)), is(true));
|
assertThat(dateTime.isBefore(DateTime.now(DateTimeZone.UTC)), is(true));
|
||||||
|
|
||||||
assertThat(remoteHostAddress().getHost(), equalTo(sourceMap.get("node_host_name")));
|
assertThat(remoteAddress.getHost(), equalTo(sourceMap.get("node_host_name")));
|
||||||
assertThat(remoteHostAddress().getAddress(), equalTo(sourceMap.get("node_host_address")));
|
assertThat(remoteAddress.getAddress(), equalTo(sourceMap.get("node_host_address")));
|
||||||
|
|
||||||
assertEquals(layer, sourceMap.get("layer"));
|
assertEquals(layer, sourceMap.get("layer"));
|
||||||
assertEquals(type, sourceMap.get("event_type"));
|
assertEquals(type, sourceMap.get("event_type"));
|
||||||
|
@ -702,25 +700,25 @@ public class IndexAuditTrailTests extends SecurityIntegTestCase {
|
||||||
assertThat(sourceMap.get("request_body"), nullValue());
|
assertThat(sourceMap.get("request_body"), nullValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private static class LocalHostMockMessage extends TransportMessage {
|
private class LocalHostMockMessage extends TransportMessage {
|
||||||
LocalHostMockMessage() {
|
LocalHostMockMessage() {
|
||||||
remoteAddress(new LocalTransportAddress("local_host"));
|
remoteAddress(localAddress);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class RemoteHostMockMessage extends TransportMessage {
|
private class RemoteHostMockMessage extends TransportMessage {
|
||||||
RemoteHostMockMessage() throws Exception {
|
RemoteHostMockMessage() throws Exception {
|
||||||
remoteAddress(remoteHostAddress());
|
remoteAddress(remoteAddress);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class RemoteHostMockTransportRequest extends TransportRequest {
|
private class RemoteHostMockTransportRequest extends TransportRequest {
|
||||||
RemoteHostMockTransportRequest() throws Exception {
|
RemoteHostMockTransportRequest() throws Exception {
|
||||||
remoteAddress(remoteHostAddress());
|
remoteAddress(remoteAddress);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class MockIndicesTransportMessage extends RemoteHostMockMessage implements IndicesRequest {
|
private class MockIndicesTransportMessage extends RemoteHostMockMessage implements IndicesRequest {
|
||||||
MockIndicesTransportMessage() throws Exception {
|
MockIndicesTransportMessage() throws Exception {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
@ -811,9 +809,5 @@ public class IndexAuditTrailTests extends SecurityIntegTestCase {
|
||||||
logger.debug("indices {} are yellow", indices.length == 0 ? "[_all]" : indices);
|
logger.debug("indices {} are yellow", indices.length == 0 ? "[_all]" : indices);
|
||||||
return actionGet.getStatus();
|
return actionGet.getStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static LocalTransportAddress remoteHostAddress() {
|
|
||||||
return new LocalTransportAddress("_remote_host_");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@ import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsResponse;
|
||||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||||
import org.elasticsearch.cluster.service.ClusterService;
|
import org.elasticsearch.cluster.service.ClusterService;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
|
||||||
import org.elasticsearch.test.ESIntegTestCase;
|
import org.elasticsearch.test.ESIntegTestCase;
|
||||||
import org.elasticsearch.test.SecurityIntegTestCase;
|
import org.elasticsearch.test.SecurityIntegTestCase;
|
||||||
import org.elasticsearch.test.rest.FakeRestRequest;
|
import org.elasticsearch.test.rest.FakeRestRequest;
|
||||||
|
@ -47,7 +46,7 @@ public class IndexAuditTrailUpdateMappingTests extends SecurityIntegTestCase {
|
||||||
Settings settings = Settings.builder().put("xpack.security.audit.index.rollover", rollover.name().toLowerCase(Locale.ENGLISH))
|
Settings settings = Settings.builder().put("xpack.security.audit.index.rollover", rollover.name().toLowerCase(Locale.ENGLISH))
|
||||||
.put("path.home", createTempDir()).build();
|
.put("path.home", createTempDir()).build();
|
||||||
DiscoveryNode localNode = mock(DiscoveryNode.class);
|
DiscoveryNode localNode = mock(DiscoveryNode.class);
|
||||||
when(localNode.getHostAddress()).thenReturn(LocalTransportAddress.buildUnique().toString());
|
when(localNode.getHostAddress()).thenReturn(buildNewFakeTransportAddress().toString());
|
||||||
ClusterService clusterService = mock(ClusterService.class);
|
ClusterService clusterService = mock(ClusterService.class);
|
||||||
when(clusterService.localNode()).thenReturn(localNode);
|
when(clusterService.localNode()).thenReturn(localNode);
|
||||||
auditor = new IndexAuditTrail(settings, internalClient(), threadPool, clusterService);
|
auditor = new IndexAuditTrail(settings, internalClient(), threadPool, clusterService);
|
||||||
|
|
|
@ -8,7 +8,7 @@ package org.elasticsearch.xpack.security.audit.index;
|
||||||
import org.elasticsearch.action.admin.cluster.node.info.NodeInfo;
|
import org.elasticsearch.action.admin.cluster.node.info.NodeInfo;
|
||||||
import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse;
|
import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.transport.InetSocketTransportAddress;
|
import org.elasticsearch.common.transport.TransportAddress;
|
||||||
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
|
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
|
||||||
import org.elasticsearch.test.ESIntegTestCase.Scope;
|
import org.elasticsearch.test.ESIntegTestCase.Scope;
|
||||||
import org.elasticsearch.test.InternalTestCluster;
|
import org.elasticsearch.test.InternalTestCluster;
|
||||||
|
@ -81,7 +81,7 @@ public class RemoteIndexAuditTrailStartingTests extends SecurityIntegTestCase {
|
||||||
NodesInfoResponse response = client().admin().cluster().prepareNodesInfo().execute().actionGet();
|
NodesInfoResponse response = client().admin().cluster().prepareNodesInfo().execute().actionGet();
|
||||||
final String clusterName = response.getClusterName().value();
|
final String clusterName = response.getClusterName().value();
|
||||||
for (NodeInfo nodeInfo : response.getNodes()) {
|
for (NodeInfo nodeInfo : response.getNodes()) {
|
||||||
InetSocketTransportAddress address = (InetSocketTransportAddress) nodeInfo.getTransport().address().publishAddress();
|
TransportAddress address = nodeInfo.getTransport().address().publishAddress();
|
||||||
addresses.add(address.address().getHostString() + ":" + address.address().getPort());
|
addresses.add(address.address().getHostString() + ":" + address.address().getPort());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,8 +16,6 @@ import org.elasticsearch.common.bytes.BytesArray;
|
||||||
import org.elasticsearch.common.bytes.BytesReference;
|
import org.elasticsearch.common.bytes.BytesReference;
|
||||||
import org.elasticsearch.common.network.NetworkAddress;
|
import org.elasticsearch.common.network.NetworkAddress;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.transport.InetSocketTransportAddress;
|
|
||||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
|
||||||
import org.elasticsearch.common.transport.TransportAddress;
|
import org.elasticsearch.common.transport.TransportAddress;
|
||||||
import org.elasticsearch.common.util.concurrent.ThreadContext;
|
import org.elasticsearch.common.util.concurrent.ThreadContext;
|
||||||
import org.elasticsearch.rest.RestRequest;
|
import org.elasticsearch.rest.RestRequest;
|
||||||
|
@ -119,7 +117,7 @@ public class LoggingAuditTrailTests extends ESTestCase {
|
||||||
.put("xpack.security.audit.logfile.events.emit_request_body", includeRequestBody)
|
.put("xpack.security.audit.logfile.events.emit_request_body", includeRequestBody)
|
||||||
.build();
|
.build();
|
||||||
localNode = mock(DiscoveryNode.class);
|
localNode = mock(DiscoveryNode.class);
|
||||||
when(localNode.getHostAddress()).thenReturn(LocalTransportAddress.buildUnique().toString());
|
when(localNode.getHostAddress()).thenReturn(buildNewFakeTransportAddress().toString());
|
||||||
clusterService = mock(ClusterService.class);
|
clusterService = mock(ClusterService.class);
|
||||||
when(clusterService.localNode()).thenReturn(localNode);
|
when(clusterService.localNode()).thenReturn(localNode);
|
||||||
prefix = LoggingAuditTrail.resolvePrefix(settings, localNode);
|
prefix = LoggingAuditTrail.resolvePrefix(settings, localNode);
|
||||||
|
@ -595,12 +593,8 @@ public class LoggingAuditTrailTests extends ESTestCase {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (address instanceof InetSocketTransportAddress) {
|
assertThat(text, equalTo("origin_type=[transport], origin_address=[" +
|
||||||
assertThat(text, equalTo("origin_type=[transport], origin_address=[" +
|
NetworkAddress.format(address.address().getAddress()) + "]"));
|
||||||
NetworkAddress.format(((InetSocketTransportAddress) address).address().getAddress()) + "]"));
|
|
||||||
} else {
|
|
||||||
assertThat(text, equalTo("origin_type=[transport], origin_address=[" + address + "]"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAuthenticationSuccessRest() throws Exception {
|
public void testAuthenticationSuccessRest() throws Exception {
|
||||||
|
@ -716,9 +710,9 @@ public class LoggingAuditTrailTests extends ESTestCase {
|
||||||
private MockMessage(ThreadContext threadContext) throws IOException {
|
private MockMessage(ThreadContext threadContext) throws IOException {
|
||||||
if (randomBoolean()) {
|
if (randomBoolean()) {
|
||||||
if (randomBoolean()) {
|
if (randomBoolean()) {
|
||||||
remoteAddress(new LocalTransportAddress("local_host"));
|
remoteAddress(buildNewFakeTransportAddress());
|
||||||
} else {
|
} else {
|
||||||
remoteAddress(new InetSocketTransportAddress(InetAddress.getLoopbackAddress(), 1234));
|
remoteAddress(new TransportAddress(InetAddress.getLoopbackAddress(), 1234));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (randomBoolean()) {
|
if (randomBoolean()) {
|
||||||
|
@ -731,7 +725,7 @@ public class LoggingAuditTrailTests extends ESTestCase {
|
||||||
|
|
||||||
private MockIndicesRequest(ThreadContext threadContext) throws IOException {
|
private MockIndicesRequest(ThreadContext threadContext) throws IOException {
|
||||||
if (randomBoolean()) {
|
if (randomBoolean()) {
|
||||||
remoteAddress(new LocalTransportAddress("_host"));
|
remoteAddress(buildNewFakeTransportAddress());
|
||||||
}
|
}
|
||||||
if (randomBoolean()) {
|
if (randomBoolean()) {
|
||||||
RemoteHostHeader.putRestRemoteAddress(threadContext, new InetSocketAddress(forge("localhost", "127.0.0.1"), 1234));
|
RemoteHostHeader.putRestRemoteAddress(threadContext, new InetSocketAddress(forge("localhost", "127.0.0.1"), 1234));
|
||||||
|
|
|
@ -16,7 +16,6 @@ import org.elasticsearch.client.transport.NoNodeAvailableException;
|
||||||
import org.elasticsearch.client.transport.TransportClient;
|
import org.elasticsearch.client.transport.TransportClient;
|
||||||
import org.elasticsearch.common.network.NetworkModule;
|
import org.elasticsearch.common.network.NetworkModule;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.transport.InetSocketTransportAddress;
|
|
||||||
import org.elasticsearch.common.transport.TransportAddress;
|
import org.elasticsearch.common.transport.TransportAddress;
|
||||||
import org.elasticsearch.http.HttpServerTransport;
|
import org.elasticsearch.http.HttpServerTransport;
|
||||||
import org.elasticsearch.xpack.security.Security;
|
import org.elasticsearch.xpack.security.Security;
|
||||||
|
@ -161,8 +160,6 @@ public class PkiAuthenticationTests extends SecurityIntegTestCase {
|
||||||
private String getNodeUrl() {
|
private String getNodeUrl() {
|
||||||
TransportAddress transportAddress = randomFrom(internalCluster().getInstance(HttpServerTransport.class)
|
TransportAddress transportAddress = randomFrom(internalCluster().getInstance(HttpServerTransport.class)
|
||||||
.boundAddress().boundAddresses());
|
.boundAddress().boundAddresses());
|
||||||
assertThat(transportAddress, is(instanceOf(InetSocketTransportAddress.class)));
|
return String.format(Locale.ROOT, "https://localhost:%s/", transportAddress.address().getPort());
|
||||||
InetSocketTransportAddress inetSocketTransportAddress = (InetSocketTransportAddress) transportAddress;
|
|
||||||
return String.format(Locale.ROOT, "https://localhost:%s/", inetSocketTransportAddress.address().getPort());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ import org.elasticsearch.client.RestClient;
|
||||||
import org.elasticsearch.client.transport.TransportClient;
|
import org.elasticsearch.client.transport.TransportClient;
|
||||||
import org.elasticsearch.common.network.NetworkModule;
|
import org.elasticsearch.common.network.NetworkModule;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.transport.InetSocketTransportAddress;
|
import org.elasticsearch.common.transport.TransportAddress;
|
||||||
import org.elasticsearch.test.SecurityIntegTestCase;
|
import org.elasticsearch.test.SecurityIntegTestCase;
|
||||||
import org.elasticsearch.test.SecuritySettingsSource;
|
import org.elasticsearch.test.SecuritySettingsSource;
|
||||||
import org.elasticsearch.transport.Transport;
|
import org.elasticsearch.transport.Transport;
|
||||||
|
@ -95,8 +95,7 @@ public class PkiOptionalClientAuthTests extends SecurityIntegTestCase {
|
||||||
|
|
||||||
public void testTransportClientWithoutClientCertificate() {
|
public void testTransportClientWithoutClientCertificate() {
|
||||||
Transport transport = internalCluster().getDataNodeInstance(Transport.class);
|
Transport transport = internalCluster().getDataNodeInstance(Transport.class);
|
||||||
int port = ((InetSocketTransportAddress)
|
int port = randomFrom(transport.profileBoundAddresses().get("want_client_auth").boundAddresses()).address().getPort();
|
||||||
randomFrom(transport.profileBoundAddresses().get("want_client_auth").boundAddresses())).address().getPort();
|
|
||||||
|
|
||||||
Settings sslSettingsForStore = getSSLSettingsForStore
|
Settings sslSettingsForStore = getSSLSettingsForStore
|
||||||
("/org/elasticsearch/xpack/security/transport/ssl/certs/simple/truststore-testnode-only.jks", "truststore-testnode-only");
|
("/org/elasticsearch/xpack/security/transport/ssl/certs/simple/truststore-testnode-only.jks", "truststore-testnode-only");
|
||||||
|
@ -109,7 +108,7 @@ public class PkiOptionalClientAuthTests extends SecurityIntegTestCase {
|
||||||
|
|
||||||
|
|
||||||
try (TransportClient client = new TestXPackTransportClient(settings)) {
|
try (TransportClient client = new TestXPackTransportClient(settings)) {
|
||||||
client.addTransportAddress(new InetSocketTransportAddress(InetAddress.getLoopbackAddress(), port));
|
client.addTransportAddress(new TransportAddress(InetAddress.getLoopbackAddress(), port));
|
||||||
assertGreenClusterState(client);
|
assertGreenClusterState(client);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,6 @@ package org.elasticsearch.xpack.security.transport;
|
||||||
import org.elasticsearch.common.network.NetworkAddress;
|
import org.elasticsearch.common.network.NetworkAddress;
|
||||||
import org.elasticsearch.common.network.NetworkModule;
|
import org.elasticsearch.common.network.NetworkModule;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.transport.InetSocketTransportAddress;
|
|
||||||
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.discovery.MasterNotDiscoveredException;
|
import org.elasticsearch.discovery.MasterNotDiscoveredException;
|
||||||
|
@ -87,9 +86,7 @@ public class ServerTransportFilterIntegrationTests extends SecurityIntegTestCase
|
||||||
|
|
||||||
Transport transport = internalCluster().getDataNodeInstance(Transport.class);
|
Transport transport = internalCluster().getDataNodeInstance(Transport.class);
|
||||||
TransportAddress transportAddress = transport.boundAddress().publishAddress();
|
TransportAddress transportAddress = transport.boundAddress().publishAddress();
|
||||||
assertThat(transportAddress, instanceOf(InetSocketTransportAddress.class));
|
String unicastHost = NetworkAddress.format(transportAddress.address());
|
||||||
InetSocketAddress inetSocketAddress = ((InetSocketTransportAddress) transportAddress).address();
|
|
||||||
String unicastHost = NetworkAddress.format(inetSocketAddress);
|
|
||||||
|
|
||||||
// test that starting up a node works
|
// test that starting up a node works
|
||||||
Settings nodeSettings = Settings.builder()
|
Settings nodeSettings = Settings.builder()
|
||||||
|
@ -118,13 +115,6 @@ public class ServerTransportFilterIntegrationTests extends SecurityIntegTestCase
|
||||||
writeFile(xpackConf, "users", configUsers());
|
writeFile(xpackConf, "users", configUsers());
|
||||||
writeFile(xpackConf, "users_roles", configUsersRoles());
|
writeFile(xpackConf, "users_roles", configUsersRoles());
|
||||||
writeFile(xpackConf, "roles.yml", configRoles());
|
writeFile(xpackConf, "roles.yml", configRoles());
|
||||||
|
|
||||||
Transport transport = internalCluster().getDataNodeInstance(Transport.class);
|
|
||||||
TransportAddress transportAddress = transport.profileBoundAddresses().get("client").publishAddress();
|
|
||||||
assertThat(transportAddress, instanceOf(InetSocketTransportAddress.class));
|
|
||||||
InetSocketAddress inetSocketAddress = ((InetSocketTransportAddress) transportAddress).address();
|
|
||||||
int port = inetSocketAddress.getPort();
|
|
||||||
|
|
||||||
// test that starting up a node works
|
// test that starting up a node works
|
||||||
Settings nodeSettings = Settings.builder()
|
Settings nodeSettings = Settings.builder()
|
||||||
.put("xpack.security.authc.realms.file.type", FileRealm.TYPE)
|
.put("xpack.security.authc.realms.file.type", FileRealm.TYPE)
|
||||||
|
|
|
@ -11,6 +11,7 @@ import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||||
import org.elasticsearch.common.inject.AbstractModule;
|
import org.elasticsearch.common.inject.AbstractModule;
|
||||||
import org.elasticsearch.common.inject.Binder;
|
import org.elasticsearch.common.inject.Binder;
|
||||||
import org.elasticsearch.common.inject.Module;
|
import org.elasticsearch.common.inject.Module;
|
||||||
|
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
|
@ -58,7 +59,6 @@ import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
@ClusterScope(scope = SUITE, numDataNodes = 0)
|
@ClusterScope(scope = SUITE, numDataNodes = 0)
|
||||||
@ESIntegTestCase.SuppressLocalMode
|
|
||||||
public class TransportFilterTests extends ESIntegTestCase {
|
public class TransportFilterTests extends ESIntegTestCase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -305,7 +305,7 @@ public class TransportFilterTests extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<TransportInterceptor> getTransportInterceptors() {
|
public List<TransportInterceptor> getTransportInterceptors(NamedWriteableRegistry namedWriteableRegistry) {
|
||||||
return Collections.singletonList(new TransportInterceptor() {
|
return Collections.singletonList(new TransportInterceptor() {
|
||||||
@Override
|
@Override
|
||||||
public <T extends TransportRequest> TransportRequestHandler<T> interceptHandler(String action,
|
public <T extends TransportRequest> TransportRequestHandler<T> interceptHandler(String action,
|
||||||
|
|
|
@ -11,7 +11,6 @@ import org.elasticsearch.common.network.NetworkAddress;
|
||||||
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.transport.BoundTransportAddress;
|
import org.elasticsearch.common.transport.BoundTransportAddress;
|
||||||
import org.elasticsearch.common.transport.InetSocketTransportAddress;
|
|
||||||
import org.elasticsearch.common.transport.TransportAddress;
|
import org.elasticsearch.common.transport.TransportAddress;
|
||||||
import org.elasticsearch.http.HttpServerTransport;
|
import org.elasticsearch.http.HttpServerTransport;
|
||||||
import org.elasticsearch.license.XPackLicenseState;
|
import org.elasticsearch.license.XPackLicenseState;
|
||||||
|
@ -68,17 +67,17 @@ public class IPFilterTests extends ESTestCase {
|
||||||
TransportSettings.TRANSPORT_PROFILES_SETTING)));
|
TransportSettings.TRANSPORT_PROFILES_SETTING)));
|
||||||
|
|
||||||
httpTransport = mock(HttpServerTransport.class);
|
httpTransport = mock(HttpServerTransport.class);
|
||||||
InetSocketTransportAddress httpAddress = new InetSocketTransportAddress(InetAddress.getLoopbackAddress(), 9200);
|
TransportAddress httpAddress = new TransportAddress(InetAddress.getLoopbackAddress(), 9200);
|
||||||
when(httpTransport.boundAddress()).thenReturn(new BoundTransportAddress(new TransportAddress[] { httpAddress }, httpAddress));
|
when(httpTransport.boundAddress()).thenReturn(new BoundTransportAddress(new TransportAddress[] { httpAddress }, httpAddress));
|
||||||
when(httpTransport.lifecycleState()).thenReturn(Lifecycle.State.STARTED);
|
when(httpTransport.lifecycleState()).thenReturn(Lifecycle.State.STARTED);
|
||||||
|
|
||||||
transport = mock(Transport.class);
|
transport = mock(Transport.class);
|
||||||
InetSocketTransportAddress address = new InetSocketTransportAddress(InetAddress.getLoopbackAddress(), 9300);
|
TransportAddress address = new TransportAddress(InetAddress.getLoopbackAddress(), 9300);
|
||||||
when(transport.boundAddress()).thenReturn(new BoundTransportAddress(new TransportAddress[]{ address }, address));
|
when(transport.boundAddress()).thenReturn(new BoundTransportAddress(new TransportAddress[]{ address }, address));
|
||||||
when(transport.lifecycleState()).thenReturn(Lifecycle.State.STARTED);
|
when(transport.lifecycleState()).thenReturn(Lifecycle.State.STARTED);
|
||||||
|
|
||||||
Map<String, BoundTransportAddress> profileBoundAddresses = Collections.singletonMap("client",
|
Map<String, BoundTransportAddress> profileBoundAddresses = Collections.singletonMap("client",
|
||||||
new BoundTransportAddress(new TransportAddress[]{ new InetSocketTransportAddress(InetAddress.getLoopbackAddress(), 9500) },
|
new BoundTransportAddress(new TransportAddress[]{ new TransportAddress(InetAddress.getLoopbackAddress(), 9500) },
|
||||||
address));
|
address));
|
||||||
when(transport.profileBoundAddresses()).thenReturn(profileBoundAddresses);
|
when(transport.profileBoundAddresses()).thenReturn(profileBoundAddresses);
|
||||||
}
|
}
|
||||||
|
@ -196,7 +195,7 @@ public class IPFilterTests extends ESTestCase {
|
||||||
public void testThatBoundAddressIsNeverRejected() throws Exception {
|
public void testThatBoundAddressIsNeverRejected() throws Exception {
|
||||||
List<String> addressStrings = new ArrayList<>();
|
List<String> addressStrings = new ArrayList<>();
|
||||||
for (TransportAddress address : transport.boundAddress().boundAddresses()) {
|
for (TransportAddress address : transport.boundAddress().boundAddresses()) {
|
||||||
addressStrings.add(NetworkAddress.format(((InetSocketTransportAddress) address).address().getAddress()));
|
addressStrings.add(NetworkAddress.format(address.address().getAddress()));
|
||||||
}
|
}
|
||||||
|
|
||||||
Settings settings;
|
Settings settings;
|
||||||
|
|
|
@ -8,7 +8,6 @@ package org.elasticsearch.xpack.security.transport.filter;
|
||||||
import org.elasticsearch.client.Client;
|
import org.elasticsearch.client.Client;
|
||||||
import org.elasticsearch.common.network.NetworkModule;
|
import org.elasticsearch.common.network.NetworkModule;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.transport.InetSocketTransportAddress;
|
|
||||||
import org.elasticsearch.common.transport.TransportAddress;
|
import org.elasticsearch.common.transport.TransportAddress;
|
||||||
import org.elasticsearch.http.HttpServerTransport;
|
import org.elasticsearch.http.HttpServerTransport;
|
||||||
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
|
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
|
||||||
|
@ -53,11 +52,8 @@ public class IpFilteringIntegrationTests extends SecurityIntegTestCase {
|
||||||
public void testThatIpFilteringIsIntegratedIntoNettyPipelineViaHttp() throws Exception {
|
public void testThatIpFilteringIsIntegratedIntoNettyPipelineViaHttp() throws Exception {
|
||||||
TransportAddress transportAddress =
|
TransportAddress transportAddress =
|
||||||
randomFrom(internalCluster().getDataNodeInstance(HttpServerTransport.class).boundAddress().boundAddresses());
|
randomFrom(internalCluster().getDataNodeInstance(HttpServerTransport.class).boundAddress().boundAddresses());
|
||||||
assertThat(transportAddress, is(instanceOf(InetSocketTransportAddress.class)));
|
|
||||||
InetSocketTransportAddress inetSocketTransportAddress = (InetSocketTransportAddress) transportAddress;
|
|
||||||
|
|
||||||
try (Socket socket = new Socket()){
|
try (Socket socket = new Socket()){
|
||||||
trySocketConnection(socket, inetSocketTransportAddress.address());
|
trySocketConnection(socket, transportAddress.address());
|
||||||
assertThat(socket.isClosed(), is(true));
|
assertThat(socket.isClosed(), is(true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -88,7 +84,6 @@ public class IpFilteringIntegrationTests extends SecurityIntegTestCase {
|
||||||
private static int getProfilePort(String profile) {
|
private static int getProfilePort(String profile) {
|
||||||
TransportAddress transportAddress =
|
TransportAddress transportAddress =
|
||||||
randomFrom(internalCluster().getInstance(Transport.class).profileBoundAddresses().get(profile).boundAddresses());
|
randomFrom(internalCluster().getInstance(Transport.class).profileBoundAddresses().get(profile).boundAddresses());
|
||||||
assert transportAddress instanceof InetSocketTransportAddress;
|
return transportAddress.address().getPort();
|
||||||
return ((InetSocketTransportAddress)transportAddress).address().getPort();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@ import org.elasticsearch.common.network.InetAddresses;
|
||||||
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.transport.BoundTransportAddress;
|
import org.elasticsearch.common.transport.BoundTransportAddress;
|
||||||
import org.elasticsearch.common.transport.InetSocketTransportAddress;
|
|
||||||
import org.elasticsearch.common.transport.TransportAddress;
|
import org.elasticsearch.common.transport.TransportAddress;
|
||||||
import org.elasticsearch.http.HttpServerTransport;
|
import org.elasticsearch.http.HttpServerTransport;
|
||||||
import org.elasticsearch.license.XPackLicenseState;
|
import org.elasticsearch.license.XPackLicenseState;
|
||||||
|
@ -55,7 +54,7 @@ public class IPFilterNetty3UpstreamHandlerTests extends ESTestCase {
|
||||||
boolean isHttpEnabled = randomBoolean();
|
boolean isHttpEnabled = randomBoolean();
|
||||||
|
|
||||||
Transport transport = mock(Transport.class);
|
Transport transport = mock(Transport.class);
|
||||||
InetSocketTransportAddress address = new InetSocketTransportAddress(InetAddress.getLoopbackAddress(), 9300);
|
TransportAddress address = new TransportAddress(InetAddress.getLoopbackAddress(), 9300);
|
||||||
when(transport.boundAddress()).thenReturn(new BoundTransportAddress(new TransportAddress[] { address }, address));
|
when(transport.boundAddress()).thenReturn(new BoundTransportAddress(new TransportAddress[] { address }, address));
|
||||||
when(transport.lifecycleState()).thenReturn(Lifecycle.State.STARTED);
|
when(transport.lifecycleState()).thenReturn(Lifecycle.State.STARTED);
|
||||||
ClusterSettings clusterSettings = new ClusterSettings(Settings.EMPTY, new HashSet<>(Arrays.asList(
|
ClusterSettings clusterSettings = new ClusterSettings(Settings.EMPTY, new HashSet<>(Arrays.asList(
|
||||||
|
@ -73,7 +72,7 @@ public class IPFilterNetty3UpstreamHandlerTests extends ESTestCase {
|
||||||
ipFilter.setBoundTransportAddress(transport.boundAddress(), transport.profileBoundAddresses());
|
ipFilter.setBoundTransportAddress(transport.boundAddress(), transport.profileBoundAddresses());
|
||||||
if (isHttpEnabled) {
|
if (isHttpEnabled) {
|
||||||
HttpServerTransport httpTransport = mock(HttpServerTransport.class);
|
HttpServerTransport httpTransport = mock(HttpServerTransport.class);
|
||||||
InetSocketTransportAddress httpAddress = new InetSocketTransportAddress(InetAddress.getLoopbackAddress(), 9200);
|
TransportAddress httpAddress = new TransportAddress(InetAddress.getLoopbackAddress(), 9200);
|
||||||
when(httpTransport.boundAddress()).thenReturn(new BoundTransportAddress(new TransportAddress[] { httpAddress }, httpAddress));
|
when(httpTransport.boundAddress()).thenReturn(new BoundTransportAddress(new TransportAddress[] { httpAddress }, httpAddress));
|
||||||
when(httpTransport.lifecycleState()).thenReturn(Lifecycle.State.STARTED);
|
when(httpTransport.lifecycleState()).thenReturn(Lifecycle.State.STARTED);
|
||||||
ipFilter.setBoundHttpTransportAddress(httpTransport.boundAddress());
|
ipFilter.setBoundHttpTransportAddress(httpTransport.boundAddress());
|
||||||
|
|
|
@ -9,11 +9,9 @@ import org.elasticsearch.client.Client;
|
||||||
import org.elasticsearch.client.transport.NoNodeAvailableException;
|
import org.elasticsearch.client.transport.NoNodeAvailableException;
|
||||||
import org.elasticsearch.client.transport.TransportClient;
|
import org.elasticsearch.client.transport.TransportClient;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.transport.InetSocketTransportAddress;
|
|
||||||
import org.elasticsearch.common.transport.TransportAddress;
|
import org.elasticsearch.common.transport.TransportAddress;
|
||||||
import org.elasticsearch.test.SecurityIntegTestCase;
|
import org.elasticsearch.test.SecurityIntegTestCase;
|
||||||
import org.elasticsearch.transport.Transport;
|
import org.elasticsearch.transport.Transport;
|
||||||
import org.elasticsearch.xpack.security.Security;
|
|
||||||
import org.elasticsearch.xpack.TestXPackTransportClient;
|
import org.elasticsearch.xpack.TestXPackTransportClient;
|
||||||
|
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
|
@ -92,15 +90,14 @@ public class SslHostnameVerificationTests extends SecurityIntegTestCase {
|
||||||
public void testThatHostnameMismatchDeniesTransportClientConnection() throws Exception {
|
public void testThatHostnameMismatchDeniesTransportClientConnection() throws Exception {
|
||||||
Transport transport = internalCluster().getDataNodeInstance(Transport.class);
|
Transport transport = internalCluster().getDataNodeInstance(Transport.class);
|
||||||
TransportAddress transportAddress = transport.boundAddress().publishAddress();
|
TransportAddress transportAddress = transport.boundAddress().publishAddress();
|
||||||
assertThat(transportAddress, instanceOf(InetSocketTransportAddress.class));
|
InetSocketAddress inetSocketAddress = transportAddress.address();
|
||||||
InetSocketAddress inetSocketAddress = ((InetSocketTransportAddress) transportAddress).address();
|
|
||||||
|
|
||||||
Settings settings = Settings.builder().put(transportClientSettings())
|
Settings settings = Settings.builder().put(transportClientSettings())
|
||||||
.put("xpack.ssl.verification_mode", "full")
|
.put("xpack.ssl.verification_mode", "full")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
try (TransportClient client = new TestXPackTransportClient(settings)) {
|
try (TransportClient client = new TestXPackTransportClient(settings)) {
|
||||||
client.addTransportAddress(new InetSocketTransportAddress(inetSocketAddress.getAddress(), inetSocketAddress.getPort()));
|
client.addTransportAddress(new TransportAddress(inetSocketAddress.getAddress(), inetSocketAddress.getPort()));
|
||||||
client.admin().cluster().prepareHealth().get();
|
client.admin().cluster().prepareHealth().get();
|
||||||
fail("Expected a NoNodeAvailableException due to hostname verification failures");
|
fail("Expected a NoNodeAvailableException due to hostname verification failures");
|
||||||
} catch (NoNodeAvailableException e) {
|
} catch (NoNodeAvailableException e) {
|
||||||
|
|
|
@ -11,7 +11,6 @@ import org.elasticsearch.common.network.InetAddresses;
|
||||||
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.transport.BoundTransportAddress;
|
import org.elasticsearch.common.transport.BoundTransportAddress;
|
||||||
import org.elasticsearch.common.transport.InetSocketTransportAddress;
|
|
||||||
import org.elasticsearch.common.transport.TransportAddress;
|
import org.elasticsearch.common.transport.TransportAddress;
|
||||||
import org.elasticsearch.http.HttpServerTransport;
|
import org.elasticsearch.http.HttpServerTransport;
|
||||||
import org.elasticsearch.license.XPackLicenseState;
|
import org.elasticsearch.license.XPackLicenseState;
|
||||||
|
@ -45,7 +44,7 @@ public class IpFilterRemoteAddressFilterTests extends ESTestCase {
|
||||||
boolean isHttpEnabled = randomBoolean();
|
boolean isHttpEnabled = randomBoolean();
|
||||||
|
|
||||||
Transport transport = mock(Transport.class);
|
Transport transport = mock(Transport.class);
|
||||||
InetSocketTransportAddress address = new InetSocketTransportAddress(InetAddress.getLoopbackAddress(), 9300);
|
TransportAddress address = new TransportAddress(InetAddress.getLoopbackAddress(), 9300);
|
||||||
when(transport.boundAddress()).thenReturn(new BoundTransportAddress(new TransportAddress[] { address }, address));
|
when(transport.boundAddress()).thenReturn(new BoundTransportAddress(new TransportAddress[] { address }, address));
|
||||||
when(transport.lifecycleState()).thenReturn(Lifecycle.State.STARTED);
|
when(transport.lifecycleState()).thenReturn(Lifecycle.State.STARTED);
|
||||||
ClusterSettings clusterSettings = new ClusterSettings(Settings.EMPTY, new HashSet<>(Arrays.asList(
|
ClusterSettings clusterSettings = new ClusterSettings(Settings.EMPTY, new HashSet<>(Arrays.asList(
|
||||||
|
@ -63,7 +62,7 @@ public class IpFilterRemoteAddressFilterTests extends ESTestCase {
|
||||||
ipFilter.setBoundTransportAddress(transport.boundAddress(), transport.profileBoundAddresses());
|
ipFilter.setBoundTransportAddress(transport.boundAddress(), transport.profileBoundAddresses());
|
||||||
if (isHttpEnabled) {
|
if (isHttpEnabled) {
|
||||||
HttpServerTransport httpTransport = mock(HttpServerTransport.class);
|
HttpServerTransport httpTransport = mock(HttpServerTransport.class);
|
||||||
InetSocketTransportAddress httpAddress = new InetSocketTransportAddress(InetAddress.getLoopbackAddress(), 9200);
|
TransportAddress httpAddress = new TransportAddress(InetAddress.getLoopbackAddress(), 9200);
|
||||||
when(httpTransport.boundAddress()).thenReturn(new BoundTransportAddress(new TransportAddress[] { httpAddress }, httpAddress));
|
when(httpTransport.boundAddress()).thenReturn(new BoundTransportAddress(new TransportAddress[] { httpAddress }, httpAddress));
|
||||||
when(httpTransport.lifecycleState()).thenReturn(Lifecycle.State.STARTED);
|
when(httpTransport.lifecycleState()).thenReturn(Lifecycle.State.STARTED);
|
||||||
ipFilter.setBoundHttpTransportAddress(httpTransport.boundAddress());
|
ipFilter.setBoundHttpTransportAddress(httpTransport.boundAddress());
|
||||||
|
|
|
@ -20,7 +20,6 @@ import org.elasticsearch.client.transport.TransportClient;
|
||||||
import org.elasticsearch.common.io.Streams;
|
import org.elasticsearch.common.io.Streams;
|
||||||
import org.elasticsearch.common.network.NetworkModule;
|
import org.elasticsearch.common.network.NetworkModule;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.transport.InetSocketTransportAddress;
|
|
||||||
import org.elasticsearch.common.transport.TransportAddress;
|
import org.elasticsearch.common.transport.TransportAddress;
|
||||||
import org.elasticsearch.http.HttpServerTransport;
|
import org.elasticsearch.http.HttpServerTransport;
|
||||||
import org.elasticsearch.xpack.ssl.SSLService;
|
import org.elasticsearch.xpack.ssl.SSLService;
|
||||||
|
@ -132,8 +131,7 @@ public class SslIntegrationTests extends SecurityIntegTestCase {
|
||||||
private String getNodeUrl() {
|
private String getNodeUrl() {
|
||||||
TransportAddress transportAddress =
|
TransportAddress transportAddress =
|
||||||
randomFrom(internalCluster().getInstance(HttpServerTransport.class).boundAddress().boundAddresses());
|
randomFrom(internalCluster().getInstance(HttpServerTransport.class).boundAddress().boundAddresses());
|
||||||
assertThat(transportAddress, is(instanceOf(InetSocketTransportAddress.class)));
|
TransportAddress inetSocketTransportAddress = transportAddress;
|
||||||
InetSocketTransportAddress inetSocketTransportAddress = (InetSocketTransportAddress) transportAddress;
|
|
||||||
return String.format(Locale.ROOT, "https://%s:%s/", "localhost", inetSocketTransportAddress.address().getPort());
|
return String.format(Locale.ROOT, "https://%s:%s/", "localhost", inetSocketTransportAddress.address().getPort());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,6 @@ package org.elasticsearch.xpack.security.transport.ssl;
|
||||||
import org.elasticsearch.client.transport.NoNodeAvailableException;
|
import org.elasticsearch.client.transport.NoNodeAvailableException;
|
||||||
import org.elasticsearch.client.transport.TransportClient;
|
import org.elasticsearch.client.transport.TransportClient;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.transport.InetSocketTransportAddress;
|
|
||||||
import org.elasticsearch.common.transport.TransportAddress;
|
import org.elasticsearch.common.transport.TransportAddress;
|
||||||
import org.elasticsearch.xpack.security.Security;
|
import org.elasticsearch.xpack.security.Security;
|
||||||
import org.elasticsearch.xpack.ssl.SSLClientAuth;
|
import org.elasticsearch.xpack.ssl.SSLClientAuth;
|
||||||
|
@ -123,7 +122,7 @@ public class SslMultiPortTests extends SecurityIntegTestCase {
|
||||||
*/
|
*/
|
||||||
public void testThatStandardTransportClientCanConnectToNoClientAuthProfile() throws Exception {
|
public void testThatStandardTransportClientCanConnectToNoClientAuthProfile() throws Exception {
|
||||||
try(TransportClient transportClient = createTransportClient(Settings.EMPTY)) {
|
try(TransportClient transportClient = createTransportClient(Settings.EMPTY)) {
|
||||||
transportClient.addTransportAddress(new InetSocketTransportAddress(InetAddress.getLoopbackAddress(),
|
transportClient.addTransportAddress(new TransportAddress(InetAddress.getLoopbackAddress(),
|
||||||
getProfilePort("no_client_auth")));
|
getProfilePort("no_client_auth")));
|
||||||
assertGreenClusterState(transportClient);
|
assertGreenClusterState(transportClient);
|
||||||
}
|
}
|
||||||
|
@ -138,7 +137,7 @@ public class SslMultiPortTests extends SecurityIntegTestCase {
|
||||||
*/
|
*/
|
||||||
public void testThatStandardTransportClientCannotConnectToClientProfile() throws Exception {
|
public void testThatStandardTransportClientCannotConnectToClientProfile() throws Exception {
|
||||||
try (TransportClient transportClient = createTransportClient(Settings.EMPTY)) {
|
try (TransportClient transportClient = createTransportClient(Settings.EMPTY)) {
|
||||||
transportClient.addTransportAddress(new InetSocketTransportAddress(InetAddress.getLoopbackAddress(), getProfilePort("client")));
|
transportClient.addTransportAddress(new TransportAddress(InetAddress.getLoopbackAddress(), getProfilePort("client")));
|
||||||
transportClient.admin().cluster().prepareHealth().get();
|
transportClient.admin().cluster().prepareHealth().get();
|
||||||
fail("Expected NoNodeAvailableException");
|
fail("Expected NoNodeAvailableException");
|
||||||
} catch (NoNodeAvailableException e) {
|
} catch (NoNodeAvailableException e) {
|
||||||
|
@ -153,7 +152,7 @@ public class SslMultiPortTests extends SecurityIntegTestCase {
|
||||||
*/
|
*/
|
||||||
public void testThatStandardTransportClientCannotConnectToNoSslProfile() throws Exception {
|
public void testThatStandardTransportClientCannotConnectToNoSslProfile() throws Exception {
|
||||||
try (TransportClient transportClient = createTransportClient(Settings.EMPTY)) {
|
try (TransportClient transportClient = createTransportClient(Settings.EMPTY)) {
|
||||||
transportClient.addTransportAddress(new InetSocketTransportAddress(InetAddress.getLoopbackAddress(), getProfilePort("no_ssl")));
|
transportClient.addTransportAddress(new TransportAddress(InetAddress.getLoopbackAddress(), getProfilePort("no_ssl")));
|
||||||
assertGreenClusterState(transportClient);
|
assertGreenClusterState(transportClient);
|
||||||
fail("Expected NoNodeAvailableException");
|
fail("Expected NoNodeAvailableException");
|
||||||
} catch (NoNodeAvailableException e) {
|
} catch (NoNodeAvailableException e) {
|
||||||
|
@ -170,7 +169,7 @@ public class SslMultiPortTests extends SecurityIntegTestCase {
|
||||||
Settings settings = getSSLSettingsForStore(
|
Settings settings = getSSLSettingsForStore(
|
||||||
"/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient-client-profile.jks", "testclient-client-profile");
|
"/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient-client-profile.jks", "testclient-client-profile");
|
||||||
try (TransportClient transportClient = createTransportClient(settings)) {
|
try (TransportClient transportClient = createTransportClient(settings)) {
|
||||||
transportClient.addTransportAddress(new InetSocketTransportAddress(InetAddress.getLoopbackAddress(), getProfilePort("client")));
|
transportClient.addTransportAddress(new TransportAddress(InetAddress.getLoopbackAddress(), getProfilePort("client")));
|
||||||
assertGreenClusterState(transportClient);
|
assertGreenClusterState(transportClient);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -185,7 +184,7 @@ public class SslMultiPortTests extends SecurityIntegTestCase {
|
||||||
Settings settings = getSSLSettingsForStore(
|
Settings settings = getSSLSettingsForStore(
|
||||||
"/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient-client-profile.jks", "testclient-client-profile");
|
"/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient-client-profile.jks", "testclient-client-profile");
|
||||||
try (TransportClient transportClient = createTransportClient(settings)) {
|
try (TransportClient transportClient = createTransportClient(settings)) {
|
||||||
transportClient.addTransportAddress(new InetSocketTransportAddress(InetAddress.getLoopbackAddress(),
|
transportClient.addTransportAddress(new TransportAddress(InetAddress.getLoopbackAddress(),
|
||||||
getProfilePort("no_client_auth")));
|
getProfilePort("no_client_auth")));
|
||||||
assertGreenClusterState(transportClient);
|
assertGreenClusterState(transportClient);
|
||||||
}
|
}
|
||||||
|
@ -219,7 +218,7 @@ public class SslMultiPortTests extends SecurityIntegTestCase {
|
||||||
Settings settings = getSSLSettingsForStore(
|
Settings settings = getSSLSettingsForStore(
|
||||||
"/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient-client-profile.jks", "testclient-client-profile");
|
"/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient-client-profile.jks", "testclient-client-profile");
|
||||||
try (TransportClient transportClient = createTransportClient(settings)) {
|
try (TransportClient transportClient = createTransportClient(settings)) {
|
||||||
transportClient.addTransportAddress(new InetSocketTransportAddress(InetAddress.getLoopbackAddress(), getProfilePort("no_ssl")));
|
transportClient.addTransportAddress(new TransportAddress(InetAddress.getLoopbackAddress(), getProfilePort("no_ssl")));
|
||||||
transportClient.admin().cluster().prepareHealth().get();
|
transportClient.admin().cluster().prepareHealth().get();
|
||||||
fail("Expected NoNodeAvailableException");
|
fail("Expected NoNodeAvailableException");
|
||||||
} catch (NoNodeAvailableException e) {
|
} catch (NoNodeAvailableException e) {
|
||||||
|
@ -237,7 +236,7 @@ public class SslMultiPortTests extends SecurityIntegTestCase {
|
||||||
.put("cluster.name", internalCluster().getClusterName())
|
.put("cluster.name", internalCluster().getClusterName())
|
||||||
.build();
|
.build();
|
||||||
try (TransportClient transportClient = new TestXPackTransportClient(settings)) {
|
try (TransportClient transportClient = new TestXPackTransportClient(settings)) {
|
||||||
transportClient.addTransportAddress(new InetSocketTransportAddress(InetAddress.getLoopbackAddress(), getProfilePort("no_ssl")));
|
transportClient.addTransportAddress(new TransportAddress(InetAddress.getLoopbackAddress(), getProfilePort("no_ssl")));
|
||||||
assertGreenClusterState(transportClient);
|
assertGreenClusterState(transportClient);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -270,7 +269,7 @@ public class SslMultiPortTests extends SecurityIntegTestCase {
|
||||||
.put("cluster.name", internalCluster().getClusterName())
|
.put("cluster.name", internalCluster().getClusterName())
|
||||||
.build();
|
.build();
|
||||||
try (TransportClient transportClient = new TestXPackTransportClient(settings)) {
|
try (TransportClient transportClient = new TestXPackTransportClient(settings)) {
|
||||||
transportClient.addTransportAddress(new InetSocketTransportAddress(InetAddress.getLoopbackAddress(), getProfilePort("client")));
|
transportClient.addTransportAddress(new TransportAddress(InetAddress.getLoopbackAddress(), getProfilePort("client")));
|
||||||
assertGreenClusterState(transportClient);
|
assertGreenClusterState(transportClient);
|
||||||
fail("Expected NoNodeAvailableException");
|
fail("Expected NoNodeAvailableException");
|
||||||
} catch (NoNodeAvailableException e) {
|
} catch (NoNodeAvailableException e) {
|
||||||
|
@ -288,7 +287,7 @@ public class SslMultiPortTests extends SecurityIntegTestCase {
|
||||||
.put("cluster.name", internalCluster().getClusterName())
|
.put("cluster.name", internalCluster().getClusterName())
|
||||||
.build();
|
.build();
|
||||||
try (TransportClient transportClient = new TestXPackTransportClient(settings)) {
|
try (TransportClient transportClient = new TestXPackTransportClient(settings)) {
|
||||||
transportClient.addTransportAddress(new InetSocketTransportAddress(InetAddress.getLoopbackAddress(),
|
transportClient.addTransportAddress(new TransportAddress(InetAddress.getLoopbackAddress(),
|
||||||
getProfilePort("no_client_auth")));
|
getProfilePort("no_client_auth")));
|
||||||
assertGreenClusterState(transportClient);
|
assertGreenClusterState(transportClient);
|
||||||
fail("Expected NoNodeAvailableException");
|
fail("Expected NoNodeAvailableException");
|
||||||
|
@ -312,7 +311,7 @@ public class SslMultiPortTests extends SecurityIntegTestCase {
|
||||||
.put("xpack.ssl.truststore.password", "truststore-testnode-only")
|
.put("xpack.ssl.truststore.password", "truststore-testnode-only")
|
||||||
.build();
|
.build();
|
||||||
try (TransportClient transportClient = new TestXPackTransportClient(settings)) {
|
try (TransportClient transportClient = new TestXPackTransportClient(settings)) {
|
||||||
transportClient.addTransportAddress(new InetSocketTransportAddress(InetAddress.getLoopbackAddress(),
|
transportClient.addTransportAddress(new TransportAddress(InetAddress.getLoopbackAddress(),
|
||||||
getProfilePort("no_client_auth")));
|
getProfilePort("no_client_auth")));
|
||||||
assertGreenClusterState(transportClient);
|
assertGreenClusterState(transportClient);
|
||||||
}
|
}
|
||||||
|
@ -334,7 +333,7 @@ public class SslMultiPortTests extends SecurityIntegTestCase {
|
||||||
.put("xpack.ssl.truststore.password", "truststore-testnode-only")
|
.put("xpack.ssl.truststore.password", "truststore-testnode-only")
|
||||||
.build();
|
.build();
|
||||||
try (TransportClient transportClient = new TestXPackTransportClient(settings)) {
|
try (TransportClient transportClient = new TestXPackTransportClient(settings)) {
|
||||||
transportClient.addTransportAddress(new InetSocketTransportAddress(InetAddress.getLoopbackAddress(), getProfilePort("client")));
|
transportClient.addTransportAddress(new TransportAddress(InetAddress.getLoopbackAddress(), getProfilePort("client")));
|
||||||
assertGreenClusterState(transportClient);
|
assertGreenClusterState(transportClient);
|
||||||
fail("Expected NoNodeAvailableException");
|
fail("Expected NoNodeAvailableException");
|
||||||
} catch (NoNodeAvailableException e) {
|
} catch (NoNodeAvailableException e) {
|
||||||
|
@ -381,7 +380,7 @@ public class SslMultiPortTests extends SecurityIntegTestCase {
|
||||||
.put("xpack.ssl.truststore.password", "truststore-testnode-only")
|
.put("xpack.ssl.truststore.password", "truststore-testnode-only")
|
||||||
.build();
|
.build();
|
||||||
try (TransportClient transportClient = new TestXPackTransportClient(settings)) {
|
try (TransportClient transportClient = new TestXPackTransportClient(settings)) {
|
||||||
transportClient.addTransportAddress(new InetSocketTransportAddress(InetAddress.getLoopbackAddress(), getProfilePort("no_ssl")));
|
transportClient.addTransportAddress(new TransportAddress(InetAddress.getLoopbackAddress(), getProfilePort("no_ssl")));
|
||||||
assertGreenClusterState(transportClient);
|
assertGreenClusterState(transportClient);
|
||||||
fail("Expected NoNodeAvailableException");
|
fail("Expected NoNodeAvailableException");
|
||||||
} catch (NoNodeAvailableException e) {
|
} catch (NoNodeAvailableException e) {
|
||||||
|
@ -421,7 +420,7 @@ public class SslMultiPortTests extends SecurityIntegTestCase {
|
||||||
.put("xpack.ssl.client_authentication", SSLClientAuth.REQUIRED)
|
.put("xpack.ssl.client_authentication", SSLClientAuth.REQUIRED)
|
||||||
.build();
|
.build();
|
||||||
try (TransportClient transportClient = new TestXPackTransportClient(settings)) {
|
try (TransportClient transportClient = new TestXPackTransportClient(settings)) {
|
||||||
transportClient.addTransportAddress(new InetSocketTransportAddress(InetAddress.getLoopbackAddress(), getProfilePort("client")));
|
transportClient.addTransportAddress(new TransportAddress(InetAddress.getLoopbackAddress(), getProfilePort("client")));
|
||||||
assertGreenClusterState(transportClient);
|
assertGreenClusterState(transportClient);
|
||||||
fail("Expected NoNodeAvailableException");
|
fail("Expected NoNodeAvailableException");
|
||||||
} catch (NoNodeAvailableException e) {
|
} catch (NoNodeAvailableException e) {
|
||||||
|
@ -441,7 +440,7 @@ public class SslMultiPortTests extends SecurityIntegTestCase {
|
||||||
.put("xpack.ssl.client_authentication", SSLClientAuth.REQUIRED)
|
.put("xpack.ssl.client_authentication", SSLClientAuth.REQUIRED)
|
||||||
.build();
|
.build();
|
||||||
try (TransportClient transportClient = new TestXPackTransportClient(settings)) {
|
try (TransportClient transportClient = new TestXPackTransportClient(settings)) {
|
||||||
transportClient.addTransportAddress(new InetSocketTransportAddress(InetAddress.getLoopbackAddress(),
|
transportClient.addTransportAddress(new TransportAddress(InetAddress.getLoopbackAddress(),
|
||||||
getProfilePort("no_client_auth")));
|
getProfilePort("no_client_auth")));
|
||||||
assertGreenClusterState(transportClient);
|
assertGreenClusterState(transportClient);
|
||||||
fail("Expected NoNodeAvailableException");
|
fail("Expected NoNodeAvailableException");
|
||||||
|
@ -453,7 +452,6 @@ public class SslMultiPortTests extends SecurityIntegTestCase {
|
||||||
private static int getProfilePort(String profile) {
|
private static int getProfilePort(String profile) {
|
||||||
TransportAddress transportAddress =
|
TransportAddress transportAddress =
|
||||||
randomFrom(internalCluster().getInstance(Transport.class).profileBoundAddresses().get(profile).boundAddresses());
|
randomFrom(internalCluster().getInstance(Transport.class).profileBoundAddresses().get(profile).boundAddresses());
|
||||||
assert transportAddress instanceof InetSocketTransportAddress;
|
return transportAddress.address().getPort();
|
||||||
return ((InetSocketTransportAddress)transportAddress).address().getPort();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,10 +17,9 @@ import org.bouncycastle.operator.jcajce.JcaContentSignerBuilder;
|
||||||
import org.elasticsearch.ElasticsearchException;
|
import org.elasticsearch.ElasticsearchException;
|
||||||
import org.elasticsearch.common.network.InetAddressHelper;
|
import org.elasticsearch.common.network.InetAddressHelper;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.transport.InetSocketTransportAddress;
|
import org.elasticsearch.common.transport.TransportAddress;
|
||||||
import org.elasticsearch.common.util.set.Sets;
|
import org.elasticsearch.common.util.set.Sets;
|
||||||
import org.elasticsearch.env.Environment;
|
import org.elasticsearch.env.Environment;
|
||||||
import org.elasticsearch.xpack.security.Security;
|
|
||||||
import org.elasticsearch.test.SecurityIntegTestCase;
|
import org.elasticsearch.test.SecurityIntegTestCase;
|
||||||
import org.elasticsearch.test.SecuritySettingsSource;
|
import org.elasticsearch.test.SecuritySettingsSource;
|
||||||
import org.elasticsearch.transport.Transport;
|
import org.elasticsearch.transport.Transport;
|
||||||
|
@ -114,7 +113,7 @@ public class SSLReloadIntegTests extends SecurityIntegTestCase {
|
||||||
String node = randomFrom(internalCluster().getNodeNames());
|
String node = randomFrom(internalCluster().getNodeNames());
|
||||||
SSLService sslService = new SSLService(settings, new Environment(settings));
|
SSLService sslService = new SSLService(settings, new Environment(settings));
|
||||||
SSLSocketFactory sslSocketFactory = sslService.sslSocketFactory(settings);
|
SSLSocketFactory sslSocketFactory = sslService.sslSocketFactory(settings);
|
||||||
InetSocketTransportAddress address = (InetSocketTransportAddress) internalCluster()
|
TransportAddress address = internalCluster()
|
||||||
.getInstance(Transport.class, node).boundAddress().publishAddress();
|
.getInstance(Transport.class, node).boundAddress().publishAddress();
|
||||||
try (SSLSocket socket = (SSLSocket) sslSocketFactory.createSocket(address.getAddress(), address.getPort())) {
|
try (SSLSocket socket = (SSLSocket) sslSocketFactory.createSocket(address.getAddress(), address.getPort())) {
|
||||||
assertThat(socket.isConnected(), is(true));
|
assertThat(socket.isConnected(), is(true));
|
||||||
|
|
|
@ -26,7 +26,6 @@ import org.elasticsearch.env.Environment;
|
||||||
import org.elasticsearch.index.query.QueryBuilder;
|
import org.elasticsearch.index.query.QueryBuilder;
|
||||||
import org.elasticsearch.license.XPackLicenseState;
|
import org.elasticsearch.license.XPackLicenseState;
|
||||||
import org.elasticsearch.script.Script;
|
import org.elasticsearch.script.Script;
|
||||||
import org.elasticsearch.script.ScriptSettings;
|
|
||||||
import org.elasticsearch.xpack.XPackSettings;
|
import org.elasticsearch.xpack.XPackSettings;
|
||||||
import org.elasticsearch.plugins.Plugin;
|
import org.elasticsearch.plugins.Plugin;
|
||||||
import org.elasticsearch.script.MockMustacheScriptEngine;
|
import org.elasticsearch.script.MockMustacheScriptEngine;
|
||||||
|
@ -41,7 +40,6 @@ import org.elasticsearch.test.ESIntegTestCase;
|
||||||
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
|
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
|
||||||
import org.elasticsearch.test.TestCluster;
|
import org.elasticsearch.test.TestCluster;
|
||||||
import org.elasticsearch.test.store.MockFSIndexStore;
|
import org.elasticsearch.test.store.MockFSIndexStore;
|
||||||
import org.elasticsearch.test.transport.AssertingLocalTransport;
|
|
||||||
import org.elasticsearch.test.transport.MockTransportService;
|
import org.elasticsearch.test.transport.MockTransportService;
|
||||||
import org.elasticsearch.xpack.support.clock.Clock;
|
import org.elasticsearch.xpack.support.clock.Clock;
|
||||||
import org.elasticsearch.xpack.watcher.WatcherLifeCycleService;
|
import org.elasticsearch.xpack.watcher.WatcherLifeCycleService;
|
||||||
|
@ -165,7 +163,6 @@ public abstract class AbstractWatcherIntegrationTestCase extends ESIntegTestCase
|
||||||
// security has its own transport service
|
// security has its own transport service
|
||||||
plugins.remove(MockTransportService.TestPlugin.class);
|
plugins.remove(MockTransportService.TestPlugin.class);
|
||||||
// security has its own transport
|
// security has its own transport
|
||||||
plugins.remove(AssertingLocalTransport.TestPlugin.class);
|
|
||||||
// we have to explicitly add it otherwise we will fail to set the check_index_on_close setting
|
// we have to explicitly add it otherwise we will fail to set the check_index_on_close setting
|
||||||
plugins.add(MockFSIndexStore.TestPlugin.class);
|
plugins.add(MockFSIndexStore.TestPlugin.class);
|
||||||
plugins.add(MockMustacheScriptEngine.TestPlugin.class);
|
plugins.add(MockMustacheScriptEngine.TestPlugin.class);
|
||||||
|
|
|
@ -224,7 +224,7 @@ public class HttpSecretsIntegrationTests extends AbstractWatcherIntegrationTestC
|
||||||
value = contentSource.getValue("result.actions.0.webhook.request.auth.username");
|
value = contentSource.getValue("result.actions.0.webhook.request.auth.username");
|
||||||
assertThat(value, notNullValue());
|
assertThat(value, notNullValue());
|
||||||
assertThat(value, instanceOf(String.class));
|
assertThat(value, instanceOf(String.class));
|
||||||
assertThat((String) value, is(USERNAME)); // the auth username exists
|
assertThat(value, is(USERNAME)); // the auth username exists
|
||||||
|
|
||||||
value = contentSource.getValue("result.actions.0.webhook.request.auth.password");
|
value = contentSource.getValue("result.actions.0.webhook.request.auth.password");
|
||||||
assertThat(value, nullValue()); // but the auth password was filtered out
|
assertThat(value, nullValue()); // but the auth password was filtered out
|
||||||
|
|
|
@ -18,7 +18,6 @@ import org.elasticsearch.discovery.zen.ping.ZenPing;
|
||||||
import org.elasticsearch.discovery.zen.ping.ZenPingService;
|
import org.elasticsearch.discovery.zen.ping.ZenPingService;
|
||||||
import org.elasticsearch.discovery.zen.ping.unicast.UnicastZenPing;
|
import org.elasticsearch.discovery.zen.ping.unicast.UnicastZenPing;
|
||||||
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
|
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
|
||||||
import org.elasticsearch.test.ESIntegTestCase.SuppressLocalMode;
|
|
||||||
import org.elasticsearch.test.discovery.ClusterDiscoveryConfiguration;
|
import org.elasticsearch.test.discovery.ClusterDiscoveryConfiguration;
|
||||||
import org.elasticsearch.test.junit.annotations.TestLogging;
|
import org.elasticsearch.test.junit.annotations.TestLogging;
|
||||||
import org.elasticsearch.xpack.watcher.WatcherService;
|
import org.elasticsearch.xpack.watcher.WatcherService;
|
||||||
|
@ -55,7 +54,6 @@ import static org.hamcrest.core.Is.is;
|
||||||
@BadApple(bugUrl = "https://github.com/elastic/x-plugins/issues/1007")
|
@BadApple(bugUrl = "https://github.com/elastic/x-plugins/issues/1007")
|
||||||
@TestLogging("org.elasticsearch.discovery:TRACE,org.elasticsearch.watcher:TRACE")
|
@TestLogging("org.elasticsearch.discovery:TRACE,org.elasticsearch.watcher:TRACE")
|
||||||
@ClusterScope(scope = TEST, numClientNodes = 0, transportClientRatio = 0, randomDynamicTemplates = false, numDataNodes = 0)
|
@ClusterScope(scope = TEST, numClientNodes = 0, transportClientRatio = 0, randomDynamicTemplates = false, numDataNodes = 0)
|
||||||
@SuppressLocalMode
|
|
||||||
public class NoMasterNodeTests extends AbstractWatcherIntegrationTestCase {
|
public class NoMasterNodeTests extends AbstractWatcherIntegrationTestCase {
|
||||||
private ClusterDiscoveryConfiguration.UnicastZen config;
|
private ClusterDiscoveryConfiguration.UnicastZen config;
|
||||||
|
|
||||||
|
|
|
@ -12,9 +12,7 @@ import org.elasticsearch.client.Client;
|
||||||
import org.elasticsearch.client.transport.TransportClient;
|
import org.elasticsearch.client.transport.TransportClient;
|
||||||
import org.elasticsearch.common.logging.ESLoggerFactory;
|
import org.elasticsearch.common.logging.ESLoggerFactory;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.transport.InetSocketTransportAddress;
|
|
||||||
import org.elasticsearch.common.transport.TransportAddress;
|
import org.elasticsearch.common.transport.TransportAddress;
|
||||||
import org.elasticsearch.test.ESIntegTestCase;
|
|
||||||
import org.elasticsearch.xpack.client.PreBuiltXPackTransportClient;
|
import org.elasticsearch.xpack.client.PreBuiltXPackTransportClient;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
|
@ -42,7 +40,6 @@ import static org.hamcrest.Matchers.notNullValue;
|
||||||
* your test.
|
* your test.
|
||||||
*/
|
*/
|
||||||
@LuceneTestCase.SuppressSysoutChecks(bugUrl = "we log a lot on purpose")
|
@LuceneTestCase.SuppressSysoutChecks(bugUrl = "we log a lot on purpose")
|
||||||
@ESIntegTestCase.SuppressLocalMode
|
|
||||||
public abstract class MigrateToolTestCase extends LuceneTestCase {
|
public abstract class MigrateToolTestCase extends LuceneTestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -105,7 +102,7 @@ public abstract class MigrateToolTestCase extends LuceneTestCase {
|
||||||
String ip = stringAddress.substring(0, lastColon);
|
String ip = stringAddress.substring(0, lastColon);
|
||||||
String port = stringAddress.substring(lastColon + 1);
|
String port = stringAddress.substring(lastColon + 1);
|
||||||
try {
|
try {
|
||||||
transportAddresses[i++] = new InetSocketTransportAddress(InetAddress.getByName(ip), Integer.valueOf(port));
|
transportAddresses[i++] = new TransportAddress(InetAddress.getByName(ip), Integer.valueOf(port));
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
throw new IllegalArgumentException("port is not valid, expected number but was [" + port + "]");
|
throw new IllegalArgumentException("port is not valid, expected number but was [" + port + "]");
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ import org.elasticsearch.common.io.PathUtils;
|
||||||
import org.elasticsearch.common.network.NetworkAddress;
|
import org.elasticsearch.common.network.NetworkAddress;
|
||||||
import org.elasticsearch.common.network.NetworkModule;
|
import org.elasticsearch.common.network.NetworkModule;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.transport.InetSocketTransportAddress;
|
import org.elasticsearch.common.transport.TransportAddress;
|
||||||
import org.elasticsearch.plugins.Plugin;
|
import org.elasticsearch.plugins.Plugin;
|
||||||
import org.elasticsearch.xpack.security.Security;
|
import org.elasticsearch.xpack.security.Security;
|
||||||
import org.elasticsearch.test.ESIntegTestCase;
|
import org.elasticsearch.test.ESIntegTestCase;
|
||||||
|
@ -134,7 +134,7 @@ public class SmokeTestMonitoringWithSecurityIT extends ESIntegTestCase {
|
||||||
|
|
||||||
InetSocketAddress[] httpAddresses = new InetSocketAddress[nodes.size()];
|
InetSocketAddress[] httpAddresses = new InetSocketAddress[nodes.size()];
|
||||||
for (int i = 0; i < nodes.size(); i++) {
|
for (int i = 0; i < nodes.size(); i++) {
|
||||||
httpAddresses[i] = ((InetSocketTransportAddress) nodes.get(i).getHttp().address().publishAddress()).address();
|
httpAddresses[i] = nodes.get(i).getHttp().address().publishAddress().address();
|
||||||
}
|
}
|
||||||
return httpAddresses;
|
return httpAddresses;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue