Skip to content

Commit

Permalink
Remove addition ITs
Browse files Browse the repository at this point in the history
  • Loading branch information
cbuescher committed Jan 20, 2025
1 parent bc6c926 commit ee3344b
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 204 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,9 @@

package org.elasticsearch.lucene;

import io.netty.handler.codec.http.HttpMethod;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.InputStreamEntity;
import org.elasticsearch.client.Request;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.WarningsHandler;
import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.settings.Settings;
Expand Down Expand Up @@ -177,7 +174,6 @@ protected static void indexDocs(String indexName, int numDocs) throws Exception
{"field_0":"%s","field_1":%d,"field_2":"%s"}
""", indexName, Integer.toString(n), n, randomFrom(Locale.getAvailableLocales()).getDisplayName())));
request.setJsonEntity(docs.toString());
request.setOptions(RequestOptions.DEFAULT.toBuilder().setWarningsHandler(WarningsHandler.PERMISSIVE));
var response = assertOK(client().performRequest(request));
assertThat(entityAsMap(response).get("errors"), allOf(notNullValue(), is(false)));
}
Expand All @@ -193,7 +189,6 @@ protected static void mountIndex(String repository, String snapshot, String inde
"index": "%s",
"renamed_index": "%s"
}""", indexName, renamedIndexName));
request.setOptions(RequestOptions.DEFAULT.toBuilder().setWarningsHandler(WarningsHandler.PERMISSIVE));
var responseBody = createFromResponse(client().performRequest(request));
assertThat(responseBody.evaluate("snapshot.shards.total"), equalTo((int) responseBody.evaluate("snapshot.shards.successful")));
assertThat(responseBody.evaluate("snapshot.shards.failed"), equalTo(0));
Expand Down Expand Up @@ -227,10 +222,6 @@ protected static void restoreIndex(
}

protected static void updateRandomIndexSettings(String indexName) throws IOException {
updateRandomIndexSettings(indexName, RequestOptions.DEFAULT);
}

protected static void updateRandomIndexSettings(String indexName, RequestOptions requestOptions) throws IOException {
final var settings = Settings.builder();
int updates = randomIntBetween(1, 3);
for (int i = 0; i < updates; i++) {
Expand All @@ -242,13 +233,7 @@ protected static void updateRandomIndexSettings(String indexName, RequestOptions
default -> throw new IllegalStateException();
}
}
updateIndexSettingsLenient(indexName, settings.build(), requestOptions);
}

protected static void updateIndexSettingsLenient(String indexName, Settings settings, RequestOptions requestOptions) throws IOException {
final var request = newXContentRequest(HttpMethod.PUT, "/" + indexName + "/_settings", settings);
request.setOptions(requestOptions);
assertOK(client().performRequest(request));
updateIndexSettings(indexName, settings);
}

protected static void updateRandomMappings(String indexName) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,11 @@

package org.elasticsearch.lucene;

import io.netty.handler.codec.http.HttpMethod;
import org.elasticsearch.client.Request;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RequestOptions.Builder;
import org.elasticsearch.client.WarningsHandler;
import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.repositories.fs.FsRepository;
import org.elasticsearch.test.cluster.util.Version;
import org.elasticsearch.xcontent.ToXContent;

import java.io.IOException;

import static org.hamcrest.Matchers.equalTo;

Expand All @@ -37,21 +29,6 @@ public FullClusterRestartSearchableSnapshotIndexCompatibilityIT(Version version)
super(version);
}

public static final Builder IGNORE_WARNINGS = RequestOptions.DEFAULT.toBuilder().setWarningsHandler(WarningsHandler.PERMISSIVE);

private void createIndexLenient(String indexName, ToXContent settings) throws IOException {
final Request createIndex = newXContentRequest(HttpMethod.PUT, "/" + indexName, (builder, params) -> {
builder.startObject("settings");
settings.toXContent(builder, params);
builder.endObject();
return builder;
});

createIndex.setOptions(IGNORE_WARNINGS);
client().performRequest(createIndex);
ensureGreen(indexName);
}

