Browse Source

Introduce oldClusterHasFeatures to `full-cluster-restart` (#104462)

Remove Version-based prerequisites in favour of feature-based prerequisites in ParameterizedFullClusterRestartTestCase and derived.

Follows #104279
Lorenzo Dematté 1 year ago
parent
commit
f437b7416a

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

@@ -14,7 +14,6 @@ import com.carrotsearch.randomizedtesting.annotations.Name;
 
 import org.apache.http.util.EntityUtils;
 import org.elasticsearch.Build;
-import org.elasticsearch.Version;
 import org.elasticsearch.action.admin.cluster.settings.RestClusterGetSettingsResponse;
 import org.elasticsearch.client.Request;
 import org.elasticsearch.client.Response;
@@ -266,10 +265,7 @@ public class FullClusterRestartIT extends ParameterizedFullClusterRestartTestCas
     }
 
     public void testSearchTimeSeriesMode() throws Exception {
-
-        var originalClusterHasNewTimeSeriesIndexing = parseLegacyVersion(getOldClusterVersion()).map(v -> v.onOrAfter(Version.V_8_2_0))
-            .orElse(true);
-        assumeTrue("indexing time series indices changed in 8.2.0", originalClusterHasNewTimeSeriesIndexing);
+        assumeTrue("indexing time series indices changed in 8.2.0", oldClusterHasFeature(RestTestLegacyFeatures.TSDB_NEW_INDEX_FORMAT));
         int numDocs;
         if (isRunningAgainstOldCluster()) {
             numDocs = createTimeSeriesModeIndex(1);
@@ -307,9 +303,7 @@ public class FullClusterRestartIT extends ParameterizedFullClusterRestartTestCas
     }
 
     public void testNewReplicasTimeSeriesMode() throws Exception {
-        var originalClusterHasNewTimeSeriesIndexing = parseLegacyVersion(getOldClusterVersion()).map(v -> v.onOrAfter(Version.V_8_2_0))
-            .orElse(true);
-        assumeTrue("indexing time series indices changed in 8.2.0", originalClusterHasNewTimeSeriesIndexing);
+        assumeTrue("indexing time series indices changed in 8.2.0", oldClusterHasFeature(RestTestLegacyFeatures.TSDB_NEW_INDEX_FORMAT));
         if (isRunningAgainstOldCluster()) {
             createTimeSeriesModeIndex(0);
         } else {
@@ -1216,9 +1210,7 @@ public class FullClusterRestartIT extends ParameterizedFullClusterRestartTestCas
         }
 
         @UpdateForV9 // This check can be removed (always assume true)
-        var originalClusterSupportsReplicationOfClosedIndices = parseLegacyVersion(getOldClusterVersion()).map(
-            v -> v.onOrAfter(Version.V_7_2_0)
-        ).orElse(true);
+        var originalClusterSupportsReplicationOfClosedIndices = oldClusterHasFeature(RestTestLegacyFeatures.REPLICATION_OF_CLOSED_INDICES);
 
         if (originalClusterSupportsReplicationOfClosedIndices) {
             ensureGreenLongWait(index);
@@ -1624,9 +1616,7 @@ public class FullClusterRestartIT extends ParameterizedFullClusterRestartTestCas
     public void testSystemIndexMetadataIsUpgraded() throws Exception {
 
         @UpdateForV9 // assumeTrue can be removed (condition always true)
-        var originalClusterTaskIndexIsSystemIndex = parseLegacyVersion(getOldClusterVersion()).map(v -> v.onOrAfter(Version.V_7_10_0))
-            .orElse(true);
-
+        var originalClusterTaskIndexIsSystemIndex = oldClusterHasFeature(RestTestLegacyFeatures.TASK_INDEX_SYSTEM_INDEX);
         assumeTrue(".tasks became a system index in 7.10.0", originalClusterTaskIndexIsSystemIndex);
         final String systemIndexWarning = "this request accesses system indices: [.tasks], but in a future major version, direct "
             + "access to system indices will be prevented by default";
@@ -1748,8 +1738,7 @@ public class FullClusterRestartIT extends ParameterizedFullClusterRestartTestCas
      */
     @UpdateForV9 // This test can be removed in v9
     public void testEnableSoftDeletesOnRestore() throws Exception {
-        var originalClusterDidNotEnforceSoftDeletes = parseLegacyVersion(getOldClusterVersion()).map(v -> v.before(Version.V_8_0_0))
-            .orElse(false);
+        var originalClusterDidNotEnforceSoftDeletes = oldClusterHasFeature(RestTestLegacyFeatures.SOFT_DELETES_ENFORCED) == false;
 
         assumeTrue("soft deletes must be enabled on 8.0+", originalClusterDidNotEnforceSoftDeletes);
         final String snapshot = "snapshot-" + index;
@@ -1862,9 +1851,8 @@ public class FullClusterRestartIT extends ParameterizedFullClusterRestartTestCas
      */
     @UpdateForV9
     public void testTransportCompressionSetting() throws IOException {
-        var originalClusterCompressSettingIsBoolean = parseLegacyVersion(getOldClusterVersion()).map(v -> v.before(Version.V_7_14_0))
-            .orElse(false);
-        assumeTrue("the old transport.compress setting existed before 7.14", originalClusterCompressSettingIsBoolean);
+        var originalClusterBooleanCompressSetting = oldClusterHasFeature(RestTestLegacyFeatures.NEW_TRANSPORT_COMPRESSED_SETTING) == false;
+        assumeTrue("the old transport.compress setting existed before 7.14", originalClusterBooleanCompressSetting);
         if (isRunningAgainstOldCluster()) {
             client().performRequest(
                 newXContentRequest(

+ 23 - 0
qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/upgrades/ParameterizedFullClusterRestartTestCase.java

@@ -14,6 +14,7 @@ import com.carrotsearch.randomizedtesting.annotations.TestCaseOrdering;
 
 import org.elasticsearch.client.Request;
 import org.elasticsearch.client.Response;
+import org.elasticsearch.features.NodeFeature;
 import org.elasticsearch.index.IndexVersion;
 import org.elasticsearch.index.IndexVersions;
 import org.elasticsearch.test.cluster.ElasticsearchCluster;
@@ -26,6 +27,7 @@ import org.junit.Before;
 import java.util.Arrays;
 import java.util.Locale;
 import java.util.Map;
+import java.util.Set;
 
 import static org.elasticsearch.upgrades.FullClusterRestartUpgradeStatus.OLD;
 import static org.elasticsearch.upgrades.FullClusterRestartUpgradeStatus.UPGRADED;
@@ -39,6 +41,8 @@ public abstract class ParameterizedFullClusterRestartTestCase extends ESRestTest
     private static IndexVersion oldIndexVersion;
     private static boolean upgradeFailed = false;
     private static boolean upgraded = false;
+
+    private static Set<String> oldClusterFeatures;
     private final FullClusterRestartUpgradeStatus requestedUpgradeStatus;
 
     public ParameterizedFullClusterRestartTestCase(@Name("cluster") FullClusterRestartUpgradeStatus upgradeStatus) {
@@ -50,6 +54,15 @@ public abstract class ParameterizedFullClusterRestartTestCase extends ESRestTest
         return Arrays.stream(FullClusterRestartUpgradeStatus.values()).map(v -> new Object[] { v }).toList();
     }
 
+    @Before
+    public void extractOldClusterFeatures() {
+        if (upgraded == false && oldClusterFeatures == null) {
+            assert testFeatureServiceInitialized()
+                : "Old cluster features can be extracted only after testFeatureService has been initialized. See ESRestTestCase#initClient";
+            oldClusterFeatures = Set.copyOf(testFeatureService.getAllSupportedFeatures());
+        }
+    }
+
     @Before
     public void extractOldIndexVersion() throws Exception {
         if (upgraded == false) {
@@ -111,6 +124,7 @@ public abstract class ParameterizedFullClusterRestartTestCase extends ESRestTest
     public static void resetUpgrade() {
         upgraded = false;
         upgradeFailed = false;
+        oldClusterFeatures = null;
     }
 
     public boolean isRunningAgainstOldCluster() {
@@ -121,6 +135,15 @@ public abstract class ParameterizedFullClusterRestartTestCase extends ESRestTest
         return OLD_CLUSTER_VERSION;
     }
 
+    protected static boolean oldClusterHasFeature(String featureId) {
+        assert oldClusterFeatures != null : "Old cluster features cannot be accessed before initialization is completed";
+        return oldClusterFeatures.contains(featureId);
+    }
+
+    protected static boolean oldClusterHasFeature(NodeFeature feature) {
+        return oldClusterHasFeature(feature.id());
+    }
+
     public static IndexVersion getOldClusterIndexVersion() {
         assert oldIndexVersion != null;
         return oldIndexVersion;

+ 2 - 5
qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/upgrades/QueryBuilderBWCIT.java

@@ -42,6 +42,7 @@ import org.elasticsearch.test.cluster.ElasticsearchCluster;
 import org.elasticsearch.test.cluster.FeatureFlag;
 import org.elasticsearch.test.cluster.local.LocalClusterConfigProvider;
 import org.elasticsearch.test.cluster.local.distribution.DistributionType;
+import org.elasticsearch.test.rest.RestTestLegacyFeatures;
 import org.elasticsearch.xcontent.XContentBuilder;
 import org.junit.ClassRule;
 
@@ -53,7 +54,6 @@ import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 
-import static org.elasticsearch.cluster.ClusterState.VERSION_INTRODUCING_TRANSPORT_VERSIONS;
 import static org.elasticsearch.xcontent.XContentFactory.jsonBuilder;
 
 /**
@@ -255,10 +255,7 @@ public class QueryBuilderBWCIT extends ParameterizedFullClusterRestartTestCase {
                 ) {
 
                     @UpdateForV9 // condition will always be true
-                    var originalClusterHasTransportVersion = parseLegacyVersion(getOldClusterVersion()).map(
-                        v -> v.onOrAfter(VERSION_INTRODUCING_TRANSPORT_VERSIONS)
-                    ).orElse(true);
-
+                    var originalClusterHasTransportVersion = oldClusterHasFeature(RestTestLegacyFeatures.TRANSPORT_VERSION_SUPPORTED);
                     final TransportVersion transportVersion;
                     if (originalClusterHasTransportVersion == false) {
                         transportVersion = TransportVersion.fromId(

+ 8 - 1
qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/FeatureUpgradeIT.java

@@ -100,7 +100,14 @@ public class FeatureUpgradeIT extends ParameterizedRollingUpgradeTestCase {
 
                 assertThat(feature, aMapWithSize(4));
                 assertThat(feature.get("minimum_index_version"), equalTo(getOldClusterIndexVersion().toString()));
-                if (getOldClusterVersion().before(TransportGetFeatureUpgradeStatusAction.NO_UPGRADE_REQUIRED_VERSION)) {
+
+                // Feature migration happens only across major versions; also, we usually begin to require migrations once we start testing
+                // for the next major version upgrade (see e.g. #93666). Trying to express this with features may be problematic, so we
+                // want to keep using versions here. We also assume that for non-semantic version migrations are not required.
+                boolean migrationNeeded = parseLegacyVersion(getOldClusterVersion()).map(
+                    v -> v.before(TransportGetFeatureUpgradeStatusAction.NO_UPGRADE_REQUIRED_VERSION)
+                ).orElse(false);
+                if (migrationNeeded) {
                     assertThat(feature.get("migration_status"), equalTo("MIGRATION_NEEDED"));
                 } else {
                     assertThat(feature.get("migration_status"), equalTo("NO_MIGRATION_NEEDED"));

+ 6 - 4
qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/ParameterizedRollingUpgradeTestCase.java

@@ -17,6 +17,7 @@ import org.elasticsearch.common.settings.Settings;
 import org.elasticsearch.core.SuppressForbidden;
 import org.elasticsearch.features.NodeFeature;
 import org.elasticsearch.index.IndexVersion;
+import org.elasticsearch.index.IndexVersions;
 import org.elasticsearch.test.cluster.ElasticsearchCluster;
 import org.elasticsearch.test.cluster.FeatureFlag;
 import org.elasticsearch.test.cluster.local.distribution.DistributionType;
@@ -99,12 +100,13 @@ public abstract class ParameterizedRollingUpgradeTestCase extends ESRestTestCase
             Map<String, Object> nodeMap = objectPath.evaluate("nodes");
             for (String id : nodeMap.keySet()) {
                 Number ix = objectPath.evaluate("nodes." + id + ".index_version");
-                IndexVersion version;
+                final IndexVersion version;
                 if (ix != null) {
                     version = IndexVersion.fromId(ix.intValue());
                 } else {
                     // it doesn't have index version (pre 8.11) - just infer it from the release version
-                    version = IndexVersion.fromId(getOldClusterVersion().id);
+                    version = parseLegacyVersion(getOldClusterVersion()).map(v -> IndexVersion.fromId(v.id))
+                        .orElse(IndexVersions.MINIMUM_COMPATIBLE);
                 }
 
                 if (indexVersion == null) {
@@ -152,8 +154,8 @@ public abstract class ParameterizedRollingUpgradeTestCase extends ESRestTestCase
     }
 
     @Deprecated // Use the new testing framework and oldClusterHasFeature(feature) instead
-    protected static org.elasticsearch.Version getOldClusterVersion() {
-        return org.elasticsearch.Version.fromString(OLD_CLUSTER_VERSION);
+    protected static String getOldClusterVersion() {
+        return OLD_CLUSTER_VERSION;
     }
 
     protected static boolean oldClusterHasFeature(String featureId) {

+ 6 - 2
test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java

@@ -274,6 +274,10 @@ public abstract class ESRestTestCase extends ESTestCase {
         return testFeatureService.clusterHasFeature(feature.id());
     }
 
+    protected static boolean testFeatureServiceInitialized() {
+        return testFeatureService != ALL_FEATURES;
+    }
+
     @Before
     public void initClient() throws IOException {
         if (client == null) {
@@ -281,7 +285,7 @@ public abstract class ESRestTestCase extends ESTestCase {
             assert clusterHosts == null;
             assert availableFeatures == null;
             assert nodesVersions == null;
-            assert testFeatureService == ALL_FEATURES;
+            assert testFeatureServiceInitialized() == false;
             clusterHosts = parseClusterHosts(getTestRestCluster());
             logger.info("initializing REST clients against {}", clusterHosts);
             client = buildClient(restClientSettings(), clusterHosts.toArray(new HttpHost[clusterHosts.size()]));
@@ -343,7 +347,7 @@ public abstract class ESRestTestCase extends ESTestCase {
             testFeatureService = createTestFeatureService(getClusterStateFeatures(adminClient), semanticNodeVersions);
         }
 
-        assert testFeatureService != ALL_FEATURES;
+        assert testFeatureServiceInitialized();
         assert client != null;
         assert adminClient != null;
         assert clusterHosts != null;

+ 39 - 1
test/framework/src/main/java/org/elasticsearch/test/rest/RestTestLegacyFeatures.java

@@ -97,6 +97,32 @@ public class RestTestLegacyFeatures implements FeatureSpecification {
     public static final NodeFeature INDEXING_SLOWLOG_LEVEL_SETTING_REMOVED = new NodeFeature("settings.indexing_slowlog_level_removed");
     public static final NodeFeature DEPRECATION_WARNINGS_LEAK_FIXED = new NodeFeature("deprecation_warnings_leak_fixed");
 
+    // QA - Full cluster restart
+    @UpdateForV9
+    public static final NodeFeature REPLICATION_OF_CLOSED_INDICES = new NodeFeature("indices.closed_replication_supported");
+    @UpdateForV9
+    public static final NodeFeature TASK_INDEX_SYSTEM_INDEX = new NodeFeature("tasks.moved_to_system_index");
+    @UpdateForV9
+    public static final NodeFeature SOFT_DELETES_ENFORCED = new NodeFeature("indices.soft_deletes_enforced");
+    @UpdateForV9
+    public static final NodeFeature NEW_TRANSPORT_COMPRESSED_SETTING = new NodeFeature("transport.new_compressed_setting");
+    @UpdateForV9
+    public static final NodeFeature SHUTDOWN_SUPPORTED = new NodeFeature("shutdown.supported");
+    @UpdateForV9
+    public static final NodeFeature SERVICE_ACCOUNTS_SUPPORTED = new NodeFeature("auth.service_accounts_supported");
+    @UpdateForV9
+    public static final NodeFeature TRANSFORM_SUPPORTED = new NodeFeature("transform.supported");
+    @UpdateForV9
+    public static final NodeFeature SLM_SUPPORTED = new NodeFeature("slm.supported");
+    @UpdateForV9
+    public static final NodeFeature DATA_STREAMS_SUPPORTED = new NodeFeature("data_stream.supported");
+    @UpdateForV9
+    public static final NodeFeature NEW_DATA_STREAMS_INDEX_NAME_FORMAT = new NodeFeature("data_stream.new_index_name_format");
+    @UpdateForV9
+    public static final NodeFeature DISABLE_FIELD_NAMES_FIELD_REMOVED = new NodeFeature("disable_of_field_names_field_removed");
+    @UpdateForV9
+    public static final NodeFeature ML_NLP_SUPPORTED = new NodeFeature("ml.nlp_supported");
+
     // YAML
     public static final NodeFeature REST_ELASTIC_PRODUCT_HEADER_PRESENT = new NodeFeature("action.rest.product_header_present");
 
@@ -133,7 +159,19 @@ public class RestTestLegacyFeatures implements FeatureSpecification {
             entry(TSDB_GENERALLY_AVAILABLE, Version.V_8_7_0),
             entry(TSDB_EMPTY_TEMPLATE_FIXED, Version.V_8_11_0),
             entry(INDEXING_SLOWLOG_LEVEL_SETTING_REMOVED, Version.V_8_0_0),
-            entry(DEPRECATION_WARNINGS_LEAK_FIXED, Version.V_7_17_9)
+            entry(DEPRECATION_WARNINGS_LEAK_FIXED, Version.V_7_17_9),
+            entry(REPLICATION_OF_CLOSED_INDICES, Version.V_7_2_0),
+            entry(TASK_INDEX_SYSTEM_INDEX, Version.V_7_10_0),
+            entry(SOFT_DELETES_ENFORCED, Version.V_8_0_0),
+            entry(NEW_TRANSPORT_COMPRESSED_SETTING, Version.V_7_14_0),
+            entry(SHUTDOWN_SUPPORTED, Version.V_7_15_0),
+            entry(SERVICE_ACCOUNTS_SUPPORTED, Version.V_7_13_0),
+            entry(TRANSFORM_SUPPORTED, Version.V_7_2_0),
+            entry(SLM_SUPPORTED, Version.V_7_4_0),
+            entry(DATA_STREAMS_SUPPORTED, Version.V_7_9_0),
+            entry(NEW_DATA_STREAMS_INDEX_NAME_FORMAT, Version.V_7_11_0),
+            entry(DISABLE_FIELD_NAMES_FIELD_REMOVED, Version.V_8_0_0),
+            entry(ML_NLP_SUPPORTED, Version.V_8_0_0)
         );
     }
 }

+ 5 - 6
x-pack/plugin/shutdown/qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/xpack/restart/FullClusterRestartIT.java

@@ -8,7 +8,6 @@ package org.elasticsearch.xpack.restart;
 
 import com.carrotsearch.randomizedtesting.annotations.Name;
 
-import org.elasticsearch.Version;
 import org.elasticsearch.client.Request;
 import org.elasticsearch.client.Response;
 import org.elasticsearch.cluster.metadata.SingleNodeShutdownMetadata;
@@ -21,11 +20,12 @@ import org.elasticsearch.test.cluster.FeatureFlag;
 import org.elasticsearch.test.cluster.local.distribution.DistributionType;
 import org.elasticsearch.test.cluster.util.resource.Resource;
 import org.elasticsearch.test.rest.ESRestTestCase;
+import org.elasticsearch.test.rest.RestTestLegacyFeatures;
 import org.elasticsearch.upgrades.FullClusterRestartUpgradeStatus;
 import org.elasticsearch.upgrades.ParameterizedFullClusterRestartTestCase;
 import org.elasticsearch.xcontent.XContentBuilder;
 import org.elasticsearch.xcontent.json.JsonXContent;
-import org.junit.BeforeClass;
+import org.junit.Before;
 import org.junit.ClassRule;
 
 import java.io.IOException;
@@ -88,11 +88,10 @@ public class FullClusterRestartIT extends ParameterizedFullClusterRestartTestCas
             .build();
     }
 
-    @BeforeClass
-    public static void checkClusterVersion() {
+    @Before
+    public void checkClusterVersion() {
         @UpdateForV9 // always true
-        var originalClusterSupportsShutdown = parseLegacyVersion(getOldClusterVersion()).map(v -> v.onOrAfter(Version.V_7_15_0))
-            .orElse(true);
+        var originalClusterSupportsShutdown = oldClusterHasFeature(RestTestLegacyFeatures.SHUTDOWN_SUPPORTED);
         assumeTrue("no shutdown in versions before 7.15", originalClusterSupportsShutdown);
     }
 

+ 11 - 11
x-pack/qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/xpack/restart/FullClusterRestartIT.java

@@ -11,7 +11,6 @@ import com.carrotsearch.randomizedtesting.annotations.Name;
 import org.apache.http.entity.ContentType;
 import org.apache.http.entity.StringEntity;
 import org.apache.http.util.EntityUtils;
-import org.elasticsearch.Version;
 import org.elasticsearch.client.Request;
 import org.elasticsearch.client.RequestOptions;
 import org.elasticsearch.client.Response;
@@ -294,8 +293,7 @@ public class FullClusterRestartIT extends AbstractXpackFullClusterRestartTestCas
 
     public void testServiceAccountApiKey() throws IOException {
         @UpdateForV9
-        var originalClusterSupportsServiceAccounts = parseLegacyVersion(getOldClusterVersion()).map(v -> v.onOrAfter(Version.V_7_13_0))
-            .orElse(true);
+        var originalClusterSupportsServiceAccounts = oldClusterHasFeature(RestTestLegacyFeatures.SERVICE_ACCOUNTS_SUPPORTED);
         assumeTrue("no service accounts in versions before 7.13", originalClusterSupportsServiceAccounts);
 
         if (isRunningAgainstOldCluster()) {
@@ -506,8 +504,7 @@ public class FullClusterRestartIT extends AbstractXpackFullClusterRestartTestCas
 
     public void testTransformLegacyTemplateCleanup() throws Exception {
         @UpdateForV9
-        var originalClusterSupportsTransform = parseLegacyVersion(getOldClusterVersion()).map(v -> v.onOrAfter(Version.V_7_2_0))
-            .orElse(true);
+        var originalClusterSupportsTransform = oldClusterHasFeature(RestTestLegacyFeatures.TRANSFORM_SUPPORTED);
         assumeTrue("Before 7.2 transforms didn't exist", originalClusterSupportsTransform);
 
         if (isRunningAgainstOldCluster()) {
@@ -589,7 +586,7 @@ public class FullClusterRestartIT extends AbstractXpackFullClusterRestartTestCas
 
     public void testSlmPolicyAndStats() throws IOException {
         @UpdateForV9
-        var originalClusterSupportsSlm = parseLegacyVersion(getOldClusterVersion()).map(v -> v.onOrAfter(Version.V_7_4_0)).orElse(true);
+        var originalClusterSupportsSlm = oldClusterHasFeature(RestTestLegacyFeatures.SLM_SUPPORTED);
 
         SnapshotLifecyclePolicy slmPolicy = new SnapshotLifecyclePolicy(
             "test-policy",
@@ -942,12 +939,10 @@ public class FullClusterRestartIT extends AbstractXpackFullClusterRestartTestCas
     public void testDataStreams() throws Exception {
 
         @UpdateForV9
-        var originalClusterSupportsDataStreams = parseLegacyVersion(getOldClusterVersion()).map(v -> v.onOrAfter(Version.V_7_9_0))
-            .orElse(true);
+        var originalClusterSupportsDataStreams = oldClusterHasFeature(RestTestLegacyFeatures.DATA_STREAMS_SUPPORTED);
 
         @UpdateForV9
-        var originalClusterDataStreamHasDateInIndexName = parseLegacyVersion(getOldClusterVersion()).map(v -> v.onOrAfter(Version.V_7_11_0))
-            .orElse(true);
+        var originalClusterDataStreamHasDateInIndexName = oldClusterHasFeature(RestTestLegacyFeatures.NEW_DATA_STREAMS_INDEX_NAME_FORMAT);
 
         assumeTrue("no data streams in versions before 7.9.0", originalClusterSupportsDataStreams);
         if (isRunningAgainstOldCluster()) {
@@ -995,8 +990,13 @@ public class FullClusterRestartIT extends AbstractXpackFullClusterRestartTestCas
     /**
      * Tests that a single document survives. Super basic smoke test.
      */
+    @UpdateForV9 // Can be removed
     public void testDisableFieldNameField() throws IOException {
-        assumeTrue("can only disable field names field before 8.0", Version.fromString(getOldClusterVersion()).before(Version.V_8_0_0));
+        assumeFalse(
+            "can only disable field names field before 8.0",
+            oldClusterHasFeature(RestTestLegacyFeatures.DISABLE_FIELD_NAMES_FIELD_REMOVED)
+        );
+
         String docLocation = "/nofnf/_doc/1";
         String doc = """
             {

+ 4 - 5
x-pack/qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/xpack/restart/MLModelDeploymentFullClusterRestartIT.java

@@ -11,7 +11,6 @@ import com.carrotsearch.randomizedtesting.annotations.Name;
 
 import org.apache.http.util.EntityUtils;
 import org.apache.lucene.tests.util.LuceneTestCase;
-import org.elasticsearch.Version;
 import org.elasticsearch.client.Request;
 import org.elasticsearch.client.Response;
 import org.elasticsearch.client.ResponseException;
@@ -20,6 +19,7 @@ import org.elasticsearch.common.util.concurrent.ThreadContext;
 import org.elasticsearch.common.xcontent.support.XContentMapValues;
 import org.elasticsearch.core.Strings;
 import org.elasticsearch.core.UpdateForV9;
+import org.elasticsearch.test.rest.RestTestLegacyFeatures;
 import org.elasticsearch.upgrades.FullClusterRestartUpgradeStatus;
 import org.elasticsearch.xpack.core.ml.inference.assignment.AllocationStatus;
 import org.junit.Before;
@@ -93,10 +93,9 @@ public class MLModelDeploymentFullClusterRestartIT extends AbstractXpackFullClus
     }
 
     public void testDeploymentSurvivesRestart() throws Exception {
-        @UpdateForV9 // upgrade will always be from v8, condition can be removed
-        var originalClusterAtLeastV8 = parseLegacyVersion(getOldClusterVersion()).map(v -> v.onOrAfter(Version.V_8_0_0)).orElse(true);
-        // These tests assume the original cluster is v8 - testing for features on the _current_ cluster will break for NEW
-        assumeTrue("NLP model deployments added in 8.0", originalClusterAtLeastV8);
+        @UpdateForV9 // condition will always be true from v8, can be removed
+        var originalClusterSupportsNlpModels = oldClusterHasFeature(RestTestLegacyFeatures.ML_NLP_SUPPORTED);
+        assumeTrue("NLP model deployments added in 8.0", originalClusterSupportsNlpModels);
 
         String modelId = "trained-model-full-cluster-restart";