Skip to content

Commit fcdfa5b

Browse files
authored
Remove some easy/straightforward instances of UpdateForV9 (#114134)
1 parent 3c5b74b commit fcdfa5b

File tree

13 files changed

+26
-298
lines changed

13 files changed

+26
-298
lines changed

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

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1602,10 +1602,6 @@ public void testResize() throws Exception {
16021602

16031603
@SuppressWarnings("unchecked")
16041604
public void testSystemIndexMetadataIsUpgraded() throws Exception {
1605-
1606-
@UpdateForV9(owner = UpdateForV9.Owner.CORE_INFRA) // assumeTrue can be removed (condition always true)
1607-
var originalClusterTaskIndexIsSystemIndex = oldClusterHasFeature(RestTestLegacyFeatures.TASK_INDEX_SYSTEM_INDEX);
1608-
assumeTrue(".tasks became a system index in 7.10.0", originalClusterTaskIndexIsSystemIndex);
16091605
final String systemIndexWarning = "this request accesses system indices: [.tasks], but in a future major version, direct "
16101606
+ "access to system indices will be prevented by default";
16111607
if (isRunningAgainstOldCluster()) {
@@ -1665,29 +1661,6 @@ public void testSystemIndexMetadataIsUpgraded() throws Exception {
16651661
throw new AssertionError(".tasks index does not exist yet");
16661662
}
16671663
});
1668-
1669-
// If we are on 7.x create an alias that includes both a system index and a non-system index so we can be sure it gets
1670-
// upgraded properly. If we're already on 8.x, skip this part of the test.
1671-
if (clusterHasFeature(RestTestLegacyFeatures.SYSTEM_INDICES_REST_ACCESS_ENFORCED) == false) {
1672-
// Create an alias to make sure it gets upgraded properly
1673-
Request putAliasRequest = newXContentRequest(HttpMethod.POST, "/_aliases", (builder, params) -> {
1674-
builder.startArray("actions");
1675-
for (var index : List.of(".tasks", "test_index_reindex")) {
1676-
builder.startObject()
1677-
.startObject("add")
1678-
.field("index", index)
1679-
.field("alias", "test-system-alias")
1680-
.endObject()
1681-
.endObject();
1682-
}
1683-
return builder.endArray();
1684-
});
1685-
putAliasRequest.setOptions(expectVersionSpecificWarnings(v -> {
1686-
v.current(systemIndexWarning);
1687-
v.compatible(systemIndexWarning);
1688-
}));
1689-
assertThat(client().performRequest(putAliasRequest).getStatusLine().getStatusCode(), is(200));
1690-
}
16911664
} else {
16921665
assertBusy(() -> {
16931666
Request clusterStateRequest = new Request("GET", "/_cluster/state/metadata");

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

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import org.elasticsearch.client.ResponseException;
1616
import org.elasticsearch.index.IndexVersion;
1717
import org.elasticsearch.test.XContentTestUtils.JsonMapView;
18-
import org.elasticsearch.test.rest.RestTestLegacyFeatures;
1918

2019
import java.util.Map;
2120

@@ -87,25 +86,6 @@ public void testSystemIndicesUpgrades() throws Exception {
8786
throw new AssertionError(".tasks index does not exist yet");
8887
}
8988
});
90-
91-
// If we are on 7.x create an alias that includes both a system index and a non-system index so we can be sure it gets
92-
// upgraded properly. If we're already on 8.x, skip this part of the test.
93-
if (clusterHasFeature(RestTestLegacyFeatures.SYSTEM_INDICES_REST_ACCESS_ENFORCED) == false) {
94-
// Create an alias to make sure it gets upgraded properly
95-
Request putAliasRequest = new Request("POST", "/_aliases");
96-
putAliasRequest.setJsonEntity("""
97-
{
98-
"actions": [
99-
{"add": {"index": ".tasks", "alias": "test-system-alias"}},
100-
{"add": {"index": "test_index_reindex", "alias": "test-system-alias"}}
101-
]
102-
}""");
103-
putAliasRequest.setOptions(expectVersionSpecificWarnings(v -> {
104-
v.current(systemIndexWarning);
105-
v.compatible(systemIndexWarning);
106-
}));
107-
assertThat(client().performRequest(putAliasRequest).getStatusLine().getStatusCode(), is(200));
108-
}
10989
} else if (isUpgradedCluster()) {
11090
assertBusy(() -> {
11191
Request clusterStateRequest = new Request("GET", "/_cluster/state/metadata");

test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java

Lines changed: 10 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -719,10 +719,6 @@ protected boolean preserveTemplatesUponCompletion() {
719719
* all feature states, deleting system indices, system associated indices, and system data streams.
720720
*/
721721
protected boolean resetFeatureStates() {
722-
if (clusterHasFeature(RestTestLegacyFeatures.FEATURE_STATE_RESET_SUPPORTED) == false) {
723-
return false;
724-
}
725-
726722
// ML reset fails when ML is disabled in versions before 8.7
727723
if (isMlEnabled() == false && clusterHasFeature(RestTestLegacyFeatures.ML_STATE_RESET_FALLBACK_ON_DISABLED) == false) {
728724
return false;
@@ -917,22 +913,10 @@ private void wipeCluster() throws Exception {
917913
.filter(name -> isXPackTemplate(name) == false)
918914
.collect(Collectors.toList());
919915
if (names.isEmpty() == false) {
920-
// Ideally we would want to check if the elected master node supports this feature and send the delete request
921-
// directly to that node, but node-specific feature checks is something we want to avoid if possible.
922-
if (clusterHasFeature(RestTestLegacyFeatures.DELETE_TEMPLATE_MULTIPLE_NAMES_SUPPORTED)) {
923-
try {
924-
adminClient().performRequest(new Request("DELETE", "_index_template/" + String.join(",", names)));
925-
} catch (ResponseException e) {
926-
logger.warn(() -> format("unable to remove multiple composable index templates %s", names), e);
927-
}
928-
} else {
929-
for (String name : names) {
930-
try {
931-
adminClient().performRequest(new Request("DELETE", "_index_template/" + name));
932-
} catch (ResponseException e) {
933-
logger.warn(() -> format("unable to remove composable index template %s", name), e);
934-
}
935-
}
916+
try {
917+
adminClient().performRequest(new Request("DELETE", "_index_template/" + String.join(",", names)));
918+
} catch (ResponseException e) {
919+
logger.warn(() -> format("unable to remove multiple composable index templates %s", names), e);
936920
}
937921
}
938922
} catch (Exception e) {
@@ -948,22 +932,10 @@ private void wipeCluster() throws Exception {
948932
.filter(name -> isXPackTemplate(name) == false)
949933
.collect(Collectors.toList());
950934
if (names.isEmpty() == false) {
951-
// Ideally we would want to check if the elected master node supports this feature and send the delete request
952-
// directly to that node, but node-specific feature checks is something we want to avoid if possible.
953-
if (clusterHasFeature(RestTestLegacyFeatures.DELETE_TEMPLATE_MULTIPLE_NAMES_SUPPORTED)) {
954-
try {
955-
adminClient().performRequest(new Request("DELETE", "_component_template/" + String.join(",", names)));
956-
} catch (ResponseException e) {
957-
logger.warn(() -> format("unable to remove multiple component templates %s", names), e);
958-
}
959-
} else {
960-
for (String componentTemplate : names) {
961-
try {
962-
adminClient().performRequest(new Request("DELETE", "_component_template/" + componentTemplate));
963-
} catch (ResponseException e) {
964-
logger.warn(() -> format("unable to remove component template %s", componentTemplate), e);
965-
}
966-
}
935+
try {
936+
adminClient().performRequest(new Request("DELETE", "_component_template/" + String.join(",", names)));
937+
} catch (ResponseException e) {
938+
logger.warn(() -> format("unable to remove multiple component templates %s", names), e);
967939
}
968940
}
969941
} catch (Exception e) {
@@ -1141,7 +1113,6 @@ protected static void wipeAllIndices() throws IOException {
11411113
}
11421114

11431115
protected static void wipeAllIndices(boolean preserveSecurityIndices) throws IOException {
1144-
boolean includeHidden = clusterHasFeature(RestTestLegacyFeatures.HIDDEN_INDICES_SUPPORTED);
11451116
try {
11461117
// remove all indices except some history indices which can pop up after deleting all data streams but shouldn't interfere
11471118
final List<String> indexPatterns = new ArrayList<>(
@@ -1151,7 +1122,7 @@ protected static void wipeAllIndices(boolean preserveSecurityIndices) throws IOE
11511122
indexPatterns.add("-.security-*");
11521123
}
11531124
final Request deleteRequest = new Request("DELETE", Strings.collectionToCommaDelimitedString(indexPatterns));
1154-
deleteRequest.addParameter("expand_wildcards", "open,closed" + (includeHidden ? ",hidden" : ""));
1125+
deleteRequest.addParameter("expand_wildcards", "open,closed,hidden");
11551126
final Response response = adminClient().performRequest(deleteRequest);
11561127
try (InputStream is = response.getEntity().getContent()) {
11571128
assertTrue((boolean) XContentHelper.convertToMap(XContentType.JSON.xContent(), is, true).get("acknowledged"));
@@ -1320,9 +1291,8 @@ private void wipeRollupJobs() throws IOException {
13201291
}
13211292

13221293
protected void refreshAllIndices() throws IOException {
1323-
boolean includeHidden = clusterHasFeature(RestTestLegacyFeatures.HIDDEN_INDICES_SUPPORTED);
13241294
Request refreshRequest = new Request("POST", "/_refresh");
1325-
refreshRequest.addParameter("expand_wildcards", "open" + (includeHidden ? ",hidden" : ""));
1295+
refreshRequest.addParameter("expand_wildcards", "open,hidden");
13261296
// Allow system index deprecation warnings
13271297
refreshRequest.setOptions(RequestOptions.DEFAULT.toBuilder().setWarningsHandler(warnings -> {
13281298
if (warnings.isEmpty()) {
@@ -2488,18 +2458,6 @@ public static void setIgnoredErrorResponseCodes(Request request, RestStatus... r
24882458
}
24892459

24902460
private static XContentType randomSupportedContentType() {
2491-
if (clusterHasFeature(RestTestLegacyFeatures.SUPPORTS_TRUE_BINARY_RESPONSES) == false) {
2492-
// Very old versions encode binary stored fields using base64 in all formats, not just JSON, but we expect to see raw binary
2493-
// fields in non-JSON formats, so we stick to JSON in these cases.
2494-
return XContentType.JSON;
2495-
}
2496-
2497-
if (clusterHasFeature(RestTestLegacyFeatures.SUPPORTS_VENDOR_XCONTENT_TYPES) == false) {
2498-
// The VND_* formats were introduced part-way through the 7.x series for compatibility with 8.x, but are not supported by older
2499-
// 7.x versions.
2500-
return randomFrom(XContentType.JSON, XContentType.CBOR, XContentType.YAML, XContentType.SMILE);
2501-
}
2502-
25032461
return randomFrom(XContentType.values());
25042462
}
25052463

test/framework/src/main/java/org/elasticsearch/test/rest/RestTestLegacyFeatures.java

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,8 @@
2727
public class RestTestLegacyFeatures implements FeatureSpecification {
2828
public static final NodeFeature ML_STATE_RESET_FALLBACK_ON_DISABLED = new NodeFeature("ml.state_reset_fallback_on_disabled");
2929
@UpdateForV9(owner = UpdateForV9.Owner.CORE_INFRA)
30-
public static final NodeFeature FEATURE_STATE_RESET_SUPPORTED = new NodeFeature("system_indices.feature_state_reset_supported");
31-
public static final NodeFeature SYSTEM_INDICES_REST_ACCESS_ENFORCED = new NodeFeature("system_indices.rest_access_enforced");
32-
@UpdateForV9(owner = UpdateForV9.Owner.CORE_INFRA)
33-
public static final NodeFeature SYSTEM_INDICES_REST_ACCESS_DEPRECATED = new NodeFeature("system_indices.rest_access_deprecated");
34-
@UpdateForV9(owner = UpdateForV9.Owner.CORE_INFRA)
35-
public static final NodeFeature HIDDEN_INDICES_SUPPORTED = new NodeFeature("indices.hidden_supported");
36-
@UpdateForV9(owner = UpdateForV9.Owner.CORE_INFRA)
3730
public static final NodeFeature COMPONENT_TEMPLATE_SUPPORTED = new NodeFeature("indices.component_template_supported");
38-
@UpdateForV9(owner = UpdateForV9.Owner.CORE_INFRA)
39-
public static final NodeFeature DELETE_TEMPLATE_MULTIPLE_NAMES_SUPPORTED = new NodeFeature(
40-
"indices.delete_template_multiple_names_supported"
41-
);
4231
public static final NodeFeature ML_NEW_MEMORY_FORMAT = new NodeFeature("ml.new_memory_format");
43-
@UpdateForV9(owner = UpdateForV9.Owner.CORE_INFRA)
44-
public static final NodeFeature SUPPORTS_VENDOR_XCONTENT_TYPES = new NodeFeature("rest.supports_vendor_xcontent_types");
45-
@UpdateForV9(owner = UpdateForV9.Owner.CORE_INFRA)
46-
public static final NodeFeature SUPPORTS_TRUE_BINARY_RESPONSES = new NodeFeature("rest.supports_true_binary_responses");
4732

4833
/** These are "pure test" features: normally we would not need them, and test for TransportVersion/fallback to Version (see for example
4934
* {@code ESRestTestCase#minimumTransportVersion()}. However, some tests explicitly check and validate the content of a response, so
@@ -61,21 +46,6 @@ public class RestTestLegacyFeatures implements FeatureSpecification {
6146
public static final NodeFeature DESIRED_NODE_API_SUPPORTED = new NodeFeature("desired_node_supported");
6247
public static final NodeFeature SECURITY_UPDATE_API_KEY = new NodeFeature("security.api_key_update");
6348
public static final NodeFeature SECURITY_BULK_UPDATE_API_KEY = new NodeFeature("security.api_key_bulk_update");
64-
@UpdateForV9(owner = UpdateForV9.Owner.CORE_INFRA)
65-
public static final NodeFeature WATCHES_VERSION_IN_META = new NodeFeature("watcher.version_in_meta");
66-
@UpdateForV9(owner = UpdateForV9.Owner.CORE_INFRA)
67-
public static final NodeFeature SECURITY_ROLE_DESCRIPTORS_OPTIONAL = new NodeFeature("security.role_descriptors_optional");
68-
@UpdateForV9(owner = UpdateForV9.Owner.CORE_INFRA)
69-
public static final NodeFeature SEARCH_AGGREGATIONS_FORCE_INTERVAL_SELECTION_DATE_HISTOGRAM = new NodeFeature(
70-
"search.aggregations.force_interval_selection_on_date_histogram"
71-
);
72-
@UpdateForV9(owner = UpdateForV9.Owner.CORE_INFRA)
73-
public static final NodeFeature TRANSFORM_NEW_API_ENDPOINT = new NodeFeature("transform.new_api_endpoint");
74-
// Ref: https://github.com/elastic/elasticsearch/pull/65205
75-
@UpdateForV9(owner = UpdateForV9.Owner.CORE_INFRA)
76-
public static final NodeFeature ML_INDICES_HIDDEN = new NodeFeature("ml.indices_hidden");
77-
@UpdateForV9(owner = UpdateForV9.Owner.CORE_INFRA)
78-
public static final NodeFeature ML_ANALYTICS_MAPPINGS = new NodeFeature("ml.analytics_mappings");
7949

8050
public static final NodeFeature TSDB_NEW_INDEX_FORMAT = new NodeFeature("indices.tsdb_new_format");
8151
public static final NodeFeature TSDB_GENERALLY_AVAILABLE = new NodeFeature("indices.tsdb_supported");
@@ -104,14 +74,10 @@ public class RestTestLegacyFeatures implements FeatureSpecification {
10474
@UpdateForV9(owner = UpdateForV9.Owner.CORE_INFRA)
10575
public static final NodeFeature REPLICATION_OF_CLOSED_INDICES = new NodeFeature("indices.closed_replication_supported");
10676
@UpdateForV9(owner = UpdateForV9.Owner.CORE_INFRA)
107-
public static final NodeFeature TASK_INDEX_SYSTEM_INDEX = new NodeFeature("tasks.moved_to_system_index");
108-
@UpdateForV9(owner = UpdateForV9.Owner.CORE_INFRA)
10977
public static final NodeFeature SOFT_DELETES_ENFORCED = new NodeFeature("indices.soft_deletes_enforced");
11078
@UpdateForV9(owner = UpdateForV9.Owner.CORE_INFRA)
11179
public static final NodeFeature NEW_TRANSPORT_COMPRESSED_SETTING = new NodeFeature("transport.new_compressed_setting");
11280
@UpdateForV9(owner = UpdateForV9.Owner.CORE_INFRA)
113-
public static final NodeFeature SHUTDOWN_SUPPORTED = new NodeFeature("shutdown.supported");
114-
@UpdateForV9(owner = UpdateForV9.Owner.CORE_INFRA)
11581
public static final NodeFeature SERVICE_ACCOUNTS_SUPPORTED = new NodeFeature("auth.service_accounts_supported");
11682
@UpdateForV9(owner = UpdateForV9.Owner.CORE_INFRA)
11783
public static final NodeFeature TRANSFORM_SUPPORTED = new NodeFeature("transform.supported");
@@ -140,27 +106,14 @@ public class RestTestLegacyFeatures implements FeatureSpecification {
140106
@Override
141107
public Map<NodeFeature, Version> getHistoricalFeatures() {
142108
return Map.ofEntries(
143-
entry(FEATURE_STATE_RESET_SUPPORTED, Version.V_7_13_0),
144-
entry(SYSTEM_INDICES_REST_ACCESS_ENFORCED, Version.V_8_0_0),
145-
entry(SYSTEM_INDICES_REST_ACCESS_DEPRECATED, Version.V_7_10_0),
146-
entry(HIDDEN_INDICES_SUPPORTED, Version.V_7_7_0),
147109
entry(COMPONENT_TEMPLATE_SUPPORTED, Version.V_7_8_0),
148-
entry(DELETE_TEMPLATE_MULTIPLE_NAMES_SUPPORTED, Version.V_7_13_0),
149110
entry(ML_STATE_RESET_FALLBACK_ON_DISABLED, Version.V_8_7_0),
150111
entry(SECURITY_UPDATE_API_KEY, Version.V_8_4_0),
151112
entry(SECURITY_BULK_UPDATE_API_KEY, Version.V_8_5_0),
152113
entry(ML_NEW_MEMORY_FORMAT, Version.V_8_11_0),
153-
entry(SUPPORTS_VENDOR_XCONTENT_TYPES, Version.V_7_11_0),
154-
entry(SUPPORTS_TRUE_BINARY_RESPONSES, Version.V_7_7_0),
155114
entry(TRANSPORT_VERSION_SUPPORTED, VERSION_INTRODUCING_TRANSPORT_VERSIONS),
156115
entry(STATE_REPLACED_TRANSPORT_VERSION_WITH_NODES_VERSION, Version.V_8_11_0),
157116
entry(ML_MEMORY_OVERHEAD_FIXED, Version.V_8_2_1),
158-
entry(WATCHES_VERSION_IN_META, Version.V_7_13_0),
159-
entry(SECURITY_ROLE_DESCRIPTORS_OPTIONAL, Version.V_7_3_0),
160-
entry(SEARCH_AGGREGATIONS_FORCE_INTERVAL_SELECTION_DATE_HISTOGRAM, Version.V_7_2_0),
161-
entry(TRANSFORM_NEW_API_ENDPOINT, Version.V_7_5_0),
162-
entry(ML_INDICES_HIDDEN, Version.V_7_7_0),
163-
entry(ML_ANALYTICS_MAPPINGS, Version.V_7_3_0),
164117
entry(REST_ELASTIC_PRODUCT_HEADER_PRESENT, Version.V_8_0_1),
165118
entry(DESIRED_NODE_API_SUPPORTED, Version.V_8_1_0),
166119
entry(TSDB_NEW_INDEX_FORMAT, Version.V_8_2_0),
@@ -173,10 +126,8 @@ public Map<NodeFeature, Version> getHistoricalFeatures() {
173126
entry(INDEXING_SLOWLOG_LEVEL_SETTING_REMOVED, Version.V_8_0_0),
174127
entry(DEPRECATION_WARNINGS_LEAK_FIXED, Version.V_7_17_9),
175128
entry(REPLICATION_OF_CLOSED_INDICES, Version.V_7_2_0),
176-
entry(TASK_INDEX_SYSTEM_INDEX, Version.V_7_10_0),
177129
entry(SOFT_DELETES_ENFORCED, Version.V_8_0_0),
178130
entry(NEW_TRANSPORT_COMPRESSED_SETTING, Version.V_7_14_0),
179-
entry(SHUTDOWN_SUPPORTED, Version.V_7_15_0),
180131
entry(SERVICE_ACCOUNTS_SUPPORTED, Version.V_7_13_0),
181132
entry(TRANSFORM_SUPPORTED, Version.V_7_2_0),
182133
entry(SLM_SUPPORTED, Version.V_7_4_0),

0 commit comments

Comments
 (0)