Skip to content

Commit

Permalink
address test failures
Browse files Browse the repository at this point in the history
  • Loading branch information
jakelandis committed Oct 26, 2021
1 parent eb684cc commit c7b8067
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<FollowStatsAction.StatsResponse> mockStatuses() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit c7b8067

Please sign in to comment.