/**
* Creates an index and a snapshot on N-2, then mounts the snapshot on N.
*/
Expand All @@ -66,12 +43,12 @@ public void testSearchableSnapshot() throws Exception {
registerRepository(client(), repository, FsRepository.TYPE, true, repositorySettings());

logger.debug("--> creating index [{}]", index);
createIndexLenient(
createIndex(
client(),
index,
Settings.builder()
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
.put("index.mapper.dynamic", false)
.put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true)
.build()
);
Expand Down Expand Up @@ -104,27 +81,19 @@ public void testSearchableSnapshot() throws Exception {
assertThat(indexVersion(mountedIndex), equalTo(VERSION_MINUS_2));
assertDocCount(client(), mountedIndex, numDocs);

updateRandomIndexSettings(mountedIndex, IGNORE_WARNINGS.build());
updateRandomIndexSettings(mountedIndex);
updateRandomMappings(mountedIndex);

logger.debug("--> adding replica to test peer-recovery");
updateIndexSettingsLenient(
mountedIndex,
Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1).build(),
IGNORE_WARNINGS.build()
);
updateIndexSettings(mountedIndex, Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1));
ensureGreen(mountedIndex);

logger.debug("--> closing index [{}]", mountedIndex);
closeIndex(mountedIndex);
ensureGreen(mountedIndex);

logger.debug("--> adding replica to test peer-recovery for closed shards");
updateIndexSettingsLenient(
mountedIndex,
Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 2).build(),
IGNORE_WARNINGS.build()
);
updateIndexSettings(mountedIndex, Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 2));
ensureGreen(mountedIndex);

logger.debug("--> re-opening index [{}]", mountedIndex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
package org.elasticsearch.upgrades;

import com.carrotsearch.randomizedtesting.annotations.Name;

import org.elasticsearch.client.Request;
import org.elasticsearch.client.Response;
import org.elasticsearch.client.ResponseException;
Expand All @@ -21,8 +22,6 @@
import java.util.Map;

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

public class UpgradeWithOldIndexSettingsIT extends AbstractRollingUpgradeTestCase {

Expand Down Expand Up @@ -69,39 +68,6 @@ public void testOldIndexSettings() throws Exception {
}
}

public void testMapperDynamicIndexSetting() throws IOException {
assumeTrue(
"Setting deprecated in 6.x, but was disallowed/removed incorrectly in some 7.x versions and can only be set safely in 7.17.22. "
+ "Setting can't be used in 8.x ",
getOldClusterTestVersion().before("8.0.0") && getOldClusterTestVersion().after("7.17.21")
);
String indexName = "my-index";
if (isOldCluster()) {
createIndex(indexName);
Request request = new Request("PUT", "/" + indexName + "/_settings");
request.setJsonEntity(org.elasticsearch.common.Strings.toString(Settings.builder().put("index.mapper.dynamic", true).build()));
request.setOptions(
expectWarnings(
"[index.mapper.dynamic] setting was deprecated in Elasticsearch and will be removed in a future release! "
+ "See the breaking changes documentation for the next major version."
)
);
assertOK(client().performRequest(request));
} else {
if (isUpgradedCluster()) {
var indexSettings = getIndexSettings(indexName);
assertThat(XContentMapValues.extractValue(indexName + ".settings.index.mapper.dynamic", indexSettings), equalTo("true"));
ensureGreen(indexName);
// New indices can never define the index.mapper.dynamic setting.
Exception e = expectThrows(
ResponseException.class,
() -> createIndex("my-index2", Settings.builder().put("index.mapper.dynamic", true).build())
);
assertThat(e.getMessage(), containsString("unknown setting [index.mapper.dynamic]"));
}
}
}

private void assertCount(String index, int countAtLeast) throws IOException {
Request searchTestIndexRequest = new Request("POST", "/" + index + "/_search");
searchTestIndexRequest.addParameter(TOTAL_HITS_AS_INT_PARAM, "true");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public enum Property {
* forbidden in indices created from {@link Version#V_8_0_0} onwards.
*/
@UpdateForV9(owner = UpdateForV9.Owner.CORE_INFRA) // introduce IndexSettingDeprecatedInV8AndRemovedInV10
// note we still need v7 settings in v9 because we support reading from N-2 indices now
// note we still need v7 settings in v9 because we support reading from N-2 indices now
IndexSettingDeprecatedInV7AndRemovedInV8,

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,24 +291,6 @@ public void testReadOnlyVersionCompatibility() {
)
);
}
{
var idxMetadata = newIndexMeta(
"index-mapper-dynamic",
Settings.builder()
.put(IndexMetadata.SETTING_BLOCKS_WRITE, true)
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.fromId(6080099))
.put(IndexMetadata.SETTING_VERSION_COMPATIBILITY, indexCreated)
.put("index.mapper.dynamic", true)
.build()
);
IndexMetadata newIndexMetadata = service.verifyIndexMetadata(idxMetadata, IndexVersions.MINIMUM_COMPATIBLE,
IndexVersions.MINIMUM_READONLY_COMPATIBLE);
// check setting isn't archived
assertNotNull(newIndexMetadata.getSettings().get("index.mapper.dynamic"));
assertWarnings(
"[index.mapper.dynamic] setting was deprecated in the previous Elasticsearch release and is removed in this release."
);
}
}

