Skip to content

Commit

Permalink
Fix EnsureNoWarning assertion backport(#73647) (#73685)
Browse files Browse the repository at this point in the history
EnsureNoWarnings method should assert that there is no other warnings
than the allowed "predefined" warnings in filteredWarnings() method

bug introduced in #71207
backports #73647
  • Loading branch information
pgomulka authored Jun 3, 2021
1 parent 9552101 commit 3c2adab
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,10 @@ String getUseSerialGC() {

public void testSystemCallFilterCheck() throws NodeValidationException {
final AtomicBoolean isSystemCallFilterInstalled = new AtomicBoolean();
BootstrapContext context = randomBoolean() ? createTestContext(Settings.builder().put("bootstrap.system_call_filter", true)
.build(), null) : emptyContext;
boolean useBootstrapSystemCallFilter = randomBoolean();
BootstrapContext context = useBootstrapSystemCallFilter ?
createTestContext(Settings.builder().put("bootstrap.system_call_filter", true).build(), null)
: emptyContext;

final BootstrapChecks.SystemCallFilterCheck systemCallFilterEnabledCheck = new BootstrapChecks.SystemCallFilterCheck() {
@Override
Expand All @@ -435,9 +437,20 @@ boolean isSystemCallFilterInstalled() {
e.getMessage(),
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 " +
"and will be removed in a future release!" +
" 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 " +
"and will be removed in a future release!" +
" See the breaking changes documentation for the next major version.");
}

BootstrapContext context_1 = createTestContext(Settings.builder().put("bootstrap.system_call_filter", false).build(), null);
final BootstrapChecks.SystemCallFilterCheck systemCallFilterNotEnabledCheck = new BootstrapChecks.SystemCallFilterCheck() {
@Override
Expand All @@ -447,8 +460,12 @@ 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.");
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.");
}

public void testMightForkCheck() throws NodeValidationException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,8 @@ public final void testNullInput() throws Exception {
} else {
expectThrows(MapperParsingException.class, () -> mapper.parse(source(b -> b.nullField("field"))));
}

assertWarnings(getParseMinimalWarnings());
}

protected boolean allowsNullValues() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,10 @@ public final void startClusters() throws Exception {
@Override
public List<String> filteredWarnings() {
return Stream.concat(super.filteredWarnings().stream(),
Stream.of("Configuring multiple [path.data] paths is deprecated. Use RAID or other system level features for utilizing " +
"multiple disks. This feature will be removed in 8.0.")).collect(Collectors.toList());
Stream.of("setting [path.shared_data] is deprecated and will be removed in a future release",
"Configuring [path.data] with a list is deprecated. Instead specify as a string value.",
"Configuring multiple [path.data] paths is deprecated. Use RAID or other system level features for utilizing " +
"multiple disks. This feature will be removed in 8.0.")).collect(Collectors.toList());
}

@After
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static org.elasticsearch.cluster.coordination.ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING;
import static org.elasticsearch.discovery.SettingsBasedSeedHostsProvider.DISCOVERY_SEED_HOSTS_SETTING;
Expand Down Expand Up @@ -189,6 +192,14 @@ protected boolean addMockHttpTransport() {
return true;
}

@Override
protected List<String> filteredWarnings() {
return Stream.concat(super.filteredWarnings().stream(),
Stream.of("[index.data_path] setting was deprecated in Elasticsearch and will be removed in a future release! " +
"See the breaking changes documentation for the next major version."))
.collect(Collectors.toList());
}

private Node newNode() {
final Path tempDir = createTempDir();
final String nodeName = nodeSettings().get(Node.NODE_NAME_SETTING.getKey(), "node_s_0");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ private void ensureNoWarnings() {
// unit tests do not run with the bundled JDK, if there are warnings we need to filter the no-jdk deprecation warning
final List<String> filteredWarnings = warnings
.stream()
.filter(k -> filteredWarnings().stream().anyMatch(s -> s.contains(k)))
.filter(k -> filteredWarnings().stream().noneMatch(s -> k.contains(s)))
.collect(Collectors.toList());
assertThat("unexpected warning headers", filteredWarnings, empty());
} else {
Expand All @@ -428,13 +428,16 @@ private void ensureNoWarnings() {

protected List<String> filteredWarnings() {
List<String> filtered = new ArrayList<>();
if (enableJodaDeprecationWarningsCheck()) {
filtered.add("Configuring [path.data] with a list is deprecated. Instead specify as a string value");
filtered.add("setting [path.shared_data] is deprecated and will be removed in a future release");
if (enableJodaDeprecationWarningsCheck() == false) {
filtered.add(JodaDeprecationPatterns.USE_NEW_FORMAT_SPECIFIERS);
}
if (JvmInfo.jvmInfo().getBundledJdk() == false) {
filtered.add("no-jdk distributions that do not bundle a JDK are deprecated and will be removed in a future release");
}
return filtered;

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,19 @@ public void setup() {
this.subjectShards = new HashSet<>(randomSubsetOf(randomIntBetween(1, shardIds.size()), shardIds));
}

@Override
protected List<String> filteredWarnings() {
return Stream.concat(
super.filteredWarnings().stream(),
Stream.of(
"[index.routing.allocation.include._tier] setting was deprecated in Elasticsearch "
+ "and will be removed in a future release! See the breaking changes documentation for the next major version.",
"[index.routing.allocation.require._tier] setting was deprecated in Elasticsearch "
+ "and will be removed in a future release! See the breaking changes documentation for the next major version."
)
).collect(Collectors.toList());
}

public void testStoragePreventsAllocation() {
ClusterState lastState = null;
int maxRounds = state.getRoutingNodes().unassigned().size() + 3; // (allocated + start + detect-same)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ public void testClusterRequires() {
containsString("node does not match all cluster setting [cluster.routing.allocation.require._tier] " +
"tier filters [data_hot]"));
}
assertWarnings("[cluster.routing.allocation.require._tier] 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 testClusterIncludes() {
Expand All @@ -126,6 +128,8 @@ public void testClusterIncludes() {
.build());
Decision d;
RoutingNode node;
assertWarnings("[cluster.routing.allocation.include._tier] setting was deprecated in Elasticsearch " +
"and will be removed in a future release! See the breaking changes documentation for the next major version.");

for (DiscoveryNode n : Arrays.asList(WARM_NODE, DATA_NODE, COLD_NODE)) {
node = new RoutingNode(n.getId(), n, shard);
Expand Down Expand Up @@ -161,7 +165,8 @@ public void testClusterExcludes() {
.build());
Decision d;
RoutingNode node;

assertWarnings("[cluster.routing.allocation.exclude._tier] setting was deprecated in Elasticsearch " +
"and will be removed in a future release! See the breaking changes documentation for the next major version.");
for (DiscoveryNode n : Arrays.asList(WARM_NODE, DATA_NODE)) {
node = new RoutingNode(n.getId(), n, shard);
d = decider.canAllocate(shard, node, allocation);
Expand Down Expand Up @@ -216,6 +221,8 @@ public void testIndexRequires() {
assertThat(d.getExplanation(),
containsString("node does not match all index setting [index.routing.allocation.require._tier] tier filters [data_hot]"));
}
assertWarnings("[index.routing.allocation.require._tier] 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 testIndexIncludes() {
Expand Down Expand Up @@ -250,6 +257,8 @@ public void testIndexIncludes() {
containsString("node does not match any index setting [index.routing.allocation.include._tier] " +
"tier filters [data_warm,data_cold]"));
}
assertWarnings("[index.routing.allocation.include._tier] 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 testIndexExcludes() {
Expand Down Expand Up @@ -285,6 +294,8 @@ public void testIndexExcludes() {
d = decider.canRemain(shard, node, allocation);
assertThat(n.toString(), d.type(), equalTo(Decision.Type.YES));
}
assertWarnings("[index.routing.allocation.exclude._tier] 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 testIndexPrefer() {
Expand Down Expand Up @@ -428,6 +439,9 @@ public void testIndexPreferWithInclude() {
assertThat(node.toString(), d.getExplanation(),
containsString("index has a preference for tiers [data_warm,data_cold] and node has tier [data_warm]"));
}

assertWarnings("[index.routing.allocation.include._tier] 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 testIndexPreferWithExclude() {
Expand All @@ -453,6 +467,7 @@ public void testIndexPreferWithExclude() {
Decision d;
RoutingNode node;


for (DiscoveryNode n : Arrays.asList(HOT_NODE, COLD_NODE, CONTENT_NODE)) {
node = new RoutingNode(n.getId(), n, shard);
d = decider.canAllocate(shard, node, allocation);
Expand Down Expand Up @@ -490,6 +505,8 @@ public void testIndexPreferWithExclude() {
assertThat(node.toString(), d.getExplanation(),
containsString("node matches any index setting [index.routing.allocation.exclude._tier] tier filters [data_warm]"));
}
assertWarnings("[index.routing.allocation.exclude._tier] 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 testIndexPreferWithRequire() {
Expand Down Expand Up @@ -552,6 +569,8 @@ public void testIndexPreferWithRequire() {
assertThat(node.toString(), d.getExplanation(),
containsString("index has a preference for tiers [data_warm,data_cold] and node has tier [data_warm]"));
}
assertWarnings("[index.routing.allocation.require._tier] 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 testClusterAndIndex() {
Expand Down Expand Up @@ -601,6 +620,10 @@ public void testClusterAndIndex() {
d = decider.canRemain(shard, node, allocation);
assertThat(n.toString(), d.type(), equalTo(Decision.Type.YES));
}
assertWarnings("[cluster.routing.allocation.exclude._tier] setting was deprecated in Elasticsearch " +
"and will be removed in a future release! See the breaking changes documentation for the next major version.",
"[index.routing.allocation.include._tier] 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 testTierNodesPresent() {
Expand Down Expand Up @@ -670,7 +693,10 @@ public void testExistedClusterFilters() {
EmptySnapshotsInfoService.INSTANCE);

ClusterState clusterState = prepareState(service.reroute(ClusterState.EMPTY_STATE, "initial state"));

assertWarnings("[cluster.routing.allocation.include._tier] setting was deprecated in Elasticsearch " +
"and will be removed in a future release! See the breaking changes documentation for the next major version.",
"[cluster.routing.allocation.exclude._tier] setting was deprecated in Elasticsearch " +
"and will be removed in a future release! See the breaking changes documentation for the next major version.");
RoutingAllocation allocation = new RoutingAllocation(allocationDeciders, clusterState.getRoutingNodes(), clusterState,
null, null, 0);
allocation.debugDecision(true);
Expand Down Expand Up @@ -727,6 +753,12 @@ public void testFrozenIllegalForRegularIndices() {
Settings settings = builder.build();
IllegalArgumentException exception = expectThrows(IllegalArgumentException.class, () -> setting.get(settings));
assertThat(exception.getMessage(), equalTo("[data_frozen] tier can only be used for partial searchable snapshots"));
allowedWarnings("[index.routing.allocation.exclude._tier] setting was deprecated in Elasticsearch " +
"and will be removed in a future release! See the breaking changes documentation for the next major version.",
"[index.routing.allocation.include._tier] setting was deprecated in Elasticsearch " +
"and will be removed in a future release! See the breaking changes documentation for the next major version.",
"[index.routing.allocation.require._tier] 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 testFrozenLegalForPartialSnapshot() {
Expand All @@ -739,6 +771,12 @@ public void testFrozenLegalForPartialSnapshot() {

// validate do not throw
assertThat(setting.get(settings), equalTo(DATA_FROZEN));
allowedWarnings("[index.routing.allocation.exclude._tier] setting was deprecated in Elasticsearch " +
"and will be removed in a future release! See the breaking changes documentation for the next major version.",
"[index.routing.allocation.include._tier] setting was deprecated in Elasticsearch " +
"and will be removed in a future release! See the breaking changes documentation for the next major version.",
"[index.routing.allocation.require._tier] 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 testDefaultValueForPreference() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,8 @@ public void testIndexTemplatesWithMultipleTypes() throws IOException {
assertThat(issues, hasSize(1));
assertThat(issues.get(0).getDetails(),
equalTo("Index templates [multiple-types] define multiple types and so will cause errors when used in index creation"));
assertWarnings("Index template multiple-types contains multiple typed mappings;" +
" templates in 8x will only support a single mapping");

Metadata goodMetadata = Metadata.builder()
.templates(ImmutableOpenMap.<String, IndexTemplateMetadata>builder().fPut("single-type", singleType).build())
Expand Down

0 comments on commit 3c2adab

Please sign in to comment.