|
76 | 76 | import static org.opensearch.node.remotestore.RemoteStoreNodeAttribute.REMOTE_STORE_TRANSLOG_REPOSITORY_NAME_ATTRIBUTE_KEY;
|
77 | 77 | import static org.opensearch.node.remotestore.RemoteStoreNodeService.MIGRATION_DIRECTION_SETTING;
|
78 | 78 | import static org.opensearch.node.remotestore.RemoteStoreNodeService.REMOTE_STORE_COMPATIBILITY_MODE_SETTING;
|
| 79 | +import static org.opensearch.test.VersionUtils.allOpenSearchVersions; |
79 | 80 | import static org.opensearch.test.VersionUtils.allVersions;
|
80 | 81 | import static org.opensearch.test.VersionUtils.maxCompatibleVersion;
|
81 | 82 | import static org.opensearch.test.VersionUtils.randomCompatibleVersion;
|
@@ -885,6 +886,64 @@ public void testUpdatesClusterStateWithMultiNodeClusterAndSameRepository() throw
|
885 | 886 | validateRepositoryMetadata(result.resultingState, clusterManagerNode, 2);
|
886 | 887 | }
|
887 | 888 |
|
| 889 | + public void testNodeJoinInMixedMode() { |
| 890 | + Settings nodeSettings = Settings.builder().put(REMOTE_STORE_MIGRATION_EXPERIMENTAL, "true").build(); |
| 891 | + FeatureFlags.initializeFeatureFlags(nodeSettings); |
| 892 | + |
| 893 | + List<Version> versions = allOpenSearchVersions(); |
| 894 | + assert versions.size() >= 2 : "test requires at least two open search versions"; |
| 895 | + Version baseVersion = versions.get(versions.size() - 2); |
| 896 | + Version higherVersion = versions.get(versions.size() - 1); |
| 897 | + |
| 898 | + DiscoveryNode currentNode1 = new DiscoveryNode(UUIDs.base64UUID(), buildNewFakeTransportAddress(), baseVersion); |
| 899 | + DiscoveryNode currentNode2 = new DiscoveryNode(UUIDs.base64UUID(), buildNewFakeTransportAddress(), baseVersion); |
| 900 | + DiscoveryNodes currentNodes = DiscoveryNodes.builder() |
| 901 | + .add(currentNode1) |
| 902 | + .localNodeId(currentNode1.getId()) |
| 903 | + .add(currentNode2) |
| 904 | + .localNodeId(currentNode2.getId()) |
| 905 | + .build(); |
| 906 | + |
| 907 | + Settings mixedModeCompatibilitySettings = Settings.builder() |
| 908 | + .put(REMOTE_STORE_COMPATIBILITY_MODE_SETTING.getKey(), RemoteStoreNodeService.CompatibilityMode.MIXED) |
| 909 | + .build(); |
| 910 | + |
| 911 | + Metadata metadata = Metadata.builder().persistentSettings(mixedModeCompatibilitySettings).build(); |
| 912 | + |
| 913 | + // joining node of a higher version than the current nodes |
| 914 | + DiscoveryNode joiningNode1 = new DiscoveryNode( |
| 915 | + randomAlphaOfLength(10), |
| 916 | + randomAlphaOfLength(10), |
| 917 | + buildNewFakeTransportAddress(), |
| 918 | + remoteStoreNodeAttributes(SEGMENT_REPO, TRANSLOG_REPO), |
| 919 | + Collections.singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), |
| 920 | + higherVersion |
| 921 | + ); |
| 922 | + final IllegalStateException exception = expectThrows( |
| 923 | + IllegalStateException.class, |
| 924 | + () -> JoinTaskExecutor.ensureNodesCompatibility(joiningNode1, currentNodes, metadata) |
| 925 | + ); |
| 926 | + String reason = String.format( |
| 927 | + Locale.ROOT, |
| 928 | + "remote migration : a node [%s] of higher version [%s] is not allowed to join a cluster with maximum version [%s]", |
| 929 | + joiningNode1, |
| 930 | + joiningNode1.getVersion(), |
| 931 | + currentNodes.getMaxNodeVersion() |
| 932 | + ); |
| 933 | + assertEquals(reason, exception.getMessage()); |
| 934 | + |
| 935 | + // joining node of the same version as the current nodes |
| 936 | + DiscoveryNode joiningNode2 = new DiscoveryNode( |
| 937 | + randomAlphaOfLength(10), |
| 938 | + randomAlphaOfLength(10), |
| 939 | + buildNewFakeTransportAddress(), |
| 940 | + remoteStoreNodeAttributes(SEGMENT_REPO, TRANSLOG_REPO), |
| 941 | + Collections.singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), |
| 942 | + baseVersion |
| 943 | + ); |
| 944 | + JoinTaskExecutor.ensureNodesCompatibility(joiningNode2, currentNodes, metadata); |
| 945 | + } |
| 946 | + |
888 | 947 | private void validateRepositoryMetadata(ClusterState updatedState, DiscoveryNode existingNode, int expectedRepositories)
|
889 | 948 | throws Exception {
|
890 | 949 |
|
|
0 commit comments