diff --git a/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/MarvelPlugin.java b/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/MarvelPlugin.java index 68eca82c13d..c65660ac26b 100644 --- a/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/MarvelPlugin.java +++ b/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/MarvelPlugin.java @@ -10,6 +10,7 @@ import org.elasticsearch.common.component.LifecycleComponent; import org.elasticsearch.common.inject.Module; import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.Loggers; +import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.SettingsModule; import org.elasticsearch.marvel.agent.AgentService; @@ -35,6 +36,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; +import java.util.function.Function; public class MarvelPlugin extends Plugin { @@ -42,6 +44,8 @@ public class MarvelPlugin extends Plugin { public static final String NAME = "marvel"; public static final String ENABLED = NAME + ".enabled"; + public static final Setting INDEX_MARVEL_VERSION_SETTING = new Setting<>("index.marvel.plugin.version", "", Function.identity(), false, Setting.Scope.INDEX); + public static final Setting INDEX_MARVEL_TEMPLATE_VERSION_SETTING = new Setting<>("index.marvel.template.version", "", Function.identity(), false, Setting.Scope.INDEX); private final Settings settings; private final boolean enabled; @@ -144,5 +148,7 @@ public class MarvelPlugin extends Plugin { module.registerSetting(MarvelSettings.CLUSTER_STATE_TIMEOUT_SETTING); module.registerSetting(MarvelSettings.CLUSTER_STATS_TIMEOUT_SETTING); module.registerSetting(CleanerService.HISTORY_SETTING); + module.registerSetting(INDEX_MARVEL_VERSION_SETTING); + module.registerSetting(INDEX_MARVEL_TEMPLATE_VERSION_SETTING); } } diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/cleaner/local/LocalIndicesCleanerTests.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/cleaner/local/LocalIndicesCleanerTests.java index 93011e0ad0c..d711256a19f 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/cleaner/local/LocalIndicesCleanerTests.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/cleaner/local/LocalIndicesCleanerTests.java @@ -11,14 +11,26 @@ import org.elasticsearch.index.IndexNotFoundException; import org.elasticsearch.marvel.agent.exporter.local.LocalExporter; import org.elasticsearch.marvel.agent.settings.MarvelSettings; import org.elasticsearch.marvel.cleaner.AbstractIndicesCleanerTestCase; +import org.elasticsearch.plugins.Plugin; +import org.elasticsearch.test.InternalSettingsPlugin; import org.joda.time.DateTime; +import java.util.ArrayList; +import java.util.Collection; + import static org.elasticsearch.common.settings.Settings.settingsBuilder; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.hamcrest.Matchers.equalTo; public class LocalIndicesCleanerTests extends AbstractIndicesCleanerTestCase { + @Override + protected Collection> nodePlugins() { + ArrayList> plugins = new ArrayList<>(super.nodePlugins()); + plugins.add(InternalSettingsPlugin.class); + return plugins; + } + @Override protected Settings nodeSettings(int nodeOrdinal) { return Settings.builder() 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 5ed585af0bc..306ca9a58b5 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 @@ -25,6 +25,7 @@ import org.elasticsearch.shield.authc.support.SecuredString; import org.elasticsearch.shield.crypto.InternalCryptoService; import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.test.TestCluster; +import org.elasticsearch.test.store.MockFSIndexStore; import org.elasticsearch.test.transport.AssertingLocalTransport; import org.elasticsearch.test.transport.MockTransportService; import org.elasticsearch.xpack.XPackPlugin; @@ -74,7 +75,6 @@ public abstract class MarvelIntegTestCase extends ESIntegTestCase { //TODO: for now lets isolate marvel tests from watcher (randomize this later) .put("watcher.enabled", false) - // we do this by default in core, but for marvel this isn't needed and only adds noise. .put("index.store.mock.check_index_on_close", false); @@ -102,6 +102,7 @@ public abstract class MarvelIntegTestCase extends ESIntegTestCase { Set> plugins = new HashSet<>(super.getMockPlugins()); plugins.remove(MockTransportService.TestPlugin.class); // shield has its own transport service plugins.remove(AssertingLocalTransport.TestPlugin.class); // shield has its own transport + plugins.add(MockFSIndexStore.TestPlugin.class); return plugins; } @@ -397,7 +398,7 @@ public abstract class MarvelIntegTestCase extends ESIntegTestCase { .put("shield.audit.enabled", auditLogsEnabled) // Test framework sometimes randomily selects the 'index' or 'none' cache and that makes the // validation in ShieldPlugin fail. Shield can only run with this query cache impl - .put(IndexModule.QUERY_CACHE_TYPE, ShieldPlugin.OPT_OUT_QUERY_CACHE); + .put(IndexModule.INDEX_QUERY_CACHE_TYPE_SETTING.getKey(), ShieldPlugin.OPT_OUT_QUERY_CACHE); } catch (IOException ex) { throw new RuntimeException("failed to build settings for shield", ex); } diff --git a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/ShieldPlugin.java b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/ShieldPlugin.java index 370d8672d24..9fb9fa9a694 100644 --- a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/ShieldPlugin.java +++ b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/ShieldPlugin.java @@ -327,7 +327,7 @@ public class ShieldPlugin extends Plugin { unauthorized users. */ private void addQueryCacheSettings(Settings.Builder settingsBuilder) { - settingsBuilder.put(IndexModule.QUERY_CACHE_TYPE, OPT_OUT_QUERY_CACHE); + settingsBuilder.put(IndexModule.INDEX_QUERY_CACHE_TYPE_SETTING.getKey(), OPT_OUT_QUERY_CACHE); } private static boolean isShieldMandatory(String[] existingMandatoryPlugins) { @@ -365,12 +365,12 @@ public class ShieldPlugin extends Plugin { // in case this are node settings then the plugin additional settings have not been applied yet, // so we use 'opt_out_cache' as default. So in that case we only fail if the node settings contain // another cache impl than 'opt_out_cache'. - queryCacheImplementation = settings.get(IndexModule.QUERY_CACHE_TYPE, OPT_OUT_QUERY_CACHE); + queryCacheImplementation = settings.get(IndexModule.INDEX_QUERY_CACHE_TYPE_SETTING.getKey(), OPT_OUT_QUERY_CACHE); } else { - queryCacheImplementation = settings.get(IndexModule.QUERY_CACHE_TYPE); + queryCacheImplementation = settings.get(IndexModule.INDEX_QUERY_CACHE_TYPE_SETTING.getKey()); } if (OPT_OUT_QUERY_CACHE.equals(queryCacheImplementation) == false) { - throw new IllegalStateException("shield does not support a user specified query cache. remove the setting [" + IndexModule.QUERY_CACHE_TYPE + "] with value [" + queryCacheImplementation + "]"); + throw new IllegalStateException("shield does not support a user specified query cache. remove the setting [" + IndexModule.INDEX_QUERY_CACHE_TYPE_SETTING.getKey() + "] with value [" + queryCacheImplementation + "]"); } } } diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/integration/DocumentAndFieldLevelSecurityTests.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/integration/DocumentAndFieldLevelSecurityTests.java index cb2e0d28713..de52a543d3b 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/integration/DocumentAndFieldLevelSecurityTests.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/integration/DocumentAndFieldLevelSecurityTests.java @@ -107,7 +107,7 @@ public class DocumentAndFieldLevelSecurityTests extends ShieldIntegTestCase { public void testQueryCache() throws Exception { assertAcked(client().admin().indices().prepareCreate("test") - .setSettings(Settings.builder().put(IndexModule.QUERY_CACHE_EVERYTHING, true)) + .setSettings(Settings.builder().put(IndexModule.INDEX_QUERY_CACHE_EVERYTHING_SETTING.getKey(), true)) .addMapping("type1", "field1", "type=string", "field2", "type=string") ); client().prepareIndex("test", "type1", "1").setSource("field1", "value1") 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 ed4eac1e3e0..ebe2854ce52 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 @@ -470,7 +470,7 @@ public class DocumentLevelSecurityTests extends ShieldIntegTestCase { public void testRequestCache() throws Exception { assertAcked(client().admin().indices().prepareCreate("test") - .setSettings(Settings.builder().put(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED, true)) + .setSettings(Settings.builder().put(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING.getKey(), true)) .addMapping("type1", "field1", "type=string", "field2", "type=string") ); client().prepareIndex("test", "type1", "1").setSource("field1", "value1") 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 08985ac5059..6d769b8cd2d 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 @@ -372,7 +372,7 @@ public class FieldLevelSecurityTests extends ShieldIntegTestCase { public void testQueryCache() throws Exception { assertAcked(client().admin().indices().prepareCreate("test") - .setSettings(Settings.builder().put(IndexModule.QUERY_CACHE_EVERYTHING, true)) + .setSettings(Settings.builder().put(IndexModule.INDEX_QUERY_CACHE_EVERYTHING_SETTING.getKey(), true)) .addMapping("type1", "field1", "type=string", "field2", "type=string") ); client().prepareIndex("test", "type1", "1").setSource("field1", "value1", "field2", "value2") @@ -396,7 +396,7 @@ public class FieldLevelSecurityTests extends ShieldIntegTestCase { public void testRequestCache() throws Exception { assertAcked(client().admin().indices().prepareCreate("test") - .setSettings(Settings.builder().put(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED, true)) + .setSettings(Settings.builder().put(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING.getKey(), true)) .addMapping("type1", "field1", "type=string", "field2", "type=string") ); client().prepareIndex("test", "type1", "1").setSource("field1", "value1", "field2", "value2") diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/ShieldF.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/ShieldF.java index 5153434c485..506a8b71018 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/ShieldF.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/ShieldF.java @@ -41,7 +41,7 @@ public class ShieldF { settings.put("security.manager.enabled", "false"); // Disable Marvel to prevent cluster activity settings.put("marvel.enabled", "false"); - settings.put(IndexModule.QUERY_CACHE_TYPE, ShieldPlugin.OPT_OUT_QUERY_CACHE); + settings.put(IndexModule.INDEX_QUERY_CACHE_TYPE_SETTING.getKey(), ShieldPlugin.OPT_OUT_QUERY_CACHE); settings.put("cluster.name", ShieldF.class.getSimpleName()); String homeDir = System.getProperty("es.path.home"); 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 2f830b63e67..4347ee61656 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 @@ -167,7 +167,7 @@ public class IndexAuditTrailTests extends ShieldIntegTestCase { // For tests we forcefully configure Shield's custom query cache because the test framework randomizes the query cache impl, // but if shield is disabled then we don't need to forcefully set the query cache if (useShield == false) { - builder.remove(IndexModule.QUERY_CACHE_TYPE); + builder.remove(IndexModule.INDEX_QUERY_CACHE_TYPE_SETTING.getKey()); } return builder.build(); } diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authz/accesscontrol/FieldDataCacheWithFieldSubsetReaderTests.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authz/accesscontrol/FieldDataCacheWithFieldSubsetReaderTests.java index d2a38d625f0..0e15cb00803 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authz/accesscontrol/FieldDataCacheWithFieldSubsetReaderTests.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authz/accesscontrol/FieldDataCacheWithFieldSubsetReaderTests.java @@ -156,7 +156,7 @@ public class FieldDataCacheWithFieldSubsetReaderTests extends ESTestCase { .numberOfReplicas(0) .creationDate(System.currentTimeMillis()) .build(); - return new IndexSettings(indexMetaData, settings, Collections.emptyList()); + return new IndexSettings(indexMetaData, settings); } private static class DummyAccountingFieldDataCache implements IndexFieldDataCache { diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/test/ShieldIntegTestCase.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/test/ShieldIntegTestCase.java index c9d715e08ed..2f3483be9a1 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/test/ShieldIntegTestCase.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/test/ShieldIntegTestCase.java @@ -10,6 +10,7 @@ import org.elasticsearch.action.admin.cluster.node.info.NodeInfo; import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; import org.elasticsearch.client.Client; import org.elasticsearch.cluster.health.ClusterHealthStatus; +import org.elasticsearch.common.Nullable; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.shield.authc.support.SecuredString; @@ -110,7 +111,7 @@ public abstract class ShieldIntegTestCase extends ESIntegTestCase { @Override protected void before() throws Throwable { Scope currentClusterScope = getCurrentClusterScope(); - switch(currentClusterScope) { + switch (currentClusterScope) { case SUITE: if (customShieldSettingsSource == null) { customShieldSettingsSource = new CustomShieldSettingsSource(sslTransportEnabled(), createTempDir(), currentClusterScope); @@ -176,6 +177,7 @@ public abstract class ShieldIntegTestCase extends ESIntegTestCase { /** * Allows for us to get the system key that is being used for the cluster + * * @return the system key bytes */ protected byte[] systemKey() { @@ -301,4 +303,4 @@ public abstract class ShieldIntegTestCase extends ESIntegTestCase { assertNoTimeout(clusterHealthResponse); assertThat(clusterHealthResponse.getStatus(), is(ClusterHealthStatus.GREEN)); } -} +} \ No newline at end of file diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/test/ShieldSettingsSource.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/test/ShieldSettingsSource.java index 7ec85417b67..36fb1293674 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/test/ShieldSettingsSource.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/test/ShieldSettingsSource.java @@ -136,7 +136,7 @@ public class ShieldSettingsSource extends ClusterDiscoveryConfiguration.UnicastZ .put("shield.authz.store.files.roles", writeFile(folder, "roles.yml", configRoles())) // Test framework sometimes randomily selects the 'index' or 'none' cache and that makes the // validation in ShieldPlugin fail. - .put(IndexModule.QUERY_CACHE_TYPE, ShieldPlugin.OPT_OUT_QUERY_CACHE) + .put(IndexModule.INDEX_QUERY_CACHE_TYPE_SETTING.getKey(), ShieldPlugin.OPT_OUT_QUERY_CACHE) .put(getNodeSSLSettings()); setUser(builder, nodeClientUsername(), nodeClientPassword()); diff --git a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/support/WatcherIndexTemplateRegistryTests.java b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/support/WatcherIndexTemplateRegistryTests.java index afe23aa6100..291de60d212 100644 --- a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/support/WatcherIndexTemplateRegistryTests.java +++ b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/support/WatcherIndexTemplateRegistryTests.java @@ -6,11 +6,19 @@ package org.elasticsearch.watcher.support; import org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse; +import org.elasticsearch.cluster.metadata.IndexMetaData; +import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.common.settings.SettingsModule; +import org.elasticsearch.plugins.Plugin; import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.watcher.WatcherModule; import org.elasticsearch.watcher.test.AbstractWatcherIntegrationTestCase; +import java.util.ArrayList; +import java.util.Collection; +import java.util.function.Function; + import static org.elasticsearch.test.ESIntegTestCase.Scope.TEST; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.hamcrest.Matchers.equalTo; @@ -20,6 +28,14 @@ import static org.hamcrest.core.Is.is; */ @ESIntegTestCase.ClusterScope(scope = TEST, numClientNodes = 0, transportClientRatio = 0, randomDynamicTemplates = false, numDataNodes = 1) public class WatcherIndexTemplateRegistryTests extends AbstractWatcherIntegrationTestCase { + + @Override + protected Collection> nodePlugins() { + ArrayList> plugins = new ArrayList<>(super.nodePlugins()); + plugins.add(SettingTestPlugin.class); + return plugins; + } + public void testTemplates() throws Exception { assertAcked( client().admin().cluster().prepareUpdateSettings() @@ -55,4 +71,21 @@ public class WatcherIndexTemplateRegistryTests extends AbstractWatcherIntegratio } }); } + + public static class SettingTestPlugin extends Plugin { + public String name() { + return "watcher-index-template-registry-settings-plugin"; + } + + @Override + public String description() { + return "installs a setting this test needs"; + } + + public static final Setting KEY_1 = new Setting<>("index.key1", "", Function.identity(), false, Setting.Scope.INDEX); + + public void onModule(SettingsModule module) { + module.registerSetting(KEY_1); + } + } } diff --git a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/test/AbstractWatcherIntegrationTestCase.java b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/test/AbstractWatcherIntegrationTestCase.java index cbc0035a47d..9e0bde3e732 100644 --- a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/test/AbstractWatcherIntegrationTestCase.java +++ b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/test/AbstractWatcherIntegrationTestCase.java @@ -32,6 +32,7 @@ import org.elasticsearch.shield.crypto.InternalCryptoService; import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.test.ESIntegTestCase.ClusterScope; import org.elasticsearch.test.TestCluster; +import org.elasticsearch.test.store.MockFSIndexStore; import org.elasticsearch.test.transport.AssertingLocalTransport; import org.elasticsearch.test.transport.MockTransportService; import org.elasticsearch.watcher.WatcherLifeCycleService; @@ -124,7 +125,6 @@ public abstract class AbstractWatcherIntegrationTestCase extends ESIntegTestCase //TODO: for now lets isolate watcher tests from marvel (randomize this later) .put("marvel.enabled", false) - // we do this by default in core, but for watcher this isn't needed and only adds noise. .put("index.store.mock.check_index_on_close", false) .put("scroll.size", randomIntBetween(1, 100)) @@ -147,6 +147,7 @@ public abstract class AbstractWatcherIntegrationTestCase extends ESIntegTestCase Set> plugins = new HashSet<>(super.getMockPlugins()); plugins.remove(MockTransportService.TestPlugin.class); // shield has its own transport service plugins.remove(AssertingLocalTransport.TestPlugin.class); // shield has its own transport + plugins.add(MockFSIndexStore.TestPlugin.class); // we have to explicitly add it otherwise we will fail to set the check_index_on_close setting return plugins; } @@ -676,7 +677,7 @@ public abstract class AbstractWatcherIntegrationTestCase extends ESIntegTestCase .put("shield.audit.enabled", auditLogsEnabled) // Test framework sometimes randomily selects the 'index' or 'none' cache and that makes the // validation in ShieldPlugin fail. Shield can only run with this query cache impl - .put(IndexModule.QUERY_CACHE_TYPE, ShieldPlugin.OPT_OUT_QUERY_CACHE) + .put(IndexModule.INDEX_QUERY_CACHE_TYPE_SETTING.getKey(), ShieldPlugin.OPT_OUT_QUERY_CACHE) .build(); } catch (IOException ex) { throw new RuntimeException("failed to build settings for shield", ex);