|
|
@@ -39,6 +39,7 @@ import org.elasticsearch.features.FeatureSpecification;
|
|
|
import org.elasticsearch.features.NodeFeature;
|
|
|
import org.elasticsearch.index.IndexVersion;
|
|
|
import org.elasticsearch.index.IndexVersions;
|
|
|
+import org.elasticsearch.snapshots.SearchableSnapshotsSettings;
|
|
|
import org.elasticsearch.test.ClusterServiceUtils;
|
|
|
import org.elasticsearch.test.ESTestCase;
|
|
|
import org.elasticsearch.test.MockLog;
|
|
|
@@ -58,6 +59,7 @@ import java.util.stream.Stream;
|
|
|
|
|
|
import static org.elasticsearch.cluster.metadata.DesiredNodesTestCase.assertDesiredNodesStatusIsCorrect;
|
|
|
import static org.elasticsearch.cluster.metadata.DesiredNodesTestCase.randomDesiredNode;
|
|
|
+import static org.elasticsearch.index.IndexModule.INDEX_STORE_TYPE_SETTING;
|
|
|
import static org.elasticsearch.test.VersionUtils.maxCompatibleVersion;
|
|
|
import static org.elasticsearch.test.VersionUtils.randomCompatibleVersion;
|
|
|
import static org.elasticsearch.test.VersionUtils.randomVersion;
|
|
|
@@ -89,12 +91,18 @@ public class NodeJoinExecutorTests extends ESTestCase {
|
|
|
.build();
|
|
|
metaBuilder.put(indexMetadata, false);
|
|
|
Metadata metadata = metaBuilder.build();
|
|
|
- NodeJoinExecutor.ensureIndexCompatibility(IndexVersions.MINIMUM_COMPATIBLE, IndexVersion.current(), metadata);
|
|
|
+ NodeJoinExecutor.ensureIndexCompatibility(
|
|
|
+ IndexVersions.MINIMUM_COMPATIBLE,
|
|
|
+ IndexVersions.MINIMUM_READONLY_COMPATIBLE,
|
|
|
+ IndexVersion.current(),
|
|
|
+ metadata
|
|
|
+ );
|
|
|
|
|
|
expectThrows(
|
|
|
IllegalStateException.class,
|
|
|
() -> NodeJoinExecutor.ensureIndexCompatibility(
|
|
|
IndexVersions.MINIMUM_COMPATIBLE,
|
|
|
+ IndexVersions.MINIMUM_READONLY_COMPATIBLE,
|
|
|
IndexVersionUtils.getPreviousVersion(IndexVersion.current()),
|
|
|
metadata
|
|
|
)
|
|
|
@@ -113,10 +121,78 @@ public class NodeJoinExecutorTests extends ESTestCase {
|
|
|
Metadata metadata = metaBuilder.build();
|
|
|
expectThrows(
|
|
|
IllegalStateException.class,
|
|
|
- () -> NodeJoinExecutor.ensureIndexCompatibility(IndexVersions.MINIMUM_COMPATIBLE, IndexVersion.current(), metadata)
|
|
|
+ () -> NodeJoinExecutor.ensureIndexCompatibility(
|
|
|
+ IndexVersions.MINIMUM_COMPATIBLE,
|
|
|
+ IndexVersions.MINIMUM_READONLY_COMPATIBLE,
|
|
|
+ IndexVersion.current(),
|
|
|
+ metadata
|
|
|
+ )
|
|
|
);
|
|
|
}
|
|
|
|
|
|
+ public void testJoinClusterWithReadOnlyCompatibleIndices() {
|
|
|
+ assertThat(
|
|
|
+ "8.x has no N-2 support so read-only compatibility is the same as regular read/write compatibility",
|
|
|
+ IndexVersions.MINIMUM_READONLY_COMPATIBLE,
|
|
|
+ equalTo(IndexVersions.MINIMUM_COMPATIBLE)
|
|
|
+ );
|
|
|
+ {
|
|
|
+ var indexMetadata = IndexMetadata.builder("searchable-snapshot")
|
|
|
+ .settings(
|
|
|
+ Settings.builder()
|
|
|
+ .put(INDEX_STORE_TYPE_SETTING.getKey(), SearchableSnapshotsSettings.SEARCHABLE_SNAPSHOT_STORE_TYPE)
|
|
|
+ .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersions.MINIMUM_READONLY_COMPATIBLE)
|
|
|
+ .put(IndexMetadata.SETTING_BLOCKS_WRITE, randomBoolean())
|
|
|
+ )
|
|
|
+ .numberOfShards(1)
|
|
|
+ .numberOfReplicas(1)
|
|
|
+ .build();
|
|
|
+
|
|
|
+ NodeJoinExecutor.ensureIndexCompatibility(
|
|
|
+ IndexVersions.MINIMUM_COMPATIBLE,
|
|
|
+ IndexVersions.MINIMUM_READONLY_COMPATIBLE,
|
|
|
+ IndexVersion.current(),
|
|
|
+ Metadata.builder().put(indexMetadata, false).build()
|
|
|
+ );
|
|
|
+ }
|
|
|
+ {
|
|
|
+ var indexMetadata = IndexMetadata.builder("archive")
|
|
|
+ .settings(
|
|
|
+ Settings.builder()
|
|
|
+ .put(IndexMetadata.SETTING_VERSION_CREATED, Version.fromId(randomFrom(5000099, 6000099)))
|
|
|
+ .put(IndexMetadata.SETTING_VERSION_COMPATIBILITY, IndexVersions.MINIMUM_READONLY_COMPATIBLE)
|
|
|
+ .put(IndexMetadata.SETTING_BLOCKS_WRITE, randomBoolean())
|
|
|
+ )
|
|
|
+ .numberOfShards(1)
|
|
|
+ .numberOfReplicas(1)
|
|
|
+ .build();
|
|
|
+
|
|
|
+ NodeJoinExecutor.ensureIndexCompatibility(
|
|
|
+ IndexVersions.MINIMUM_COMPATIBLE,
|
|
|
+ IndexVersions.MINIMUM_READONLY_COMPATIBLE,
|
|
|
+ IndexVersion.current(),
|
|
|
+ Metadata.builder().put(indexMetadata, false).build()
|
|
|
+ );
|
|
|
+ }
|
|
|
+ {
|
|
|
+ var indexMetadata = IndexMetadata.builder("legacy")
|
|
|
+ .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.fromId(randomFrom(5000099, 6000099))))
|
|
|
+ .numberOfShards(1)
|
|
|
+ .numberOfReplicas(1)
|
|
|
+ .build();
|
|
|
+
|
|
|
+ expectThrows(
|
|
|
+ IllegalStateException.class,
|
|
|
+ () -> NodeJoinExecutor.ensureIndexCompatibility(
|
|
|
+ IndexVersions.MINIMUM_COMPATIBLE,
|
|
|
+ IndexVersions.MINIMUM_READONLY_COMPATIBLE,
|
|
|
+ IndexVersion.current(),
|
|
|
+ Metadata.builder().put(indexMetadata, false).build()
|
|
|
+ )
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public void testPreventJoinClusterWithUnsupportedNodeVersions() {
|
|
|
DiscoveryNodes.Builder builder = DiscoveryNodes.builder();
|
|
|
final Version version = randomCompatibleVersion(random(), Version.CURRENT);
|
|
|
@@ -467,7 +543,12 @@ public class NodeJoinExecutorTests extends ESTestCase {
|
|
|
.build();
|
|
|
metaBuilder.put(indexMetadata, false);
|
|
|
Metadata metadata = metaBuilder.build();
|
|
|
- NodeJoinExecutor.ensureIndexCompatibility(IndexVersions.MINIMUM_COMPATIBLE, IndexVersion.current(), metadata);
|
|
|
+ NodeJoinExecutor.ensureIndexCompatibility(
|
|
|
+ IndexVersions.MINIMUM_COMPATIBLE,
|
|
|
+ IndexVersions.MINIMUM_READONLY_COMPATIBLE,
|
|
|
+ IndexVersion.current(),
|
|
|
+ metadata
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
public static Settings.Builder randomCompatibleVersionSettings() {
|