diff --git a/server/src/test/java/org/elasticsearch/bootstrap/BootstrapChecksTests.java b/server/src/test/java/org/elasticsearch/bootstrap/BootstrapChecksTests.java index a7b0dbe5ebe94..82a9ba5349a46 100644 --- a/server/src/test/java/org/elasticsearch/bootstrap/BootstrapChecksTests.java +++ b/server/src/test/java/org/elasticsearch/bootstrap/BootstrapChecksTests.java @@ -8,10 +8,12 @@ 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; import org.elasticsearch.cluster.metadata.Metadata; +import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.core.CheckedConsumer; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.transport.BoundTransportAddress; @@ -438,17 +440,17 @@ 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 " + + assertWarning(new DeprecationWarning(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."); + " See the breaking changes documentation for the next major version.")); } isSystemCallFilterInstalled.set(true); BootstrapChecks.check(context, true, Collections.singletonList(systemCallFilterEnabledCheck)); if (useBootstrapSystemCallFilter) { - assertWarnings("[bootstrap.system_call_filter] setting was deprecated in Elasticsearch " + + assertWarning(new DeprecationWarning(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."); + " See the breaking changes documentation for the next major version.")); } BootstrapContext context_1 = createTestContext(Settings.builder().put("bootstrap.system_call_filter", false).build(), null); @@ -460,12 +462,14 @@ 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!" + - " See the breaking changes documentation for the next major version."); + assertWarning(new DeprecationWarning(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!" + - " See the breaking changes documentation for the next major version."); + assertWarning(new DeprecationWarning(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.")); } public void testMightForkCheck() throws NodeValidationException { 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..41d477c12bd22 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,14 @@ protected final void assertSettingDeprecationsAndWarnings(final Setting[] set .toArray(DeprecationWarning[]::new)); } + /** + * Convenience method to assert warnings for settings deprecations and general deprecation warnings. + * @param expectedWarning expected {@link DeprecationWarning}. + */ + protected final void assertWarning(DeprecationWarning expectedWarning) { + assertWarnings(true, expectedWarning); + } + /** * 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..5012e45decf01 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,9 @@ 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."); + assertWarning(new DeprecationWarning(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/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..5e2579ca1bfdc 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; @@ -141,10 +142,10 @@ public void testDoCollect() throws Exception { assertThat(actual.getExecutingPolicy(), equalTo(expected)); } - assertWarnings( + assertWarning(new DeprecationWarning(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." - ); + )); } private EnrichStatsCollector createCollector(ClusterService clusterService, XPackLicenseState licenseState, Client client) {