Merge branch 'master' into feature/shield-ui

Original commit: elastic/x-pack-elasticsearch@df1da8abf0
This commit is contained in:
Lukas Olson 2016-05-06 13:28:58 -07:00
commit 08c3ea7a69
68 changed files with 597 additions and 279 deletions

View File

@ -20,6 +20,7 @@ import org.elasticsearch.xpack.XPackPlugin;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;
import static org.elasticsearch.shield.authc.support.UsernamePasswordToken.basicAuthHeaderValue;
@ -104,10 +105,10 @@ public class ShieldTransportClientIT extends ESIntegTestCase {
TransportClient transportClient(Settings extraSettings) {
NodesInfoResponse nodeInfos = client().admin().cluster().prepareNodesInfo().get();
NodeInfo[] nodes = nodeInfos.getNodes();
assertTrue(nodes.length > 0);
List<NodeInfo> nodes = nodeInfos.getNodes();
assertTrue(nodes.isEmpty() == false);
TransportAddress publishAddress = randomFrom(nodes).getTransport().address().publishAddress();
String clusterName = nodeInfos.getClusterNameAsString();
String clusterName = nodeInfos.getClusterName().value();
Settings settings = Settings.builder()
.put(extraSettings)

View File

@ -21,6 +21,7 @@ import org.elasticsearch.xpack.XPackPlugin;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import static org.hamcrest.Matchers.is;
@ -58,10 +59,10 @@ public class CustomRealmIT extends ESIntegTestCase {
public void testTransportClient() throws Exception {
NodesInfoResponse nodeInfos = client().admin().cluster().prepareNodesInfo().get();
NodeInfo[] nodes = nodeInfos.getNodes();
assertTrue(nodes.length > 0);
List<NodeInfo> nodes = nodeInfos.getNodes();
assertTrue(nodes.isEmpty() == false);
TransportAddress publishAddress = randomFrom(nodes).getTransport().address().publishAddress();
String clusterName = nodeInfos.getClusterNameAsString();
String clusterName = nodeInfos.getClusterName().value();
Settings settings = Settings.builder()
.put("cluster.name", clusterName)
@ -78,10 +79,10 @@ public class CustomRealmIT extends ESIntegTestCase {
public void testTransportClientWrongAuthentication() throws Exception {
NodesInfoResponse nodeInfos = client().admin().cluster().prepareNodesInfo().get();
NodeInfo[] nodes = nodeInfos.getNodes();
assertTrue(nodes.length > 0);
List<NodeInfo> nodes = nodeInfos.getNodes();
assertTrue(nodes.isEmpty() == false);
TransportAddress publishAddress = randomFrom(nodes).getTransport().address().publishAddress();
String clusterName = nodeInfos.getClusterNameAsString();
String clusterName = nodeInfos.getClusterName().value();
Settings settings = Settings.builder()
.put("cluster.name", clusterName)

View File

@ -28,6 +28,7 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.hamcrest.Matchers.equalTo;
@ -117,12 +118,12 @@ public class SmokeTestMonitoringWithShieldIT extends ESIntegTestCase {
}
private InetSocketAddress[] httpAddresses() {
NodeInfo[] nodes = client().admin().cluster().prepareNodesInfo().clear().setHttp(true).get().getNodes();
assertThat(nodes.length, greaterThan(0));
List<NodeInfo> nodes = client().admin().cluster().prepareNodesInfo().clear().setHttp(true).get().getNodes();
assertThat(nodes.size(), greaterThan(0));
InetSocketAddress[] httpAddresses = new InetSocketAddress[nodes.length];
for (int i = 0; i < nodes.length; i++) {
httpAddresses[i] = ((InetSocketTransportAddress) nodes[i].getHttp().address().publishAddress()).address();
InetSocketAddress[] httpAddresses = new InetSocketAddress[nodes.size()];
for (int i = 0; i < nodes.size(); i++) {
httpAddresses[i] = ((InetSocketTransportAddress) nodes.get(i).getHttp().address().publishAddress()).address();
}
return httpAddresses;
}

View File

@ -278,7 +278,7 @@ public class GraphExploreRequest extends ActionRequest<GraphExploreRequest> impl
* are considered in this stage
* @return a {@link Hop} object that holds settings for a stage in the graph exploration
*/
public Hop createNextHop(QueryBuilder<?> guidingQuery) {
public Hop createNextHop(QueryBuilder guidingQuery) {
Hop parent = null;
if (hops.size() > 0) {
parent = hops.get(hops.size() - 1);

View File

@ -120,7 +120,7 @@ public class GraphExploreRequestBuilder extends ActionRequestBuilder<GraphExplor
* are considered in this stage
* @return a {@link Hop} object that holds settings for a stage in the graph exploration
*/
public Hop createNextHop(@Nullable QueryBuilder<?> guidingQuery) {
public Hop createNextHop(@Nullable QueryBuilder guidingQuery) {
return request.createNextHop(guidingQuery);
}

View File

@ -44,7 +44,7 @@ import java.util.List;
public class Hop {
final Hop parentHop;
List<VertexRequest> vertices = null;
QueryBuilder<?> guidingQuery = null;
QueryBuilder guidingQuery = null;
Hop(Hop parent) {
this.parentHop = parent;
@ -88,7 +88,7 @@ public class Hop {
}
}
public QueryBuilder<?> guidingQuery() {
public QueryBuilder guidingQuery() {
if (guidingQuery != null) {
return guidingQuery;
}
@ -117,7 +117,7 @@ public class Hop {
*
* @param queryBuilder any query
*/
public void guidingQuery(QueryBuilder<?> queryBuilder) {
public void guidingQuery(QueryBuilder queryBuilder) {
guidingQuery = queryBuilder;
}

View File

@ -6,8 +6,6 @@
package org.elasticsearch.license.plugin;
import org.elasticsearch.action.ActionModule;
import org.elasticsearch.client.Client;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.common.component.LifecycleComponent;
import org.elasticsearch.common.inject.Inject;
@ -28,15 +26,19 @@ import org.elasticsearch.license.plugin.rest.RestDeleteLicenseAction;
import org.elasticsearch.license.plugin.rest.RestGetLicenseAction;
import org.elasticsearch.license.plugin.rest.RestPutLicenseAction;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import static org.elasticsearch.xpack.XPackPlugin.isTribeClientNode;
import static org.elasticsearch.xpack.XPackPlugin.isTribeNode;
import static org.elasticsearch.xpack.XPackPlugin.transportClientMode;
public class Licensing {
public static final String NAME = "license";
private final boolean isEnabled;
protected final boolean transportClient;
private final boolean isTransportClient;
private final boolean isTribeNode;
static {
MetaData.registerPrototype(LicensesMetaData.TYPE, LicensesMetaData.PROTO);
@ -44,12 +46,12 @@ public class Licensing {
@Inject
public Licensing(Settings settings) {
this.transportClient = TransportClient.CLIENT_TYPE.equals(settings.get(Client.CLIENT_TYPE_SETTING_S.getKey()));
isEnabled = transportClient == false;
isTransportClient = transportClientMode(settings);
isTribeNode = isTribeNode(settings);
}
public void onModule(NetworkModule module) {
if (transportClient == false) {
if (isTransportClient == false && isTribeNode == false) {
module.registerRestHandler(RestPutLicenseAction.class);
module.registerRestHandler(RestGetLicenseAction.class);
module.registerRestHandler(RestDeleteLicenseAction.class);
@ -57,21 +59,22 @@ public class Licensing {
}
public void onModule(ActionModule module) {
module.registerAction(PutLicenseAction.INSTANCE, TransportPutLicenseAction.class);
module.registerAction(GetLicenseAction.INSTANCE, TransportGetLicenseAction.class);
module.registerAction(DeleteLicenseAction.INSTANCE, TransportDeleteLicenseAction.class);
if (isTribeNode == false) {
module.registerAction(PutLicenseAction.INSTANCE, TransportPutLicenseAction.class);
module.registerAction(GetLicenseAction.INSTANCE, TransportGetLicenseAction.class);
module.registerAction(DeleteLicenseAction.INSTANCE, TransportDeleteLicenseAction.class);
}
}
public Collection<Class<? extends LifecycleComponent>> nodeServices() {
Collection<Class<? extends LifecycleComponent>> services = new ArrayList<>();
if (isEnabled) {
services.add(LicensesService.class);
if (isTransportClient == false && isTribeNode == false) {
return Collections.<Class<? extends LifecycleComponent>>singletonList(LicensesService.class);
}
return services;
return Collections.emptyList();
}
public Collection<Module> nodeModules() {
if (isEnabled) {
if (isTransportClient == false && isTribeNode == false) {
return Collections.<Module>singletonList(new LicensingModule());
}
return Collections.emptyList();

View File

@ -0,0 +1,50 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.license.plugin;
import org.elasticsearch.client.Client;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.license.plugin.action.delete.DeleteLicenseAction;
import org.elasticsearch.license.plugin.action.delete.DeleteLicenseRequest;
import org.elasticsearch.license.plugin.action.get.GetLicenseAction;
import org.elasticsearch.license.plugin.action.get.GetLicenseRequest;
import org.elasticsearch.license.plugin.action.put.PutLicenseAction;
import org.elasticsearch.license.plugin.action.put.PutLicenseRequest;
import org.elasticsearch.xpack.TribeTransportTestCase;
import static org.elasticsearch.license.plugin.TestUtils.generateSignedLicense;
public class LicenseTribeTests extends TribeTransportTestCase {
@Override
protected void verifyActionOnClientNode(Client client) throws Exception {
assertLicenseTransportActionsWorks(client);
}
@Override
protected void verifyActionOnMasterNode(Client masterClient) throws Exception {
assertLicenseTransportActionsWorks(masterClient);
}
@Override
protected void verifyActionOnDataNode(Client dataNodeClient) throws Exception {
assertLicenseTransportActionsWorks(dataNodeClient);
}
private static void assertLicenseTransportActionsWorks(Client client) throws Exception {
client.execute(GetLicenseAction.INSTANCE, new GetLicenseRequest()).get();
client.execute(PutLicenseAction.INSTANCE, new PutLicenseRequest()
.license(generateSignedLicense(TimeValue.timeValueHours(1))));
client.execute(DeleteLicenseAction.INSTANCE, new DeleteLicenseRequest());
}
@Override
protected void verifyActionOnTribeNode(Client tribeClient) {
failAction(tribeClient, GetLicenseAction.INSTANCE);
failAction(tribeClient, PutLicenseAction.INSTANCE);
failAction(tribeClient, DeleteLicenseAction.INSTANCE);
}
}

View File

@ -6,6 +6,7 @@
package org.elasticsearch.license.plugin;
import org.elasticsearch.action.ActionFuture;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.license.core.License;
import org.elasticsearch.license.plugin.action.delete.DeleteLicenseAction;
@ -18,20 +19,42 @@ import org.elasticsearch.license.plugin.action.put.PutLicenseAction;
import org.elasticsearch.license.plugin.action.put.PutLicenseRequestBuilder;
import org.elasticsearch.license.plugin.action.put.PutLicenseResponse;
import org.elasticsearch.license.plugin.core.LicensesStatus;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.junit.After;
import org.elasticsearch.marvel.Monitoring;
import org.elasticsearch.node.Node;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.shield.Security;
import org.elasticsearch.test.ESSingleNodeTestCase;
import org.elasticsearch.xpack.XPackPlugin;
import org.elasticsearch.xpack.watcher.Watcher;
import java.util.Collection;
import java.util.Collections;
import static org.elasticsearch.license.plugin.TestUtils.dateMath;
import static org.elasticsearch.license.plugin.TestUtils.generateSignedLicense;
import static org.elasticsearch.test.ESIntegTestCase.Scope.TEST;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.not;
@ClusterScope(scope = TEST, numDataNodes = 10)
public class LicensesTransportTests extends AbstractLicensesIntegrationTestCase {
@After
public void beforeTest() throws Exception {
wipeAllLicenses();
public class LicensesTransportTests extends ESSingleNodeTestCase {
@Override
protected boolean resetNodeAfterTest() {
return true;
}
@Override
protected Collection<Class<? extends Plugin>> getPlugins() {
return Collections.singletonList(XPackPlugin.class);
}
@Override
protected Settings nodeSettings() {
Settings.Builder newSettings = Settings.builder();
newSettings.put(XPackPlugin.featureEnabledSetting(Security.NAME), false);
newSettings.put(XPackPlugin.featureEnabledSetting(Monitoring.NAME), false);
newSettings.put(XPackPlugin.featureEnabledSetting(Watcher.NAME), false);
newSettings.put(Node.NODE_DATA_SETTING.getKey(), true);
return newSettings.build();
}
public void testEmptyGetLicense() throws Exception {
@ -47,7 +70,8 @@ public class LicensesTransportTests extends AbstractLicensesIntegrationTestCase
// put license
PutLicenseRequestBuilder putLicenseRequestBuilder =
new PutLicenseRequestBuilder(client().admin().cluster(), PutLicenseAction.INSTANCE).setLicense(signedLicense);
new PutLicenseRequestBuilder(client().admin().cluster(), PutLicenseAction.INSTANCE).setLicense(signedLicense)
.setAcknowledge(true);
PutLicenseResponse putLicenseResponse = putLicenseRequestBuilder.get();
assertThat(putLicenseResponse.isAcknowledged(), equalTo(true));
assertThat(putLicenseResponse.status(), equalTo(LicensesStatus.VALID));
@ -63,7 +87,8 @@ public class LicensesTransportTests extends AbstractLicensesIntegrationTestCase
// put license source
PutLicenseRequestBuilder putLicenseRequestBuilder =
new PutLicenseRequestBuilder(client().admin().cluster(), PutLicenseAction.INSTANCE).setLicense(licenseString);
new PutLicenseRequestBuilder(client().admin().cluster(), PutLicenseAction.INSTANCE).setLicense(licenseString)
.setAcknowledge(true);
PutLicenseResponse putLicenseResponse = putLicenseRequestBuilder.get();
assertThat(putLicenseResponse.isAcknowledged(), equalTo(true));
assertThat(putLicenseResponse.status(), equalTo(LicensesStatus.VALID));
@ -97,25 +122,20 @@ public class LicensesTransportTests extends AbstractLicensesIntegrationTestCase
public void testPutExpiredLicense() throws Exception {
License expiredLicense = generateSignedLicense(dateMath("now-10d/d", System.currentTimeMillis()), TimeValue.timeValueMinutes(2));
License signedLicense = generateSignedLicense(TimeValue.timeValueMinutes(2));
PutLicenseRequestBuilder builder = new PutLicenseRequestBuilder(client().admin().cluster(), PutLicenseAction.INSTANCE);
builder.setLicense(signedLicense);
// put license should return valid (as there is one valid license)
PutLicenseResponse putLicenseResponse = builder.get();
assertThat(putLicenseResponse.status(), equalTo(LicensesStatus.VALID));
builder.setLicense(expiredLicense);
putLicenseResponse = builder.get();
PutLicenseResponse putLicenseResponse = builder.get();
assertThat(putLicenseResponse.status(), equalTo(LicensesStatus.EXPIRED));
// get license should not return the expired license
GetLicenseResponse getLicenseResponse = new GetLicenseRequestBuilder(client().admin().cluster(), GetLicenseAction.INSTANCE).get();
assertThat(getLicenseResponse.license(), equalTo(signedLicense));
assertThat(getLicenseResponse.license(), not(expiredLicense));
}
public void testPutLicensesSimple() throws Exception {
License basicSignedLicense = generateSignedLicense("basic", TimeValue.timeValueMinutes(5));
PutLicenseRequestBuilder putLicenseRequestBuilder =
new PutLicenseRequestBuilder(client().admin().cluster(), PutLicenseAction.INSTANCE).setLicense(basicSignedLicense);
new PutLicenseRequestBuilder(client().admin().cluster(), PutLicenseAction.INSTANCE).setLicense(basicSignedLicense)
.setAcknowledge(true);
PutLicenseResponse putLicenseResponse = putLicenseRequestBuilder.get();
assertThat(putLicenseResponse.status(), equalTo(LicensesStatus.VALID));
GetLicenseResponse getLicenseResponse = new GetLicenseRequestBuilder(client().admin().cluster(), GetLicenseAction.INSTANCE).get();
@ -133,7 +153,8 @@ public class LicensesTransportTests extends AbstractLicensesIntegrationTestCase
public void testRemoveLicensesSimple() throws Exception {
License goldLicense = generateSignedLicense("gold", TimeValue.timeValueMinutes(5));
PutLicenseRequestBuilder putLicenseRequestBuilder =
new PutLicenseRequestBuilder(client().admin().cluster(), PutLicenseAction.INSTANCE).setLicense(goldLicense);
new PutLicenseRequestBuilder(client().admin().cluster(), PutLicenseAction.INSTANCE).setLicense(goldLicense)
.setAcknowledge(true);
PutLicenseResponse putLicenseResponse = putLicenseRequestBuilder.get();
assertThat(putLicenseResponse.isAcknowledged(), equalTo(true));
assertThat(putLicenseResponse.status(), equalTo(LicensesStatus.VALID));

View File

@ -0,0 +1,237 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.xpack;
import org.elasticsearch.action.Action;
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
import org.elasticsearch.action.admin.cluster.node.info.NodeInfo;
import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.client.Requests;
import org.elasticsearch.cluster.health.ClusterHealthStatus;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.cluster.node.DiscoveryNodes;
import org.elasticsearch.common.Priority;
import org.elasticsearch.common.UUIDs;
import org.elasticsearch.common.network.NetworkModule;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.discovery.zen.ping.unicast.UnicastZenPing;
import org.elasticsearch.graph.Graph;
import org.elasticsearch.marvel.Monitoring;
import org.elasticsearch.node.Node;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.shield.Security;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.elasticsearch.test.ESIntegTestCase.Scope;
import org.elasticsearch.test.InternalTestCluster;
import org.elasticsearch.test.NodeConfigurationSource;
import org.elasticsearch.test.TestCluster;
import org.elasticsearch.xpack.watcher.Watcher;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.hamcrest.Matchers.anyOf;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
@ClusterScope(scope = Scope.TEST, transportClientRatio = 0, numClientNodes = 1, numDataNodes = 0)
public abstract class TribeTransportTestCase extends ESIntegTestCase {
private static final Collection<String> ALL_FEATURES = Arrays.asList(Security.NAME, Monitoring.NAME,
Watcher.NAME, Graph.NAME);
protected List<String> enabledFeatures() {
return Collections.emptyList();
}
@Override
protected final Settings nodeSettings(int nodeOrdinal) {
final Settings.Builder builder = Settings.builder()
.put(NetworkModule.HTTP_ENABLED.getKey(), false)
.put(Node.NODE_LOCAL_SETTING.getKey(), true);
List<String> enabledFeatures = enabledFeatures();
for (String feature : ALL_FEATURES) {
builder.put(XPackPlugin.featureEnabledSetting(feature), enabledFeatures.contains(feature));
}
return builder.build();
}
@Override
protected final Collection<Class<? extends Plugin>> nodePlugins() {
return Collections.<Class<? extends Plugin>>singletonList(XPackPlugin.class);
}
@Override
protected final Collection<Class<? extends Plugin>> transportClientPlugins() {
return nodePlugins();
}
public void testTribeSetup() throws Exception {
NodeConfigurationSource nodeConfigurationSource = new NodeConfigurationSource() {
@Override
public Settings nodeSettings(int nodeOrdinal) {
return TribeTransportTestCase.this.nodeSettings(nodeOrdinal);
}
@Override
public Collection<Class<? extends Plugin>> nodePlugins() {
return TribeTransportTestCase.this.nodePlugins();
}
@Override
public Settings transportClientSettings() {
return TribeTransportTestCase.this.transportClientSettings();
}
@Override
public Collection<Class<? extends Plugin>> transportClientPlugins() {
return TribeTransportTestCase.this.transportClientPlugins();
}
};
final InternalTestCluster cluster2 = new InternalTestCluster(InternalTestCluster.configuredNodeMode(),
randomLong(), createTempDir(), 2, 2,
UUIDs.randomBase64UUID(random()), nodeConfigurationSource, 1, false, "tribe_node2",
getMockPlugins(), getClientWrapper());
cluster2.beforeTest(random(), 0.0);
cluster2.ensureAtLeastNumDataNodes(2);
logger.info("create 2 indices, test1 on t1, and test2 on t2");
assertAcked(internalCluster().client().admin().indices().prepareCreate("test1").get());
assertAcked(cluster2.client().admin().indices().prepareCreate("test2").get());
ensureYellow(internalCluster());
ensureYellow(cluster2);
Map<String,String> asMap = internalCluster().getDefaultSettings().getAsMap();
Settings.Builder tribe1Defaults = Settings.builder();
Settings.Builder tribe2Defaults = Settings.builder();
for (Map.Entry<String, String> entry : asMap.entrySet()) {
if (entry.getKey().startsWith("path.")) {
continue;
}
tribe1Defaults.put("tribe.t1." + entry.getKey(), entry.getValue());
tribe2Defaults.put("tribe.t2." + entry.getKey(), entry.getValue());
}
// give each tribe it's unicast hosts to connect to
tribe1Defaults.putArray("tribe.t1." + UnicastZenPing.DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING.getKey(),
getUnicastHosts(internalCluster().client()));
tribe1Defaults.putArray("tribe.t2." + UnicastZenPing.DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING.getKey(),
getUnicastHosts(cluster2.client()));
Settings merged = Settings.builder()
.put("tribe.t1.cluster.name", internalCluster().getClusterName())
.put("tribe.t2.cluster.name", cluster2.getClusterName())
.put("tribe.blocks.write", false)
.put(tribe1Defaults.build())
.put(tribe2Defaults.build())
.put(internalCluster().getDefaultSettings())
.put("node.name", "tribe_node") // make sure we can identify threads from this node
.put(Node.NODE_LOCAL_SETTING.getKey(), true)
.build();
final Node tribeNode = new Node(merged).start();
Client tribeClient = tribeNode.client();
logger.info("wait till tribe has the same nodes as the 2 clusters");
assertBusy(() -> {
DiscoveryNodes tribeNodes = tribeNode.client().admin().cluster().prepareState().get().getState().getNodes();
assertThat(countDataNodesForTribe("t1", tribeNodes),
equalTo(internalCluster().client().admin().cluster().prepareState().get().getState()
.getNodes().getDataNodes().size()));
assertThat(countDataNodesForTribe("t2", tribeNodes),
equalTo(cluster2.client().admin().cluster().prepareState().get().getState()
.getNodes().getDataNodes().size()));
});
logger.info(" --> verify transport actions for tribe node");
verifyActionOnTribeNode(tribeClient);
logger.info(" --> verify transport actions for data node");
verifyActionOnDataNode((randomBoolean() ? internalCluster() : cluster2).dataNodeClient());
logger.info(" --> verify transport actions for master node");
verifyActionOnMasterNode((randomBoolean() ? internalCluster() : cluster2).masterClient());
logger.info(" --> verify transport actions for client node");
verifyActionOnClientNode((randomBoolean() ? internalCluster() : cluster2).coordOnlyNodeClient());
try {
cluster2.wipe(Collections.<String>emptySet());
} finally {
cluster2.afterTest();
}
tribeNode.close();
cluster2.close();
}
/**
* Verify transport action behaviour on client node
*/
protected abstract void verifyActionOnClientNode(Client client) throws Exception;
/**
* Verify transport action behaviour on master node
*/
protected abstract void verifyActionOnMasterNode(Client masterClient) throws Exception;
/**
* Verify transport action behaviour on data node
*/
protected abstract void verifyActionOnDataNode(Client dataNodeClient) throws Exception;
/**
* Verify transport action behaviour on tribe node
*/
protected abstract void verifyActionOnTribeNode(Client tribeClient);
protected void failAction(Client client, Action action) {
try {
client.execute(action, action.newRequestBuilder(client).request());
fail("expected [" + action.name() + "] to fail");
} catch (IllegalStateException e) {
assertThat(e.getMessage(), containsString("failed to find action"));
}
}
private void ensureYellow(TestCluster testCluster) {
ClusterHealthResponse actionGet = testCluster.client().admin().cluster()
.health(Requests.clusterHealthRequest().waitForYellowStatus()
.waitForEvents(Priority.LANGUID).waitForRelocatingShards(0)).actionGet();
if (actionGet.isTimedOut()) {
logger.info("ensureGreen timed out, cluster state:\n{}\n{}", testCluster.client().admin().cluster()
.prepareState().get().getState().prettyPrint(),
testCluster.client().admin().cluster().preparePendingClusterTasks().get().prettyPrint());
assertThat("timed out waiting for yellow state", actionGet.isTimedOut(), equalTo(false));
}
assertThat(actionGet.getStatus(), anyOf(equalTo(ClusterHealthStatus.YELLOW), equalTo(ClusterHealthStatus.GREEN)));
}
private int countDataNodesForTribe(String tribeName, DiscoveryNodes nodes) {
int count = 0;
for (DiscoveryNode node : nodes) {
if (!node.isDataNode()) {
continue;
}
if (tribeName.equals(node.getAttributes().get("tribe.name"))) {
count++;
}
}
return count;
}
private static String[] getUnicastHosts(Client client) {
ArrayList<String> unicastHosts = new ArrayList<>();
NodesInfoResponse nodeInfos = client.admin().cluster().prepareNodesInfo().clear().setTransport(true).get();
for (NodeInfo info : nodeInfos.getNodes()) {
TransportAddress address = info.getTransport().getAddress().publishAddress();
unicastHosts.add(address.getAddress() + ":" + address.getPort());
}
return unicastHosts.toArray(new String[unicastHosts.size()]);
}
}

View File

@ -42,11 +42,13 @@ public class Monitoring {
private final Settings settings;
private final boolean enabled;
private final boolean transportClientMode;
private final boolean tribeNode;
public Monitoring(Settings settings) {
this.settings = settings;
this.enabled = MonitoringSettings.ENABLED.get(settings);
this.transportClientMode = XPackPlugin.transportClientMode(settings);
this.tribeNode = XPackPlugin.isTribeNode(settings);
}
boolean isEnabled() {
@ -60,7 +62,7 @@ public class Monitoring {
public Collection<Module> nodeModules() {
List<Module> modules = new ArrayList<>();
modules.add(new MonitoringModule(enabled, transportClientMode));
if (enabled && transportClientMode == false) {
if (enabled && transportClientMode == false && tribeNode == false) {
modules.add(new CollectorModule());
modules.add(new ExporterModule(settings));
modules.add(new MonitoringClientModule());
@ -69,7 +71,7 @@ public class Monitoring {
}
public Collection<Class<? extends LifecycleComponent>> nodeServices() {
if (enabled == false || transportClientMode) {
if (enabled == false || transportClientMode || tribeNode) {
return Collections.emptyList();
}
return Arrays.<Class<? extends LifecycleComponent>>asList(MonitoringLicensee.class,
@ -82,19 +84,19 @@ public class Monitoring {
}
public void onModule(ActionModule module) {
if (enabled) {
if (enabled && tribeNode == false) {
module.registerAction(MonitoringBulkAction.INSTANCE, TransportMonitoringBulkAction.class);
}
}
public void onModule(NetworkModule module) {
if (enabled && transportClientMode == false) {
if (enabled && transportClientMode == false && tribeNode == false) {
module.registerRestHandler(RestMonitoringBulkAction.class);
}
}
public void onModule(LazyInitializationModule module) {
if (enabled) {
if (enabled && tribeNode == false) {
module.registerLazyInitializable(MonitoringClientProxy.class);
}
}

View File

@ -5,9 +5,9 @@
*/
package org.elasticsearch.marvel.agent.collector.node;
import org.elasticsearch.action.admin.cluster.node.stats.NodeStats;
import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsRequest;
import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsResponse;
import org.elasticsearch.action.admin.indices.stats.CommonStatsFlags;
import org.elasticsearch.bootstrap.BootstrapInfo;
import org.elasticsearch.client.Client;
@ -72,16 +72,14 @@ public class NodeStatsCollector extends AbstractCollector<NodeStatsCollector> {
request.threadPool(true);
request.fs(true);
NodeStats[] nodesStatsResponses = client.admin().cluster().nodesStats(request).actionGet().getNodes();
NodesStatsResponse response = client.admin().cluster().nodesStats(request).actionGet();
// In unusual scenarios, node stats can be empty (e.g., closing an index in the middle of the request)
// Note: NodesStatsResponse does not currently override failures, so we cannot log the actual reason
if (nodesStatsResponses.length == 0) {
logger.debug("_local NodesStatsResponse is empty");
return null;
// if there's a failure, then we failed to work with the _local node (guaranteed a single exception)
if (response.hasFailures()) {
throw response.failures().get(0);
}
NodeStats nodeStats = nodesStatsResponses[0];
NodeStats nodeStats = response.getNodes().get(0);
// Here we are calling directly the DiskThresholdDecider to retrieve the high watermark value
// It would be nicer to use a settings API like documented in #6732

View File

@ -37,6 +37,7 @@ public class IndexStatsResolver extends MonitoringIndexNameResolver.Timestamped<
"index_stats.primaries.segments.stored_fields_memory_in_bytes",
"index_stats.primaries.segments.term_vectors_memory_in_bytes",
"index_stats.primaries.segments.norms_memory_in_bytes",
"index_stats.primaries.segments.points_memory_in_bytes",
"index_stats.primaries.segments.doc_values_memory_in_bytes",
"index_stats.primaries.segments.index_writer_memory_in_bytes",
"index_stats.primaries.segments.version_map_memory_in_bytes",
@ -57,6 +58,7 @@ public class IndexStatsResolver extends MonitoringIndexNameResolver.Timestamped<
"index_stats.total.segments.stored_fields_memory_in_bytes",
"index_stats.total.segments.term_vectors_memory_in_bytes",
"index_stats.total.segments.norms_memory_in_bytes",
"index_stats.total.segments.points_memory_in_bytes",
"index_stats.total.segments.doc_values_memory_in_bytes",
"index_stats.total.segments.index_writer_memory_in_bytes",
"index_stats.total.segments.version_map_memory_in_bytes",

View File

@ -45,6 +45,7 @@ public class NodeStatsResolver extends MonitoringIndexNameResolver.Timestamped<N
"node_stats.indices.segments.stored_fields_memory_in_bytes",
"node_stats.indices.segments.term_vectors_memory_in_bytes",
"node_stats.indices.segments.norms_memory_in_bytes",
"node_stats.indices.segments.points_memory_in_bytes",
"node_stats.indices.segments.doc_values_memory_in_bytes",
"node_stats.indices.segments.index_writer_memory_in_bytes",
"node_stats.indices.segments.version_map_memory_in_bytes",

View File

@ -72,7 +72,7 @@ public class MarvelPluginTests extends MarvelIntegTestCase {
private void assertPluginIsLoaded() {
NodesInfoResponse response = client().admin().cluster().prepareNodesInfo().setPlugins(true).get();
for (NodeInfo nodeInfo : response) {
for (NodeInfo nodeInfo : response.getNodes()) {
assertNotNull(nodeInfo.getPlugins());
boolean found = false;
@ -103,7 +103,7 @@ public class MarvelPluginTests extends MarvelIntegTestCase {
internalCluster().getDataNodeInstance(klass);
fail("should have thrown an exception about missing implementation");
} catch (Exception ce) {
assertThat("message contains error about missing implemention: " + ce.getMessage(),
assertThat("message contains error about missing implementation: " + ce.getMessage(),
ce.getMessage().contains("No implementation"), equalTo(true));
}
}

View File

@ -0,0 +1,51 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.marvel;
import org.elasticsearch.client.Client;
import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.marvel.action.MonitoringBulkAction;
import org.elasticsearch.marvel.action.MonitoringBulkDoc;
import org.elasticsearch.marvel.action.MonitoringBulkRequest;
import org.elasticsearch.xpack.TribeTransportTestCase;
import java.util.Collections;
import java.util.List;
public class MonitoringTribeTests extends TribeTransportTestCase {
@Override
protected List<String> enabledFeatures() {
return Collections.singletonList(Monitoring.NAME);
}
@Override
protected void verifyActionOnClientNode(Client client) throws Exception {
assertMonitoringTransportActionsWorks(client);
}
@Override
protected void verifyActionOnMasterNode(Client masterClient) throws Exception {
assertMonitoringTransportActionsWorks(masterClient);
}
@Override
protected void verifyActionOnDataNode(Client dataNodeClient) throws Exception {
assertMonitoringTransportActionsWorks(dataNodeClient);
}
private static void assertMonitoringTransportActionsWorks(Client client) throws Exception {
MonitoringBulkDoc doc = new MonitoringBulkDoc(randomAsciiOfLength(2), randomAsciiOfLength(2));
doc.setType(randomAsciiOfLength(5));
doc.setSource(new BytesArray("{\"key\" : \"value\"}"));
client.execute(MonitoringBulkAction.INSTANCE, new MonitoringBulkRequest());
}
@Override
protected void verifyActionOnTribeNode(Client tribeClient) {
failAction(tribeClient, MonitoringBulkAction.INSTANCE);
}
}

View File

@ -105,7 +105,7 @@ public class TransportMonitoringBulkActionTests extends ESTestCase {
clusterService.setClusterStatePublisher((event, ackListener) -> {});
clusterService.start();
transportService = new TransportService(transport, threadPool);
transportService = new TransportService(Settings.EMPTY, transport, threadPool, clusterService.state().getClusterName());
transportService.start();
transportService.acceptIncomingRequests();
exportService = new CapturingExporters();

View File

@ -50,7 +50,7 @@ public class ClusterStatsCollectorTests extends AbstractCollectorTestCase {
assertThat(clusterInfoMarvelDoc.getClusterName(),
equalTo(client().admin().cluster().prepareState().setMetaData(true).get().getClusterName().value()));
assertThat(clusterInfoMarvelDoc.getVersion(),
equalTo(client().admin().cluster().prepareNodesInfo().get().getNodes()[0].getVersion().toString()));
equalTo(client().admin().cluster().prepareNodesInfo().get().getNodes().get(0).getVersion().toString()));
assertThat(clusterInfoMarvelDoc.getLicense(), notNullValue());

View File

@ -6,7 +6,6 @@
package org.elasticsearch.marvel.agent.resolver.cluster;
import org.elasticsearch.Version;
import org.elasticsearch.action.admin.cluster.stats.ClusterStatsNodeResponse;
import org.elasticsearch.action.admin.cluster.stats.ClusterStatsResponse;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.node.DiscoveryNode;
@ -18,6 +17,7 @@ import org.elasticsearch.marvel.agent.collector.cluster.ClusterInfoMonitoringDoc
import org.elasticsearch.marvel.agent.exporter.MarvelTemplateUtils;
import org.elasticsearch.marvel.agent.resolver.MonitoringIndexNameResolverTestCase;
import java.util.Collections;
import java.util.UUID;
import static java.util.Collections.emptyMap;
@ -46,7 +46,7 @@ public class ClusterInfoResolverTests extends MonitoringIndexNameResolverTestCas
doc.setLicense(licenseBuilder.build());
doc.setClusterName(randomAsciiOfLength(5));
doc.setClusterStats(new ClusterStatsResponse(Math.abs(randomLong()), ClusterName.DEFAULT,
randomAsciiOfLength(5), new ClusterStatsNodeResponse[]{}));
randomAsciiOfLength(5), Collections.emptyList(), Collections.emptyList()));
return doc;
} catch (Exception e) {
throw new IllegalStateException("Failed to generated random ClusterInfoMarvelDoc", e);

View File

@ -92,12 +92,13 @@ public class ClusterStatsResolverTests extends MonitoringIndexNameResolverTestCa
* @return a testing {@link ClusterStatsResponse} used to resolve a marvel document.
*/
private ClusterStatsResponse randomClusterStats() {
ClusterStatsNodeResponse[] responses = {
List<ClusterStatsNodeResponse> responses = Collections.singletonList(
new ClusterStatsNodeResponse(new DiscoveryNode("node_0", DummyTransportAddress.INSTANCE,
emptyMap(), emptySet(), Version.CURRENT),
ClusterHealthStatus.GREEN, randomNodeInfo(), randomNodeStats(), randomShardStats())
};
return new ClusterStatsResponse(Math.abs(randomLong()), ClusterName.DEFAULT, UUID.randomUUID().toString(), responses);
);
return new ClusterStatsResponse(Math.abs(randomLong()), ClusterName.DEFAULT, UUID.randomUUID().toString(),
responses, Collections.emptyList());
}
/**

View File

@ -5,6 +5,7 @@
*/
package org.elasticsearch.shield.action.realm;
import org.elasticsearch.action.FailedNodeException;
import org.elasticsearch.action.support.nodes.BaseNodeResponse;
import org.elasticsearch.action.support.nodes.BaseNodesResponse;
import org.elasticsearch.cluster.ClusterName;
@ -16,6 +17,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import java.io.IOException;
import java.util.List;
/**
*
@ -25,40 +27,31 @@ public class ClearRealmCacheResponse extends BaseNodesResponse<ClearRealmCacheRe
public ClearRealmCacheResponse() {
}
public ClearRealmCacheResponse(ClusterName clusterName, Node[] nodes) {
super(clusterName, nodes);
public ClearRealmCacheResponse(ClusterName clusterName, List<Node> nodes, List<FailedNodeException> failures) {
super(clusterName, nodes, failures);
}
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
nodes = new Node[in.readVInt()];
for (int i = 0; i < nodes.length; i++) {
nodes[i] = Node.readNodeResponse(in);
}
protected List<ClearRealmCacheResponse.Node> readNodesFrom(StreamInput in) throws IOException {
return in.readList(Node::readNodeResponse);
}
@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
out.writeVInt(nodes.length);
for (Node node : nodes) {
node.writeTo(out);
}
protected void writeNodesTo(StreamOutput out, List<ClearRealmCacheResponse.Node> nodes) throws IOException {
out.writeStreamableList(nodes);
}
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject();
builder.field("cluster_name", getClusterName().value());
builder.startObject("nodes");
for (ClearRealmCacheResponse.Node node: getNodes()) {
for (ClearRealmCacheResponse.Node node : getNodes()) {
builder.startObject(node.getNode().getId());
builder.field("name", node.getNode().getName());
builder.endObject();
}
builder.endObject();
return builder.endObject();
return builder;
}
@Override

View File

@ -6,6 +6,7 @@
package org.elasticsearch.shield.action.realm;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.action.FailedNodeException;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.nodes.TransportNodesAction;
import org.elasticsearch.cluster.ClusterName;
@ -19,9 +20,7 @@ import org.elasticsearch.shield.authc.support.CachingRealm;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicReferenceArray;
/**
*
@ -37,23 +36,15 @@ public class TransportClearRealmCacheAction extends TransportNodesAction<ClearRe
ActionFilters actionFilters, Realms realms,
IndexNameExpressionResolver indexNameExpressionResolver) {
super(settings, ClearRealmCacheAction.NAME, clusterName, threadPool, clusterService, transportService, actionFilters,
indexNameExpressionResolver, ClearRealmCacheRequest::new, ClearRealmCacheRequest.Node::new, ThreadPool.Names.MANAGEMENT);
indexNameExpressionResolver, ClearRealmCacheRequest::new, ClearRealmCacheRequest.Node::new, ThreadPool.Names.MANAGEMENT,
ClearRealmCacheResponse.Node.class);
this.realms = realms;
}
@Override
protected ClearRealmCacheResponse newResponse(ClearRealmCacheRequest request, AtomicReferenceArray responses) {
final List<ClearRealmCacheResponse.Node> nodes = new ArrayList<>();
for (int i = 0; i < responses.length(); i++) {
Object resp = responses.get(i);
if (resp instanceof ClearRealmCacheResponse.Node) {
nodes.add((ClearRealmCacheResponse.Node) resp);
} else if (resp != null) {
// null is possible if there is an error and we do not accumulate exceptions...
throw new IllegalArgumentException("node response [" + resp.getClass() + "] is not the correct type");
}
}
return new ClearRealmCacheResponse(clusterName, nodes.toArray(new ClearRealmCacheResponse.Node[nodes.size()]));
protected ClearRealmCacheResponse newResponse(ClearRealmCacheRequest request,
List<ClearRealmCacheResponse.Node> responses, List<FailedNodeException> failures) {
return new ClearRealmCacheResponse(clusterName, responses, failures);
}
@Override

View File

@ -5,6 +5,7 @@
*/
package org.elasticsearch.shield.action.role;
import org.elasticsearch.action.FailedNodeException;
import org.elasticsearch.action.support.nodes.BaseNodeResponse;
import org.elasticsearch.action.support.nodes.BaseNodesResponse;
import org.elasticsearch.cluster.ClusterName;
@ -16,6 +17,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import java.io.IOException;
import java.util.List;
/**
* The response object that will be returned when clearing the cache of native roles
@ -25,32 +27,22 @@ public class ClearRolesCacheResponse extends BaseNodesResponse<ClearRolesCacheRe
public ClearRolesCacheResponse() {
}
public ClearRolesCacheResponse(ClusterName clusterName, Node[] nodes) {
super(clusterName, nodes);
public ClearRolesCacheResponse(ClusterName clusterName, List<Node> nodes, List<FailedNodeException> failures) {
super(clusterName, nodes, failures);
}
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
nodes = new Node[in.readVInt()];
for (int i = 0; i < nodes.length; i++) {
nodes[i] = Node.readNodeResponse(in);
}
protected List<ClearRolesCacheResponse.Node> readNodesFrom(StreamInput in) throws IOException {
return in.readList(Node::readNodeResponse);
}
@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
out.writeVInt(nodes.length);
for (Node node : nodes) {
node.writeTo(out);
}
protected void writeNodesTo(StreamOutput out, List<ClearRolesCacheResponse.Node> nodes) throws IOException {
out.writeStreamableList(nodes);
}
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject();
builder.field("cluster_name", getClusterName().value());
builder.startObject("nodes");
for (ClearRolesCacheResponse.Node node: getNodes()) {
builder.startObject(node.getNode().getId());
@ -58,7 +50,8 @@ public class ClearRolesCacheResponse extends BaseNodesResponse<ClearRolesCacheRe
builder.endObject();
}
builder.endObject();
return builder.endObject();
return builder;
}
@Override

View File

@ -5,6 +5,7 @@
*/
package org.elasticsearch.shield.action.role;
import org.elasticsearch.action.FailedNodeException;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.nodes.TransportNodesAction;
import org.elasticsearch.cluster.ClusterName;
@ -16,9 +17,7 @@ import org.elasticsearch.shield.authz.store.NativeRolesStore;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicReferenceArray;
/**
*
@ -33,24 +32,15 @@ public class TransportClearRolesCacheAction extends TransportNodesAction<ClearRo
ClusterService clusterService, TransportService transportService, ActionFilters actionFilters,
NativeRolesStore rolesStore, IndexNameExpressionResolver indexNameExpressionResolver) {
super(settings, ClearRolesCacheAction.NAME, clusterName, threadPool, clusterService, transportService,
actionFilters, indexNameExpressionResolver, ClearRolesCacheRequest::new, ClearRolesCacheRequest.Node::new,
ThreadPool.Names.MANAGEMENT);
actionFilters, indexNameExpressionResolver, ClearRolesCacheRequest::new, ClearRolesCacheRequest.Node::new,
ThreadPool.Names.MANAGEMENT, ClearRolesCacheResponse.Node.class);
this.rolesStore = rolesStore;
}
@Override
protected ClearRolesCacheResponse newResponse(ClearRolesCacheRequest request, AtomicReferenceArray nodesResponses) {
List<ClearRolesCacheResponse.Node> responses = new ArrayList<>(nodesResponses.length());
for (int i = 0; i < nodesResponses.length(); i++) {
Object resp = nodesResponses.get(i);
if (resp instanceof ClearRolesCacheResponse.Node) {
responses.add((ClearRolesCacheResponse.Node) resp);
} else if (resp == null) {
// null is possible if there is an error and we do not accumulate exceptions...
throw new IllegalArgumentException("node response [" + resp.getClass() + "] is not the correct type");
}
}
return new ClearRolesCacheResponse(clusterName, responses.toArray(new ClearRolesCacheResponse.Node[responses.size()]));
protected ClearRolesCacheResponse newResponse(ClearRolesCacheRequest request,
List<ClearRolesCacheResponse.Node> responses, List<FailedNodeException> failures) {
return new ClearRolesCacheResponse(clusterName, responses, failures);
}
@Override

View File

@ -34,8 +34,7 @@ public class RestAuthenticateAction extends BaseRestHandler {
public RestAuthenticateAction(Settings settings, RestController controller, Client client, SecurityContext securityContext) {
super(settings, client);
this.securityContext = securityContext;
controller.registerHandler(GET, "/_shield/authenticate", this); // deprecate
controller.registerHandler(GET, "/_shield/_authenticate", this);
controller.registerHandler(GET, "/_xpack/security/authenticate", this); // deprecate
}
@Override

View File

@ -8,18 +8,12 @@ package org.elasticsearch.shield.rest.action.realm;
import org.elasticsearch.client.Client;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.rest.BaseRestHandler;
import org.elasticsearch.rest.BytesRestResponse;
import org.elasticsearch.rest.RestChannel;
import org.elasticsearch.rest.RestController;
import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.rest.RestResponse;
import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.rest.action.support.RestBuilderListener;
import org.elasticsearch.rest.action.support.RestActions.NodesResponseRestListener;
import org.elasticsearch.shield.action.realm.ClearRealmCacheRequest;
import org.elasticsearch.shield.action.realm.ClearRealmCacheResponse;
import org.elasticsearch.shield.client.SecurityClient;
import static org.elasticsearch.rest.RestRequest.Method.POST;
@ -29,8 +23,8 @@ public class RestClearRealmCacheAction extends BaseRestHandler {
@Inject
public RestClearRealmCacheAction(Settings settings, RestController controller, Client client) {
super(settings, client);
controller.registerHandler(POST, "/_shield/realm/{realms}/_cache/clear", this); // deprecated
controller.registerHandler(POST, "/_shield/realm/{realms}/_clear_cache", this);
controller.registerHandler(POST, "/_xpack/security/realm/{realms}/_cache/clear", this); // deprecated
controller.registerHandler(POST, "/_xpack/security/realm/{realms}/_clear_cache", this);
}
@Override
@ -41,13 +35,7 @@ public class RestClearRealmCacheAction extends BaseRestHandler {
ClearRealmCacheRequest req = new ClearRealmCacheRequest().realms(realms).usernames(usernames);
new SecurityClient(client).clearRealmCache(req, new RestBuilderListener<ClearRealmCacheResponse>(channel) {
@Override
public RestResponse buildResponse(ClearRealmCacheResponse response, XContentBuilder builder) throws Exception {
response.toXContent(builder, ToXContent.EMPTY_PARAMS);
return new BytesRestResponse(RestStatus.OK, builder);
}
});
new SecurityClient(client).clearRealmCache(req, new NodesResponseRestListener<>(channel));
}
}

View File

@ -8,18 +8,12 @@ package org.elasticsearch.shield.rest.action.role;
import org.elasticsearch.client.Client;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.rest.BaseRestHandler;
import org.elasticsearch.rest.BytesRestResponse;
import org.elasticsearch.rest.RestChannel;
import org.elasticsearch.rest.RestController;
import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.rest.RestResponse;
import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.rest.action.support.RestBuilderListener;
import org.elasticsearch.rest.action.support.RestActions.NodesResponseRestListener;
import org.elasticsearch.shield.action.role.ClearRolesCacheRequest;
import org.elasticsearch.shield.action.role.ClearRolesCacheResponse;
import org.elasticsearch.shield.client.SecurityClient;
import static org.elasticsearch.rest.RestRequest.Method.POST;
@ -32,7 +26,7 @@ public class RestClearRolesCacheAction extends BaseRestHandler {
@Inject
public RestClearRolesCacheAction(Settings settings, RestController controller, Client client) {
super(settings, client);
controller.registerHandler(POST, "/_shield/role/{name}/_clear_cache", this);
controller.registerHandler(POST, "/_xpack/security/role/{name}/_clear_cache", this);
}
@Override
@ -42,12 +36,6 @@ public class RestClearRolesCacheAction extends BaseRestHandler {
ClearRolesCacheRequest req = new ClearRolesCacheRequest().names(roles);
new SecurityClient(client).clearRolesCache(req, new RestBuilderListener<ClearRolesCacheResponse>(channel) {
@Override
public RestResponse buildResponse(ClearRolesCacheResponse response, XContentBuilder builder) throws Exception {
response.toXContent(builder, ToXContent.EMPTY_PARAMS);
return new BytesRestResponse(RestStatus.OK, builder);
}
});
new SecurityClient(client).clearRolesCache(req, new NodesResponseRestListener<>(channel));
}
}

View File

@ -29,7 +29,7 @@ public class RestDeleteRoleAction extends BaseRestHandler {
@Inject
public RestDeleteRoleAction(Settings settings, RestController controller, Client client) {
super(settings, client);
controller.registerHandler(RestRequest.Method.DELETE, "/_shield/role/{name}", this);
controller.registerHandler(RestRequest.Method.DELETE, "/_xpack/security/role/{name}", this);
}
@Override

View File

@ -30,8 +30,8 @@ public class RestGetRolesAction extends BaseRestHandler {
@Inject
public RestGetRolesAction(Settings settings, RestController controller, Client client) {
super(settings, client);
controller.registerHandler(RestRequest.Method.GET, "/_shield/role/", this);
controller.registerHandler(RestRequest.Method.GET, "/_shield/role/{name}", this);
controller.registerHandler(RestRequest.Method.GET, "/_xpack/security/role/", this);
controller.registerHandler(RestRequest.Method.GET, "/_xpack/security/role/{name}", this);
}
@Override

View File

@ -29,8 +29,8 @@ public class RestPutRoleAction extends BaseRestHandler {
@Inject
public RestPutRoleAction(Settings settings, RestController controller, Client client) {
super(settings, client);
controller.registerHandler(RestRequest.Method.POST, "/_shield/role/{name}", this);
controller.registerHandler(RestRequest.Method.PUT, "/_shield/role/{name}", this);
controller.registerHandler(RestRequest.Method.POST, "/_xpack/security/role/{name}", this);
controller.registerHandler(RestRequest.Method.PUT, "/_xpack/security/role/{name}", this);
}
@Override

View File

@ -32,10 +32,10 @@ public class RestChangePasswordAction extends BaseRestHandler {
public RestChangePasswordAction(Settings settings, Client client, RestController controller, SecurityContext securityContext) {
super(settings, client);
this.securityContext = securityContext;
controller.registerHandler(RestRequest.Method.POST, "/_shield/user/{username}/_password", this);
controller.registerHandler(RestRequest.Method.PUT, "/_shield/user/{username}/_password", this);
controller.registerHandler(RestRequest.Method.POST, "/_shield/user/_password", this);
controller.registerHandler(RestRequest.Method.PUT, "/_shield/user/_password", this);
controller.registerHandler(RestRequest.Method.POST, "/_xpack/security/user/{username}/_password", this);
controller.registerHandler(RestRequest.Method.PUT, "/_xpack/security/user/{username}/_password", this);
controller.registerHandler(RestRequest.Method.POST, "/_xpack/security/user/_password", this);
controller.registerHandler(RestRequest.Method.PUT, "/_xpack/security/user/_password", this);
}
@Override

View File

@ -30,7 +30,7 @@ public class RestDeleteUserAction extends BaseRestHandler {
@Inject
public RestDeleteUserAction(Settings settings, RestController controller, Client client) {
super(settings, client);
controller.registerHandler(RestRequest.Method.DELETE, "/_shield/user/{username}", this);
controller.registerHandler(RestRequest.Method.DELETE, "/_xpack/security/user/{username}", this);
}
@Override

View File

@ -31,8 +31,8 @@ public class RestGetUsersAction extends BaseRestHandler {
@Inject
public RestGetUsersAction(Settings settings, RestController controller, Client client) {
super(settings, client);
controller.registerHandler(RestRequest.Method.GET, "/_shield/user/", this);
controller.registerHandler(RestRequest.Method.GET, "/_shield/user/{username}", this);
controller.registerHandler(RestRequest.Method.GET, "/_xpack/security/user/", this);
controller.registerHandler(RestRequest.Method.GET, "/_xpack/security/user/{username}", this);
}
@Override

View File

@ -29,8 +29,8 @@ public class RestPutUserAction extends BaseRestHandler {
@Inject
public RestPutUserAction(Settings settings, RestController controller, Client client) {
super(settings, client);
controller.registerHandler(RestRequest.Method.POST, "/_shield/user/{username}", this);
controller.registerHandler(RestRequest.Method.PUT, "/_shield/user/{username}", this);
controller.registerHandler(RestRequest.Method.POST, "/_xpack/security/user/{username}", this);
controller.registerHandler(RestRequest.Method.PUT, "/_xpack/security/user/{username}", this);
}
@Override

View File

@ -5,6 +5,7 @@
*/
package org.elasticsearch.shield.transport;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
@ -22,8 +23,9 @@ public class ShieldClientTransportService extends TransportService {
private final ClientTransportFilter clientFilter;
@Inject
public ShieldClientTransportService(Settings settings, Transport transport, ThreadPool threadPool, ClientTransportFilter clientFilter) {
super(settings, transport, threadPool);
public ShieldClientTransportService(Settings settings, Transport transport, ThreadPool threadPool,
ClusterName clusterName, ClientTransportFilter clientFilter) {
super(settings, transport, threadPool, clusterName);
this.clientFilter = clientFilter;
}

View File

@ -5,6 +5,7 @@
*/
package org.elasticsearch.shield.transport;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
@ -55,12 +56,13 @@ public class ShieldServerTransportService extends TransportService {
@Inject
public ShieldServerTransportService(Settings settings, Transport transport, ThreadPool threadPool,
ClusterName clusterName,
AuthenticationService authcService,
AuthorizationService authzService,
ShieldActionMapper actionMapper,
ClientTransportFilter clientTransportFilter,
SecurityLicenseState licenseState) {
super(settings, transport, threadPool);
super(settings, transport, threadPool, clusterName);
this.authcService = authcService;
this.authzService = authzService;
this.actionMapper = actionMapper;

View File

@ -106,7 +106,7 @@ public class ClearRealmsCacheTests extends ShieldIntegTestCase {
@Override
public void executeRequest() throws Exception {
executeHttpRequest("/_shield/realm/" + (randomBoolean() ? "*" : "_all") + "/_clear_cache",
executeHttpRequest("/_xpack/security/realm/" + (randomBoolean() ? "*" : "_all") + "/_clear_cache",
Collections.<String, String>emptyMap());
}
},
@ -129,7 +129,7 @@ public class ClearRealmsCacheTests extends ShieldIntegTestCase {
@Override
public void executeRequest() throws Exception {
String path = "/_shield/realm/" + (randomBoolean() ? "*" : "_all") + "/_clear_cache";
String path = "/_xpack/security/realm/" + (randomBoolean() ? "*" : "_all") + "/_clear_cache";
Map<String, String> params = Collections.singletonMap("usernames", String.join(",", evicted_usernames));
executeHttpRequest(path, params);
}
@ -147,7 +147,7 @@ public class ClearRealmsCacheTests extends ShieldIntegTestCase {
securityClient.clearRealmCache(request, new ActionListener<ClearRealmCacheResponse>() {
@Override
public void onResponse(ClearRealmCacheResponse response) {
assertThat(response.getNodes().length, equalTo(internalCluster().getNodeNames().length));
assertThat(response.getNodes().size(), equalTo(internalCluster().getNodeNames().length));
latch.countDown();
}

View File

@ -131,9 +131,9 @@ public class ClearRolesCacheTests extends NativeRealmIntegTestCase {
if (useHttp) {
String path;
if (rolesToClear == null) {
path = "/_shield/role/" + (randomBoolean() ? "*" : "_all") + "/_clear_cache";
path = "/_xpack/security/role/" + (randomBoolean() ? "*" : "_all") + "/_clear_cache";
} else {
path = "/_shield/role/" + Strings.arrayToCommaDelimitedString(rolesToClear) + "/_clear_cache";
path = "/_xpack/security/role/" + Strings.arrayToCommaDelimitedString(rolesToClear) + "/_clear_cache";
}
HttpResponse response = httpClient().path(path).method("POST")
.addHeader("Authorization",

View File

@ -37,6 +37,6 @@ public class VersionCompatibilityTests extends ESTestCase {
*
*/
assertThat("Remove workaround in LicenseService class when es core supports merging cluster level custom metadata",
Version.CURRENT.onOrBefore(Version.V_5_0_0_alpha2), is(true));
Version.CURRENT.equals(Version.V_5_0_0), is(true));
}
}

View File

@ -146,7 +146,7 @@ public class IndexAuditTrailTests extends ShieldIntegTestCase {
remoteCluster.beforeTest(random(), 0.5);
NodesInfoResponse response = remoteCluster.client().admin().cluster().prepareNodesInfo().execute().actionGet();
TransportInfo info = response.getNodes()[0].getTransport();
TransportInfo info = response.getNodes().get(0).getTransport();
InetSocketTransportAddress inet = (InetSocketTransportAddress) info.address().publishAddress();
Settings.Builder builder = Settings.builder()

View File

@ -82,7 +82,7 @@ public class RemoteIndexAuditTrailStartingTests extends ShieldIntegTestCase {
final List<String> addresses = new ArrayList<>();
// get addresses for current cluster
NodesInfoResponse response = client().admin().cluster().prepareNodesInfo().execute().actionGet();
final String clusterName = response.getClusterNameAsString();
final String clusterName = response.getClusterName().value();
for (NodeInfo nodeInfo : response.getNodes()) {
InetSocketTransportAddress address = (InetSocketTransportAddress) nodeInfo.getTransport().address().publishAddress();
addresses.add(address.address().getHostString() + ":" + address.address().getPort());

View File

@ -25,6 +25,7 @@ import org.elasticsearch.xpack.XPackPlugin;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static org.hamcrest.Matchers.containsString;
@ -207,10 +208,10 @@ public class RunAsIntegTests extends ShieldIntegTestCase {
// build our own here to better mimic an actual client...
TransportClient getTransportClient(Settings extraSettings) {
NodesInfoResponse nodeInfos = client().admin().cluster().prepareNodesInfo().get();
NodeInfo[] nodes = nodeInfos.getNodes();
assertTrue(nodes.length > 0);
List<NodeInfo> nodes = nodeInfos.getNodes();
assertTrue(nodes.isEmpty() == false);
TransportAddress publishAddress = randomFrom(nodes).getTransport().address().publishAddress();
String clusterName = nodeInfos.getClusterNameAsString();
String clusterName = nodeInfos.getClusterName().value();
Settings settings = Settings.builder()
.put(extraSettings)

View File

@ -47,7 +47,7 @@ public class RestAuthenticateActionTests extends ShieldIntegTestCase {
}
public void testAuthenticateApi() throws Exception {
HttpResponse response = httpClient().method("GET").path("/_shield/authenticate")
HttpResponse response = httpClient().method("GET").path("/_xpack/security/authenticate")
.addHeader("Authorization", basicAuthHeaderValue(ShieldSettingsSource.DEFAULT_USER_NAME,
new SecuredString(ShieldSettingsSource.DEFAULT_PASSWORD.toCharArray())))
.execute();
@ -61,7 +61,7 @@ public class RestAuthenticateActionTests extends ShieldIntegTestCase {
}
public void testAuthenticateApiWithoutAuthentication() throws Exception {
HttpResponse response = httpClient().method("GET").path("/_shield/authenticate")
HttpResponse response = httpClient().method("GET").path("/_xpack/security/authenticate")
.execute();
if (anonymousEnabled) {

View File

@ -6,6 +6,7 @@
package org.elasticsearch.shield.transport;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.inject.AbstractModule;
import org.elasticsearch.common.inject.Inject;
@ -307,9 +308,9 @@ public class TransportFilterTests extends ESIntegTestCase {
@Inject
public InternalPluginServerTransportService(Settings settings, Transport transport, ThreadPool threadPool,
AuthenticationService authcService, AuthorizationService authzService, ShieldActionMapper actionMapper,
ClientTransportFilter clientTransportFilter) {
super(settings, transport, threadPool, authcService, authzService, actionMapper, clientTransportFilter,
ClusterName clusterName, AuthenticationService authcService, AuthorizationService authzService,
ShieldActionMapper actionMapper, ClientTransportFilter clientTransportFilter) {
super(settings, transport, threadPool, clusterName, authcService, authzService, actionMapper, clientTransportFilter,
mock(SecurityLicenseState.class));
when(licenseState.authenticationAndAuthorizationEnabled()).thenReturn(true);
}

View File

@ -140,7 +140,7 @@ public abstract class ShieldIntegTestCase extends ESIntegTestCase {
//before methods from the superclass are run before this, which means that the current cluster is ready to go
public void assertShieldIsInstalled() {
NodesInfoResponse nodeInfos = client().admin().cluster().prepareNodesInfo().clear().setPlugins(true).get();
for (NodeInfo nodeInfo : nodeInfos) {
for (NodeInfo nodeInfo : nodeInfos.getNodes()) {
// TODO: disable this assertion for now, due to random runs with mock plugins. perhaps run without mock plugins?
// assertThat(nodeInfo.getPlugins().getInfos(), hasSize(2));
Collection<String> pluginNames =

View File

@ -110,3 +110,4 @@ internal:indices/flush/synced/pre
internal:indices/flush/synced/sync
internal:admin/repository/verify
internal:plugin/license/cluster/register_trial_license
internal:transport/handshake

View File

@ -1,10 +1,10 @@
{
"shield.authenticate": {
"xpack.security.authenticate": {
"documentation": "Retrieve details about the currently authenticated user",
"methods": [ "GET" ],
"url": {
"path": "/_shield/authenticate",
"paths": [ "/_shield/authenticate" ],
"path": "/_xpack/security/authenticate",
"paths": [ "/_xpack/security/authenticate" ],
"parts": {},
"params": {}
},

View File

@ -1,10 +1,10 @@
{
"shield.change_password": {
"xpack.security.change_password": {
"documentation": "Change the password of a user",
"methods": [ "PUT", "POST" ],
"url": {
"path": "/_shield/user/{username}/_password",
"paths": [ "/_shield/user/{username}/_password", "/_shield/user/_password" ],
"path": "/_xpack/security/user/{username}/_password",
"paths": [ "/_xpack/security/user/{username}/_password", "/_xpack/security/user/_password" ],
"parts": {
"username": {
"type" : "string",

View File

@ -1,10 +1,10 @@
{
"shield.clear_cached_realms": {
"xpack.security.clear_cached_realms": {
"documentation": "Clears the internal user caches for specified realms",
"methods": [ "POST" ],
"url": {
"path": "/_shield/realm/{realms}/_clear_cache",
"paths": [ "/_shield/realm/{realms}/_clear_cache" ],
"path": "/_xpack/security/realm/{realms}/_clear_cache",
"paths": [ "/_xpack/security/realm/{realms}/_clear_cache" ],
"parts": {
"realms": {
"type" : "string",

View File

@ -1,10 +1,10 @@
{
"shield.clear_cached_roles": {
"xpack.security.clear_cached_roles": {
"documentation": "Clears the internal caches for specified roles",
"methods": [ "PUT", "POST" ],
"url": {
"path": "/_shield/role/{name}/_clear_cache",
"paths": [ "/_shield/role/{name}/_clear_cache" ],
"path": "/_xpack/security/role/{name}/_clear_cache",
"paths": [ "/_xpack/security/role/{name}/_clear_cache" ],
"parts": {
"name": {
"type" : "string",

View File

@ -1,10 +1,10 @@
{
"shield.delete_role": {
"xpack.security.delete_role": {
"documentation": "Remove a role from the native shield realm",
"methods": [ "DELETE" ],
"url": {
"path": "/_shield/role/{name}",
"paths": [ "/_shield/role/{name}" ],
"path": "/_xpack/security/role/{name}",
"paths": [ "/_xpack/security/role/{name}" ],
"parts": {
"name": {
"type" : "string",

View File

@ -1,10 +1,10 @@
{
"shield.delete_user": {
"xpack.security.delete_user": {
"documentation": "Remove a user from the native shield realm",
"methods": [ "DELETE" ],
"url": {
"path": "/_shield/user/{username}",
"paths": [ "/_shield/user/{username}" ],
"path": "/_xpack/security/user/{username}",
"paths": [ "/_xpack/security/user/{username}" ],
"parts": {
"username": {
"type" : "string",

View File

@ -1,10 +1,10 @@
{
"shield.get_role": {
"xpack.security.get_role": {
"documentation": "Retrieve one or more roles from the native shield realm",
"methods": [ "GET" ],
"url": {
"path": "/_shield/role/{name}",
"paths": [ "/_shield/role/{name}", "/_shield/role" ],
"path": "/_xpack/security/role/{name}",
"paths": [ "/_xpack/security/role/{name}", "/_xpack/security/role" ],
"parts": {
"name": {
"type" : "string",

View File

@ -1,10 +1,10 @@
{
"shield.get_user": {
"xpack.security.get_user": {
"documentation": "Retrieve one or more users from the native shield realm",
"methods": [ "GET" ],
"url": {
"path": "/_shield/user/{username}",
"paths": [ "/_shield/user/{username}", "/_shield/user" ],
"path": "/_xpack/security/user/{username}",
"paths": [ "/_xpack/security/user/{username}", "/_xpack/security/user" ],
"parts": {
"username": {
"type" : "list",

View File

@ -1,10 +1,10 @@
{
"shield.put_role": {
"xpack.security.put_role": {
"documentation": "Update or create a role for the native shield realm",
"methods": [ "PUT", "POST" ],
"url": {
"path": "/_shield/role/{name}",
"paths": [ "/_shield/role/{name}" ],
"path": "/_xpack/security/role/{name}",
"paths": [ "/_xpack/security/role/{name}" ],
"parts": {
"name": {
"type" : "string",

View File

@ -1,10 +1,10 @@
{
"shield.put_user": {
"xpack.security.put_user": {
"documentation": "Update or create a user for the native shield realm",
"methods": [ "PUT", "POST" ],
"url": {
"path": "/_shield/user/{username}",
"paths": [ "/_shield/user/{username}" ],
"path": "/_xpack/security/user/{username}",
"paths": [ "/_xpack/security/user/{username}" ],
"parts": {
"username": {
"type" : "string",

View File

@ -5,7 +5,7 @@
cluster.health:
wait_for_status: yellow
- do:
shield.authenticate: {}
xpack.security.authenticate: {}
- match: { username: "test_user" }
- match: { roles.0: "superuser" }

View File

@ -8,7 +8,7 @@
wait_for_status: yellow
- do:
shield.put_user:
xpack.security.put_user:
username: "joe"
body: >
{
@ -26,7 +26,7 @@
# change password
- do:
shield.change_password:
xpack.security.change_password:
username: "joe"
body: >
{
@ -57,7 +57,7 @@
wait_for_status: yellow
- do:
shield.put_role:
xpack.security.put_role:
name: "user"
body: >
{
@ -72,7 +72,7 @@
- match: { role: { created: true } }
- do:
shield.put_user:
xpack.security.put_user:
username: "joe"
body: >
{
@ -92,7 +92,7 @@
- do:
headers:
Authorization: "Basic am9lOnMza3JpdA=="
shield.change_password:
xpack.security.change_password:
body: >
{
"password" : "s3krit2"
@ -122,7 +122,7 @@
wait_for_status: yellow
- do:
shield.put_role:
xpack.security.put_role:
name: "user"
body: >
{
@ -137,7 +137,7 @@
- match: { role: { created: true } }
- do:
shield.put_user:
xpack.security.put_user:
username: "joe"
body: >
{
@ -158,7 +158,7 @@
headers:
Authorization: "Basic am9lOnMza3JpdA=="
catch: forbidden
shield.change_password:
xpack.security.change_password:
username: "anotheruser"
body: >
{

View File

@ -8,7 +8,7 @@
wait_for_status: yellow
- do:
shield.put_role:
xpack.security.put_role:
name: "admin_role"
body: >
{
@ -23,7 +23,7 @@
- match: { role: { created: true } }
- do:
shield.put_user:
xpack.security.put_user:
username: "joe"
body: >
{
@ -40,7 +40,7 @@
- match: { timed_out: false }
- do:
shield.get_role:
xpack.security.get_role:
name: "admin_role"
- match: { admin_role.cluster.0: "all" }
- match: { admin_role.indices.0.names.0: "*" }

View File

@ -8,7 +8,7 @@
wait_for_status: yellow
- do:
shield.put_role:
xpack.security.put_role:
name: "admin_role2"
body: >
{
@ -23,7 +23,7 @@
- match: { role: { created: true } }
- do:
shield.put_user:
xpack.security.put_user:
username: "joe"
body: >
{
@ -61,7 +61,7 @@
- match: { timed_out: false }
- do:
shield.get_role:
xpack.security.get_role:
name: "admin_role2"
- match: { admin_role2.cluster.0: "all" }
- match: { admin_role2.indices.0.names.0: "foo" }

View File

@ -1,12 +1,12 @@
"Get missing role":
- do:
catch: missing
shield.get_role:
xpack.security.get_role:
name: 'foo'
---
"Get missing (multiple) roles":
- do:
catch: missing
shield.get_role:
xpack.security.get_role:
name: [ 'foo', 'bar' ]

View File

@ -8,7 +8,7 @@
wait_for_status: yellow
- do:
shield.put_user:
xpack.security.put_user:
username: "joe"
body: >
{
@ -30,7 +30,7 @@
- match: { timed_out: false }
- do:
shield.get_user:
xpack.security.get_user:
username: "joe"
- match: { joe.username: "joe" }
- match: { joe.roles.0: "superuser" }

View File

@ -8,7 +8,7 @@
wait_for_status: yellow
- do:
shield.put_user:
xpack.security.put_user:
username: "joe"
body: >
{
@ -18,7 +18,7 @@
- match: { user: { created: true } }
- do:
shield.get_user:
xpack.security.get_user:
username: "joe"
- match: { joe.username: "joe" }
- match: { joe.roles.0: "superuser" }
@ -30,7 +30,7 @@
- match: { timed_out: false }
- do:
shield.put_user:
xpack.security.put_user:
username: "joe"
body: >
{
@ -46,7 +46,7 @@
- match: { user: { created: false } }
- do:
shield.get_user:
xpack.security.get_user:
username: "joe"
- match: { joe.username: "joe" }
- match: { joe.roles.0: "superuser" }

View File

@ -6,7 +6,7 @@
- do:
catch: request
shield.put_user:
xpack.security.put_user:
username: "joe"
body: >
{
@ -24,7 +24,7 @@
wait_for_status: yellow
- do:
shield.put_user:
xpack.security.put_user:
username: "joe"
body: >
{
@ -41,7 +41,7 @@
- match: { timed_out: false }
- do:
shield.get_user:
xpack.security.get_user:
username: "joe"
- match: { joe.username: "joe" }
- match: { joe.roles.0: "superuser" }
@ -51,7 +51,7 @@
# update the user without a password
- do:
shield.put_user:
xpack.security.put_user:
username: "joe"
body: >
{
@ -74,7 +74,7 @@
# validate other properties
- do:
shield.get_user:
xpack.security.get_user:
username: "joe"
- match: { joe.username: "joe" }
- match: { joe.roles.0: "superuser" }
@ -86,7 +86,7 @@
# update with password
- do:
shield.put_user:
xpack.security.put_user:
username: "joe"
body: >
{
@ -118,7 +118,7 @@
# validate properties
- do:
shield.get_user:
xpack.security.get_user:
username: "joe"
- match: { joe.username: "joe" }
- match: { joe.roles.0: "superuser" }

View File

@ -1,12 +1,12 @@
"Get missing user":
- do:
catch: missing
shield.get_user:
xpack.security.get_user:
username: 'foo'
---
"Get missing (multiple) users":
- do:
catch: missing
shield.get_user:
xpack.security.get_user:
username: [ 'foo', 'bar' ]

View File

@ -88,7 +88,7 @@ public abstract class XPackRestTestCase extends ESRestTestCase {
// TODO remove this once the built-in SUPERUSER role is added that can delete the index and we use the built in admin user here
try (CloseableHttpClient client = HttpClients.createMinimal(new BasicHttpClientConnectionManager())) {
final URL url = getClusterUrls()[0];
HttpGet getUsersRequest = new HttpGet(new URI("http", null, url.getHost(), url.getPort(), "/_shield/user", null, null));
HttpGet getUsersRequest = new HttpGet(new URI("http", null, url.getHost(), url.getPort(), "/_xpack/security/user", null, null));
getUsersRequest.addHeader("Authorization", BASIC_AUTH_VALUE);
try (CloseableHttpResponse closeableHttpResponse = client.execute(getUsersRequest)) {
assertThat(closeableHttpResponse.getStatusLine().getStatusCode(), is(200));
@ -99,14 +99,14 @@ public abstract class XPackRestTestCase extends ESRestTestCase {
// in the structure of this API, the users are the keyset
for (String user : responseMap.keySet()) {
HttpDelete delete = new HttpDelete(new URI("http", null, url.getHost(), url.getPort(),
"/_shield/user/" + user, null, null));
"/_xpack/security/user/" + user, null, null));
delete.addHeader("Authorization", BASIC_AUTH_VALUE);
try (CloseableHttpResponse deleteResponse = client.execute(delete)) {
}
}
}
HttpGet getRolesRequest = new HttpGet(new URI("http", null, url.getHost(), url.getPort(), "/_shield/role",
HttpGet getRolesRequest = new HttpGet(new URI("http", null, url.getHost(), url.getPort(), "/_xpack/security/role",
null, null));
getRolesRequest.addHeader("Authorization", BASIC_AUTH_VALUE);
try (CloseableHttpResponse closeableHttpResponse = client.execute(getRolesRequest)) {
@ -118,7 +118,7 @@ public abstract class XPackRestTestCase extends ESRestTestCase {
// in the structure of this API, the users are the keyset
for (String role : responseMap.keySet()) {
HttpDelete delete = new HttpDelete(new URI("http", null, url.getHost(), url.getPort(),
"/_shield/role/" + role, null, null));
"/_xpack/security/role/" + role, null, null));
delete.addHeader("Authorization", BASIC_AUTH_VALUE);
try (CloseableHttpResponse deleteResponse = client.execute(delete)) {
}

View File

@ -81,7 +81,7 @@ public class WatcherPluginDisableTests extends ESIntegTestCase {
public void testThreadPools() throws Exception {
NodesInfoResponse nodesInfo = client().admin().cluster().prepareNodesInfo().setThreadPool(true).get();
for (NodeInfo nodeInfo : nodesInfo) {
for (NodeInfo nodeInfo : nodesInfo.getNodes()) {
ThreadPoolInfo threadPoolInfo = nodeInfo.getThreadPool();
for (ThreadPool.Info info : threadPoolInfo) {
assertThat(info.getName(), not(is(InternalWatchExecutor.THREAD_POOL_NAME)));

View File

@ -165,7 +165,7 @@ public class WatcherScheduleEngineBenchmark {
try {
while (start.get()) {
NodesStatsResponse response = client.admin().cluster().prepareNodesStats("_master").setJvm(true).get();
ByteSizeValue heapUsed = response.getNodes()[0].getJvm().getMem().getHeapUsed();
ByteSizeValue heapUsed = response.getNodes().get(0).getJvm().getMem().getHeapUsed();
jvmUsedHeapSpace.inc(heapUsed.bytes());
Thread.sleep(1000);
}
@ -179,7 +179,7 @@ public class WatcherScheduleEngineBenchmark {
sampleThread.join();
NodesStatsResponse response = client.admin().cluster().prepareNodesStats().setThreadPool(true).get();
for (NodeStats nodeStats : response) {
for (NodeStats nodeStats : response.getNodes()) {
for (ThreadPoolStats.Stats threadPoolStats : nodeStats.getThreadPool()) {
if ("watcher".equals(threadPoolStats.getName())) {
stats.setWatcherThreadPoolStats(threadPoolStats);