diff --git a/elasticsearch/qa/messy-test-watcher-with-groovy/src/test/java/org/elasticsearch/messy/tests/GroovyScriptConditionIT.java b/elasticsearch/qa/messy-test-watcher-with-groovy/src/test/java/org/elasticsearch/messy/tests/GroovyScriptConditionIT.java index 076ca34737f..2f9facc1b49 100644 --- a/elasticsearch/qa/messy-test-watcher-with-groovy/src/test/java/org/elasticsearch/messy/tests/GroovyScriptConditionIT.java +++ b/elasticsearch/qa/messy-test-watcher-with-groovy/src/test/java/org/elasticsearch/messy/tests/GroovyScriptConditionIT.java @@ -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 = diff --git a/elasticsearch/qa/shield-audit-tests/build.gradle b/elasticsearch/qa/shield-audit-tests/build.gradle index 7b0c0cbe825..454f3f33d33 100644 --- a/elasticsearch/qa/shield-audit-tests/build.gradle +++ b/elasticsearch/qa/shield-audit-tests/build.gradle @@ -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()}", diff --git a/elasticsearch/qa/shield-client-tests/build.gradle b/elasticsearch/qa/shield-client-tests/build.gradle index 75199ff7eeb..1e4099fee20 100644 --- a/elasticsearch/qa/shield-client-tests/build.gradle +++ b/elasticsearch/qa/shield-client-tests/build.gradle @@ -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()}", diff --git a/elasticsearch/qa/shield-core-rest-tests/build.gradle b/elasticsearch/qa/shield-core-rest-tests/build.gradle index e8b38558d15..ad48d2e98dd 100644 --- a/elasticsearch/qa/shield-core-rest-tests/build.gradle +++ b/elasticsearch/qa/shield-core-rest-tests/build.gradle @@ -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()}", diff --git a/elasticsearch/qa/shield-example-realm/build.gradle b/elasticsearch/qa/shield-example-realm/build.gradle index 20b8dd2c37b..f0803a3ebf1 100644 --- a/elasticsearch/qa/shield-example-realm/build.gradle +++ b/elasticsearch/qa/shield-example-realm/build.gradle @@ -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 \ No newline at end of file +integTest.mustRunAfter precommit diff --git a/elasticsearch/qa/shield-example-realm/src/main/resources/xpack-extension-descriptor.properties b/elasticsearch/qa/shield-example-realm/src/main/resources/x-pack-extension-descriptor.properties similarity index 100% rename from elasticsearch/qa/shield-example-realm/src/main/resources/xpack-extension-descriptor.properties rename to elasticsearch/qa/shield-example-realm/src/main/resources/x-pack-extension-descriptor.properties diff --git a/elasticsearch/qa/shield-reindex-tests/build.gradle b/elasticsearch/qa/shield-reindex-tests/build.gradle index 735090a7c36..ef409b366df 100644 --- a/elasticsearch/qa/shield-reindex-tests/build.gradle +++ b/elasticsearch/qa/shield-reindex-tests/build.gradle @@ -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') diff --git a/elasticsearch/qa/shield-tribe-node-tests/integration-tests.xml b/elasticsearch/qa/shield-tribe-node-tests/integration-tests.xml index 1b773cb560c..f3dffc65824 100644 --- a/elasticsearch/qa/shield-tribe-node-tests/integration-tests.xml +++ b/elasticsearch/qa/shield-tribe-node-tests/integration-tests.xml @@ -75,10 +75,10 @@ Adding roles.yml - + Adding shield users... - + diff --git a/elasticsearch/qa/smoke-test-found-license-with-shield-and-watcher/integration-tests.xml b/elasticsearch/qa/smoke-test-found-license-with-shield-and-watcher/integration-tests.xml index 6cbb6907506..375f3db605f 100644 --- a/elasticsearch/qa/smoke-test-found-license-with-shield-and-watcher/integration-tests.xml +++ b/elasticsearch/qa/smoke-test-found-license-with-shield-and-watcher/integration-tests.xml @@ -63,10 +63,10 @@ Adding roles.yml with watcher roles - + Adding shield users... - + @@ -76,7 +76,7 @@ - + @@ -86,7 +86,7 @@ - + diff --git a/elasticsearch/qa/smoke-test-graph-with-shield/build.gradle b/elasticsearch/qa/smoke-test-graph-with-shield/build.gradle index 5c3cb6551d0..166cb2c821b 100644 --- a/elasticsearch/qa/smoke-test-graph-with-shield/build.gradle +++ b/elasticsearch/qa/smoke-test-graph-with-shield/build.gradle @@ -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()}", diff --git a/elasticsearch/qa/smoke-test-plugins-ssl/build.gradle b/elasticsearch/qa/smoke-test-plugins-ssl/build.gradle index a3fc29f702e..fc2b3515258 100644 --- a/elasticsearch/qa/smoke-test-plugins-ssl/build.gradle +++ b/elasticsearch/qa/smoke-test-plugins-ssl/build.gradle @@ -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 diff --git a/elasticsearch/qa/smoke-test-plugins-ssl/src/test/java/org/elasticsearch/smoketest/SmokeTestMonitoringWithShieldIT.java b/elasticsearch/qa/smoke-test-plugins-ssl/src/test/java/org/elasticsearch/smoketest/SmokeTestMonitoringWithShieldIT.java index 09a6feb8ad9..a64fb1f6667 100644 --- a/elasticsearch/qa/smoke-test-plugins-ssl/src/test/java/org/elasticsearch/smoketest/SmokeTestMonitoringWithShieldIT.java +++ b/elasticsearch/qa/smoke-test-plugins-ssl/src/test/java/org/elasticsearch/smoketest/SmokeTestMonitoringWithShieldIT.java @@ -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"; diff --git a/elasticsearch/qa/smoke-test-plugins/build.gradle b/elasticsearch/qa/smoke-test-plugins/build.gradle index b62b0c6b798..02f763f90ec 100644 --- a/elasticsearch/qa/smoke-test-plugins/build.gradle +++ b/elasticsearch/qa/smoke-test-plugins/build.gradle @@ -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()}", diff --git a/elasticsearch/qa/smoke-test-watcher-with-shield/build.gradle b/elasticsearch/qa/smoke-test-watcher-with-shield/build.gradle index 12b40d0914f..789db6ea5c3 100644 --- a/elasticsearch/qa/smoke-test-watcher-with-shield/build.gradle +++ b/elasticsearch/qa/smoke-test-watcher-with-shield/build.gradle @@ -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()}", diff --git a/elasticsearch/x-pack/bin/xpack/.in.bat b/elasticsearch/x-pack/bin/x-pack/.in.bat similarity index 97% rename from elasticsearch/x-pack/bin/xpack/.in.bat rename to elasticsearch/x-pack/bin/x-pack/.in.bat index 9d09123147f..f7b5ec35b2c 100644 --- a/elasticsearch/x-pack/bin/xpack/.in.bat +++ b/elasticsearch/x-pack/bin/x-pack/.in.bat @@ -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%" diff --git a/elasticsearch/x-pack/bin/xpack/extension b/elasticsearch/x-pack/bin/x-pack/extension similarity index 85% rename from elasticsearch/x-pack/bin/xpack/extension rename to elasticsearch/x-pack/bin/x-pack/extension index 35e061c7deb..56405637625 100755 --- a/elasticsearch/x-pack/bin/xpack/extension +++ b/elasticsearch/x-pack/bin/x-pack/extension @@ -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 \ No newline at end of file +exit $status diff --git a/elasticsearch/x-pack/bin/xpack/extension.bat b/elasticsearch/x-pack/bin/x-pack/extension.bat similarity index 100% rename from elasticsearch/x-pack/bin/xpack/extension.bat rename to elasticsearch/x-pack/bin/x-pack/extension.bat diff --git a/elasticsearch/x-pack/build.gradle b/elasticsearch/x-pack/build.gradle index 02526722332..48cbe9e9dbb 100644 --- a/elasticsearch/x-pack/build.gradle +++ b/elasticsearch/x-pack/build.gradle @@ -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 diff --git a/elasticsearch/x-pack/graph/src/test/java/org/elasticsearch/graph/test/GraphTests.java b/elasticsearch/x-pack/graph/src/test/java/org/elasticsearch/graph/test/GraphTests.java index 878250c8584..489b476d664 100644 --- a/elasticsearch/x-pack/graph/src/test/java/org/elasticsearch/graph/test/GraphTests.java +++ b/elasticsearch/x-pack/graph/src/test/java/org/elasticsearch/graph/test/GraphTests.java @@ -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(); diff --git a/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/AgentService.java b/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/AgentService.java index f8099becc1e..908bf3745d3 100644 --- a/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/AgentService.java +++ b/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/AgentService.java @@ -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 { } } + /** 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 { 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 { continue; } - if (logger.isTraceEnabled()) { - logger.trace("collecting data - collectors [{}]", Strings.collectionToCommaDelimitedString(collectors)); - } + try (Releasable ignore = collectionLock.acquire()) { - Collection docs = new ArrayList<>(); - for (Collector collector : collectors) { - if (collecting) { - Collection 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 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 { } 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 collect() { + if (logger.isTraceEnabled()) { + logger.trace("collecting data - collectors [{}]", Strings.collectionToCommaDelimitedString(collectors)); + } + + Collection docs = new ArrayList<>(); + for (Collector collector : collectors) { + if (collecting) { + Collection 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; + } } } diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/MarvelPluginTests.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/MarvelPluginTests.java index 99ab9879cdf..a0fb6d3a4b2 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/MarvelPluginTests.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/MarvelPluginTests.java @@ -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() diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/action/MonitoringBulkTests.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/action/MonitoringBulkTests.java index 5a00c6c41bd..26a8a95aea3 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/action/MonitoringBulkTests.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/action/MonitoringBulkTests.java @@ -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 diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/exporter/http/HttpExporterTests.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/exporter/http/HttpExporterTests.java index 0ece35ae523..e975df6336b 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/exporter/http/HttpExporterTests.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/exporter/http/HttpExporterTests.java @@ -84,7 +84,6 @@ public class HttpExporterTests extends MarvelIntegTestCase { @After public void cleanup() throws Exception { - stopCollection(); webServer.shutdown(); } diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/resolver/cluster/ClusterStateTests.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/resolver/cluster/ClusterStateTests.java index 89e43e1a480..f71e20ddc73 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/resolver/cluster/ClusterStateTests.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/resolver/cluster/ClusterStateTests.java @@ -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(); } diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/test/MarvelIntegTestCase.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/test/MarvelIntegTestCase.java index b6a3f76250a..71edac0f604 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/test/MarvelIntegTestCase.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/test/MarvelIntegTestCase.java @@ -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. */ diff --git a/elasticsearch/x-pack/shield/bin/xpack/syskeygen b/elasticsearch/x-pack/shield/bin/x-pack/syskeygen similarity index 86% rename from elasticsearch/x-pack/shield/bin/xpack/syskeygen rename to elasticsearch/x-pack/shield/bin/x-pack/syskeygen index 47ba00497c8..0d31e25136a 100755 --- a/elasticsearch/x-pack/shield/bin/xpack/syskeygen +++ b/elasticsearch/x-pack/shield/bin/x-pack/syskeygen @@ -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=$? diff --git a/elasticsearch/x-pack/shield/bin/xpack/syskeygen.bat b/elasticsearch/x-pack/shield/bin/x-pack/syskeygen.bat similarity index 100% rename from elasticsearch/x-pack/shield/bin/xpack/syskeygen.bat rename to elasticsearch/x-pack/shield/bin/x-pack/syskeygen.bat diff --git a/elasticsearch/x-pack/shield/bin/xpack/users b/elasticsearch/x-pack/shield/bin/x-pack/users similarity index 86% rename from elasticsearch/x-pack/shield/bin/xpack/users rename to elasticsearch/x-pack/shield/bin/x-pack/users index fda25e854ee..b8f3af686e4 100755 --- a/elasticsearch/x-pack/shield/bin/xpack/users +++ b/elasticsearch/x-pack/shield/bin/x-pack/users @@ -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=$? diff --git a/elasticsearch/x-pack/shield/bin/xpack/users.bat b/elasticsearch/x-pack/shield/bin/x-pack/users.bat similarity index 100% rename from elasticsearch/x-pack/shield/bin/xpack/users.bat rename to elasticsearch/x-pack/shield/bin/x-pack/users.bat diff --git a/elasticsearch/x-pack/shield/config/xpack/logging.yml b/elasticsearch/x-pack/shield/config/x-pack/logging.yml similarity index 100% rename from elasticsearch/x-pack/shield/config/xpack/logging.yml rename to elasticsearch/x-pack/shield/config/x-pack/logging.yml diff --git a/elasticsearch/x-pack/shield/config/xpack/role_mapping.yml b/elasticsearch/x-pack/shield/config/x-pack/role_mapping.yml similarity index 100% rename from elasticsearch/x-pack/shield/config/xpack/role_mapping.yml rename to elasticsearch/x-pack/shield/config/x-pack/role_mapping.yml diff --git a/elasticsearch/x-pack/shield/config/xpack/roles.yml b/elasticsearch/x-pack/shield/config/x-pack/roles.yml similarity index 100% rename from elasticsearch/x-pack/shield/config/xpack/roles.yml rename to elasticsearch/x-pack/shield/config/x-pack/roles.yml diff --git a/elasticsearch/x-pack/shield/config/xpack/users b/elasticsearch/x-pack/shield/config/x-pack/users similarity index 100% rename from elasticsearch/x-pack/shield/config/xpack/users rename to elasticsearch/x-pack/shield/config/x-pack/users diff --git a/elasticsearch/x-pack/shield/config/xpack/users_roles b/elasticsearch/x-pack/shield/config/x-pack/users_roles similarity index 100% rename from elasticsearch/x-pack/shield/config/xpack/users_roles rename to elasticsearch/x-pack/shield/config/x-pack/users_roles diff --git a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/authc/file/FileUserPasswdStore.java b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/authc/file/FileUserPasswdStore.java index a9f0941cd54..f8008329650 100644 --- a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/authc/file/FileUserPasswdStore.java +++ b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/authc/file/FileUserPasswdStore.java @@ -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); } diff --git a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/authc/file/FileUserRolesStore.java b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/authc/file/FileUserRolesStore.java index 0b4c1efe7ab..566adca87d0 100644 --- a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/authc/file/FileUserRolesStore.java +++ b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/authc/file/FileUserRolesStore.java @@ -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()); } diff --git a/elasticsearch/x-pack/shield/src/main/resources/org/elasticsearch/shield/crypto/tool/syskey-generate.help b/elasticsearch/x-pack/shield/src/main/resources/org/elasticsearch/shield/crypto/tool/syskey-generate.help index d4a175fb16e..c4dc6c228e9 100644 --- a/elasticsearch/x-pack/shield/src/main/resources/org/elasticsearch/shield/crypto/tool/syskey-generate.help +++ b/elasticsearch/x-pack/shield/src/main/resources/org/elasticsearch/shield/crypto/tool/syskey-generate.help @@ -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. diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/integration/DocumentLevelSecurityTests.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/integration/DocumentLevelSecurityTests.java index 4b788c0e336..e414ed83c6d 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/integration/DocumentLevelSecurityTests.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/integration/DocumentLevelSecurityTests.java @@ -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) diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/integration/FieldLevelSecurityTests.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/integration/FieldLevelSecurityTests.java index 3642b61251f..5369569b101 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/integration/FieldLevelSecurityTests.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/integration/FieldLevelSecurityTests.java @@ -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) diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/audit/index/IndexAuditTrailTests.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/audit/index/IndexAuditTrailTests.java index 502b0be9e78..46c88beeefc 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/audit/index/IndexAuditTrailTests.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/audit/index/IndexAuditTrailTests.java @@ -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(); diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/audit/index/RemoteIndexAuditTrailStartingTests.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/audit/index/RemoteIndexAuditTrailStartingTests.java index 86ebe3c3568..1f5c0fbefbc 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/audit/index/RemoteIndexAuditTrailStartingTests.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/audit/index/RemoteIndexAuditTrailStartingTests.java @@ -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 diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authc/file/tool/UsersToolTests.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authc/file/tool/UsersToolTests.java index 89af9b4017c..9cfa53152d7 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authc/file/tool/UsersToolTests.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authc/file/tool/UsersToolTests.java @@ -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()))), diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authz/accesscontrol/IndicesAccessControlTests.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authz/accesscontrol/IndicesAccessControlTests.java index 49d4eb8f2f0..cd711595765 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authz/accesscontrol/IndicesAccessControlTests.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authz/accesscontrol/IndicesAccessControlTests.java @@ -135,7 +135,7 @@ public class IndicesAccessControlTests extends ESTestCase { public void testMergeNotGranted() { final Set notGrantedFields = randomFrom(null, Collections.emptySet(), Collections.singleton("baz")); final Set notGrantedQueries = randomFrom(null, Collections.emptySet(), - Collections.singleton(new BytesArray(new byte[] { randomByte() }))); + Collections.singleton(new BytesArray(new byte[] { randomByte() }))); final IndexAccessControl indexAccessControl = new IndexAccessControl(false, notGrantedFields, notGrantedQueries); final BytesReference query1 = new BytesArray(new byte[] { 0x1 }); diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/crypto/tool/SystemKeyToolTests.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/crypto/tool/SystemKeyToolTests.java index 95d20b10661..f7056504463 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/crypto/tool/SystemKeyToolTests.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/crypto/tool/SystemKeyToolTests.java @@ -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); diff --git a/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/XPackPlugin.java b/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/XPackPlugin.java index af42ebdc055..b615bc42ef6 100644 --- a/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/XPackPlugin.java +++ b/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/XPackPlugin.java @@ -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"); } } diff --git a/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/extensions/InstallXPackExtensionCommand.java b/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/extensions/InstallXPackExtensionCommand.java index 749cc745760..3f97ea13546 100644 --- a/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/extensions/InstallXPackExtensionCommand.java +++ b/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/extensions/InstallXPackExtensionCommand.java @@ -46,7 +46,7 @@ import static org.elasticsearch.cli.Terminal.Verbosity.VERBOSE; * directory in order to verify the extension satisfies the following requirements: *
    *
  • The property file exists and contains valid metadata. See {@link XPackExtensionInfo#readFromProperties(Path)}
  • - *
  • Jar hell does not exist, either between the extension's own jars or with the parent classloader (elasticsearch + xpack)
  • + *
  • Jar hell does not exist, either between the extension's own jars or with the parent classloader (elasticsearch + x-pack)
  • *
*/ class InstallXPackExtensionCommand extends Command { diff --git a/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/extensions/RemoveXPackExtensionCommand.java b/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/extensions/RemoveXPackExtensionCommand.java index 4b51adbaa82..b700a8d62ad 100644 --- a/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/extensions/RemoveXPackExtensionCommand.java +++ b/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/extensions/RemoveXPackExtensionCommand.java @@ -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 extensionPaths = new ArrayList<>(); diff --git a/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/extensions/XPackExtensionInfo.java b/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/extensions/XPackExtensionInfo.java index 08a3eb01626..d705f8457ae 100644 --- a/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/extensions/XPackExtensionInfo.java +++ b/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/extensions/XPackExtensionInfo.java @@ -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; diff --git a/elasticsearch/x-pack/src/test/java/org/elasticsearch/xpack/extensions/InstallXPackExtensionCommandTests.java b/elasticsearch/x-pack/src/test/java/org/elasticsearch/xpack/extensions/InstallXPackExtensionCommandTests.java index e86e7112545..33d96ccbb03 100644 --- a/elasticsearch/x-pack/src/test/java/org/elasticsearch/xpack/extensions/InstallXPackExtensionCommandTests.java +++ b/elasticsearch/x-pack/src/test/java/org/elasticsearch/xpack/extensions/InstallXPackExtensionCommandTests.java @@ -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 stream = Files.newDirectoryStream(env.pluginsFile().resolve("xpack").resolve("extensions"))) { + try (DirectoryStream 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); } } diff --git a/elasticsearch/x-pack/src/test/java/org/elasticsearch/xpack/extensions/ListXPackExtensionCommandTests.java b/elasticsearch/x-pack/src/test/java/org/elasticsearch/xpack/extensions/ListXPackExtensionCommandTests.java index 2f61e219687..c4f484daa9e 100644 --- a/elasticsearch/x-pack/src/test/java/org/elasticsearch/xpack/extensions/ListXPackExtensionCommandTests.java +++ b/elasticsearch/x-pack/src/test/java/org/elasticsearch/xpack/extensions/ListXPackExtensionCommandTests.java @@ -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); } diff --git a/elasticsearch/x-pack/src/test/java/org/elasticsearch/xpack/extensions/RemoveXPackExtensionCommandTests.java b/elasticsearch/x-pack/src/test/java/org/elasticsearch/xpack/extensions/RemoveXPackExtensionCommandTests.java index aa5a27d1f76..fec7b42e86f 100644 --- a/elasticsearch/x-pack/src/test/java/org/elasticsearch/xpack/extensions/RemoveXPackExtensionCommandTests.java +++ b/elasticsearch/x-pack/src/test/java/org/elasticsearch/xpack/extensions/RemoveXPackExtensionCommandTests.java @@ -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); } diff --git a/elasticsearch/x-pack/src/test/resources/rest-api-spec/test/xpack/10_basic.yaml b/elasticsearch/x-pack/src/test/resources/rest-api-spec/test/xpack/10_basic.yaml index efedbf34e42..1b084271907 100644 --- a/elasticsearch/x-pack/src/test/resources/rest-api-spec/test/xpack/10_basic.yaml +++ b/elasticsearch/x-pack/src/test/resources/rest-api-spec/test/xpack/10_basic.yaml @@ -10,4 +10,4 @@ - do: nodes.info: {} - - match: { nodes.$master.plugins.0.name: xpack } + - match: { nodes.$master.plugins.0.name: x-pack } diff --git a/elasticsearch/x-pack/watcher/bin/xpack/croneval b/elasticsearch/x-pack/watcher/bin/x-pack/croneval similarity index 91% rename from elasticsearch/x-pack/watcher/bin/xpack/croneval rename to elasticsearch/x-pack/watcher/bin/x-pack/croneval index 18c3a6604dd..1a13b517e5e 100755 --- a/elasticsearch/x-pack/watcher/bin/xpack/croneval +++ b/elasticsearch/x-pack/watcher/bin/x-pack/croneval @@ -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=$? diff --git a/elasticsearch/x-pack/watcher/bin/xpack/croneval.bat b/elasticsearch/x-pack/watcher/bin/x-pack/croneval.bat similarity index 100% rename from elasticsearch/x-pack/watcher/bin/xpack/croneval.bat rename to elasticsearch/x-pack/watcher/bin/x-pack/croneval.bat diff --git a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/actions/index/IndexActionTests.java b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/actions/index/IndexActionTests.java index 1e13e2e4af6..beefbda1513 100644 --- a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/actions/index/IndexActionTests.java +++ b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/actions/index/IndexActionTests.java @@ -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( diff --git a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/condition/compare/array/ArrayCompareConditionSearchTests.java b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/condition/compare/array/ArrayCompareConditionSearchTests.java index 37eb55b5e06..1c864a220ee 100644 --- a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/condition/compare/array/ArrayCompareConditionSearchTests.java +++ b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/condition/compare/array/ArrayCompareConditionSearchTests.java @@ -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); diff --git a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/support/http/HttpClientTests.java b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/support/http/HttpClientTests.java index c4af1c0924c..0afaf192257 100644 --- a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/support/http/HttpClientTests.java +++ b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/support/http/HttpClientTests.java @@ -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) {