private IndexMetadataVerifier getIndexMetadataVerifier() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -845,9 +845,7 @@ public void testTimeSeriesTimeBoundary() {
}

public void testIndexMapperDynamic() {
Settings settings = Settings.builder()
.put(INDEX_MAPPER_DYNAMIC_SETTING.getKey(), randomBoolean())
.build();
Settings settings = Settings.builder().put(INDEX_MAPPER_DYNAMIC_SETTING.getKey(), randomBoolean()).build();

INDEX_MAPPER_DYNAMIC_SETTING.get(settings);
assertWarnings(
Expand All @@ -856,19 +854,22 @@ public void testIndexMapperDynamic() {

IndexMetadata idxMetaData = newIndexMeta("test", settings);
IndexMetadataVerifier indexMetadataVerifier = new IndexMetadataVerifier(
Settings.EMPTY,
null,
xContentRegistry(),
new MapperRegistry(Collections.emptyMap(), Collections.emptyMap(), Collections.emptyMap(), MapperPlugin.NOOP_FIELD_FILTER),
IndexScopedSettings.DEFAULT_SCOPED_SETTINGS,
null,
MapperMetrics.NOOP
);
IndexMetadata verifiedMetaData = indexMetadataVerifier.verifyIndexMetadata(idxMetaData, IndexVersions.MINIMUM_COMPATIBLE,
IndexVersions.MINIMUM_READONLY_COMPATIBLE);
Settings.EMPTY,
null,
xContentRegistry(),
new MapperRegistry(Collections.emptyMap(), Collections.emptyMap(), Collections.emptyMap(), MapperPlugin.NOOP_FIELD_FILTER),
IndexScopedSettings.DEFAULT_SCOPED_SETTINGS,
null,
MapperMetrics.NOOP
);
IndexMetadata verifiedMetaData = indexMetadataVerifier.verifyIndexMetadata(
idxMetaData,
IndexVersions.MINIMUM_COMPATIBLE,
IndexVersions.MINIMUM_READONLY_COMPATIBLE
);
assertEquals(idxMetaData, verifiedMetaData);
assertWarnings(
"[index.mapper.dynamic] setting was deprecated in the previous Elasticsearch release and is removed in this release."
"[index.mapper.dynamic] setting was deprecated in the previous Elasticsearch release and is removed in this release."
);
}

Expand Down

0 comments on commit ee3344b

Please sign in to comment.