diff --git a/libs/ssl-config/src/main/java/org/elasticsearch/common/ssl/SslConfigurationKeys.java b/libs/ssl-config/src/main/java/org/elasticsearch/common/ssl/SslConfigurationKeys.java index 3df79d003776c..b82fb07f8e0a0 100644 --- a/libs/ssl-config/src/main/java/org/elasticsearch/common/ssl/SslConfigurationKeys.java +++ b/libs/ssl-config/src/main/java/org/elasticsearch/common/ssl/SslConfigurationKeys.java @@ -57,7 +57,7 @@ public class SslConfigurationKeys { public static final String TRUSTSTORE_SECURE_PASSWORD = "truststore.secure_password"; /** * The password for the file configured in {@link #TRUSTSTORE_PATH}, as a non-secure setting. - * The use of this setting {@link #isDeprecated(String) is deprecated}. + * The use of this setting {@link #isDeprecatedWarning(String) is deprecated}. */ public static final String TRUSTSTORE_LEGACY_PASSWORD = "truststore.password"; /** @@ -82,7 +82,7 @@ public class SslConfigurationKeys { public static final String KEYSTORE_SECURE_PASSWORD = "keystore.secure_password"; /** * The password for the file configured in {@link #KEYSTORE_PATH}, as a non-secure setting. - * The use of this setting {@link #isDeprecated(String) is deprecated}. + * The use of this setting {@link #isDeprecatedWarning(String) is deprecated}. */ public static final String KEYSTORE_LEGACY_PASSWORD = "keystore.password"; /** @@ -92,7 +92,7 @@ public class SslConfigurationKeys { public static final String KEYSTORE_SECURE_KEY_PASSWORD = "keystore.secure_key_password"; /** * The password for the key within the {@link #KEYSTORE_PATH configured keystore}, as a non-secure setting. - * The use of this setting {@link #isDeprecated(String) is deprecated}. + * The use of this setting {@link #isDeprecatedWarning(String) is deprecated}. * If no key password is specified, it will default to the keystore password. */ public static final String KEYSTORE_LEGACY_KEY_PASSWORD = "keystore.key_password"; @@ -121,11 +121,14 @@ public class SslConfigurationKeys { public static final String KEY_SECURE_PASSPHRASE = "secure_key_passphrase"; /** * The password to read the configured {@link #KEY}, as a non-secure setting. - * The use of this setting {@link #isDeprecated(String) is deprecated}. + * The use of this setting {@link #isDeprecatedWarning(String) is deprecated}. */ public static final String KEY_LEGACY_PASSPHRASE = "key_passphrase"; - private static final Set DEPRECATED_KEYS = new HashSet<>( + /** + * Warning severity deprecated keys + */ + private static final Set DEPRECATED_WARNING_KEYS = new HashSet<>( Arrays.asList(TRUSTSTORE_LEGACY_PASSWORD, KEYSTORE_LEGACY_PASSWORD, KEYSTORE_LEGACY_KEY_PASSWORD, KEY_LEGACY_PASSPHRASE) ); @@ -161,10 +164,10 @@ public static List getSecureStringKeys() { } /** - * @return {@code true} if the provided key is a deprecated setting + * @return {@code true} if the provided key is a deprecated setting at warning severity */ - public static boolean isDeprecated(String key) { - return DEPRECATED_KEYS.contains(key); + public static boolean isDeprecatedWarning(String key) { + return DEPRECATED_WARNING_KEYS.contains(key); } } diff --git a/modules/reindex/src/main/java/org/elasticsearch/reindex/ReindexSslConfig.java b/modules/reindex/src/main/java/org/elasticsearch/reindex/ReindexSslConfig.java index d4dbdf1de70a8..0a9f76d67366a 100644 --- a/modules/reindex/src/main/java/org/elasticsearch/reindex/ReindexSslConfig.java +++ b/modules/reindex/src/main/java/org/elasticsearch/reindex/ReindexSslConfig.java @@ -50,16 +50,16 @@ public class ReindexSslConfig { static { Setting.Property[] defaultProperties = new Setting.Property[] { Setting.Property.NodeScope, Setting.Property.Filtered }; - Setting.Property[] deprecatedProperties = new Setting.Property[] { Setting.Property.Deprecated, Setting.Property.NodeScope, + Setting.Property[] deprecatedProperties = new Setting.Property[] { Setting.Property.DeprecatedWarning, Setting.Property.NodeScope, Setting.Property.Filtered }; for (String key : SslConfigurationKeys.getStringKeys()) { String settingName = "reindex.ssl." + key; - final Setting.Property[] properties = SslConfigurationKeys.isDeprecated(key) ? deprecatedProperties : defaultProperties; + final Setting.Property[] properties = SslConfigurationKeys.isDeprecatedWarning(key) ? deprecatedProperties : defaultProperties; SETTINGS.put(settingName, simpleString(settingName, properties)); } for (String key : SslConfigurationKeys.getListKeys()) { String settingName = "reindex.ssl." + key; - final Setting.Property[] properties = SslConfigurationKeys.isDeprecated(key) ? deprecatedProperties : defaultProperties; + final Setting.Property[] properties = SslConfigurationKeys.isDeprecatedWarning(key) ? deprecatedProperties : defaultProperties; SETTINGS.put(settingName, listSetting(settingName, Collections.emptyList(), Function.identity(), properties)); } for (String key : SslConfigurationKeys.getSecureStringKeys()) { diff --git a/server/src/main/java/org/elasticsearch/bootstrap/BootstrapSettings.java b/server/src/main/java/org/elasticsearch/bootstrap/BootstrapSettings.java index bd64fceb7ec43..13cee47215088 100644 --- a/server/src/main/java/org/elasticsearch/bootstrap/BootstrapSettings.java +++ b/server/src/main/java/org/elasticsearch/bootstrap/BootstrapSettings.java @@ -23,7 +23,7 @@ private BootstrapSettings() { public static final Setting MEMORY_LOCK_SETTING = Setting.boolSetting("bootstrap.memory_lock", false, Property.NodeScope); public static final Setting SYSTEM_CALL_FILTER_SETTING = - Setting.boolSetting("bootstrap.system_call_filter", true, Property.Deprecated, Property.NodeScope); + Setting.boolSetting("bootstrap.system_call_filter", true, Property.DeprecatedWarning, Property.NodeScope); public static final Setting CTRLHANDLER_SETTING = Setting.boolSetting("bootstrap.ctrlhandler", true, Property.NodeScope); diff --git a/server/src/main/java/org/elasticsearch/cluster/metadata/IndexMetadata.java b/server/src/main/java/org/elasticsearch/cluster/metadata/IndexMetadata.java index 173622e7bc944..c49ee312412bb 100644 --- a/server/src/main/java/org/elasticsearch/cluster/metadata/IndexMetadata.java +++ b/server/src/main/java/org/elasticsearch/cluster/metadata/IndexMetadata.java @@ -287,7 +287,7 @@ public static APIBlock readFrom(StreamInput input) throws IOException { public static final String SETTING_HISTORY_UUID = "index.history.uuid"; public static final String SETTING_DATA_PATH = "index.data_path"; public static final Setting INDEX_DATA_PATH_SETTING = - new Setting<>(SETTING_DATA_PATH, "", Function.identity(), Property.IndexScope, Property.Deprecated); + new Setting<>(SETTING_DATA_PATH, "", Function.identity(), Property.IndexScope, Property.DeprecatedWarning); public static final String INDEX_UUID_NA_VALUE = "_na_"; public static final String INDEX_ROUTING_REQUIRE_GROUP_PREFIX = "index.routing.allocation.require"; diff --git a/server/src/main/java/org/elasticsearch/common/settings/SecureSetting.java b/server/src/main/java/org/elasticsearch/common/settings/SecureSetting.java index e989539dfeb42..a2aaf536bb359 100644 --- a/server/src/main/java/org/elasticsearch/common/settings/SecureSetting.java +++ b/server/src/main/java/org/elasticsearch/common/settings/SecureSetting.java @@ -26,7 +26,8 @@ public abstract class SecureSetting extends Setting { /** Determines whether legacy settings with sensitive values should be allowed. */ private static final boolean ALLOW_INSECURE_SETTINGS = Booleans.parseBoolean(System.getProperty("es.allow_insecure_settings", "false")); - private static final Set ALLOWED_PROPERTIES = EnumSet.of(Property.Deprecated, Property.Consistent); + private static final Set ALLOWED_PROPERTIES = EnumSet.of(Property.Deprecated, Property.DeprecatedWarning, + Property.Consistent); private static final Property[] FIXED_PROPERTIES = { Property.NodeScope diff --git a/server/src/main/java/org/elasticsearch/repositories/blobstore/BlobStoreRepository.java b/server/src/main/java/org/elasticsearch/repositories/blobstore/BlobStoreRepository.java index 3c266b19f521f..8f3a1dc84d6d5 100644 --- a/server/src/main/java/org/elasticsearch/repositories/blobstore/BlobStoreRepository.java +++ b/server/src/main/java/org/elasticsearch/repositories/blobstore/BlobStoreRepository.java @@ -221,7 +221,7 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent imp public static final Setting CACHE_REPOSITORY_DATA = Setting.boolSetting( "cache_repository_data", true, - Setting.Property.Deprecated + Setting.Property.DeprecatedWarning ); /** diff --git a/server/src/test/java/org/elasticsearch/bootstrap/BootstrapChecksTests.java b/server/src/test/java/org/elasticsearch/bootstrap/BootstrapChecksTests.java index a7b0dbe5ebe94..940ca71cb2bdd 100644 --- a/server/src/test/java/org/elasticsearch/bootstrap/BootstrapChecksTests.java +++ b/server/src/test/java/org/elasticsearch/bootstrap/BootstrapChecksTests.java @@ -8,6 +8,7 @@ package org.elasticsearch.bootstrap; +import org.apache.logging.log4j.Level; import org.apache.logging.log4j.Logger; import org.apache.lucene.util.Constants; import org.elasticsearch.cluster.coordination.ClusterBootstrapService; @@ -438,7 +439,7 @@ boolean isSystemCallFilterInstalled() { containsString("system call filters failed to install; " + "check the logs and fix your configuration or disable system call filters at your own risk")); if (useBootstrapSystemCallFilter) { - assertWarnings("[bootstrap.system_call_filter] setting was deprecated in Elasticsearch " + + assertWarnings(Level.WARN, "[bootstrap.system_call_filter] setting was deprecated in Elasticsearch " + "and will be removed in a future release!" + " See the breaking changes documentation for the next major version."); } @@ -446,7 +447,7 @@ boolean isSystemCallFilterInstalled() { isSystemCallFilterInstalled.set(true); BootstrapChecks.check(context, true, Collections.singletonList(systemCallFilterEnabledCheck)); if (useBootstrapSystemCallFilter) { - assertWarnings("[bootstrap.system_call_filter] setting was deprecated in Elasticsearch " + + assertWarnings(Level.WARN, "[bootstrap.system_call_filter] setting was deprecated in Elasticsearch " + "and will be removed in a future release!" + " See the breaking changes documentation for the next major version."); } @@ -460,11 +461,13 @@ boolean isSystemCallFilterInstalled() { }; isSystemCallFilterInstalled.set(false); BootstrapChecks.check(context_1, true, Collections.singletonList(systemCallFilterNotEnabledCheck)); - assertWarnings("[bootstrap.system_call_filter] setting was deprecated in Elasticsearch and will be removed in a future release!" + + assertWarnings(Level.WARN, "[bootstrap.system_call_filter] setting was deprecated in Elasticsearch and will be removed in a " + + "future release!" + " See the breaking changes documentation for the next major version."); isSystemCallFilterInstalled.set(true); BootstrapChecks.check(context_1, true, Collections.singletonList(systemCallFilterNotEnabledCheck)); - assertWarnings("[bootstrap.system_call_filter] setting was deprecated in Elasticsearch and will be removed in a future release!" + + assertWarnings(Level.WARN, "[bootstrap.system_call_filter] setting was deprecated in Elasticsearch and will be removed in a " + + "future release!" + " See the breaking changes documentation for the next major version."); } diff --git a/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java index 38dd18dccbfe8..754f5c254ec97 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java @@ -468,6 +468,15 @@ protected final void assertSettingDeprecationsAndWarnings(final Setting[] set .toArray(DeprecationWarning[]::new)); } + /** + * Convenience method to assert warnings at a specific level for settings deprecations and general deprecation warnings. + * @param expectedWarnings expected general deprecation warnings. + */ + protected final void assertWarnings(Level level, String... expectedWarnings) { + assertWarnings(true, Arrays.stream(expectedWarnings).map(expectedWarning -> new DeprecationWarning(level, + expectedWarning)).toArray(DeprecationWarning[]::new)); + } + /** * Convenience method to assert warnings for settings deprecations and general deprecation warnings. All warnings passed to this method * are assumed to be at DeprecationLogger.CRITICAL level. diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/monitoring/collector/ccr/StatsCollectorTests.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/monitoring/collector/ccr/StatsCollectorTests.java index 93d26764a570e..752c9ac4a7eb6 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/monitoring/collector/ccr/StatsCollectorTests.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/monitoring/collector/ccr/StatsCollectorTests.java @@ -6,6 +6,7 @@ */ package org.elasticsearch.xpack.monitoring.collector.ccr; +import org.apache.logging.log4j.Level; import org.elasticsearch.action.ActionFuture; import org.elasticsearch.client.Client; import org.elasticsearch.cluster.service.ClusterService; @@ -150,8 +151,8 @@ public void testDoCollect() throws Exception { assertThat(document.getId(), nullValue()); assertThat(document.stats(), is(autoFollowStats)); - assertWarnings("[xpack.monitoring.collection.ccr.stats.timeout] setting was deprecated in Elasticsearch and will be removed in " + - "a future release! See the breaking changes documentation for the next major version."); + assertWarnings(Level.WARN, "[xpack.monitoring.collection.ccr.stats.timeout] setting was deprecated in Elasticsearch and will " + + "be removed in a future release! See the breaking changes documentation for the next major version."); } private List mockStatuses() { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/LifecycleSettings.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/LifecycleSettings.java index f25fa7f1aa650..2344a1701e206 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/LifecycleSettings.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/LifecycleSettings.java @@ -49,7 +49,7 @@ public class LifecycleSettings { true, Setting.Property.NodeScope); public static final Setting LIFECYCLE_STEP_MASTER_TIMEOUT_SETTING = Setting.positiveTimeSetting(LIFECYCLE_STEP_MASTER_TIMEOUT, TimeValue.timeValueSeconds(30), Setting.Property.Dynamic, - Setting.Property.NodeScope, Setting.Property.Deprecated); + Setting.Property.NodeScope, Setting.Property.DeprecatedWarning); // This setting configures how much time since step_time should ILM wait for a condition to be met. After the threshold wait time has // elapsed ILM will likely stop waiting and go to the next step. // Also see {@link org.elasticsearch.xpack.core.ilm.ClusterStateWaitUntilThresholdStep} diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/monitoring/MonitoringField.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/monitoring/MonitoringField.java index 934e40b500757..06dd6cee2dc1d 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/monitoring/MonitoringField.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/monitoring/MonitoringField.java @@ -31,7 +31,8 @@ public final class MonitoringField { public static final Setting HISTORY_DURATION = timeSetting("xpack.monitoring.history.duration", TimeValue.timeValueHours(7 * 24), // default value (7 days) HISTORY_DURATION_MINIMUM, // minimum value - Setting.Property.Dynamic, Setting.Property.NodeScope, Setting.Property.Deprecated); + Setting.Property.Dynamic, Setting.Property.NodeScope, + Setting.Property.DeprecatedWarning); private MonitoringField() {} } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authc/ldap/LdapUserSearchSessionFactorySettings.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authc/ldap/LdapUserSearchSessionFactorySettings.java index 0a155af5b7f99..71002bd9d9bea 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authc/ldap/LdapUserSearchSessionFactorySettings.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authc/ldap/LdapUserSearchSessionFactorySettings.java @@ -21,7 +21,7 @@ public final class LdapUserSearchSessionFactorySettings { public static final Setting.AffixSetting SEARCH_ATTRIBUTE = Setting.affixKeySetting( RealmSettings.realmSettingPrefix(LDAP_TYPE), "user_search.attribute", key -> new Setting<>(key, LdapUserSearchSessionFactorySettings.DEFAULT_USERNAME_ATTRIBUTE, Function.identity(), - Setting.Property.NodeScope, Setting.Property.Deprecated)); + Setting.Property.NodeScope, Setting.Property.DeprecatedWarning)); public static final Setting.AffixSetting SEARCH_BASE_DN = RealmSettings.simpleString(LDAP_TYPE, "user_search.base_dn", Setting.Property.NodeScope); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authc/ldap/PoolingSessionFactorySettings.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authc/ldap/PoolingSessionFactorySettings.java index a1eb5b115e470..575c5690ce5e4 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authc/ldap/PoolingSessionFactorySettings.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authc/ldap/PoolingSessionFactorySettings.java @@ -28,7 +28,7 @@ public final class PoolingSessionFactorySettings { public static final Function> LEGACY_BIND_PASSWORD = RealmSettings.affixSetting( "bind_password", key -> new Setting<>(key, "", SecureString::new, - Setting.Property.NodeScope, Setting.Property.Filtered, Setting.Property.Deprecated)); + Setting.Property.NodeScope, Setting.Property.Filtered, Setting.Property.DeprecatedWarning)); public static final Function> SECURE_BIND_PASSWORD = realmType -> Setting.affixKeySetting( diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authc/ldap/support/SessionFactorySettings.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authc/ldap/support/SessionFactorySettings.java index 395579b5886a3..eb50253cfd741 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authc/ldap/support/SessionFactorySettings.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authc/ldap/support/SessionFactorySettings.java @@ -31,7 +31,7 @@ public final class SessionFactorySettings { public static final Function> TIMEOUT_TCP_READ_SETTING = RealmSettings.affixSetting( "timeout.tcp_read", key -> Setting.timeSetting(key, TimeValue.MINUS_ONE, Setting.Property.NodeScope, - Setting.Property.Deprecated)); + Setting.Property.DeprecatedWarning)); public static final Function> TIMEOUT_RESPONSE_SETTING = RealmSettings.affixSetting( "timeout.response", key -> Setting.timeSetting(key, TimeValue.MINUS_ONE, Setting.Property.NodeScope)); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ssl/SSLConfigurationSettings.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ssl/SSLConfigurationSettings.java index 7feb3dff6403f..04417b003cad9 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ssl/SSLConfigurationSettings.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ssl/SSLConfigurationSettings.java @@ -114,7 +114,7 @@ public class SSLConfigurationSettings { Setting.affixKeySetting("xpack.security.authc.realms." + realmType + ".", "ssl.key", X509KeyPairSettings.KEY_PATH_TEMPLATE); public static final Function> LEGACY_TRUSTSTORE_PASSWORD_TEMPLATE = key -> - new Setting<>(key, "", SecureString::new, Property.Deprecated, Property.Filtered, Property.NodeScope); + new Setting<>(key, "", SecureString::new, Property.DeprecatedWarning, Property.Filtered, Property.NodeScope); public static final Setting LEGACY_TRUSTSTORE_PASSWORD_PROFILES = Setting.affixKeySetting("transport.profiles.", "xpack.security.ssl.truststore.password", LEGACY_TRUSTSTORE_PASSWORD_TEMPLATE); public static final Function> LEGACY_TRUST_STORE_PASSWORD_REALM = realmType -> diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ssl/X509KeyPairSettings.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ssl/X509KeyPairSettings.java index e25c0b584160e..b886dedf481b9 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ssl/X509KeyPairSettings.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ssl/X509KeyPairSettings.java @@ -32,7 +32,7 @@ public class X509KeyPairSettings { Optional::ofNullable, Setting.Property.NodeScope, Setting.Property.Filtered); static final Function> LEGACY_KEYSTORE_PASSWORD_TEMPLATE = key -> new Setting<>(key, "", - SecureString::new, Setting.Property.Deprecated, Setting.Property.Filtered, Setting.Property.NodeScope); + SecureString::new, Setting.Property.DeprecatedWarning, Setting.Property.Filtered, Setting.Property.NodeScope); static final Function> KEYSTORE_PASSWORD_TEMPLATE = key -> SecureSetting.secureString(key, LEGACY_KEYSTORE_PASSWORD_TEMPLATE.apply(key.replace("keystore.secure_password", "keystore.password"))); @@ -44,7 +44,7 @@ public class X509KeyPairSettings { new Setting<>(key, s -> null, Optional::ofNullable, Setting.Property.NodeScope, Setting.Property.Filtered); static final Function> LEGACY_KEYSTORE_KEY_PASSWORD_TEMPLATE = key -> new Setting<>(key, "", - SecureString::new, Setting.Property.Deprecated, Setting.Property.Filtered, Setting.Property.NodeScope); + SecureString::new, Setting.Property.DeprecatedWarning, Setting.Property.Filtered, Setting.Property.NodeScope); static final Function> KEYSTORE_KEY_PASSWORD_TEMPLATE = key -> SecureSetting.secureString(key, LEGACY_KEYSTORE_KEY_PASSWORD_TEMPLATE.apply(key.replace("keystore.secure_key_password", "keystore.key_password"))); @@ -56,7 +56,7 @@ public class X509KeyPairSettings { Optional::ofNullable, Setting.Property.NodeScope, Setting.Property.Filtered); static final Function> LEGACY_KEY_PASSWORD_TEMPLATE = key -> new Setting<>(key, "", - SecureString::new, Setting.Property.Deprecated, Setting.Property.Filtered, Setting.Property.NodeScope); + SecureString::new, Setting.Property.DeprecatedWarning, Setting.Property.Filtered, Setting.Property.NodeScope); static final Function> KEY_PASSWORD_TEMPLATE = key -> SecureSetting.secureString(key, LEGACY_KEY_PASSWORD_TEMPLATE.apply(key.replace("secure_key_passphrase", "key_passphrase"))); diff --git a/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/monitoring/collector/enrich/EnrichStatsCollectorTests.java b/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/monitoring/collector/enrich/EnrichStatsCollectorTests.java index 386a2fa379c68..ddc502e827658 100644 --- a/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/monitoring/collector/enrich/EnrichStatsCollectorTests.java +++ b/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/monitoring/collector/enrich/EnrichStatsCollectorTests.java @@ -6,6 +6,7 @@ */ package org.elasticsearch.xpack.monitoring.collector.enrich; +import org.apache.logging.log4j.Level; import org.elasticsearch.action.ActionFuture; import org.elasticsearch.client.Client; import org.elasticsearch.cluster.service.ClusterService; @@ -142,6 +143,7 @@ public void testDoCollect() throws Exception { } assertWarnings( + Level.WARN, "[xpack.monitoring.collection.enrich.stats.timeout] setting was deprecated in Elasticsearch and will be removed " + "in a future release! See the breaking changes documentation for the next major version." ); diff --git a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/plugin/EqlPlugin.java b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/plugin/EqlPlugin.java index 4c39a610f2b8e..819621824c23f 100644 --- a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/plugin/EqlPlugin.java +++ b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/plugin/EqlPlugin.java @@ -62,7 +62,7 @@ public class EqlPlugin extends Plugin implements ActionPlugin, CircuitBreakerPlu "xpack.eql.enabled", true, Setting.Property.NodeScope, - Setting.Property.Deprecated + Setting.Property.DeprecatedWarning ); public EqlPlugin() { diff --git a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/Monitoring.java b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/Monitoring.java index 27d3551da4f63..f58a0fbe77e61 100644 --- a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/Monitoring.java +++ b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/Monitoring.java @@ -89,7 +89,7 @@ public class Monitoring extends Plugin implements ActionPlugin, ReloadablePlugin true, Setting.Property.Dynamic, Setting.Property.NodeScope, Setting.Property.Deprecated); public static final Setting MIGRATION_DECOMMISSION_ALERTS = boolSetting("xpack.monitoring.migration.decommission_alerts", - false, Setting.Property.Dynamic, Setting.Property.NodeScope, Setting.Property.Deprecated); + false, Setting.Property.Dynamic, Setting.Property.NodeScope, Setting.Property.DeprecatedWarning); public static final LicensedFeature.Momentary MONITORING_CLUSTER_ALERTS_FEATURE = LicensedFeature.momentary("monitoring", "cluster-alerts", License.OperationMode.STANDARD); diff --git a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/MonitoringService.java b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/MonitoringService.java index 7c854fa5fc58c..3fa6e10e2cb3f 100644 --- a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/MonitoringService.java +++ b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/MonitoringService.java @@ -59,7 +59,7 @@ public class MonitoringService extends AbstractLifecycleComponent { */ public static final Setting ELASTICSEARCH_COLLECTION_ENABLED = Setting.boolSetting("xpack.monitoring.elasticsearch.collection.enabled", true, - Setting.Property.Dynamic, Setting.Property.NodeScope, Setting.Property.Deprecated); + Setting.Property.Dynamic, Setting.Property.NodeScope, Setting.Property.DeprecatedWarning); /** * Dynamically controls enabling or disabling the collection of Monitoring data from Elasticsearch as well as other products @@ -67,14 +67,14 @@ public class MonitoringService extends AbstractLifecycleComponent { */ public static final Setting ENABLED = Setting.boolSetting("xpack.monitoring.collection.enabled", false, - Setting.Property.Dynamic, Setting.Property.NodeScope, Setting.Property.Deprecated); + Setting.Property.Dynamic, Setting.Property.NodeScope, Setting.Property.DeprecatedWarning); /** * Sampling interval between two collections (default to 10s) */ public static final Setting INTERVAL = Setting.timeSetting("xpack.monitoring.collection.interval", TimeValue.timeValueSeconds(10), MIN_INTERVAL, - Setting.Property.Dynamic, Setting.Property.NodeScope, Setting.Property.Deprecated); + Setting.Property.Dynamic, Setting.Property.NodeScope, Setting.Property.DeprecatedWarning); /** State of the monitoring service, either started or stopped **/ private final AtomicBoolean started = new AtomicBoolean(false); diff --git a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/Collector.java b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/Collector.java index 9f9749e3c453f..edcf858475786 100644 --- a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/Collector.java +++ b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/Collector.java @@ -42,7 +42,7 @@ public abstract class Collector { */ public static final Setting> INDICES = listSetting(collectionSetting("indices"), emptyList(), Function.identity(), Property.Dynamic, Property.NodeScope, - Setting.Property.Deprecated); + Property.DeprecatedWarning); private final String name; private final Setting collectionTimeoutSetting; @@ -171,6 +171,6 @@ protected static String collectionSetting(final String settingName) { protected static Setting collectionTimeoutSetting(final String settingName) { String name = collectionSetting(settingName); - return timeSetting(name, TimeValue.timeValueSeconds(10), Property.Dynamic, Property.NodeScope, Property.Deprecated); + return timeSetting(name, TimeValue.timeValueSeconds(10), Property.Dynamic, Property.NodeScope, Property.DeprecatedWarning); } } diff --git a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/indices/IndexRecoveryCollector.java b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/indices/IndexRecoveryCollector.java index c44a28cc2c2c1..d585b208aa855 100644 --- a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/indices/IndexRecoveryCollector.java +++ b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/indices/IndexRecoveryCollector.java @@ -44,7 +44,7 @@ public class IndexRecoveryCollector extends Collector { */ public static final Setting INDEX_RECOVERY_ACTIVE_ONLY = boolSetting(collectionSetting("index.recovery.active_only"), false, Setting.Property.Dynamic, Setting.Property.NodeScope, - Setting.Property.Deprecated); + Setting.Property.DeprecatedWarning); private final Client client; diff --git a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/Exporter.java b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/Exporter.java index 3c9539cbb8868..d8ae6e91a0337 100644 --- a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/Exporter.java +++ b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/Exporter.java @@ -33,7 +33,8 @@ public abstract class Exporter implements AutoCloseable { private static final Setting.AffixSetting ENABLED_SETTING = Setting.affixKeySetting("xpack.monitoring.exporters.","enabled", - key -> Setting.boolSetting(key, true, Property.Dynamic, Property.NodeScope, Property.Deprecated), TYPE_DEPENDENCY); + key -> Setting.boolSetting(key, true, Property.Dynamic, Property.NodeScope, Property.DeprecatedWarning), + TYPE_DEPENDENCY); public static final Setting.AffixSetting TYPE_SETTING = Setting.affixKeySetting( "xpack.monitoring.exporters.", @@ -82,7 +83,7 @@ public Iterator> settings() { }, Property.Dynamic, Property.NodeScope, - Property.Deprecated)); + Property.DeprecatedWarning)); /** * Every {@code Exporter} adds the ingest pipeline to bulk requests, but they should, at the exporter level, allow that to be disabled. *

@@ -90,13 +91,15 @@ public Iterator> settings() { */ public static final Setting.AffixSetting USE_INGEST_PIPELINE_SETTING = Setting.affixKeySetting("xpack.monitoring.exporters.","use_ingest", - key -> Setting.boolSetting(key, true, Property.Dynamic, Property.NodeScope, Property.Deprecated), TYPE_DEPENDENCY); + key -> Setting.boolSetting(key, true, Property.Dynamic, Property.NodeScope, Property.Deprecated), + TYPE_DEPENDENCY); /** * Every {@code Exporter} allows users to explicitly disable cluster alerts. */ public static final Setting.AffixSetting CLUSTER_ALERTS_MANAGEMENT_SETTING = Setting.affixKeySetting("xpack.monitoring.exporters.", "cluster_alerts.management.enabled", - key -> Setting.boolSetting(key, true, Property.Dynamic, Property.NodeScope, Property.Deprecated), TYPE_DEPENDENCY); + key -> Setting.boolSetting(key, true, Property.Dynamic, Property.NodeScope, Property.DeprecatedWarning), + TYPE_DEPENDENCY); /** * Every {@code Exporter} allows users to explicitly disable specific cluster alerts. *

@@ -105,7 +108,7 @@ public Iterator> settings() { public static final Setting.AffixSetting> CLUSTER_ALERTS_BLACKLIST_SETTING = Setting .affixKeySetting("xpack.monitoring.exporters.", "cluster_alerts.management.blacklist", key -> Setting.listSetting(key, Collections.emptyList(), Function.identity(), Property.Dynamic, Property.NodeScope, - Property.Deprecated), TYPE_DEPENDENCY); + Property.DeprecatedWarning), TYPE_DEPENDENCY); /** * Every {@code Exporter} allows users to use a different index time format. @@ -118,7 +121,7 @@ public Iterator> settings() { DateFormatter::forPattern, Property.Dynamic, Property.NodeScope, - Property.Deprecated), TYPE_DEPENDENCY); + Property.DeprecatedWarning), TYPE_DEPENDENCY); private static final String INDEX_FORMAT = "yyyy.MM.dd"; diff --git a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporter.java b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporter.java index 0b2c1c8d943b9..26a355c3105cd 100644 --- a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporter.java +++ b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporter.java @@ -172,7 +172,7 @@ public Iterator> settings() { }, Property.Dynamic, Property.NodeScope, - Property.Deprecated), + Property.DeprecatedWarning), HTTP_TYPE_DEPENDENCY); /** @@ -180,7 +180,8 @@ public Iterator> settings() { */ public static final Setting.AffixSetting BULK_TIMEOUT_SETTING = Setting.affixKeySetting("xpack.monitoring.exporters.","bulk.timeout", - (key) -> Setting.timeSetting(key, TimeValue.MINUS_ONE, Property.Dynamic, Property.NodeScope, Property.Deprecated), + (key) -> Setting.timeSetting(key, TimeValue.MINUS_ONE, Property.Dynamic, Property.NodeScope, + Property.DeprecatedWarning), HTTP_TYPE_DEPENDENCY); /** * Timeout used for initiating a connection. @@ -189,7 +190,8 @@ public Iterator> settings() { Setting.affixKeySetting( "xpack.monitoring.exporters.", "connection.timeout", - (key) -> Setting.timeSetting(key, TimeValue.timeValueSeconds(6), Property.Dynamic, Property.NodeScope, Property.Deprecated), + (key) -> Setting.timeSetting(key, TimeValue.timeValueSeconds(6), Property.Dynamic, Property.NodeScope, + Property.DeprecatedWarning), HTTP_TYPE_DEPENDENCY); /** * Timeout used for reading from the connection. @@ -199,7 +201,7 @@ public Iterator> settings() { "xpack.monitoring.exporters.", "connection.read_timeout", (key) -> Setting.timeSetting(key, TimeValue.timeValueSeconds(60), Property.Dynamic, Property.NodeScope, - Property.Deprecated), + Property.DeprecatedWarning), HTTP_TYPE_DEPENDENCY); /** * Username for basic auth. @@ -251,7 +253,7 @@ public Iterator> settings() { Property.Dynamic, Property.NodeScope, Property.Filtered, - Property.Deprecated), + Property.DeprecatedWarning), HTTP_TYPE_DEPENDENCY); /** * Password for basic auth. @@ -297,7 +299,7 @@ public Iterator> settings() { Property.Dynamic, Property.NodeScope, Property.Filtered, - Property.Deprecated), + Property.DeprecatedWarning), TYPE_DEPENDENCY); /** * Secure password for basic auth. @@ -306,7 +308,7 @@ public Iterator> settings() { Setting.affixKeySetting( "xpack.monitoring.exporters.", "auth.secure_password", - key -> SecureSetting.secureString(key, null, Setting.Property.Deprecated), + key -> SecureSetting.secureString(key, null, Property.DeprecatedWarning), HTTP_TYPE_DEPENDENCY); /** * The SSL settings. @@ -317,7 +319,8 @@ public Iterator> settings() { Setting.affixKeySetting( "xpack.monitoring.exporters.", "ssl", - (key) -> Setting.groupSetting(key + ".", Property.Dynamic, Property.NodeScope, Property.Filtered, Property.Deprecated), + (key) -> Setting.groupSetting(key + ".", Property.Dynamic, Property.NodeScope, Property.Filtered, + Property.DeprecatedWarning), HTTP_TYPE_DEPENDENCY); /** @@ -339,14 +342,14 @@ public Iterator> settings() { }, Property.Dynamic, Property.NodeScope, - Property.Deprecated), + Property.DeprecatedWarning), HTTP_TYPE_DEPENDENCY); /** * A boolean setting to enable or disable sniffing for extra connections. */ public static final Setting.AffixSetting SNIFF_ENABLED_SETTING = Setting.affixKeySetting("xpack.monitoring.exporters.","sniff.enabled", - (key) -> Setting.boolSetting(key, false, Property.Dynamic, Property.NodeScope, Property.Deprecated), + (key) -> Setting.boolSetting(key, false, Property.Dynamic, Property.NodeScope, Property.DeprecatedWarning), HTTP_TYPE_DEPENDENCY); /** * A parent setting to header key/value pairs, whose names are user defined. @@ -370,7 +373,7 @@ public Iterator> settings() { }, Property.Dynamic, Property.NodeScope, - Property.Deprecated), + Property.DeprecatedWarning), HTTP_TYPE_DEPENDENCY); /** * Blacklist of headers that the user is not allowed to set. @@ -383,21 +386,23 @@ public Iterator> settings() { */ public static final Setting.AffixSetting TEMPLATE_CHECK_TIMEOUT_SETTING = Setting.affixKeySetting("xpack.monitoring.exporters.","index.template.master_timeout", - (key) -> Setting.timeSetting(key, TimeValue.MINUS_ONE, Property.Dynamic, Property.NodeScope, Property.Deprecated), + (key) -> Setting.timeSetting(key, TimeValue.MINUS_ONE, Property.Dynamic, Property.NodeScope, + Property.DeprecatedWarning), HTTP_TYPE_DEPENDENCY); /** * A boolean setting to enable or disable whether to create placeholders for the old templates. */ public static final Setting.AffixSetting TEMPLATE_CREATE_LEGACY_VERSIONS_SETTING = Setting.affixKeySetting("xpack.monitoring.exporters.","index.template.create_legacy_templates", - (key) -> Setting.boolSetting(key, true, Property.Dynamic, Property.NodeScope, Property.Deprecated), + (key) -> Setting.boolSetting(key, true, Property.Dynamic, Property.NodeScope, Property.DeprecatedWarning), HTTP_TYPE_DEPENDENCY); /** * ES level timeout used when checking and writing pipelines (used to speed up tests) */ public static final Setting.AffixSetting PIPELINE_CHECK_TIMEOUT_SETTING = Setting.affixKeySetting("xpack.monitoring.exporters.","index.pipeline.master_timeout", - (key) -> Setting.timeSetting(key, TimeValue.MINUS_ONE, Property.Dynamic, Property.NodeScope, Property.Deprecated), + (key) -> Setting.timeSetting(key, TimeValue.MINUS_ONE, Property.Dynamic, Property.NodeScope, + Property.DeprecatedWarning), HTTP_TYPE_DEPENDENCY); /** diff --git a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporter.java b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporter.java index 01830f5310eca..28808570c11db 100644 --- a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporter.java +++ b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporter.java @@ -102,7 +102,8 @@ public class LocalExporter extends Exporter implements ClusterStateListener, Cle public static final Setting.AffixSetting WAIT_MASTER_TIMEOUT_SETTING = Setting.affixKeySetting( "xpack.monitoring.exporters.", "wait_master.timeout", - (key) -> Setting.timeSetting(key, TimeValue.timeValueSeconds(30), Property.Dynamic, Property.NodeScope, Property.Deprecated), + (key) -> Setting.timeSetting(key, TimeValue.timeValueSeconds(30), Property.Dynamic, Property.NodeScope, + Property.DeprecatedWarning), TYPE_DEPENDENCY ); diff --git a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringHistoryDurationSettingsTests.java b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringHistoryDurationSettingsTests.java index f9499966631da..f1dca6feee2b8 100644 --- a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringHistoryDurationSettingsTests.java +++ b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringHistoryDurationSettingsTests.java @@ -6,6 +6,7 @@ */ package org.elasticsearch.xpack.monitoring; +import org.apache.logging.log4j.Level; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.core.TimeValue; import org.elasticsearch.test.ESTestCase; @@ -20,16 +21,16 @@ public void testHistoryDurationDefaults7Days() { assertEquals(sevenDays, MonitoringField.HISTORY_DURATION.get(Settings.EMPTY)); // Note: this verifies the semantics because this is taken for granted that it never returns null! assertEquals(sevenDays, MonitoringField.HISTORY_DURATION.get(buildSettings(MonitoringField.HISTORY_DURATION.getKey(), null))); - assertWarnings("[xpack.monitoring.history.duration] setting was deprecated in Elasticsearch and will be removed in a future " + - "release! See the breaking changes documentation for the next major version."); + assertWarnings(Level.WARN, "[xpack.monitoring.history.duration] setting was deprecated in Elasticsearch and will be removed in a " + + "future release! See the breaking changes documentation for the next major version."); } public void testHistoryDurationMinimum24Hours() { // hit the minimum assertEquals(MonitoringField.HISTORY_DURATION_MINIMUM, MonitoringField.HISTORY_DURATION.get(buildSettings(MonitoringField.HISTORY_DURATION.getKey(), "24h"))); - assertWarnings("[xpack.monitoring.history.duration] setting was deprecated in Elasticsearch and will be removed in a future " + - "release! See the breaking changes documentation for the next major version."); + assertWarnings(Level.WARN, "[xpack.monitoring.history.duration] setting was deprecated in Elasticsearch and will be removed in a " + + "future release! See the breaking changes documentation for the next major version."); } public void testHistoryDurationMinimum24HoursBlocksLower() { @@ -37,8 +38,8 @@ public void testHistoryDurationMinimum24HoursBlocksLower() { final String oneSecondEarly = (MonitoringField.HISTORY_DURATION_MINIMUM.millis() - 1) + "ms"; expectThrows(IllegalArgumentException.class, () -> MonitoringField.HISTORY_DURATION.get(buildSettings(MonitoringField.HISTORY_DURATION.getKey(), oneSecondEarly))); - assertWarnings("[xpack.monitoring.history.duration] setting was deprecated in Elasticsearch and will be removed in a future " + - "release! See the breaking changes documentation for the next major version."); + assertWarnings(Level.WARN, "[xpack.monitoring.history.duration] setting was deprecated in Elasticsearch and will be removed in a " + + "future release! See the breaking changes documentation for the next major version."); } private Settings buildSettings(String key, String value) { diff --git a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringServiceTests.java b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringServiceTests.java index e6c134512e0e7..a6c51e182cd3c 100644 --- a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringServiceTests.java +++ b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringServiceTests.java @@ -6,6 +6,7 @@ */ package org.elasticsearch.xpack.monitoring; +import org.apache.logging.log4j.Level; import org.elasticsearch.action.ActionListener; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.service.ClusterService; @@ -118,8 +119,8 @@ public void testInterval() throws Exception { // take down threads monitoringService.setMonitoringActive(false); - assertWarnings("[xpack.monitoring.collection.interval] setting was deprecated in Elasticsearch and will be removed in " + - "a future release! See the breaking changes documentation for the next major version."); + assertWarnings(Level.WARN, "[xpack.monitoring.collection.interval] setting was deprecated in Elasticsearch and will be removed " + + "in a future release! See the breaking changes documentation for the next major version."); } public void testSkipExecution() throws Exception { @@ -143,7 +144,7 @@ public void testSkipExecution() throws Exception { latch.countDown(); assertThat(exporter.getExportsCount(), equalTo(1)); - assertWarnings( + assertWarnings(Level.WARN, "[xpack.monitoring.collection.enabled] setting was deprecated in Elasticsearch and will be removed in " + "a future release! See the breaking changes documentation for the next major version.", "[xpack.monitoring.collection.interval] setting was deprecated in Elasticsearch and will be removed in " + diff --git a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/cleaner/CleanerServiceTests.java b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/cleaner/CleanerServiceTests.java index 8563bd55e72ab..5de674e37d8e4 100644 --- a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/cleaner/CleanerServiceTests.java +++ b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/cleaner/CleanerServiceTests.java @@ -6,6 +6,7 @@ */ package org.elasticsearch.xpack.monitoring.cleaner; +import org.apache.logging.log4j.Level; import org.elasticsearch.common.settings.ClusterSettings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.core.TimeValue; @@ -59,8 +60,8 @@ public void testConstructorWithInvalidRetention() { new CleanerService(settings, clusterSettings, threadPool, licenseState); } finally { - assertWarnings("[xpack.monitoring.history.duration] setting was deprecated in Elasticsearch and will be removed in " + - "a future release! See the breaking changes documentation for the next major version."); + assertWarnings(Level.WARN, "[xpack.monitoring.history.duration] setting was deprecated in Elasticsearch and will be removed " + + "in a future release! See the breaking changes documentation for the next major version."); } } @@ -70,7 +71,7 @@ public void testGetRetention() { assertEquals(expected, new CleanerService(settings, clusterSettings, threadPool, licenseState).getRetention()); - assertWarnings("[xpack.monitoring.history.duration] setting was deprecated in Elasticsearch and will be removed in " + + assertWarnings(Level.WARN, "[xpack.monitoring.history.duration] setting was deprecated in Elasticsearch and will be removed in " + "a future release! See the breaking changes documentation for the next major version."); } diff --git a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/cluster/ClusterStatsCollectorTests.java b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/cluster/ClusterStatsCollectorTests.java index 20cb601f4daaa..62d5df99e116d 100644 --- a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/cluster/ClusterStatsCollectorTests.java +++ b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/cluster/ClusterStatsCollectorTests.java @@ -6,6 +6,7 @@ */ package org.elasticsearch.xpack.monitoring.collector.cluster; +import org.apache.logging.log4j.Level; import org.elasticsearch.ElasticsearchTimeoutException; import org.elasticsearch.Version; import org.elasticsearch.action.ActionFuture; @@ -269,8 +270,8 @@ public void testDoCollect() throws Exception { verify(clusterAdminClient).prepareClusterStats(); verify(client).execute(same(XPackUsageAction.INSTANCE), any(XPackUsageRequest.class)); - assertWarnings("[xpack.monitoring.collection.cluster.stats.timeout] setting was deprecated in Elasticsearch and will be removed " + - "in a future release! See the breaking changes documentation for the next major version."); + assertWarnings(Level.WARN, "[xpack.monitoring.collection.cluster.stats.timeout] setting was deprecated in Elasticsearch and will " + + "be removed in a future release! See the breaking changes documentation for the next major version."); } public void testDoCollectNoLicense() throws Exception { @@ -333,8 +334,8 @@ public void testDoCollectNoLicense() throws Exception { final ClusterStatsMonitoringDoc doc = (ClusterStatsMonitoringDoc) results.iterator().next(); assertThat(doc.getLicense(), nullValue()); - assertWarnings("[xpack.monitoring.collection.cluster.stats.timeout] setting was deprecated in Elasticsearch and will be removed " + - "in a future release! See the breaking changes documentation for the next major version."); + assertWarnings(Level.WARN, "[xpack.monitoring.collection.cluster.stats.timeout] setting was deprecated in Elasticsearch and will " + + "be removed in a future release! See the breaking changes documentation for the next major version."); } public void testDoCollectThrowsTimeoutException() throws Exception { @@ -389,8 +390,8 @@ public void testDoCollectThrowsTimeoutException() throws Exception { client, licenseService, indexNameExpressionResolver); expectThrows(ElasticsearchTimeoutException.class, () -> collector.doCollect(node, interval, clusterState)); - assertWarnings("[xpack.monitoring.collection.cluster.stats.timeout] setting was deprecated in Elasticsearch and will be removed " + - "in a future release! See the breaking changes documentation for the next major version."); + assertWarnings(Level.WARN, "[xpack.monitoring.collection.cluster.stats.timeout] setting was deprecated in Elasticsearch and will " + + "be removed in a future release! See the breaking changes documentation for the next major version."); } } diff --git a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/indices/IndexRecoveryCollectorTests.java b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/indices/IndexRecoveryCollectorTests.java index 44b4bc9189ae9..bc10a12fb3830 100644 --- a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/indices/IndexRecoveryCollectorTests.java +++ b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/indices/IndexRecoveryCollectorTests.java @@ -6,6 +6,7 @@ */ package org.elasticsearch.xpack.monitoring.collector.indices; +import org.apache.logging.log4j.Level; import org.elasticsearch.ElasticsearchTimeoutException; import org.elasticsearch.action.FailedNodeException; import org.elasticsearch.action.admin.indices.recovery.RecoveryAction; @@ -170,7 +171,8 @@ public void testDoCollect() throws Exception { assertThat(recoveries.shardRecoveryStates().size(), equalTo(nbRecoveries)); } - assertWarnings("[xpack.monitoring.collection.index.recovery.timeout] setting was deprecated in Elasticsearch and will be " + + assertWarnings(Level.WARN, + "[xpack.monitoring.collection.index.recovery.timeout] setting was deprecated in Elasticsearch and will be " + "removed in a future release! See the breaking changes documentation for the next major version.", "[xpack.monitoring.collection.index.recovery.active_only] setting was deprecated in Elasticsearch and will be removed " + "in a future release! See the breaking changes documentation for the next major version.", @@ -221,8 +223,8 @@ public void testDoCollectThrowsTimeoutException() throws Exception { expectThrows(ElasticsearchTimeoutException.class, () -> collector.doCollect(node, interval, clusterState)); - assertWarnings("[xpack.monitoring.collection.index.recovery.timeout] setting was deprecated in Elasticsearch and will be " + - "removed in a future release! See the breaking changes documentation for the next major version."); + assertWarnings(Level.WARN, "[xpack.monitoring.collection.index.recovery.timeout] setting was deprecated in Elasticsearch " + + "and will be removed in a future release! See the breaking changes documentation for the next major version."); } } diff --git a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/indices/IndexStatsCollectorTests.java b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/indices/IndexStatsCollectorTests.java index 649fa603fffb8..d523c590caf02 100644 --- a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/indices/IndexStatsCollectorTests.java +++ b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/indices/IndexStatsCollectorTests.java @@ -6,6 +6,7 @@ */ package org.elasticsearch.xpack.monitoring.collector.indices; +import org.apache.logging.log4j.Level; import org.elasticsearch.ElasticsearchTimeoutException; import org.elasticsearch.action.FailedNodeException; import org.elasticsearch.action.admin.indices.stats.IndexStats; @@ -171,8 +172,8 @@ public void testDoCollect() throws Exception { } } - assertWarnings("[xpack.monitoring.collection.index.stats.timeout] setting was deprecated in Elasticsearch and will be removed " + - "in a future release! See the breaking changes documentation for the next major version."); + assertWarnings(Level.WARN, "[xpack.monitoring.collection.index.stats.timeout] setting was deprecated in Elasticsearch and " + + "will be removed in a future release! See the breaking changes documentation for the next major version."); } public void testDoCollectThrowsTimeoutException() throws Exception { @@ -207,8 +208,8 @@ public void testDoCollectThrowsTimeoutException() throws Exception { expectThrows(ElasticsearchTimeoutException.class, () -> collector.doCollect(node, interval, clusterState)); - assertWarnings("[xpack.monitoring.collection.index.stats.timeout] setting was deprecated in Elasticsearch and will be removed " + - "in a future release! See the breaking changes documentation for the next major version."); + assertWarnings(Level.WARN, "[xpack.monitoring.collection.index.stats.timeout] setting was deprecated in Elasticsearch and will " + + "be removed in a future release! See the breaking changes documentation for the next major version."); } } diff --git a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/ml/JobStatsCollectorTests.java b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/ml/JobStatsCollectorTests.java index 178d75de86f28..b035212a4d789 100644 --- a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/ml/JobStatsCollectorTests.java +++ b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/ml/JobStatsCollectorTests.java @@ -6,6 +6,7 @@ */ package org.elasticsearch.xpack.monitoring.collector.ml; +import org.apache.logging.log4j.Level; import org.elasticsearch.ElasticsearchTimeoutException; import org.elasticsearch.action.ActionFuture; import org.elasticsearch.action.FailedNodeException; @@ -142,8 +143,8 @@ public void testDoCollect() throws Exception { assertThat(jobStatsMonitoringDoc.getJobStats(), is(jobStat)); } - assertWarnings("[xpack.monitoring.collection.ml.job.stats.timeout] setting was deprecated in Elasticsearch and will be removed " + - "in a future release! See the breaking changes documentation for the next major version."); + assertWarnings(Level.WARN, "[xpack.monitoring.collection.ml.job.stats.timeout] setting was deprecated in Elasticsearch " + + "and will be removed in a future release! See the breaking changes documentation for the next major version."); } public void testDoCollectThrowsTimeoutException() throws Exception { @@ -174,8 +175,8 @@ public void testDoCollectThrowsTimeoutException() throws Exception { expectThrows(ElasticsearchTimeoutException.class, () -> collector.doCollect(node, interval, clusterState)); - assertWarnings("[xpack.monitoring.collection.ml.job.stats.timeout] setting was deprecated in Elasticsearch and will be removed " + - "in a future release! See the breaking changes documentation for the next major version."); + assertWarnings(Level.WARN, "[xpack.monitoring.collection.ml.job.stats.timeout] setting was deprecated in Elasticsearch " + + "and will be removed in a future release! See the breaking changes documentation for the next major version."); } private List mockJobStats() { diff --git a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/node/NodeStatsCollectorTests.java b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/node/NodeStatsCollectorTests.java index acadacb1671d7..1d952bb64316d 100644 --- a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/node/NodeStatsCollectorTests.java +++ b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/node/NodeStatsCollectorTests.java @@ -6,6 +6,7 @@ */ package org.elasticsearch.xpack.monitoring.collector.node; +import org.apache.logging.log4j.Level; import org.elasticsearch.ElasticsearchTimeoutException; import org.elasticsearch.action.ActionFuture; import org.elasticsearch.action.FailedNodeException; @@ -65,8 +66,8 @@ public void testDoCollectWithFailures() throws Exception { collector.doCollect(randomMonitoringNode(random()), randomNonNegativeLong(), clusterState)); assertEquals(exception, e); - assertWarnings("[xpack.monitoring.collection.node.stats.timeout] setting was deprecated in Elasticsearch and will be removed " + - "in a future release! See the breaking changes documentation for the next major version."); + assertWarnings(Level.WARN, "[xpack.monitoring.collection.node.stats.timeout] setting was deprecated in Elasticsearch and " + + "will be removed in a future release! See the breaking changes documentation for the next major version."); } public void testDoCollect() throws Exception { @@ -121,8 +122,8 @@ public void testDoCollect() throws Exception { assertThat(document.getNodeStats(), is(nodeStats)); assertThat(document.isMlockall(), equalTo(BootstrapInfo.isMemoryLocked())); - assertWarnings("[xpack.monitoring.collection.node.stats.timeout] setting was deprecated in Elasticsearch and will be removed " + - "in a future release! See the breaking changes documentation for the next major version."); + assertWarnings(Level.WARN, "[xpack.monitoring.collection.node.stats.timeout] setting was deprecated in Elasticsearch " + + "and will be removed in a future release! See the breaking changes documentation for the next major version."); } public void testDoCollectThrowsTimeout() throws Exception { @@ -152,8 +153,8 @@ public void testDoCollectThrowsTimeout() throws Exception { expectThrows(ElasticsearchTimeoutException.class, () -> collector.doCollect(node, interval, clusterState)); - assertWarnings("[xpack.monitoring.collection.node.stats.timeout] setting was deprecated in Elasticsearch and will be removed " + - "in a future release! See the breaking changes documentation for the next major version."); + assertWarnings(Level.WARN, "[xpack.monitoring.collection.node.stats.timeout] setting was deprecated in Elasticsearch " + + "and will be removed in a future release! See the breaking changes documentation for the next major version."); } private void thenReturnNodeStats(final Client client, final TimeValue timeout, final NodesStatsResponse nodesStatsResponse) { diff --git a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/shards/ShardsCollectorTests.java b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/shards/ShardsCollectorTests.java index fd06ac328770f..b6f68b1f3fdbb 100644 --- a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/shards/ShardsCollectorTests.java +++ b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/shards/ShardsCollectorTests.java @@ -6,6 +6,7 @@ */ package org.elasticsearch.xpack.monitoring.collector.shards; +import org.apache.logging.log4j.Level; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.routing.RoutingTable; import org.elasticsearch.cluster.routing.ShardRouting; @@ -122,8 +123,8 @@ public void testDoCollect() throws Exception { } - assertWarnings("[xpack.monitoring.collection.indices] setting was deprecated in Elasticsearch and will be removed in a" + - " future release! See the breaking changes documentation for the next major version."); + assertWarnings(Level.WARN, "[xpack.monitoring.collection.indices] setting was deprecated in Elasticsearch and will be removed " + + "in a future release! See the breaking changes documentation for the next major version."); } private static RoutingTable mockRoutingTable() { diff --git a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/ClusterAlertsUtilTests.java b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/ClusterAlertsUtilTests.java index 07aa0087697d6..4b496e7d32cca 100644 --- a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/ClusterAlertsUtilTests.java +++ b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/ClusterAlertsUtilTests.java @@ -12,6 +12,7 @@ import java.util.Set; import java.util.stream.Collectors; +import org.apache.logging.log4j.Level; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.Metadata; import org.elasticsearch.cluster.service.ClusterService; @@ -109,7 +110,7 @@ public void testGetClusterAlertsBlacklistThrowsForUnknownWatchId() { equalTo("[xpack.monitoring.exporters._random.cluster_alerts.management.blacklist] contains unrecognized Cluster " + "Alert IDs [" + unknownIdsString + "]")); - assertWarnings("[xpack.monitoring.exporters._random.cluster_alerts.management.blacklist] setting was deprecated in " + + assertWarnings(Level.WARN, "[xpack.monitoring.exporters._random.cluster_alerts.management.blacklist] setting was deprecated in " + "Elasticsearch and will be removed in a future release! See the breaking changes documentation for the next major version."); } @@ -118,8 +119,8 @@ public void testGetClusterAlertsBlacklist() { assertThat(blacklist, equalTo(ClusterAlertsUtil.getClusterAlertsBlacklist(createConfigWithBlacklist("any", blacklist)))); - assertWarnings("[xpack.monitoring.exporters.any.cluster_alerts.management.blacklist] setting was deprecated in Elasticsearch " + - "and will be removed in a future release! See the breaking changes documentation for the next major version."); + assertWarnings(Level.WARN, "[xpack.monitoring.exporters.any.cluster_alerts.management.blacklist] setting was deprecated " + + "in Elasticsearch and will be removed in a future release! See the breaking changes documentation for the next major version."); } private Exporter.Config createConfigWithBlacklist(final String name, final List blacklist) { diff --git a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/ExportersTests.java b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/ExportersTests.java index 7e98d5e6b203f..d61a0387ab363 100644 --- a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/ExportersTests.java +++ b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/ExportersTests.java @@ -6,12 +6,14 @@ */ package org.elasticsearch.xpack.monitoring.exporter; +import org.apache.logging.log4j.Level; import org.elasticsearch.action.ActionListener; import org.elasticsearch.client.Client; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.block.ClusterBlocks; import org.elasticsearch.cluster.metadata.Metadata; import org.elasticsearch.cluster.service.ClusterService; +import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.ClusterSettings; import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; @@ -117,8 +119,8 @@ public void testHostsMustBeSetIfTypeIsHttp() { assertThat(e, hasToString(containsString("Failed to parse value [http] for setting [" + prefix + ".type]"))); assertThat(e.getCause(), instanceOf(SettingsException.class)); assertThat(e.getCause(), hasToString(containsString("host list for [" + prefix + ".host] is empty"))); - assertWarnings("[xpack.monitoring.exporters.example.type] setting was deprecated in Elasticsearch and will be removed in a " + - "future release! See the breaking changes documentation for the next major version."); + assertWarnings(Level.WARN, "[xpack.monitoring.exporters.example.type] setting was deprecated in Elasticsearch and will be " + + "removed in a future release! See the breaking changes documentation for the next major version."); } public void testIndexNameTimeFormatMustBeValid() { @@ -132,8 +134,8 @@ public void testIndexNameTimeFormatMustBeValid() { assertThat(e, hasToString(containsString("Invalid format: [" + value + "]: Unknown pattern letter: j"))); assertThat(e.getCause(), instanceOf(IllegalArgumentException.class)); assertThat(e.getCause(), hasToString(containsString("Unknown pattern letter: j"))); - assertWarnings("[xpack.monitoring.exporters.example.index.name.time_format] setting was deprecated in Elasticsearch and will " + - "be removed in a future release! See the breaking changes documentation for the next major version."); + assertWarnings(Level.WARN, "[xpack.monitoring.exporters.example.index.name.time_format] setting was deprecated in Elasticsearch " + + "and will be removed in a future release! See the breaking changes documentation for the next major version."); } public void testExporterIndexPattern() { @@ -186,8 +188,8 @@ public void testInitExportersSingleDisabled() throws Exception { // the only configured exporter is disabled... yet we intentionally don't fallback on the default assertThat(internalExporters.size(), is(0)); - assertWarnings("[xpack.monitoring.exporters._name.enabled] setting was deprecated in Elasticsearch and will be removed in a " + - "future release! See the breaking changes documentation for the next major version."); + assertWarnings(Level.WARN, "[xpack.monitoring.exporters._name.enabled] setting was deprecated in Elasticsearch and will be" + + " removed in a future release! See the breaking changes documentation for the next major version."); } public void testInitExportersSingleUnknownType() throws Exception { @@ -272,15 +274,16 @@ InitializedExporters initExporters(Settings settings) { assertEquals(settings.get("xpack.monitoring.exporters._name0.use_ingest"), "true"); assertEquals(settings.get("xpack.monitoring.exporters._name1.type"), "http"); assertEquals(settings.get("xpack.monitoring.exporters._name1.use_ingest"), "false"); - assertWarnings( - "[xpack.monitoring.exporters._name1.type] setting was deprecated in Elasticsearch and will be removed in a future release! " + - "See the breaking changes documentation for the next major version.", - "[xpack.monitoring.exporters._name0.type] setting was deprecated in Elasticsearch and will be removed in a future release! " + - "See the breaking changes documentation for the next major version.", - "[xpack.monitoring.exporters._name0.use_ingest] setting was deprecated in Elasticsearch and will be removed " + - "in a future release! See the breaking changes documentation for the next major version.", - "[xpack.monitoring.exporters._name1.use_ingest] setting was deprecated in Elasticsearch and will be removed " + - "in a future release! See the breaking changes documentation for the next major version." + assertWarnings(true, + new DeprecationWarning(Level.WARN, "[xpack.monitoring.exporters._name1.type] setting was deprecated in Elasticsearch and " + + "will be removed in a future release! See the breaking changes documentation for the next major version."), + new DeprecationWarning(Level.WARN, "[xpack.monitoring.exporters._name0.type] setting was deprecated in Elasticsearch and " + + "will be removed in a future release! See the breaking changes documentation for the next major version."), + new DeprecationWarning(DeprecationLogger.CRITICAL, "[xpack.monitoring.exporters._name0.use_ingest] setting was deprecated in " + + "Elasticsearch " + + "and will be removed in a future release! See the breaking changes documentation for the next major version."), + new DeprecationWarning(DeprecationLogger.CRITICAL, "[xpack.monitoring.exporters._name1.use_ingest] setting was deprecated in " + + "Elasticsearch and will be removed in a future release! See the breaking changes documentation for the next major version.") ); } @@ -329,8 +332,8 @@ public void testNoExporters() throws Exception { exporters.close(); - assertWarnings("[xpack.monitoring.exporters.explicitly_disabled.enabled] setting was deprecated in Elasticsearch and will be " + - "removed in a future release! See the breaking changes documentation for the next major version."); + assertWarnings(Level.WARN, "[xpack.monitoring.exporters.explicitly_disabled.enabled] setting was deprecated in Elasticsearch " + + "and will be removed in a future release! See the breaking changes documentation for the next major version."); } /** diff --git a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterResourceTests.java b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterResourceTests.java index e795fcef1f1fe..5404c51050ae1 100644 --- a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterResourceTests.java +++ b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterResourceTests.java @@ -10,6 +10,7 @@ import org.apache.http.StatusLine; import org.apache.http.entity.ContentType; import org.apache.http.entity.StringEntity; +import org.apache.logging.log4j.Level; import org.elasticsearch.Version; import org.elasticsearch.client.Request; import org.elasticsearch.client.Response; @@ -545,7 +546,7 @@ public void testDeployClusterAlerts() { verifyDeleteWatches(EXPECTED_WATCHES); verifyNoMoreInteractions(client); - assertWarnings( + assertWarnings(Level.WARN, "[xpack.monitoring.exporters._http.index.template.create_legacy_templates] setting was deprecated in " + "Elasticsearch and will be removed in a future release! See the breaking changes documentation for the next " + "major version.", @@ -639,7 +640,7 @@ public void testSuccessfulChecksIfNotElectedMasterNode() { verifyPutPipelines(unsuccessfulGetPipelines); verifyNoMoreInteractions(client); - assertWarnings("[xpack.monitoring.exporters._http.index.template.create_legacy_templates] setting was deprecated in " + + assertWarnings(Level.WARN, "[xpack.monitoring.exporters._http.index.template.create_legacy_templates] setting was deprecated in " + "Elasticsearch and will be removed in a future release! See the breaking changes documentation for the next " + "major version."); } diff --git a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterTests.java b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterTests.java index 10fa69f838fe4..8e44233078fd9 100644 --- a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterTests.java +++ b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterTests.java @@ -10,6 +10,7 @@ import org.apache.http.entity.ContentType; import org.apache.http.entity.StringEntity; import org.apache.http.nio.conn.ssl.SSLIOSessionStrategy; +import org.apache.logging.log4j.Level; import org.elasticsearch.action.ActionListener; import org.elasticsearch.client.Request; import org.elasticsearch.client.Response; @@ -19,6 +20,7 @@ import org.elasticsearch.cluster.metadata.Metadata; import org.elasticsearch.cluster.node.DiscoveryNodes; import org.elasticsearch.cluster.service.ClusterService; +import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.ClusterSettings; import org.elasticsearch.common.settings.MockSecureSettings; import org.elasticsearch.common.settings.Settings; @@ -120,7 +122,7 @@ private void runTestEmptyHostList(final boolean useDefault) { assertThat(e.getCause(), hasToString(containsString("host list for [" + prefix + ".host] is empty"))); expectedWarnings.add("[xpack.monitoring.exporters.example.type] setting was deprecated in Elasticsearch and will be removed " + "in a future release! See the breaking changes documentation for the next major version."); - assertWarnings(expectedWarnings.toArray(new String[0])); + assertWarnings(Level.WARN, expectedWarnings.toArray(new String[0])); } public void testEmptyHostListOkayIfTypeNotSetDefault() { @@ -140,8 +142,8 @@ private void runTestEmptyHostListOkayIfTypeNotSet(final boolean useDefault) { builder.putList(prefix + ".host", Collections.emptyList()); final Settings settings = builder.build(); HttpExporter.HOST_SETTING.getConcreteSetting(prefix + ".host").get(settings); - assertWarnings("[xpack.monitoring.exporters.example.host] setting was deprecated in Elasticsearch and will be removed in a " + - "future release! See the breaking changes documentation for the next major version."); + assertWarnings(Level.WARN, "[xpack.monitoring.exporters.example.host] setting was deprecated in Elasticsearch and will be " + + "removed in a future release! See the breaking changes documentation for the next major version."); } public void testHostListIsRejectedIfTypeIsNotHttp() { @@ -153,7 +155,7 @@ public void testHostListIsRejectedIfTypeIsNotHttp() { new ClusterSettings(settings, new HashSet<>(Arrays.asList(HttpExporter.HOST_SETTING, Exporter.TYPE_SETTING))); final SettingsException e = expectThrows(SettingsException.class, () -> clusterSettings.validate(settings, true)); assertThat(e, hasToString(containsString("[" + prefix + ".host] is set but type is [local]"))); - assertWarnings( + assertWarnings(Level.WARN, "[xpack.monitoring.exporters.example.type] setting was deprecated in Elasticsearch and will be removed in a future release! " + "See the breaking changes documentation for the next major version.", "[xpack.monitoring.exporters.example.host] setting was deprecated in Elasticsearch and will be removed in a future release! " + @@ -178,7 +180,7 @@ public void testSecurePasswordIsRejectedIfTypeIsNotHttp() { Stream.of(HttpExporter.AUTH_SECURE_PASSWORD_SETTING, Exporter.TYPE_SETTING).collect(Collectors.toSet())); final SettingsException e = expectThrows(SettingsException.class, () -> clusterSettings.validate(settings, true)); assertThat(e, hasToString(containsString("[" + prefix + settingName + "] is set but type is [local]"))); - assertWarnings( + assertWarnings(Level.WARN, "[xpack.monitoring.exporters.example.type] setting was deprecated in Elasticsearch and will be removed in a future release! " + "See the breaking changes documentation for the next major version.", "[xpack.monitoring.exporters.example.auth.secure_password] setting was deprecated in Elasticsearch and will be removed in a " + @@ -203,7 +205,7 @@ public void testInvalidHost() { assertThat(e.getCause(), hasToString(containsString("[" + prefix + ".host] invalid host: [" + host + "]"))); assertThat(e.getCause().getCause(), instanceOf(IllegalArgumentException.class)); assertThat(e.getCause().getCause(), hasToString(containsString("HttpHosts do not use paths [/]."))); - assertWarnings( + assertWarnings(Level.WARN, "[xpack.monitoring.exporters.example.host] setting was deprecated in Elasticsearch and will be removed in a future release! " + "See the breaking changes documentation for the next major version.", "[xpack.monitoring.exporters.example.type] setting was deprecated in Elasticsearch and will be removed in a future release! " + @@ -228,7 +230,7 @@ public void testMixedSchemes() { "Failed to parse value [[\"" + httpHost + "\",\"" + httpsHost + "\"]] for setting [" + prefix + ".host]"))); assertThat(e.getCause(), instanceOf(SettingsException.class)); assertThat(e.getCause(), hasToString(containsString("[" + prefix + ".host] must use a consistent scheme: http or https"))); - assertWarnings( + assertWarnings(Level.WARN, "[xpack.monitoring.exporters.example.host] setting was deprecated in Elasticsearch and will be removed in a future release! " + "See the breaking changes documentation for the next major version.", "[xpack.monitoring.exporters.example.type] setting was deprecated in Elasticsearch and will be removed in a future release! " + @@ -257,7 +259,7 @@ public void testExporterWithBlacklistedHeaders() { assertThat(exception.getMessage(), equalTo(expected)); - assertWarnings( + assertWarnings(Level.WARN, "[xpack.monitoring.exporters._http.host] setting was deprecated in Elasticsearch and will be removed in a " + "future release! See the breaking changes documentation for the next major version.", "[xpack.monitoring.exporters._http.type] setting was deprecated in Elasticsearch and will be removed in a future release! " + @@ -284,7 +286,7 @@ public void testExporterWithEmptyHeaders() { expectThrows(SettingsException.class, () -> new HttpExporter(config, sslService, threadContext, coordinator)); assertThat(exception.getMessage(), equalTo(expected)); - assertWarnings( + assertWarnings(Level.WARN, "[xpack.monitoring.exporters._http.host] setting was deprecated in Elasticsearch and will be removed in a future release! " + "See the breaking changes documentation for the next major version.", "[xpack.monitoring.exporters._http.type] setting was deprecated in Elasticsearch and will be removed in a future release! " + @@ -306,8 +308,8 @@ public void testExporterWithPasswordButNoUsername() { IllegalArgumentException.class, () -> HttpExporter.AUTH_PASSWORD_SETTING.getConcreteSetting(prefix + ".auth.password").get(settings)); assertThat(e, hasToString(containsString(expected))); - assertWarnings("[xpack.monitoring.exporters._http.auth.password] setting was deprecated in Elasticsearch and will be removed " + - "in a future release! See the breaking changes documentation for the next major version."); + assertWarnings(Level.WARN, "[xpack.monitoring.exporters._http.auth.password] setting was deprecated in Elasticsearch and will " + + "be removed in a future release! See the breaking changes documentation for the next major version."); } public void testExporterWithUnknownBlacklistedClusterAlerts() { @@ -337,8 +339,8 @@ public void testExporterWithUnknownBlacklistedClusterAlerts() { assertThat(exception.getMessage(), equalTo("[xpack.monitoring.exporters._http.cluster_alerts.management.blacklist] contains unrecognized Cluster " + "Alert IDs [does_not_exist]")); - assertWarnings("[xpack.monitoring.exporters._http.cluster_alerts.management.blacklist] setting was deprecated in Elasticsearch" + - " and will be removed in a future release! See the breaking changes documentation for the next major version."); + assertWarnings(Level.WARN, "[xpack.monitoring.exporters._http.cluster_alerts.management.blacklist] setting was deprecated in " + + "Elasticsearch and will be removed in a future release! See the breaking changes documentation for the next major version."); } public void testExporterWithHostOnly() throws Exception { @@ -353,7 +355,7 @@ public void testExporterWithHostOnly() throws Exception { final MonitoringMigrationCoordinator coordinator = new MonitoringMigrationCoordinator(); new HttpExporter(config, sslService, threadContext, coordinator).close(); - assertWarnings( + assertWarnings(Level.WARN, "[xpack.monitoring.exporters._http.host] setting was deprecated in Elasticsearch and will be removed in a future release! " + "See the breaking changes documentation for the next major version.", "[xpack.monitoring.exporters._http.type] setting was deprecated in Elasticsearch and will be removed in a future release! " + @@ -382,8 +384,8 @@ public void testExporterWithInvalidProxyBasePath() throws Exception { assertThat(e.getCause(), instanceOf(SettingsException.class)); assertThat(e.getCause(), hasToString(containsString(expected))); - assertWarnings("[xpack.monitoring.exporters._http.proxy.base_path] setting was deprecated in Elasticsearch and will be removed " + - "in a future release! See the breaking changes documentation for the next major version."); + assertWarnings(Level.WARN, "[xpack.monitoring.exporters._http.proxy.base_path] setting was deprecated in Elasticsearch and will " + + "be removed in a future release! See the breaking changes documentation for the next major version."); } public void testCreateRestClient() throws IOException { @@ -423,7 +425,7 @@ public void testCreateRestClient() throws IOException { HttpExporter.createRestClient(config, sslService, listener).close(); if (expectedWarnings.size() > 0) { - assertWarnings(expectedWarnings.toArray(new String[0])); + assertWarnings(Level.WARN, expectedWarnings.toArray(new String[0])); } } @@ -437,8 +439,8 @@ public void testCreateCredentialsProviderWithoutSecurity() { assertNull(provider); - assertWarnings("[xpack.monitoring.exporters._http.type] setting was deprecated in Elasticsearch and will be removed in a " + - "future release! See the breaking changes documentation for the next major version."); + assertWarnings(Level.WARN, "[xpack.monitoring.exporters._http.type] setting was deprecated in Elasticsearch and will be removed " + + "in a future release! See the breaking changes documentation for the next major version."); } public void testCreateSnifferDisabledByDefault() { @@ -478,7 +480,7 @@ public void testCreateSniffer() throws IOException { verifyNoMoreInteractions(client, listener); - assertWarnings( + assertWarnings(Level.WARN, "[xpack.monitoring.exporters._http.sniff.enabled] setting was deprecated in Elasticsearch and will be removed " + "in a future release! See the breaking changes documentation for the next major version.", "[xpack.monitoring.exporters._http.host] setting was deprecated in Elasticsearch and will be removed in a future release!" + @@ -497,42 +499,47 @@ public void testCreateResources() { final Settings.Builder builder = Settings.builder() .put("xpack.monitoring.exporters._http.type", "http"); - List expectedWarnings = new ArrayList<>(); + List expectedWarnings = new ArrayList<>(); if (useIngest == false) { builder.put("xpack.monitoring.exporters._http.use_ingest", false); - expectedWarnings.add("[xpack.monitoring.exporters._http.use_ingest] setting was deprecated in Elasticsearch and will be " + - "removed in a future release! See the breaking changes documentation for the next major version."); + expectedWarnings.add(new DeprecationWarning(DeprecationLogger.CRITICAL, + "[xpack.monitoring.exporters._http.use_ingest] setting was deprecated in Elasticsearch and will be " + + "removed in a future release! See the breaking changes documentation for the next major version.")); } if (clusterAlertManagement == false) { builder.put("xpack.monitoring.exporters._http.cluster_alerts.management.enabled", false); - expectedWarnings.add("[xpack.monitoring.exporters._http.cluster_alerts.management.enabled] setting was deprecated in " + + expectedWarnings.add(new DeprecationWarning(Level.WARN, + "[xpack.monitoring.exporters._http.cluster_alerts.management.enabled] setting was deprecated in " + "Elasticsearch and will be removed in a future release! See the breaking changes documentation for the next major " + - "version."); + "version.")); } if (createOldTemplates == false) { builder.put("xpack.monitoring.exporters._http.index.template.create_legacy_templates", false); - expectedWarnings.add("[xpack.monitoring.exporters._http.index.template.create_legacy_templates] setting was deprecated in " + + expectedWarnings.add(new DeprecationWarning(Level.WARN, + "[xpack.monitoring.exporters._http.index.template.create_legacy_templates] setting was deprecated in " + "Elasticsearch and will be removed in a future release! See the breaking changes documentation for the next " + - "major version."); + "major version.")); } if (templateTimeout != null) { builder.put("xpack.monitoring.exporters._http.index.template.master_timeout", templateTimeout.getStringRep()); - expectedWarnings.add("[xpack.monitoring.exporters._http.index.template.master_timeout] setting was deprecated in " + + expectedWarnings.add(new DeprecationWarning(Level.WARN, + "[xpack.monitoring.exporters._http.index.template.master_timeout] setting was deprecated in " + "Elasticsearch and will be removed in a future release! See the breaking changes documentation for the next major " + - "version."); + "version.")); } // note: this shouldn't get used with useIngest == false, but it doesn't hurt to try to cause issues if (pipelineTimeout != null) { builder.put("xpack.monitoring.exporters._http.index.pipeline.master_timeout", pipelineTimeout.getStringRep()); if (useIngest) { - expectedWarnings.add("[xpack.monitoring.exporters._http.index.pipeline.master_timeout] setting was deprecated in " + + expectedWarnings.add(new DeprecationWarning(Level.WARN, + "[xpack.monitoring.exporters._http.index.pipeline.master_timeout] setting was deprecated in " + "Elasticsearch and will be removed in a future release! See the breaking changes documentation for the next " + - "major version."); + "major version.")); } } @@ -585,7 +592,7 @@ public void testCreateResources() { assertThat(uniqueOwners.get(0), equalTo("xpack.monitoring.exporters._http")); if (expectedWarnings.size() > 0) { - assertWarnings(expectedWarnings.toArray(new String[0])); + assertWarnings(true, expectedWarnings.toArray(new DeprecationWarning[0])); } } @@ -593,7 +600,7 @@ public void testCreateDefaultParams() { final TimeValue bulkTimeout = randomFrom(TimeValue.timeValueSeconds(30), null); final boolean useIngest = randomBoolean(); - List expectedWarnings = new ArrayList<>(); + List expectedWarnings = new ArrayList<>(); final Settings.Builder builder = Settings.builder() .put("xpack.monitoring.exporters._http.type", "http"); @@ -603,8 +610,9 @@ public void testCreateDefaultParams() { if (useIngest == false) { builder.put("xpack.monitoring.exporters._http.use_ingest", false); - expectedWarnings.add("[xpack.monitoring.exporters._http.use_ingest] setting was deprecated in Elasticsearch and will be " + - "removed in a future release! See the breaking changes documentation for the next major version."); + expectedWarnings.add(new DeprecationWarning(DeprecationLogger.CRITICAL, + "[xpack.monitoring.exporters._http.use_ingest] setting was deprecated in Elasticsearch " + + "and will be removed in a future release! See the breaking changes documentation for the next major version.")); } final Config config = createConfig(builder.build()); @@ -615,8 +623,9 @@ public void testCreateDefaultParams() { if (bulkTimeout != null) { assertThat(parameters.remove("timeout"), equalTo(bulkTimeout.toString())); - expectedWarnings.add("[xpack.monitoring.exporters._http.bulk.timeout] setting was deprecated in Elasticsearch and will be " + - "removed in a future release! See the breaking changes documentation for the next major version."); + expectedWarnings.add(new DeprecationWarning(Level.WARN, + "[xpack.monitoring.exporters._http.bulk.timeout] setting was deprecated in Elasticsearch and will be " + + "removed in a future release! See the breaking changes documentation for the next major version.")); } else { assertNull(parameters.remove("timeout")); } @@ -629,7 +638,7 @@ public void testCreateDefaultParams() { // should have removed everything assertThat(parameters.size(), equalTo(0)); if (expectedWarnings.size() > 0) { - assertWarnings(expectedWarnings.toArray(new String[0])); + assertWarnings(true, expectedWarnings.toArray(new DeprecationWarning[0])); } }