Skip to content

Commit

Permalink
Fix intermittent FileSettingsRoleMappingUpgradeIT failures (elastic#1…
Browse files Browse the repository at this point in the history
…18455)

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.
  • Loading branch information
jfreden authored Dec 12, 2024
1 parent 1e2b699 commit 68d38a6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 19 deletions.
9 changes: 0 additions & 9 deletions muted-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -444,12 +444,3 @@ tests:
- class: org.elasticsearch.reservedstate.service.RepositoriesFileSettingsIT
method: testSettingsApplied
issue: https://github.com/elastic/elasticsearch/issues/116694
- class: org.elasticsearch.upgrades.FileSettingsRoleMappingUpgradeIT
method: testRoleMappingsAppliedOnUpgrade {upgradedNodes=3}
issue: https://github.com/elastic/elasticsearch/issues/118311
- class: org.elasticsearch.upgrades.FileSettingsRoleMappingUpgradeIT
method: testRoleMappingsAppliedOnUpgrade {upgradedNodes=1}
issue: https://github.com/elastic/elasticsearch/issues/118309
- class: org.elasticsearch.upgrades.FileSettingsRoleMappingUpgradeIT
method: testRoleMappingsAppliedOnUpgrade {upgradedNodes=2}
issue: https://github.com/elastic/elasticsearch/issues/118310
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
import org.elasticsearch.test.XContentTestUtils;
import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.elasticsearch.test.cluster.local.distribution.DistributionType;
import org.elasticsearch.test.cluster.util.Version;
import org.elasticsearch.test.cluster.util.resource.Resource;
import org.junit.Before;
import org.elasticsearch.test.junit.RunnableTestRuleAdapter;
import org.junit.ClassRule;
import org.junit.rules.RuleChain;
import org.junit.rules.TemporaryFolder;
Expand Down Expand Up @@ -70,9 +71,15 @@ public String get() {
.setting("xpack.security.authc.anonymous.roles", "superuser")
.configFile("operator/settings.json", Resource.fromString(SETTING_JSON))
.build();
private static final RunnableTestRuleAdapter versionLimit = new RunnableTestRuleAdapter(
() -> assumeTrue(
"Only relevant when upgrading from a version before role mappings were stored in cluster state",
getOldClusterTestVersion().after(new Version(8, 7, 0)) && getOldClusterTestVersion().before(new Version(8, 15, 0))
)
);

@ClassRule
public static TestRule ruleChain = RuleChain.outerRule(repoDirectory).around(cluster);
public static TestRule ruleChain = RuleChain.outerRule(versionLimit).around(repoDirectory).around(cluster);

public FileSettingsRoleMappingUpgradeIT(@Name("upgradedNodes") int upgradedNodes) {
super(upgradedNodes);
Expand All @@ -83,14 +90,6 @@ protected ElasticsearchCluster getUpgradeCluster() {
return cluster;
}

@Before
public void checkVersions() {
assumeTrue(
"Only relevant when upgrading from a version before role mappings were stored in cluster state",
oldClusterHasFeature("gte_v8.7.0") && oldClusterHasFeature("gte_v8.15.0") == false
);
}

private static void waitForSecurityMigrationCompletionIfIndexExists() throws Exception {
final Request request = new Request("GET", "_cluster/state/metadata/.security-7");
assertBusy(() -> {
Expand Down

0 comments on commit 68d38a6

Please sign in to comment.