Skip to content

Commit

Permalink
Remove REST historical features (elastic#116929)
Browse files Browse the repository at this point in the history
  • Loading branch information
thecoop authored Nov 19, 2024
1 parent f3cd482 commit b17674b
Show file tree
Hide file tree
Showing 22 changed files with 116 additions and 491 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
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.junit.Before;
import org.junit.ClassRule;
import org.junit.rules.RuleChain;
Expand Down Expand Up @@ -269,10 +268,6 @@ private String getRollupIndexName() throws IOException {
}

public void testRollupIndex() throws Exception {
assumeTrue(
"Downsample got many stability improvements in 8.10.0",
oldClusterHasFeature(RestTestLegacyFeatures.TSDB_DOWNSAMPLING_STABLE)
);
if (isRunningAgainstOldCluster()) {
createIlmPolicy();
createIndex();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import org.elasticsearch.test.cluster.local.distribution.DistributionType;
import org.elasticsearch.test.rest.ESRestTestCase;
import org.elasticsearch.test.rest.ObjectPath;
import org.elasticsearch.test.rest.RestTestLegacyFeatures;
import org.elasticsearch.xcontent.ToXContent;
import org.elasticsearch.xcontent.XContentBuilder;
import org.elasticsearch.xcontent.XContentType;
Expand Down Expand Up @@ -262,7 +261,6 @@ public void testNewReplicas() throws Exception {
}

public void testSearchTimeSeriesMode() throws Exception {
assumeTrue("indexing time series indices changed in 8.2.0", oldClusterHasFeature(RestTestLegacyFeatures.TSDB_NEW_INDEX_FORMAT));
int numDocs;
if (isRunningAgainstOldCluster()) {
numDocs = createTimeSeriesModeIndex(1);
Expand Down Expand Up @@ -300,7 +298,6 @@ public void testSearchTimeSeriesMode() throws Exception {
}

public void testNewReplicasTimeSeriesMode() throws Exception {
assumeTrue("indexing time series indices changed in 8.2.0", oldClusterHasFeature(RestTestLegacyFeatures.TSDB_NEW_INDEX_FORMAT));
if (isRunningAgainstOldCluster()) {
createTimeSeriesModeIndex(0);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import org.elasticsearch.test.MapMatcher;
import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.elasticsearch.test.cluster.local.distribution.DistributionType;
import org.elasticsearch.test.rest.RestTestLegacyFeatures;
import org.hamcrest.Matcher;
import org.hamcrest.Matchers;
import org.junit.ClassRule;
Expand Down Expand Up @@ -125,8 +124,6 @@ protected ElasticsearchCluster getUpgradeCluster() {
}""";

public void testLogsIndexing() throws IOException {
assumeTrue("Test uses data streams", oldClusterHasFeature(RestTestLegacyFeatures.DATA_STREAMS_SUPPORTED));

if (isRunningAgainstOldCluster()) {
assertOK(client().performRequest(putTemplate(client(), "logs-template", STANDARD_TEMPLATE)));
assertOK(client().performRequest(createDataStream("logs-apache-production")));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.common.xcontent.support.XContentMapValues;
import org.elasticsearch.test.rest.RestTestLegacyFeatures;
import org.elasticsearch.xcontent.json.JsonXContent;

import java.io.IOException;
Expand Down Expand Up @@ -49,8 +48,6 @@ private enum ProcessorsPrecision {
}

public void testUpgradeDesiredNodes() throws Exception {
assumeTrue("Desired nodes was introduced in 8.1", oldClusterHasFeature(RestTestLegacyFeatures.DESIRED_NODE_API_SUPPORTED));

if (oldClusterHasFeature(DesiredNode.DOUBLE_PROCESSORS_SUPPORTED)) {
assertUpgradedNodesCanReadDesiredNodes();
} else if (oldClusterHasFeature(DesiredNode.RANGE_FLOAT_PROCESSORS_SUPPORTED)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import org.elasticsearch.client.Response;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.rest.RestTestLegacyFeatures;
import org.junit.Before;

import java.io.IOException;
Expand Down Expand Up @@ -244,10 +243,6 @@ private String getRollupIndexName() throws IOException {
}

public void testRollupIndex() throws Exception {
assumeTrue(
"Downsample got many stability improvements in 8.10.0",
oldClusterHasFeature(RestTestLegacyFeatures.TSDB_DOWNSAMPLING_STABLE)
);
if (isOldCluster()) {
createIlmPolicy();
createIndex();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.time.DateUtils;
import org.elasticsearch.common.xcontent.support.XContentMapValues;
import org.elasticsearch.core.UpdateForV9;
import org.elasticsearch.index.mapper.DateFieldMapper;
import org.elasticsearch.index.mapper.TimeSeriesIdFieldMapper;
import org.elasticsearch.test.ListMatcher;
import org.elasticsearch.test.rest.RestTestLegacyFeatures;
import org.elasticsearch.xcontent.XContentBuilder;
import org.elasticsearch.xcontent.XContentType;
import org.elasticsearch.xcontent.json.JsonXContent;
Expand Down Expand Up @@ -258,7 +258,6 @@ private void bulk(String index, String valueSuffix, int count) throws IOExceptio

public void testTsdb() throws IOException {
final Version oldClusterVersion = Version.fromString(getOldClusterVersion());
assumeTrue("indexing time series indices changed in 8.2.0", oldClusterHasFeature(RestTestLegacyFeatures.TSDB_NEW_INDEX_FORMAT));

StringBuilder bulk = new StringBuilder();
if (isOldCluster()) {
Expand Down Expand Up @@ -385,6 +384,7 @@ private void tsdbBulk(StringBuilder bulk, String dim, long timeStart, long timeE

private void assertTsdbAgg(final Version oldClusterVersion, final List<String> expectedTsids, final Matcher<?>... expected)
throws IOException {
@UpdateForV9(owner = UpdateForV9.Owner.SEARCH_ANALYTICS)
boolean onOrAfterTsidHashingVersion = oldClusterVersion.onOrAfter(Version.V_8_13_0);
Request request = new Request("POST", "/tsdb/_search");
request.addParameter("size", "0");
Expand Down Expand Up @@ -414,8 +414,6 @@ private void assertTsdbAgg(final Version oldClusterVersion, final List<String> e
}

public void testSyntheticSource() throws IOException {
assumeTrue("added in 8.4.0", oldClusterHasFeature(RestTestLegacyFeatures.SYNTHETIC_SOURCE_SUPPORTED));

if (isOldCluster()) {
Request createIndex = new Request("PUT", "/synthetic");
XContentBuilder indexSpec = XContentBuilder.builder(XContentType.JSON.xContent()).startObject();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.repositories.blobstore.BlobStoreRepository;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.elasticsearch.test.rest.RestTestLegacyFeatures;
import org.elasticsearch.xcontent.XContentBuilder;

import java.io.IOException;
Expand All @@ -50,12 +49,6 @@ public SnapshotBasedRecoveryIT(@Name("upgradedNodes") int upgradedNodes) {
}

public void testSnapshotBasedRecovery() throws Exception {
assumeTrue(
"Cancel shard allocation command is broken for initial versions of the desired_balance allocator",
oldClusterHasFeature(RestTestLegacyFeatures.DESIRED_BALANCED_ALLOCATOR_SUPPORTED) == false
|| oldClusterHasFeature(RestTestLegacyFeatures.DESIRED_BALANCED_ALLOCATOR_FIXED)
);

final String indexName = "snapshot_based_recovery";
final String repositoryName = "snapshot_based_recovery_repo";
final int numDocs = 200;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import org.elasticsearch.common.time.DateFormatter;
import org.elasticsearch.common.time.FormatNames;
import org.elasticsearch.test.rest.ObjectPath;
import org.elasticsearch.test.rest.RestTestLegacyFeatures;

import java.io.IOException;
import java.time.Instant;
Expand All @@ -24,8 +23,6 @@
import static org.elasticsearch.cluster.metadata.DataStreamTestHelper.backingIndexEqualTo;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.nullValue;

public class TsdbIT extends AbstractRollingUpgradeTestCase {

Expand Down Expand Up @@ -131,7 +128,6 @@ public TsdbIT(@Name("upgradedNodes") int upgradedNodes) {
""";

public void testTsdbDataStream() throws Exception {
assumeTrue("TSDB was GA-ed in 8.7.0", oldClusterHasFeature(RestTestLegacyFeatures.TSDB_GENERALLY_AVAILABLE));
String dataStreamName = "k8s";
if (isOldCluster()) {
final String INDEX_TEMPLATE = """
Expand All @@ -155,70 +151,6 @@ public void testTsdbDataStream() throws Exception {
}
}

public void testTsdbDataStreamWithComponentTemplate() throws Exception {
assumeTrue(
"TSDB was GA-ed in 8.7.0 and bug was fixed in 8.11.0",
oldClusterHasFeature(RestTestLegacyFeatures.TSDB_GENERALLY_AVAILABLE)
&& (oldClusterHasFeature(RestTestLegacyFeatures.TSDB_EMPTY_TEMPLATE_FIXED) == false)
);
String dataStreamName = "template-with-component-template";
if (isOldCluster()) {
final String COMPONENT_TEMPLATE = """
{
"template": $TEMPLATE
}
""";
var putComponentTemplate = new Request("POST", "/_component_template/1");
String template = TEMPLATE.replace("\"time_series\"", "\"time_series\", \"routing_path\": [\"k8s.pod.uid\"]");
putComponentTemplate.setJsonEntity(COMPONENT_TEMPLATE.replace("$TEMPLATE", template));
assertOK(client().performRequest(putComponentTemplate));
final String INDEX_TEMPLATE = """
{
"index_patterns": ["$PATTERN"],
"composed_of": ["1"],
"data_stream": {
}
}""";
// Add composable index template
String templateName = "2";
var putIndexTemplateRequest = new Request("POST", "/_index_template/" + templateName);
putIndexTemplateRequest.setJsonEntity(INDEX_TEMPLATE.replace("$PATTERN", dataStreamName));
assertOK(client().performRequest(putIndexTemplateRequest));

performOldClustertOperations(templateName, dataStreamName);
} else if (isMixedCluster()) {
performMixedClusterOperations(dataStreamName);
} else if (isUpgradedCluster()) {
performUpgradedClusterOperations(dataStreamName);

var dataStreams = getDataStream(dataStreamName);
assertThat(ObjectPath.evaluate(dataStreams, "data_streams.0.name"), equalTo(dataStreamName));
assertThat(ObjectPath.evaluate(dataStreams, "data_streams.0.generation"), equalTo(2));
String firstBackingIndex = ObjectPath.evaluate(dataStreams, "data_streams.0.indices.0.index_name");
{
var indices = getIndex(firstBackingIndex);
var escapedBackingIndex = firstBackingIndex.replace(".", "\\.");
assertThat(ObjectPath.evaluate(indices, escapedBackingIndex + ".data_stream"), equalTo(dataStreamName));
assertThat(ObjectPath.evaluate(indices, escapedBackingIndex + ".settings.index.mode"), nullValue());
String startTime = ObjectPath.evaluate(indices, escapedBackingIndex + ".settings.index.time_series.start_time");
assertThat(startTime, nullValue());
String endTime = ObjectPath.evaluate(indices, escapedBackingIndex + ".settings.index.time_series.end_time");
assertThat(endTime, nullValue());
}
String secondBackingIndex = ObjectPath.evaluate(dataStreams, "data_streams.0.indices.1.index_name");
{
var indices = getIndex(secondBackingIndex);
var escapedBackingIndex = secondBackingIndex.replace(".", "\\.");
assertThat(ObjectPath.evaluate(indices, escapedBackingIndex + ".data_stream"), equalTo(dataStreamName));
assertThat(ObjectPath.evaluate(indices, escapedBackingIndex + ".settings.index.mode"), equalTo("time_series"));
String startTime = ObjectPath.evaluate(indices, escapedBackingIndex + ".settings.index.time_series.start_time");
assertThat(startTime, notNullValue());
String endTime = ObjectPath.evaluate(indices, escapedBackingIndex + ".settings.index.time_series.end_time");
assertThat(endTime, notNullValue());
}
}
}

private void performUpgradedClusterOperations(String dataStreamName) throws Exception {
ensureGreen(dataStreamName);
var rolloverRequest = new Request("POST", "/" + dataStreamName + "/_rollover");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.support.XContentMapValues;
import org.elasticsearch.core.Strings;
import org.elasticsearch.test.rest.RestTestLegacyFeatures;

import java.io.IOException;
import java.util.Map;

import static org.elasticsearch.rest.action.search.RestSearchAction.TOTAL_HITS_AS_INT_PARAM;
import static org.hamcrest.Matchers.is;

public class UpgradeWithOldIndexSettingsIT extends AbstractRollingUpgradeTestCase {

Expand All @@ -35,33 +33,22 @@ public UpgradeWithOldIndexSettingsIT(@Name("upgradedNodes") int upgradedNodes) {
private static final String EXPECTED_WARNING = "[index.indexing.slowlog.level] setting was deprecated in Elasticsearch and will "
+ "be removed in a future release! See the breaking changes documentation for the next major version.";

private static final String EXPECTED_V8_WARNING = "[index.indexing.slowlog.level] setting was deprecated in the previous Elasticsearch"
+ " release and is removed in this release.";

public void testOldIndexSettings() throws Exception {
if (isOldCluster()) {
Request createTestIndex = new Request("PUT", "/" + INDEX_NAME);
createTestIndex.setJsonEntity("{\"settings\": {\"index.indexing.slowlog.level\": \"WARN\"}}");
createTestIndex.setOptions(expectWarnings(EXPECTED_WARNING));
if (oldClusterHasFeature(RestTestLegacyFeatures.INDEXING_SLOWLOG_LEVEL_SETTING_REMOVED)) {
assertTrue(
expectThrows(ResponseException.class, () -> client().performRequest(createTestIndex)).getMessage()
.contains("unknown setting [index.indexing.slowlog.level]")
);
assertTrue(
expectThrows(ResponseException.class, () -> client().performRequest(createTestIndex)).getMessage()
.contains("unknown setting [index.indexing.slowlog.level]")
);

Request createTestIndex1 = new Request("PUT", "/" + INDEX_NAME);
client().performRequest(createTestIndex1);
} else {
// create index with settings no longer valid in 8.0
client().performRequest(createTestIndex);
}
Request createTestIndex1 = new Request("PUT", "/" + INDEX_NAME);
client().performRequest(createTestIndex1);

// add some data
Request bulk = new Request("POST", "/_bulk");
bulk.addParameter("refresh", "true");
if (oldClusterHasFeature(RestTestLegacyFeatures.INDEXING_SLOWLOG_LEVEL_SETTING_REMOVED) == false) {
bulk.setOptions(expectWarnings(EXPECTED_WARNING));
}
bulk.setJsonEntity(Strings.format("""
{"index": {"_index": "%s"}}
{"f1": "v1", "f2": "v2"}
Expand All @@ -71,34 +58,12 @@ public void testOldIndexSettings() throws Exception {
// add some more data
Request bulk = new Request("POST", "/_bulk");
bulk.addParameter("refresh", "true");
if (oldClusterHasFeature(RestTestLegacyFeatures.INDEXING_SLOWLOG_LEVEL_SETTING_REMOVED) == false) {
bulk.setOptions(expectWarnings(EXPECTED_WARNING));
}
bulk.setJsonEntity(Strings.format("""
{"index": {"_index": "%s"}}
{"f1": "v3", "f2": "v4"}
""", INDEX_NAME));
client().performRequest(bulk);
} else {
if (oldClusterHasFeature(RestTestLegacyFeatures.INDEXING_SLOWLOG_LEVEL_SETTING_REMOVED) == false) {
Request createTestIndex = new Request("PUT", "/" + INDEX_NAME + "/_settings");
// update index settings should work
createTestIndex.setJsonEntity("{\"index.indexing.slowlog.level\": \"INFO\"}");
createTestIndex.setOptions(expectWarnings(EXPECTED_V8_WARNING));
client().performRequest(createTestIndex);

// ensure we were able to change the setting, despite it having no effect
Request indexSettingsRequest = new Request("GET", "/" + INDEX_NAME + "/_settings");
Map<String, Object> response = entityAsMap(client().performRequest(indexSettingsRequest));

var slowLogLevel = (String) (XContentMapValues.extractValue(
INDEX_NAME + ".settings.index.indexing.slowlog.level",
response
));

// check that we can read our old index settings
assertThat(slowLogLevel, is("INFO"));
}
assertCount(INDEX_NAME, 2);
}
}
Expand All @@ -118,16 +83,6 @@ private void assertCount(String index, int countAtLeast) throws IOException {
public static void updateIndexSettingsPermittingSlowlogDeprecationWarning(String index, Settings.Builder settings) throws IOException {
Request request = new Request("PUT", "/" + index + "/_settings");
request.setJsonEntity(org.elasticsearch.common.Strings.toString(settings.build()));
if (oldClusterHasFeature(RestTestLegacyFeatures.DEPRECATION_WARNINGS_LEAK_FIXED) == false) {
// There is a bug (fixed in 7.17.9 and 8.7.0 where deprecation warnings could leak into ClusterApplierService#applyChanges)
// Below warnings are set (and leaking) from an index in this test case
request.setOptions(expectVersionSpecificWarnings(v -> {
v.compatible(
"[index.indexing.slowlog.level] setting was deprecated in Elasticsearch and will be removed in a future release! "
+ "See the breaking changes documentation for the next major version."
);
}));
}
client().performRequest(request);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -157,23 +157,14 @@ public static DataStream newInstance(
.build();
}

public static String getLegacyDefaultBackingIndexName(
String dataStreamName,
long generation,
long epochMillis,
boolean isNewIndexNameFormat
) {
if (isNewIndexNameFormat) {
return String.format(
Locale.ROOT,
BACKING_INDEX_PREFIX + "%s-%s-%06d",
dataStreamName,
DATE_FORMATTER.formatMillis(epochMillis),
generation
);
} else {
return getLegacyDefaultBackingIndexName(dataStreamName, generation);
}
public static String getLegacyDefaultBackingIndexName(String dataStreamName, long generation, long epochMillis) {
return String.format(
Locale.ROOT,
BACKING_INDEX_PREFIX + "%s-%s-%06d",
dataStreamName,
DATE_FORMATTER.formatMillis(epochMillis),
generation
);
}

public static String getLegacyDefaultBackingIndexName(String dataStreamName, long generation) {
Expand Down
Loading

0 comments on commit b17674b

Please sign in to comment.