Skip to content

Commit ab7f7b4

Browse files
ywangdsalvatore-campagna
authored andcommitted
[Test] Move archived setting test into its own test class (elastic#116460)
As title says, the archived setting needs to be moved out to not interfere with other test methods in the same test class. Resolves: elastic#111798 Resolves: elastic#111777 Resolves: elastic#111774 Resolves: elastic#111799
1 parent fe04fab commit ab7f7b4

File tree

3 files changed

+100
-41
lines changed

3 files changed

+100
-41
lines changed

muted-tests.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ tests:
1111
- class: org.elasticsearch.xpack.restart.FullClusterRestartIT
1212
method: testDataStreams {cluster=UPGRADED}
1313
issue: https://github.com/elastic/elasticsearch/issues/111448
14-
- class: org.elasticsearch.upgrades.FullClusterRestartIT
15-
method: testSnapshotRestore {cluster=UPGRADED}
16-
issue: https://github.com/elastic/elasticsearch/issues/111798
1714
- class: org.elasticsearch.smoketest.WatcherYamlRestIT
1815
method: test {p0=watcher/usage/10_basic/Test watcher usage stats output}
1916
issue: https://github.com/elastic/elasticsearch/issues/112189
@@ -147,9 +144,6 @@ tests:
147144
- class: org.elasticsearch.backwards.MixedClusterClientYamlTestSuiteIT
148145
method: test {p0=cat.shards/10_basic/Help}
149146
issue: https://github.com/elastic/elasticsearch/issues/116110
150-
- class: org.elasticsearch.xpack.restart.CoreFullClusterRestartIT
151-
method: testSnapshotRestore {cluster=UPGRADED}
152-
issue: https://github.com/elastic/elasticsearch/issues/111799
153147
- class: org.elasticsearch.xpack.ml.integration.DatafeedJobsRestIT
154148
method: testLookbackWithIndicesOptions
155149
issue: https://github.com/elastic/elasticsearch/issues/116127
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
package org.elasticsearch.upgrades;
11+
12+
import io.netty.handler.codec.http.HttpMethod;
13+
14+
import com.carrotsearch.randomizedtesting.annotations.Name;
15+
16+
import org.elasticsearch.client.Request;
17+
import org.elasticsearch.client.RequestOptions;
18+
import org.elasticsearch.client.WarningsHandler;
19+
import org.elasticsearch.core.UpdateForV10;
20+
import org.elasticsearch.test.cluster.ElasticsearchCluster;
21+
import org.elasticsearch.test.cluster.FeatureFlag;
22+
import org.elasticsearch.test.cluster.local.LocalClusterConfigProvider;
23+
import org.elasticsearch.test.cluster.local.distribution.DistributionType;
24+
import org.elasticsearch.test.rest.ObjectPath;
25+
import org.junit.ClassRule;
26+
import org.junit.rules.RuleChain;
27+
import org.junit.rules.TemporaryFolder;
28+
import org.junit.rules.TestRule;
29+
30+
import static org.elasticsearch.cluster.routing.allocation.allocator.BalancedShardsAllocator.THRESHOLD_SETTING;
31+
32+
/**
33+
* Tests to run before and after a full cluster restart. This is run twice,
34+
* one with {@code tests.is_old_cluster} set to {@code true} against a cluster
35+
* of an older version. The cluster is shutdown and a cluster of the new
36+
* version is started with the same data directories and then this is rerun
37+
* with {@code tests.is_old_cluster} set to {@code false}.
38+
*/
39+
public class FullClusterRestartArchivedSettingsIT extends ParameterizedFullClusterRestartTestCase {
40+
41+
private static TemporaryFolder repoDirectory = new TemporaryFolder();
42+
43+
protected static LocalClusterConfigProvider clusterConfig = c -> {};
44+
45+
private static ElasticsearchCluster cluster = ElasticsearchCluster.local()
46+
.distribution(DistributionType.DEFAULT)
47+
.version(getOldClusterTestVersion())
48+
.nodes(2)
49+
.setting("path.repo", () -> repoDirectory.getRoot().getPath())
50+
.setting("xpack.security.enabled", "false")
51+
// some tests rely on the translog not being flushed
52+
.setting("indices.memory.shard_inactive_time", "60m")
53+
.apply(() -> clusterConfig)
54+
.feature(FeatureFlag.TIME_SERIES_MODE)
55+
.feature(FeatureFlag.FAILURE_STORE_ENABLED)
56+
.build();
57+
58+
@ClassRule
59+
public static TestRule ruleChain = RuleChain.outerRule(repoDirectory).around(cluster);
60+
61+
public FullClusterRestartArchivedSettingsIT(@Name("cluster") FullClusterRestartUpgradeStatus upgradeStatus) {
62+
super(upgradeStatus);
63+
}
64+
65+
@Override
66+
protected ElasticsearchCluster getUpgradeCluster() {
67+
return cluster;
68+
}
69+
70+
@UpdateForV10(owner = UpdateForV10.Owner.DISTRIBUTED_COORDINATION) // this test is just about v8->v9 upgrades, remove it in v10
71+
public void testBalancedShardsAllocatorThreshold() throws Exception {
72+
assumeTrue("test only applies for v8->v9 upgrades", getOldClusterTestVersion().getMajor() == 8);
73+
74+
final var chosenValue = randomFrom("0", "0.1", "0.5", "0.999");
75+
76+
if (isRunningAgainstOldCluster()) {
77+
final var request = newXContentRequest(
78+
HttpMethod.PUT,
79+
"/_cluster/settings",
80+
(builder, params) -> builder.startObject("persistent").field(THRESHOLD_SETTING.getKey(), chosenValue).endObject()
81+
);
82+
request.setOptions(RequestOptions.DEFAULT.toBuilder().setWarningsHandler(WarningsHandler.PERMISSIVE));
83+
assertOK(client().performRequest(request));
84+
}
85+
86+
final var clusterSettingsResponse = ObjectPath.createFromResponse(
87+
client().performRequest(new Request("GET", "/_cluster/settings"))
88+
);
89+
90+
final var settingsPath = "persistent." + THRESHOLD_SETTING.getKey();
91+
final var settingValue = clusterSettingsResponse.evaluate(settingsPath);
92+
93+
if (isRunningAgainstOldCluster()) {
94+
assertEquals(chosenValue, settingValue);
95+
} else {
96+
assertNull(settingValue);
97+
assertNotNull(clusterSettingsResponse.<String>evaluate("persistent.archived." + THRESHOLD_SETTING.getKey()));
98+
}
99+
}
100+
}

qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/upgrades/FullClusterRestartIT.java

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@
1616
import org.apache.http.util.EntityUtils;
1717
import org.elasticsearch.Build;
1818
import org.elasticsearch.client.Request;
19-
import org.elasticsearch.client.RequestOptions;
2019
import org.elasticsearch.client.Response;
2120
import org.elasticsearch.client.ResponseException;
2221
import org.elasticsearch.client.RestClient;
23-
import org.elasticsearch.client.WarningsHandler;
2422
import org.elasticsearch.cluster.metadata.IndexMetadata;
2523
import org.elasticsearch.cluster.metadata.MetadataIndexStateService;
2624
import org.elasticsearch.common.Strings;
@@ -29,7 +27,6 @@
2927
import org.elasticsearch.common.xcontent.support.XContentMapValues;
3028
import org.elasticsearch.core.Booleans;
3129
import org.elasticsearch.core.CheckedFunction;
32-
import org.elasticsearch.core.UpdateForV10;
3330
import org.elasticsearch.index.IndexSettings;
3431
import org.elasticsearch.index.IndexVersion;
3532
import org.elasticsearch.index.IndexVersions;
@@ -75,7 +72,6 @@
7572
import static java.util.stream.Collectors.toList;
7673
import static org.elasticsearch.cluster.metadata.IndexNameExpressionResolver.SYSTEM_INDEX_ENFORCEMENT_INDEX_VERSION;
7774
import static org.elasticsearch.cluster.routing.UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING;
78-
import static org.elasticsearch.cluster.routing.allocation.allocator.BalancedShardsAllocator.THRESHOLD_SETTING;
7975
import static org.elasticsearch.cluster.routing.allocation.decider.MaxRetryAllocationDecider.SETTING_ALLOCATION_MAX_RETRY;
8076
import static org.elasticsearch.test.MapMatcher.assertMap;
8177
import static org.elasticsearch.test.MapMatcher.matchesMap;
@@ -1959,35 +1955,4 @@ public static void assertNumHits(String index, int numHits, int totalShards) thr
19591955
assertThat(XContentMapValues.extractValue("_shards.successful", resp), equalTo(totalShards));
19601956
assertThat(extractTotalHits(resp), equalTo(numHits));
19611957
}
1962-
1963-
@UpdateForV10(owner = UpdateForV10.Owner.DISTRIBUTED_COORDINATION) // this test is just about v8->v9 upgrades, remove it in v10
1964-
public void testBalancedShardsAllocatorThreshold() throws Exception {
1965-
assumeTrue("test only applies for v8->v9 upgrades", getOldClusterTestVersion().getMajor() == 8);
1966-
1967-
final var chosenValue = randomFrom("0", "0.1", "0.5", "0.999");
1968-
1969-
if (isRunningAgainstOldCluster()) {
1970-
final var request = newXContentRequest(
1971-
HttpMethod.PUT,
1972-
"/_cluster/settings",
1973-
(builder, params) -> builder.startObject("persistent").field(THRESHOLD_SETTING.getKey(), chosenValue).endObject()
1974-
);
1975-
request.setOptions(RequestOptions.DEFAULT.toBuilder().setWarningsHandler(WarningsHandler.PERMISSIVE));
1976-
assertOK(client().performRequest(request));
1977-
}
1978-
1979-
final var clusterSettingsResponse = ObjectPath.createFromResponse(
1980-
client().performRequest(new Request("GET", "/_cluster/settings"))
1981-
);
1982-
1983-
final var settingsPath = "persistent." + THRESHOLD_SETTING.getKey();
1984-
final var settingValue = clusterSettingsResponse.evaluate(settingsPath);
1985-
1986-
if (isRunningAgainstOldCluster()) {
1987-
assertEquals(chosenValue, settingValue);
1988-
} else {
1989-
assertNull(settingValue);
1990-
assertNotNull(clusterSettingsResponse.<String>evaluate("persistent.archived." + THRESHOLD_SETTING.getKey()));
1991-
}
1992-
}
19931958
}

0 commit comments

Comments
 (0)