Skip to content

Commit 68d38a6

Browse files
authored
Fix intermittent FileSettingsRoleMappingUpgradeIT failures (elastic#118455)
Fixes: elastic#118311 elastic#118310 elastic#118309 Same issue that was fixed in: elastic#110963 `@BeforeClass` is executed after the test rules. This means it creates the clusters for all the invalid versions, which sometimes doesnt work. Change it to a rule which definitely evaluates before the clusters are created. This will also speed up this test in CI.
1 parent 1e2b699 commit 68d38a6

File tree

2 files changed

+9
-19
lines changed

2 files changed

+9
-19
lines changed

muted-tests.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -444,12 +444,3 @@ tests:
444444
- class: org.elasticsearch.reservedstate.service.RepositoriesFileSettingsIT
445445
method: testSettingsApplied
446446
issue: https://github.com/elastic/elasticsearch/issues/116694
447-
- class: org.elasticsearch.upgrades.FileSettingsRoleMappingUpgradeIT
448-
method: testRoleMappingsAppliedOnUpgrade {upgradedNodes=3}
449-
issue: https://github.com/elastic/elasticsearch/issues/118311
450-
- class: org.elasticsearch.upgrades.FileSettingsRoleMappingUpgradeIT
451-
method: testRoleMappingsAppliedOnUpgrade {upgradedNodes=1}
452-
issue: https://github.com/elastic/elasticsearch/issues/118309
453-
- class: org.elasticsearch.upgrades.FileSettingsRoleMappingUpgradeIT
454-
method: testRoleMappingsAppliedOnUpgrade {upgradedNodes=2}
455-
issue: https://github.com/elastic/elasticsearch/issues/118310

qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/FileSettingsRoleMappingUpgradeIT.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@
1616
import org.elasticsearch.test.XContentTestUtils;
1717
import org.elasticsearch.test.cluster.ElasticsearchCluster;
1818
import org.elasticsearch.test.cluster.local.distribution.DistributionType;
19+
import org.elasticsearch.test.cluster.util.Version;
1920
import org.elasticsearch.test.cluster.util.resource.Resource;
20-
import org.junit.Before;
21+
import org.elasticsearch.test.junit.RunnableTestRuleAdapter;
2122
import org.junit.ClassRule;
2223
import org.junit.rules.RuleChain;
2324
import org.junit.rules.TemporaryFolder;
@@ -70,9 +71,15 @@ public String get() {
7071
.setting("xpack.security.authc.anonymous.roles", "superuser")
7172
.configFile("operator/settings.json", Resource.fromString(SETTING_JSON))
7273
.build();
74+
private static final RunnableTestRuleAdapter versionLimit = new RunnableTestRuleAdapter(
75+
() -> assumeTrue(
76+
"Only relevant when upgrading from a version before role mappings were stored in cluster state",
77+
getOldClusterTestVersion().after(new Version(8, 7, 0)) && getOldClusterTestVersion().before(new Version(8, 15, 0))
78+
)
79+
);
7380

7481
@ClassRule
75-
public static TestRule ruleChain = RuleChain.outerRule(repoDirectory).around(cluster);
82+
public static TestRule ruleChain = RuleChain.outerRule(versionLimit).around(repoDirectory).around(cluster);
7683

7784
public FileSettingsRoleMappingUpgradeIT(@Name("upgradedNodes") int upgradedNodes) {
7885
super(upgradedNodes);
@@ -83,14 +90,6 @@ protected ElasticsearchCluster getUpgradeCluster() {
8390
return cluster;
8491
}
8592

86-
@Before
87-
public void checkVersions() {
88-
assumeTrue(
89-
"Only relevant when upgrading from a version before role mappings were stored in cluster state",
90-
oldClusterHasFeature("gte_v8.7.0") && oldClusterHasFeature("gte_v8.15.0") == false
91-
);
92-
}
93-
9493
private static void waitForSecurityMigrationCompletionIfIndexExists() throws Exception {
9594
final Request request = new Request("GET", "_cluster/state/metadata/.security-7");
9695
assertBusy(() -> {

0 commit comments

Comments
 (0)