Skip to content

Commit 4dc5afc

Browse files
authored
Only include settings file for working ES versions (#116250)
To avoid failed cluster starts due to #91939 in upgrade tests, we should only include `settings.json` file if we are above the buggy version. I missed "forward-porting" this to main. A follow-up PR will port the suite over to the new parametrized upgrade test class and remove the settings file from the generic upgrade test flow altogether.
1 parent d66b5ae commit 4dc5afc

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

x-pack/qa/rolling-upgrade/build.gradle

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,14 @@ BuildParams.bwcVersions.withWireCompatible { bwcVersion, baseName ->
8888
keystore 'xpack.watcher.encryption_key', file("${project.projectDir}/src/test/resources/system_key")
8989
setting 'xpack.watcher.encrypt_sensitive_data', 'true'
9090

91-
extraConfigFile 'operator/settings.json', file("${project.projectDir}/src/test/resources/operator_defined_role_mappings.json")
91+
// file-based settings processing had a bug around applying role mappings on an unrecovered index
92+
// this was fixed in 8.7.0 (https://github.com/elastic/elasticsearch/pull/92173). To avoid flakiness
93+
// in the test, we only set a role mappings file for higher versions.
94+
// TODO move this out into a separate test suite, since operator settings are not relevant for most BWC tests
95+
// and have some side-effects
96+
if (bwcVersion.onOrAfter('8.7.0')) {
97+
extraConfigFile 'operator/settings.json', file("${project.projectDir}/src/test/resources/operator_defined_role_mappings.json")
98+
}
9299

93100
// Old versions of the code contain an invalid assertion that trips
94101
// during tests. Versions 5.6.9 and 6.2.4 have been fixed by removing

x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/SecurityIndexRoleMappingCleanupIT.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77
package org.elasticsearch.upgrades;
88

9+
import org.elasticsearch.Version;
910
import org.elasticsearch.client.Request;
1011
import org.elasticsearch.client.Response;
1112
import org.elasticsearch.client.RestClient;
@@ -24,8 +25,14 @@
2425
import static org.hamcrest.Matchers.containsInAnyOrder;
2526

2627
public class SecurityIndexRoleMappingCleanupIT extends AbstractUpgradeTestCase {
28+
private static final Version UPGRADE_FROM_VERSION = Version.fromString(System.getProperty("tests.upgrade_from_version"));
2729

2830
public void testCleanupDuplicateMappings() throws Exception {
31+
// see build.gradle where we set operator/settings.json for more details on this skip
32+
assumeTrue(
33+
"Cluster requires version higher than since operator/settings.json is only set then: " + Version.V_8_7_0,
34+
UPGRADE_FROM_VERSION.onOrAfter(Version.V_8_7_0)
35+
);
2936
if (CLUSTER_TYPE == ClusterType.OLD) {
3037
// If we're in a state where the same operator-defined role mappings can exist both in cluster state and the native store
3138
// (V_8_15_0 transport added to security.role_mapping_cleanup feature added), create a state

0 commit comments

Comments
 (0)