Skip to content

Commit

Permalink
Fix intermittent FileSettingsRoleMappingUpgradeIT failures
Browse files Browse the repository at this point in the history
  • Loading branch information
jfreden committed Dec 11, 2024
1 parent 20f7919 commit ddef02d
Showing 1 changed file with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@
package org.elasticsearch.upgrades;

import com.carrotsearch.randomizedtesting.annotations.Name;

import org.elasticsearch.client.Request;
import org.elasticsearch.core.SuppressForbidden;
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.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 +69,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",
oldClusterHasFeature("gte_v8.7.0") && oldClusterHasFeature("gte_v8.15.0") == false
));


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

public FileSettingsRoleMappingUpgradeIT(@Name("upgradedNodes") int upgradedNodes) {
super(upgradedNodes);
Expand All @@ -83,14 +88,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 ddef02d

Please sign in to comment.