Merge branch 'master' into enhancement/discovery_node_one_getter

Original commit: elastic/x-pack-elasticsearch@cf4c5bc630
This commit is contained in:
javanna 2016-03-30 17:26:02 +02:00 committed by Luca Cavanna
commit 02751ffff8
57 changed files with 196 additions and 142 deletions

View File

@ -81,7 +81,7 @@ public class GroovyScriptConditionIT extends AbstractWatcherIntegrationTestCase
AggregationBuilders
.dateHistogram("minutes").field("_timestamp").interval(TimeUnit.MILLISECONDS.convert(5, TimeUnit.SECONDS))
.order(Histogram.Order.COUNT_DESC)
.subAggregation(AggregationBuilders.terms("status").field("status").size(3)));
.subAggregation(AggregationBuilders.terms("status").field("status.keyword").size(3)));
SearchResponse unmetResponse = builder.get();
ExecutableScriptCondition condition =

View File

@ -10,7 +10,7 @@ integTest {
setting 'shield.audit.enabled', 'true'
setting 'shield.audit.outputs', 'index'
setupCommand 'setupDummyUser',
'bin/xpack/users', 'useradd', 'test_user', '-p', 'changeme', '-r', 'admin'
'bin/x-pack/users', 'useradd', 'test_user', '-p', 'changeme', '-r', 'admin'
waitCondition = { node, ant ->
File tmpFile = new File(node.cwd, 'wait.success')
ant.get(src: "http://${node.httpUri()}",

View File

@ -8,9 +8,9 @@ integTest {
cluster {
plugin 'x-pack', project(':x-plugins:elasticsearch:x-pack')
setupCommand 'setupDummyUser',
'bin/xpack/users', 'useradd', 'test_user', '-p', 'changeme', '-r', 'admin'
'bin/x-pack/users', 'useradd', 'test_user', '-p', 'changeme', '-r', 'admin'
setupCommand 'setupTransportClientUser',
'bin/xpack/users', 'useradd', 'transport', '-p', 'changeme', '-r', 'transport_client'
'bin/x-pack/users', 'useradd', 'transport', '-p', 'changeme', '-r', 'transport_client'
waitCondition = { node, ant ->
File tmpFile = new File(node.cwd, 'wait.success')
ant.get(src: "http://${node.httpUri()}",

View File

@ -37,7 +37,7 @@ integTest {
setting 'xpack.watcher.enabled', 'false'
setting 'xpack.monitoring.enabled', 'false'
setupCommand 'setupDummyUser',
'bin/xpack/users', 'useradd', 'test_user', '-p', 'changeme', '-r', 'admin'
'bin/x-pack/users', 'useradd', 'test_user', '-p', 'changeme', '-r', 'admin'
waitCondition = { node, ant ->
File tmpFile = new File(node.cwd, 'wait.success')
ant.get(src: "http://${node.httpUri()}",

View File

@ -28,7 +28,7 @@ processResources {
}
task buildZip(type:Zip, dependsOn: [jar]) {
from 'build/resources/main/xpack-extension-descriptor.properties'
from 'build/resources/main/x-pack-extension-descriptor.properties'
from project.jar
}
@ -42,9 +42,9 @@ task integTest(type: org.elasticsearch.gradle.test.RestIntegTestTask, dependsOn:
setting 'shield.authc.realms.esusers.type', 'file'
setupCommand 'setupDummyUser',
'bin/xpack/users', 'useradd', 'test_user', '-p', 'changeme', '-r', 'admin'
'bin/x-pack/users', 'useradd', 'test_user', '-p', 'changeme', '-r', 'admin'
setupCommand 'installExtension',
'bin/xpack/extension', 'install', 'file:' + buildZip.archivePath
'bin/x-pack/extension', 'install', 'file:' + buildZip.archivePath
waitCondition = { node, ant ->
File tmpFile = new File(node.cwd, 'wait.success')
ant.get(src: "http://${node.httpUri()}",
@ -58,4 +58,4 @@ task integTest(type: org.elasticsearch.gradle.test.RestIntegTestTask, dependsOn:
}
}
check.dependsOn integTest
integTest.mustRunAfter precommit
integTest.mustRunAfter precommit

View File

@ -8,7 +8,7 @@ integTest {
cluster {
setting 'script.inline', 'true'
plugin 'x-pack', project(':x-plugins:elasticsearch:x-pack')
extraConfigFile 'xpack/roles.yml', 'roles.yml'
extraConfigFile 'x-pack/roles.yml', 'roles.yml'
[
test_admin: 'admin',
powerful_user: 'admin',
@ -19,7 +19,7 @@ integTest {
can_not_see_hidden_fields_user: 'can_not_see_hidden_fields',
].each { String user, String role ->
setupCommand 'setupUser#' + user,
'bin/xpack/users', 'useradd', user, '-p', 'changeme', '-r', role
'bin/x-pack/users', 'useradd', user, '-p', 'changeme', '-r', role
}
waitCondition = { node, ant ->
File tmpFile = new File(node.cwd, 'wait.success')

View File

@ -75,10 +75,10 @@
<property name="home" location="${integ.scratch}/elasticsearch-${elasticsearch.version}"/>
<echo>Adding roles.yml</echo>
<copy file="shield-roles.yml" tofile="${home}/config/xpack/roles.yml" overwrite="true"/>
<copy file="shield-roles.yml" tofile="${home}/config/x-pack/roles.yml" overwrite="true"/>
<echo>Adding shield users...</echo>
<run-script script="${home}/bin/xpack/esusers">
<run-script script="${home}/bin/x-pack/esusers">
<nested>
<arg value="useradd"/>
<arg value="test_admin"/>

View File

@ -63,10 +63,10 @@
<property name="home" location="${integ.scratch}/elasticsearch-${elasticsearch.version}"/>
<echo>Adding roles.yml with watcher roles</echo>
<copy file="watcher-with-shield-roles.yml" tofile="${home}/config/xpack/roles.yml" overwrite="true"/>
<copy file="watcher-with-shield-roles.yml" tofile="${home}/config/x-pack/roles.yml" overwrite="true"/>
<echo>Adding shield users...</echo>
<run-script script="${home}/bin/xpack/esusers">
<run-script script="${home}/bin/x-pack/esusers">
<nested>
<arg value="useradd"/>
<arg value="test_admin"/>
@ -76,7 +76,7 @@
<arg value="admin"/>
</nested>
</run-script>
<run-script script="${home}/bin/xpack/esusers">
<run-script script="${home}/bin/x-pack/esusers">
<nested>
<arg value="useradd"/>
<arg value="watcher_manager"/>
@ -86,7 +86,7 @@
<arg value="watcher_manager"/>
</nested>
</run-script>
<run-script script="${home}/bin/xpack/esusers">
<run-script script="${home}/bin/x-pack/esusers">
<nested>
<arg value="useradd"/>
<arg value="powerless_user"/>

View File

@ -16,13 +16,13 @@ integTest {
cluster {
plugin 'x-pack', project(':x-plugins:elasticsearch:x-pack')
extraConfigFile 'xpack/roles.yml', 'roles.yml'
extraConfigFile 'x-pack/roles.yml', 'roles.yml'
setupCommand 'setupTestAdminUser',
'bin/xpack/users', 'useradd', 'test_admin', '-p', 'changeme', '-r', 'admin'
'bin/x-pack/users', 'useradd', 'test_admin', '-p', 'changeme', '-r', 'admin'
setupCommand 'setupGraphExplorerUser',
'bin/xpack/users', 'useradd', 'graph_explorer', '-p', 'changeme', '-r', 'graph_explorer'
'bin/x-pack/users', 'useradd', 'graph_explorer', '-p', 'changeme', '-r', 'graph_explorer'
setupCommand 'setupPowerlessUser',
'bin/xpack/users', 'useradd', 'no_graph_explorer', '-p', 'changeme', '-r', 'no_graph_explorer'
'bin/x-pack/users', 'useradd', 'no_graph_explorer', '-p', 'changeme', '-r', 'no_graph_explorer'
waitCondition = { node, ant ->
File tmpFile = new File(node.cwd, 'wait.success')
ant.get(src: "http://${node.httpUri()}",

View File

@ -165,9 +165,9 @@ integTest {
extraConfigFile clientKeyStore.name, clientKeyStore
setupCommand 'setupTestUser',
'bin/xpack/users', 'useradd', 'test_user', '-p', 'changeme', '-r', 'admin'
'bin/x-pack/users', 'useradd', 'test_user', '-p', 'changeme', '-r', 'admin'
setupCommand 'setupMarvelUser',
'bin/xpack/users', 'useradd', 'monitoring_agent', '-p', 'changeme', '-r', 'remote_monitoring_agent'
'bin/x-pack/users', 'useradd', 'monitoring_agent', '-p', 'changeme', '-r', 'remote_monitoring_agent'
waitCondition = { node, ant ->
// HTTPS check is tricky to do, so we wait for the log file to indicate that the node is started

View File

@ -14,6 +14,7 @@ import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.shield.transport.netty.ShieldNettyTransport;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.junit.annotations.TestLogging;
import org.elasticsearch.xpack.XPackPlugin;
import org.junit.After;
import org.junit.AfterClass;
@ -41,6 +42,7 @@ import static org.hamcrest.Matchers.greaterThan;
* then uses a transport client to check that the data have been correctly received and
* indexed in the cluster.
*/
@TestLogging("org.elasticsearch.action.admin.cluster.settings:DEBUG")
public class SmokeTestMonitoringWithShieldIT extends ESIntegTestCase {
private static final String USER = "test_user";

View File

@ -18,7 +18,7 @@ integTest {
plugin 'x-pack', project(':x-plugins:elasticsearch:x-pack')
setupCommand 'setupDummyUser',
'bin/xpack/users', 'useradd', 'test_user', '-p', 'changeme', '-r', 'admin'
'bin/x-pack/users', 'useradd', 'test_user', '-p', 'changeme', '-r', 'admin'
waitCondition = { node, ant ->
File tmpFile = new File(node.cwd, 'wait.success')
ant.get(src: "http://${node.httpUri()}",

View File

@ -20,13 +20,13 @@ integTest {
cluster {
plugin 'x-pack', project(':x-plugins:elasticsearch:x-pack')
extraConfigFile 'xpack/roles.yml', 'roles.yml'
extraConfigFile 'x-pack/roles.yml', 'roles.yml'
setupCommand 'setupTestAdminUser',
'bin/xpack/users', 'useradd', 'test_admin', '-p', 'changeme', '-r', 'admin'
'bin/x-pack/users', 'useradd', 'test_admin', '-p', 'changeme', '-r', 'admin'
setupCommand 'setupWatcherManagerUser',
'bin/xpack/users', 'useradd', 'watcher_manager', '-p', 'changeme', '-r', 'watcher_manager'
'bin/x-pack/users', 'useradd', 'watcher_manager', '-p', 'changeme', '-r', 'watcher_manager'
setupCommand 'setupPowerlessUser',
'bin/xpack/users', 'useradd', 'powerless_user', '-p', 'changeme', '-r', 'crappy_role'
'bin/x-pack/users', 'useradd', 'powerless_user', '-p', 'changeme', '-r', 'crappy_role'
waitCondition = { node, ant ->
File tmpFile = new File(node.cwd, 'wait.success')
ant.get(src: "http://${node.httpUri()}",

View File

@ -78,9 +78,9 @@ REM Disables explicit GC
set JAVA_OPTS=%JAVA_OPTS% -XX:+DisableExplicitGC
REM Avoid empty elements in classpath to make JarHell happy
if "%ES_CLASSPATH%" == "" (
set ES_CLASSPATH=%ES_HOME%/lib/*;%ES_HOME%/plugins/xpack/*
set ES_CLASSPATH=%ES_HOME%/lib/*;%ES_HOME%/plugins/x-pack/*
) else (
set ES_CLASSPATH=%ES_CLASSPATH%;%ES_HOME%/lib/*;%ES_HOME%/plugins/xpack/*
set ES_CLASSPATH=%ES_CLASSPATH%;%ES_HOME%/lib/*;%ES_HOME%/plugins/x-pack/*
)
set ES_PARAMS=-Des.path.home="%ES_HOME%"

View File

@ -62,12 +62,10 @@ fi
# Try to read package config files
if [ -f "/etc/sysconfig/elasticsearch" ]; then
CONF_DIR=/etc/elasticsearch
CONF_FILE=$CONF_DIR/elasticsearch.yml
. "/etc/sysconfig/elasticsearch"
elif [ -f "/etc/default/elasticsearch" ]; then
CONF_DIR=/etc/elasticsearch
CONF_FILE=$CONF_DIR/elasticsearch.yml
. "/etc/default/elasticsearch"
fi
@ -94,9 +92,9 @@ if [ -e "$CONF_DIR" ]; then
case "$properties" in
*-Des.default.path.conf=*) ;;
*)
if [ ! -d "$CONF_DIR/xpack" ]; then
echo "ERROR: The configuration directory [$CONF_DIR/xpack] does not exist. The extension tool expects security configuration files in that location."
echo "The plugin may not have been installed with the correct configuration path. If [$ES_HOME/config/xpack] exists, please copy the 'xpack' directory to [$CONF_DIR]"
if [ ! -d "$CONF_DIR/x-pack" ]; then
echo "ERROR: The configuration directory [$CONF_DIR/x-pack] does not exist. The extension tool expects security configuration files in that location."
echo "The plugin may not have been installed with the correct configuration path. If [$ES_HOME/config/x-pack] exists, please copy the 'x-pack' directory to [$CONF_DIR]"
exit 1
fi
properties="$properties -Des.default.path.conf=$CONF_DIR"
@ -107,10 +105,16 @@ fi
export HOSTNAME=`hostname -s`
# include x-pack jars in classpath
ES_CLASSPATH="$ES_CLASSPATH:$ES_HOME/plugins/xpack/*"
ES_CLASSPATH="$ES_CLASSPATH:$ES_HOME/plugins/x-pack/*"
# CONF_FILE setting was removed
if [ ! -z "$CONF_FILE" ]; then
echo "CONF_FILE setting is no longer supported. elasticsearch.yml must be placed in the config directory and cannot be renamed."
exit 1
fi
cd "$ES_HOME" > /dev/null
"$JAVA" $ES_JAVA_OPTS -cp "$ES_CLASSPATH" -Des.path.home="$ES_HOME" $properties org.elasticsearch.xpack.extensions.XPackExtensionCli "$@"
status=$?
cd - > /dev/null
exit $status
exit $status

View File

@ -5,7 +5,7 @@ group 'org.elasticsearch.plugin'
apply plugin: 'elasticsearch.esplugin'
esplugin {
name 'xpack'
name 'x-pack'
description 'Elasticsearch Expanded Pack Plugin'
classname 'org.elasticsearch.xpack.XPackPlugin'
}
@ -112,16 +112,16 @@ bundlePlugin {
include 'LICENSE.txt'
include 'NOTICE.txt'
}
from('bin/xpack') {
from('bin/x-pack') {
into 'bin'
}
from('shield/bin/xpack') {
from('shield/bin/x-pack') {
into 'bin'
}
from('shield/config/xpack') {
from('shield/config/x-pack') {
into 'config'
}
from('watcher/bin/xpack') {
from('watcher/bin/x-pack') {
into 'bin'
}
}
@ -130,7 +130,7 @@ integTest {
// TODO: fix this rest test to not depend on a hardcoded port!
systemProperty 'tests.rest.blacklist', 'getting_started/10_monitor_cluster_health/*'
cluster {
setupCommand 'setupDummyUser', 'bin/xpack/users', 'useradd', 'test_user', '-p', 'changeme', '-r', 'admin'
setupCommand 'setupDummyUser', 'bin/x-pack/users', 'useradd', 'test_user', '-p', 'changeme', '-r', 'admin'
waitCondition = { NodeInfo node, AntBuilder ant ->
File tmpFile = new File(node.cwd, 'wait.success')
ant.get(src: "http://${node.httpUri()}",
@ -158,7 +158,7 @@ artifacts {
}
run {
setupCommand 'setupDummyUser', 'bin/xpack/users', 'useradd', 'test_user', '-p', 'changeme', '-r', 'admin'
setupCommand 'setupDummyUser', 'bin/x-pack/users', 'useradd', 'test_user', '-p', 'changeme', '-r', 'admin'
}
// classes are missing, e.g. com.ibm.icu.lang.UCharacter

View File

@ -10,7 +10,6 @@ import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.settings.Settings.Builder;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.env.NodeEnvironment;
import org.elasticsearch.graph.action.GraphExploreAction;
import org.elasticsearch.graph.action.GraphExploreRequest;
import org.elasticsearch.graph.action.GraphExploreRequestBuilder;
@ -33,13 +32,13 @@ import org.elasticsearch.test.ESSingleNodeTestCase;
import org.elasticsearch.watcher.Watcher;
import org.elasticsearch.xpack.XPackPlugin;
import java.io.IOException;
import java.util.Collection;
import java.util.Map;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS;
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
import static org.hamcrest.Matchers.greaterThan;
@ -79,7 +78,12 @@ public class GraphTests extends ESSingleNodeTestCase {
@Override
public void setUp() throws Exception {
super.setUp();
createIndex("test", Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 2).put(SETTING_NUMBER_OF_REPLICAS, 0).build());
assertAcked(client().admin().indices().prepareCreate("test")
.setSettings(SETTING_NUMBER_OF_SHARDS, 2, SETTING_NUMBER_OF_REPLICAS, 0)
.addMapping("type",
"decade", "type=keyword",
"people", "type=keyword",
"description", "type=text,fielddata=true"));
createIndex("idx_unmapped");
ensureGreen();

View File

@ -8,12 +8,14 @@ package org.elasticsearch.marvel.agent;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.component.AbstractLifecycleComponent;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.lease.Releasable;
import org.elasticsearch.common.regex.Regex;
import org.elasticsearch.common.settings.ClusterSettings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.util.CollectionUtils;
import org.elasticsearch.common.util.concurrent.EsExecutors;
import org.elasticsearch.common.util.concurrent.ReleasableLock;
import org.elasticsearch.marvel.MarvelSettings;
import org.elasticsearch.marvel.agent.collector.Collector;
import org.elasticsearch.marvel.agent.collector.cluster.ClusterStatsCollector;
@ -28,6 +30,7 @@ import java.util.Collections;
import java.util.HashSet;
import java.util.Locale;
import java.util.Set;
import java.util.concurrent.locks.ReentrantLock;
/**
* The {@code AgentService} is a service that does the work of publishing the details to the monitoring cluster.
@ -100,15 +103,18 @@ public class AgentService extends AbstractLifecycleComponent<AgentService> {
}
}
/** stop collection and exporting. this method blocks until all background activity is guaranteed to be stopped */
public void stopCollection() {
if (exportingWorker != null) {
exportingWorker.collecting = false;
final ExportingWorker worker = this.exportingWorker;
if (worker != null) {
worker.stopCollecting();
}
}
public void startCollection() {
if (exportingWorker != null) {
exportingWorker.collecting = true;
final ExportingWorker worker = this.exportingWorker;
if (worker != null) {
worker.collecting = true;
}
}
@ -164,6 +170,8 @@ public class AgentService extends AbstractLifecycleComponent<AgentService> {
volatile boolean closed = false;
volatile boolean collecting = true;
final ReleasableLock collectionLock = new ReleasableLock(new ReentrantLock(false));
@Override
public void run() {
while (!closed) {
@ -175,29 +183,13 @@ public class AgentService extends AbstractLifecycleComponent<AgentService> {
continue;
}
if (logger.isTraceEnabled()) {
logger.trace("collecting data - collectors [{}]", Strings.collectionToCommaDelimitedString(collectors));
}
try (Releasable ignore = collectionLock.acquire()) {
Collection<MonitoringDoc> docs = new ArrayList<>();
for (Collector collector : collectors) {
if (collecting) {
Collection<MonitoringDoc> result = collector.collect();
if (result != null) {
logger.trace("adding [{}] collected docs from [{}] collector", result.size(), collector.name());
docs.addAll(result);
} else {
logger.trace("skipping collected docs from [{}] collector", collector.name());
}
}
if (closed) {
// Stop collecting if the worker is marked as closed
break;
}
}
Collection<MonitoringDoc> docs = collect();
if ((docs.isEmpty() == false) && (closed == false)) {
exporters.export(docs);
if ((docs.isEmpty() == false) && (closed == false)) {
exporters.export(docs);
}
}
} catch (ExportException e) {
@ -211,5 +203,35 @@ public class AgentService extends AbstractLifecycleComponent<AgentService> {
}
logger.debug("worker shutdown");
}
/** stop collection and exporting. this method will be block until background collection is actually stopped */
public void stopCollecting() {
collecting = false;
collectionLock.acquire().close();
}
private Collection<MonitoringDoc> collect() {
if (logger.isTraceEnabled()) {
logger.trace("collecting data - collectors [{}]", Strings.collectionToCommaDelimitedString(collectors));
}
Collection<MonitoringDoc> docs = new ArrayList<>();
for (Collector collector : collectors) {
if (collecting) {
Collection<MonitoringDoc> result = collector.collect();
if (result != null) {
logger.trace("adding [{}] collected docs from [{}] collector", result.size(), collector.name());
docs.addAll(result);
} else {
logger.trace("skipping collected docs from [{}] collector", collector.name());
}
}
if (closed) {
// Stop collecting if the worker is marked as closed
break;
}
}
return docs;
}
}
}

View File

@ -19,6 +19,18 @@ import static org.hamcrest.Matchers.equalTo;
@ClusterScope(scope = TEST, transportClientRatio = 0, numClientNodes = 0, numDataNodes = 0)
public class MarvelPluginTests extends MarvelIntegTestCase {
@Override
protected void startCollection() {
// do nothing as marvel is sometime unbound
}
@Override
protected void stopCollection() {
// do nothing as marvel is sometime unbound
}
@Override
protected Settings nodeSettings(int nodeOrdinal) {
return Settings.builder()

View File

@ -13,6 +13,7 @@ import org.elasticsearch.marvel.MonitoredSystem;
import org.elasticsearch.marvel.agent.resolver.bulk.MonitoringBulkResolver;
import org.elasticsearch.marvel.test.MarvelIntegTestCase;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.test.junit.annotations.TestLogging;
import java.util.List;
import java.util.Map;
@ -27,6 +28,7 @@ import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.nullValue;
@TestLogging("_root:DEBUG")
public class MonitoringBulkTests extends MarvelIntegTestCase {
@Override

View File

@ -84,7 +84,6 @@ public class HttpExporterTests extends MarvelIntegTestCase {
@After
public void cleanup() throws Exception {
stopCollection();
webServer.shutdown();
}

View File

@ -46,7 +46,7 @@ public class ClusterStateTests extends MarvelIntegTestCase {
.put(MarvelSettings.INTERVAL.getKey(), "-1")
.put(MarvelSettings.COLLECTORS.getKey(), ClusterStateCollector.NAME)
.put("xpack.monitoring.agent.exporters.default_local.type", "local")
.put("node.custom", randomInt)
.put("node.attr.custom", randomInt)
.build();
}

View File

@ -39,6 +39,8 @@ import org.elasticsearch.xpack.XPackClient;
import org.elasticsearch.xpack.XPackPlugin;
import org.hamcrest.Matcher;
import org.jboss.netty.util.internal.SystemPropertyUtil;
import org.junit.After;
import org.junit.Before;
import java.io.BufferedWriter;
import java.io.IOException;
@ -166,6 +168,18 @@ public abstract class MarvelIntegTestCase extends ESIntegTestCase {
return templates;
}
@Before
public void setUp() throws Exception {
super.setUp();
startCollection();
}
@After
public void tearDown() throws Exception {
stopCollection();
super.tearDown();
}
/**
* Override and return {@code false} to force running without Security.
*/

View File

@ -62,12 +62,10 @@ fi
# Try to read package config files
if [ -f "/etc/sysconfig/elasticsearch" ]; then
CONF_DIR=/etc/elasticsearch
CONF_FILE=$CONF_DIR/elasticsearch.yml
. "/etc/sysconfig/elasticsearch"
elif [ -f "/etc/default/elasticsearch" ]; then
CONF_DIR=/etc/elasticsearch
CONF_FILE=$CONF_DIR/elasticsearch.yml
. "/etc/default/elasticsearch"
fi
@ -94,28 +92,20 @@ if [ -e "$CONF_DIR" ]; then
case "$properties" in
*-Des.default.path.conf=*) ;;
*)
if [ ! -d "$CONF_DIR/xpack" ]; then
echo "ERROR: The configuration directory [$CONF_DIR/xpack] does not exist. The syskeygen tool expects security configuration files in that location."
echo "The plugin may not have been installed with the correct configuration path. If [$ES_HOME/config/xpack] exists, please copy the 'xpack' directory to [$CONF_DIR]"
if [ ! -d "$CONF_DIR/x-pack" ]; then
echo "ERROR: The configuration directory [$CONF_DIR/x-pack] does not exist. The syskeygen tool expects security configuration files in that location."
echo "The plugin may not have been installed with the correct configuration path. If [$ES_HOME/config/x-pack] exists, please copy the 'x-pack' directory to [$CONF_DIR]"
exit 1
fi
properties="$properties -Des.default.path.conf=$CONF_DIR"
;;
esac
fi
if [ -e "$CONF_FILE" ]; then
case "$properties" in
*-Des.default.config=*) ;;
*)
properties="$properties -Des.default.config=$CONF_FILE"
;;
esac
fi
export HOSTNAME=`hostname -s`
# include shield jars in classpath
ES_CLASSPATH="$ES_CLASSPATH:$ES_HOME/plugins/xpack/*"
ES_CLASSPATH="$ES_CLASSPATH:$ES_HOME/plugins/x-pack/*"
# don't let JAVA_TOOL_OPTIONS slip in (e.g. crazy agents in ubuntu)
# works around https://bugs.launchpad.net/ubuntu/+source/jayatana/+bug/1441487
@ -125,6 +115,12 @@ if [ "x$JAVA_TOOL_OPTIONS" != "x" ]; then
unset JAVA_TOOL_OPTIONS
fi
# CONF_FILE setting was removed
if [ ! -z "$CONF_FILE" ]; then
echo "CONF_FILE setting is no longer supported. elasticsearch.yml must be placed in the config directory and cannot be renamed."
exit 1
fi
cd "$ES_HOME" > /dev/null
"$JAVA" $ES_JAVA_OPTS -cp "$ES_CLASSPATH" -Des.path.home="$ES_HOME" $properties org.elasticsearch.shield.crypto.tool.SystemKeyTool "$@"
status=$?

View File

@ -62,12 +62,10 @@ fi
# Try to read package config files
if [ -f "/etc/sysconfig/elasticsearch" ]; then
CONF_DIR=/etc/elasticsearch
CONF_FILE=$CONF_DIR/elasticsearch.yml
. "/etc/sysconfig/elasticsearch"
elif [ -f "/etc/default/elasticsearch" ]; then
CONF_DIR=/etc/elasticsearch
CONF_FILE=$CONF_DIR/elasticsearch.yml
. "/etc/default/elasticsearch"
fi
@ -94,28 +92,20 @@ if [ -e "$CONF_DIR" ]; then
case "$properties" in
*-Des.default.path.conf=*) ;;
*)
if [ ! -d "$CONF_DIR/xpack" ]; then
echo "ERROR: The configuration directory [$CONF_DIR/xpack] does not exist. The users tool expects security configuration files in that location."
echo "The plugin may not have been installed with the correct configuration path. If [$ES_HOME/config/xpack] exists, please copy the 'xpack' directory to [$CONF_DIR]"
if [ ! -d "$CONF_DIR/x-pack" ]; then
echo "ERROR: The configuration directory [$CONF_DIR/x-pack] does not exist. The users tool expects security configuration files in that location."
echo "The plugin may not have been installed with the correct configuration path. If [$ES_HOME/config/x-pack] exists, please copy the 'x-pack' directory to [$CONF_DIR]"
exit 1
fi
properties="$properties -Des.default.path.conf=$CONF_DIR"
;;
esac
fi
if [ -e "$CONF_FILE" ]; then
case "$properties" in
*-Des.default.config=*) ;;
*)
properties="$properties -Des.default.config=$CONF_FILE"
;;
esac
fi
export HOSTNAME=`hostname -s`
# include shield jars in classpath
ES_CLASSPATH="$ES_CLASSPATH:$ES_HOME/plugins/xpack/*"
ES_CLASSPATH="$ES_CLASSPATH:$ES_HOME/plugins/x-pack/*"
# don't let JAVA_TOOL_OPTIONS slip in (e.g. crazy agents in ubuntu)
# works around https://bugs.launchpad.net/ubuntu/+source/jayatana/+bug/1441487
@ -125,6 +115,12 @@ if [ "x$JAVA_TOOL_OPTIONS" != "x" ]; then
unset JAVA_TOOL_OPTIONS
fi
# CONF_FILE setting was removed
if [ ! -z "$CONF_FILE" ]; then
echo "CONF_FILE setting is no longer supported. elasticsearch.yml must be placed in the config directory and cannot be renamed."
exit 1
fi
cd "$ES_HOME" > /dev/null
"$JAVA" $ES_JAVA_OPTS -cp "$ES_CLASSPATH" -Des.path.home="$ES_HOME" $properties org.elasticsearch.shield.authc.file.tool.UsersTool "$@"
status=$?

View File

@ -167,7 +167,7 @@ public class FileUserPasswdStore {
}
if (users.isEmpty()) {
logger.warn("no users found in users file [{}]. use bin/xpack/file to add users and role mappings", path.toAbsolutePath());
logger.warn("no users found in users file [{}]. use bin/x-pack/users to add users and role mappings", path.toAbsolutePath());
}
return unmodifiableMap(users);
}

View File

@ -181,7 +181,7 @@ public class FileUserRolesStore {
}
if (usersRoles.isEmpty()) {
logger.warn("no entries found in users_roles file [{}]. use bin/xpack/file to add users and role mappings", path
logger.warn("no entries found in users_roles file [{}]. use bin/xpack/users to add users and role mappings", path
.toAbsolutePath());
}

View File

@ -9,7 +9,7 @@ SYNOPSIS
DESCRIPTION
Generates the system key and stores in the system_key file. By default
it will be stored in 'config/xpack/system_key' file. If the file location
it will be stored in 'config/x-pack/system_key' file. If the file location
is customized in the elasticsearch.yml (under the 'shield.system_key.file'
setting), the generated key will be stored in that custom location.

View File

@ -417,7 +417,7 @@ public class DocumentLevelSecurityTests extends ShieldIntegTestCase {
public void testGlobalAggregation() throws Exception {
assertAcked(client().admin().indices().prepareCreate("test")
.addMapping("type1", "field1", "type=text", "field2", "type=text", "field3", "type=text")
.addMapping("type1", "field1", "type=text", "field2", "type=text,fielddata=true", "field3", "type=text")
);
client().prepareIndex("test", "type1", "1").setSource("field1", "value1")
.setRefresh(true)
@ -481,7 +481,7 @@ public class DocumentLevelSecurityTests extends ShieldIntegTestCase {
public void testChildrenAggregation() throws Exception {
assertAcked(client().admin().indices().prepareCreate("test")
.addMapping("type1", "field1", "type=text", "field2", "type=text")
.addMapping("type2", "_parent", "type=type1", "field3", "type=text")
.addMapping("type2", "_parent", "type=type1", "field3", "type=text,fielddata=true")
);
client().prepareIndex("test", "type1", "1").setSource("field1", "value1")
.setRefresh(true)

View File

@ -907,7 +907,7 @@ public class FieldLevelSecurityTests extends ShieldIntegTestCase {
public void testAggs() throws Exception {
assertAcked(client().admin().indices().prepareCreate("test")
.addMapping("type1", "field1", "type=text", "field2", "type=text")
.addMapping("type1", "field1", "type=text,fielddata=true", "field2", "type=text,fielddata=true")
);
client().prepareIndex("test", "type1", "1").setSource("field1", "value1", "field2", "value2")
.setRefresh(true)

View File

@ -173,7 +173,7 @@ public class IndexAuditTrailTests extends ShieldIntegTestCase {
cluster2 = new InternalTestCluster("network", randomLong(), createTempDir(), numNodes, numNodes, cluster2Name,
cluster2SettingsSource, 0, false, SECOND_CLUSTER_NODE_PREFIX, getMockPlugins(),
useShield ? getClientWrapper() : Function.identity());
cluster2.beforeTest(getRandom(), 0.5);
cluster2.beforeTest(random(), 0.5);
remoteClient = cluster2.client();
NodesInfoResponse response = remoteClient.admin().cluster().prepareNodesInfo().execute().actionGet();

View File

@ -108,7 +108,7 @@ public class RemoteIndexAuditTrailStartingTests extends ShieldIntegTestCase {
};
remoteCluster = new InternalTestCluster("network", randomLong(), createTempDir(), numNodes, numNodes, cluster2Name,
cluster2SettingsSource, 0, false, SECOND_CLUSTER_NODE_PREFIX, getMockPlugins(), getClientWrapper());
remoteCluster.beforeTest(getRandom(), 0.5);
remoteCluster.beforeTest(random(), 0.5);
}
@After

View File

@ -28,6 +28,7 @@ import org.elasticsearch.env.Environment;
import org.elasticsearch.shield.authc.support.Hasher;
import org.elasticsearch.shield.authc.support.SecuredString;
import org.elasticsearch.shield.authc.support.SecuredStringTests;
import org.elasticsearch.xpack.XPackPlugin;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
@ -56,7 +57,7 @@ public class UsersToolTests extends CommandTestCase {
public void setupHome() throws IOException {
Path homeDir = jimfs.getPath("eshome");
IOUtils.rm(homeDir);
confDir = homeDir.resolve("config").resolve("xpack");
confDir = homeDir.resolve("config").resolve(XPackPlugin.NAME);
Files.createDirectories(confDir);
Files.write(confDir.resolve("users"), Arrays.asList(
"existing_user:" + new String(Hasher.BCRYPT.hash(new SecuredString("changeme".toCharArray()))),

View File

@ -135,7 +135,7 @@ public class IndicesAccessControlTests extends ESTestCase {
public void testMergeNotGranted() {
final Set<String> notGrantedFields = randomFrom(null, Collections.<String>emptySet(), Collections.singleton("baz"));
final Set<BytesReference> notGrantedQueries = randomFrom(null, Collections.<BytesReference>emptySet(),
Collections.singleton(new BytesArray(new byte[] { randomByte() })));
Collections.<BytesReference>singleton(new BytesArray(new byte[] { randomByte() })));
final IndexAccessControl indexAccessControl = new IndexAccessControl(false, notGrantedFields, notGrantedQueries);
final BytesReference query1 = new BytesArray(new byte[] { 0x1 });

View File

@ -64,7 +64,7 @@ public class SystemKeyToolTests extends CommandTestCase {
public void testGenerateDefaultPath() throws Exception {
assumeTrue("test cannot run with security manager enabled", System.getSecurityManager() == null);
Path keyPath = homeDir.resolve("config/xpack/system_key");
Path keyPath = homeDir.resolve("config/x-pack/system_key");
Files.createDirectories(keyPath.getParent());
execute();
byte[] bytes = Files.readAllBytes(keyPath);

View File

@ -39,7 +39,10 @@ import java.util.Collections;
public class XPackPlugin extends Plugin {
public static final String NAME = "xpack";
public static final String NAME = "x-pack";
// inside of YAML settings we still use xpack do not having handle issues with dashes
public static final String SETTINGS_NAME = "xpack";
// TODO: clean up this library to not ask for write access to all system properties!
static {
@ -228,7 +231,7 @@ public class XPackPlugin extends Plugin {
}
public static String featureSettingPrefix(String featureName) {
return NAME + "." + featureName;
return SETTINGS_NAME + "." + featureName;
}
public static String legacyFeatureEnabledSetting(String featureName) {
@ -251,6 +254,6 @@ public class XPackPlugin extends Plugin {
}
public static Path resolveXPackExtensionsFile(Environment env) {
return env.pluginsFile().resolve("xpack").resolve("extensions");
return env.pluginsFile().resolve(XPackPlugin.NAME).resolve("extensions");
}
}

View File

@ -46,7 +46,7 @@ import static org.elasticsearch.cli.Terminal.Verbosity.VERBOSE;
* directory in order to verify the extension satisfies the following requirements:
* <ul>
* <li>The property file exists and contains valid metadata. See {@link XPackExtensionInfo#readFromProperties(Path)}</li>
* <li>Jar hell does not exist, either between the extension's own jars or with the parent classloader (elasticsearch + xpack)</li>
* <li>Jar hell does not exist, either between the extension's own jars or with the parent classloader (elasticsearch + x-pack)</li>
* </ul>
*/
class InstallXPackExtensionCommand extends Command {

View File

@ -55,7 +55,7 @@ class RemoveXPackExtensionCommand extends Command {
Path extensionDir = resolveXPackExtensionsFile(env).resolve(extensionName);
if (Files.exists(extensionDir) == false) {
throw new UserError(ExitCodes.USAGE,
"Extension " + extensionName + " not found. Run 'bin/xpack/extension list' to get list of installed extensions.");
"Extension " + extensionName + " not found. Run 'bin/x-pack/extension list' to get list of installed extensions.");
}
List<Path> extensionPaths = new ArrayList<>();

View File

@ -15,7 +15,7 @@ import java.nio.file.Path;
import java.util.Properties;
public class XPackExtensionInfo {
public static final String XPACK_EXTENSION_PROPERTIES = "xpack-extension-descriptor.properties";
public static final String XPACK_EXTENSION_PROPERTIES = "x-pack-extension-descriptor.properties";
private String name;
private String description;

View File

@ -91,14 +91,14 @@ public class InstallXPackExtensionCommandTests extends ESTestCase {
}
void assertExtension(String name, Path original, Environment env) throws IOException {
Path got = env.pluginsFile().resolve("xpack").resolve("extensions").resolve(name);
Path got = env.pluginsFile().resolve("x-pack").resolve("extensions").resolve(name);
assertTrue("dir " + name + " exists", Files.exists(got));
assertTrue("jar was copied", Files.exists(got.resolve("extension.jar")));
assertInstallCleaned(env);
}
void assertInstallCleaned(Environment env) throws IOException {
try (DirectoryStream<Path> stream = Files.newDirectoryStream(env.pluginsFile().resolve("xpack").resolve("extensions"))) {
try (DirectoryStream<Path> stream = Files.newDirectoryStream(env.pluginsFile().resolve("x-pack").resolve("extensions"))) {
for (Path file : stream) {
if (file.getFileName().toString().startsWith(".installing")) {
fail("Installation dir still exists, " + file);
@ -179,7 +179,7 @@ public class InstallXPackExtensionCommandTests extends ESTestCase {
NoSuchFileException e = expectThrows(NoSuchFileException.class, () -> {
installExtension(extZip, env);
});
assertTrue(e.getMessage(), e.getMessage().contains("xpack-extension-descriptor.properties"));
assertTrue(e.getMessage(), e.getMessage().contains("x-pack-extension-descriptor.properties"));
assertInstallCleaned(env);
}
}

View File

@ -28,7 +28,7 @@ public class ListXPackExtensionCommandTests extends ESTestCase {
}
Path createExtensionDir(Environment env) throws IOException {
Path path = env.pluginsFile().resolve("xpack").resolve("extensions");
Path path = env.pluginsFile().resolve("x-pack").resolve("extensions");
return Files.createDirectories(path);
}

View File

@ -30,7 +30,7 @@ public class RemoveXPackExtensionCommandTests extends ESTestCase {
}
Path createExtensionDir(Environment env) throws IOException {
Path path = env.pluginsFile().resolve("xpack").resolve("extensions");
Path path = env.pluginsFile().resolve("x-pack").resolve("extensions");
return Files.createDirectories(path);
}

View File

@ -10,4 +10,4 @@
- do:
nodes.info: {}
- match: { nodes.$master.plugins.0.name: xpack }
- match: { nodes.$master.plugins.0.name: x-pack }

View File

@ -62,12 +62,10 @@ fi
# Try to read package config files
if [ -f "/etc/sysconfig/elasticsearch" ]; then
CONF_DIR=/etc/elasticsearch
CONF_FILE=$CONF_DIR/elasticsearch.yml
. "/etc/sysconfig/elasticsearch"
elif [ -f "/etc/default/elasticsearch" ]; then
CONF_DIR=/etc/elasticsearch
CONF_FILE=$CONF_DIR/elasticsearch.yml
. "/etc/default/elasticsearch"
fi
@ -94,19 +92,11 @@ if [ -e "$CONF_DIR" ]; then
;;
esac
fi
if [ -e "$CONF_FILE" ]; then
case "$properties" in
*-Des.default.config=*) ;;
*)
properties="$properties -Des.default.config=$CONF_FILE"
;;
esac
fi
export HOSTNAME=`hostname -s`
# include watcher jars in classpath
ES_CLASSPATH="$ES_CLASSPATH:$ES_HOME/plugins/xpack/*"
ES_CLASSPATH="$ES_CLASSPATH:$ES_HOME/plugins/x-pack/*"
# don't let JAVA_TOOL_OPTIONS slip in (e.g. crazy agents in ubuntu)
# works around https://bugs.launchpad.net/ubuntu/+source/jayatana/+bug/1441487
@ -116,6 +106,12 @@ if [ "x$JAVA_TOOL_OPTIONS" != "x" ]; then
unset JAVA_TOOL_OPTIONS
fi
# CONF_FILE setting was removed
if [ ! -z "$CONF_FILE" ]; then
echo "CONF_FILE setting is no longer supported. elasticsearch.yml must be placed in the config directory and cannot be renamed."
exit 1
fi
cd "$ES_HOME" > /dev/null
"$JAVA" $ES_JAVA_OPTS -cp "$ES_CLASSPATH" -Des.path.home="$ES_HOME" org.elasticsearch.watcher.trigger.schedule.tool.CronEvalTool "$@" $properties
status=$?

View File

@ -36,6 +36,7 @@ import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
import static org.elasticsearch.search.aggregations.AggregationBuilders.terms;
import static org.elasticsearch.search.builder.SearchSourceBuilder.searchSource;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasEntry;
import static org.hamcrest.Matchers.hasSize;
@ -120,9 +121,11 @@ public class IndexActionTests extends ESIntegTestCase {
boolean customTimestampField = "@timestamp".equals(timestampField);
if (timestampField == null || "_timestamp".equals(timestampField)) {
assertThat(prepareCreate("test-index")
.addMapping("test-type", "{ \"test-type\" : { \"_timestamp\" : { \"enabled\" : \"true\" }}}")
.get().isAcknowledged(), is(true));
assertAcked(prepareCreate("test-index")
.addMapping("test-type", "_timestamp", "enabled=true", "foo", "type=keyword"));
} else {
assertAcked(prepareCreate("test-index")
.addMapping("test-type", "foo", "type=keyword"));
}
Object list = randomFrom(

View File

@ -44,7 +44,7 @@ public class ArrayCompareConditionSearchTests extends AbstractWatcherIntegration
refresh();
SearchResponse response = client().prepareSearch(index)
.addAggregation(AggregationBuilders.terms("top_tweeters").field("user.screen_name").size(3)).get();
.addAggregation(AggregationBuilders.terms("top_tweeters").field("user.screen_name.keyword").size(3)).get();
ExecutableArrayCompareCondition condition = new ExecutableArrayCompareCondition(
@ -76,7 +76,7 @@ public class ArrayCompareConditionSearchTests extends AbstractWatcherIntegration
refresh();
response = client().prepareSearch(index)
.addAggregation(AggregationBuilders.terms("top_tweeters").field("user.screen_name").size(3)).get();
.addAggregation(AggregationBuilders.terms("top_tweeters").field("user.screen_name.keyword").size(3)).get();
ctx = mockExecutionContext("_name", new Payload.XContent(response));
result = condition.execute(ctx);

View File

@ -269,7 +269,7 @@ public class HttpClientTests extends ESTestCase {
public void testHttpResponseWithAnyStatusCodeCanReturnBody() throws Exception {
int statusCode = randomFrom(200, 201, 400, 401, 403, 404, 405, 409, 413, 429, 500, 503);
String body = RandomStrings.randomAsciiOfLength(getRandom(), 100);
String body = RandomStrings.randomAsciiOfLength(random(), 100);
boolean hasBody = usually();
MockResponse mockResponse = new MockResponse().setResponseCode(statusCode);
if (hasBody) {