|
13 | 13 | import org.opensearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest;
|
14 | 14 | import org.opensearch.action.admin.cluster.state.ClusterStateResponse;
|
15 | 15 | import org.opensearch.client.Client;
|
| 16 | +import org.opensearch.cluster.coordination.CoordinationState; |
| 17 | +import org.opensearch.cluster.coordination.PersistedStateRegistry; |
16 | 18 | import org.opensearch.common.blobstore.BlobPath;
|
17 | 19 | import org.opensearch.common.settings.Settings;
|
18 | 20 | import org.opensearch.discovery.DiscoveryStats;
|
| 21 | +import org.opensearch.gateway.GatewayMetaState; |
19 | 22 | import org.opensearch.gateway.remote.ClusterMetadataManifest.UploadedIndexMetadata;
|
20 | 23 | import org.opensearch.gateway.remote.model.RemoteClusterMetadataManifest;
|
21 | 24 | import org.opensearch.gateway.remote.model.RemoteRoutingTableBlobStore;
|
|
35 | 38 | import java.util.Base64;
|
36 | 39 | import java.util.Locale;
|
37 | 40 | import java.util.Map;
|
| 41 | +import java.util.concurrent.ExecutionException; |
38 | 42 | import java.util.function.Function;
|
39 | 43 | import java.util.stream.Collectors;
|
40 | 44 |
|
@@ -62,15 +66,15 @@ public class RemoteStatePublicationIT extends RemoteStoreBaseIntegTestCase {
|
62 | 66 | private static final String REMOTE_STATE_PREFIX = "!";
|
63 | 67 | private static final String REMOTE_ROUTING_PREFIX = "_";
|
64 | 68 | private boolean isRemoteStateEnabled = true;
|
65 |
| - private String isRemotePublicationEnabled = "true"; |
| 69 | + private boolean isRemotePublicationEnabled = true; |
66 | 70 | private boolean hasRemoteStateCharPrefix;
|
67 | 71 | private boolean hasRemoteRoutingCharPrefix;
|
68 | 72 |
|
69 | 73 | @Before
|
70 | 74 | public void setup() {
|
71 | 75 | asyncUploadMockFsRepo = false;
|
72 | 76 | isRemoteStateEnabled = true;
|
73 |
| - isRemotePublicationEnabled = "true"; |
| 77 | + isRemotePublicationEnabled = true; |
74 | 78 | hasRemoteStateCharPrefix = randomBoolean();
|
75 | 79 | hasRemoteRoutingCharPrefix = randomBoolean();
|
76 | 80 | }
|
@@ -100,6 +104,7 @@ protected Settings nodeSettings(int nodeOrdinal) {
|
100 | 104 | RemoteClusterStateService.REMOTE_CLUSTER_STATE_CHECKSUM_VALIDATION_MODE_SETTING.getKey(),
|
101 | 105 | RemoteClusterStateService.RemoteClusterStateValidationMode.FAILURE
|
102 | 106 | )
|
| 107 | + .put(REMOTE_PUBLICATION_SETTING_KEY, isRemotePublicationEnabled) |
103 | 108 | .put(
|
104 | 109 | RemoteClusterStateService.CLUSTER_REMOTE_STORE_STATE_PATH_PREFIX.getKey(),
|
105 | 110 | hasRemoteStateCharPrefix ? REMOTE_STATE_PREFIX : ""
|
@@ -220,6 +225,59 @@ public void testRemotePublicationDownloadStats() {
|
220 | 225 |
|
221 | 226 | }
|
222 | 227 |
|
| 228 | + public void testMasterReElectionUsesIncrementalUpload() throws IOException { |
| 229 | + prepareCluster(3, 2, INDEX_NAME, 1, 1); |
| 230 | + PersistedStateRegistry persistedStateRegistry = internalCluster().getClusterManagerNodeInstance(PersistedStateRegistry.class); |
| 231 | + GatewayMetaState.RemotePersistedState remotePersistedState = (GatewayMetaState.RemotePersistedState) persistedStateRegistry |
| 232 | + .getPersistedState(PersistedStateRegistry.PersistedStateType.REMOTE); |
| 233 | + ClusterMetadataManifest manifest = remotePersistedState.getLastAcceptedManifest(); |
| 234 | + // force elected master to step down |
| 235 | + internalCluster().stopCurrentClusterManagerNode(); |
| 236 | + ensureStableCluster(4); |
| 237 | + |
| 238 | + persistedStateRegistry = internalCluster().getClusterManagerNodeInstance(PersistedStateRegistry.class); |
| 239 | + CoordinationState.PersistedState persistedStateAfterElection = persistedStateRegistry.getPersistedState( |
| 240 | + PersistedStateRegistry.PersistedStateType.REMOTE |
| 241 | + ); |
| 242 | + ClusterMetadataManifest manifestAfterElection = persistedStateAfterElection.getLastAcceptedManifest(); |
| 243 | + |
| 244 | + // coordination metadata is updated, it will be unequal |
| 245 | + assertNotEquals(manifest.getCoordinationMetadata(), manifestAfterElection.getCoordinationMetadata()); |
| 246 | + // all other attributes are not uploaded again and will be pointing to same files in manifest after new master is elected |
| 247 | + assertEquals(manifest.getClusterUUID(), manifestAfterElection.getClusterUUID()); |
| 248 | + assertEquals(manifest.getIndices(), manifestAfterElection.getIndices()); |
| 249 | + assertEquals(manifest.getSettingsMetadata(), manifestAfterElection.getSettingsMetadata()); |
| 250 | + assertEquals(manifest.getTemplatesMetadata(), manifestAfterElection.getTemplatesMetadata()); |
| 251 | + assertEquals(manifest.getCustomMetadataMap(), manifestAfterElection.getCustomMetadataMap()); |
| 252 | + assertEquals(manifest.getRoutingTableVersion(), manifest.getRoutingTableVersion()); |
| 253 | + assertEquals(manifest.getIndicesRouting(), manifestAfterElection.getIndicesRouting()); |
| 254 | + } |
| 255 | + |
| 256 | + public void testVotingConfigAreCommitted() throws ExecutionException, InterruptedException { |
| 257 | + prepareCluster(3, 2, INDEX_NAME, 1, 2); |
| 258 | + ensureStableCluster(5); |
| 259 | + ensureGreen(INDEX_NAME); |
| 260 | + // add two new nodes to the cluster, to update the voting config |
| 261 | + internalCluster().startClusterManagerOnlyNodes(2, Settings.EMPTY); |
| 262 | + ensureStableCluster(7); |
| 263 | + |
| 264 | + internalCluster().getInstances(PersistedStateRegistry.class).forEach(persistedStateRegistry -> { |
| 265 | + CoordinationState.PersistedState localState = persistedStateRegistry.getPersistedState( |
| 266 | + PersistedStateRegistry.PersistedStateType.LOCAL |
| 267 | + ); |
| 268 | + CoordinationState.PersistedState remoteState = persistedStateRegistry.getPersistedState( |
| 269 | + PersistedStateRegistry.PersistedStateType.REMOTE |
| 270 | + ); |
| 271 | + if (remoteState != null) { |
| 272 | + assertEquals( |
| 273 | + localState.getLastAcceptedState().getLastCommittedConfiguration(), |
| 274 | + remoteState.getLastAcceptedState().getLastCommittedConfiguration() |
| 275 | + ); |
| 276 | + assertEquals(5, remoteState.getLastAcceptedState().getLastCommittedConfiguration().getNodeIds().size()); |
| 277 | + } |
| 278 | + }); |
| 279 | + } |
| 280 | + |
223 | 281 | private void assertDataNodeDownloadStats(NodesStatsResponse nodesStatsResponse) {
|
224 | 282 | // assert cluster state stats for data node
|
225 | 283 | DiscoveryStats dataNodeDiscoveryStats = nodesStatsResponse.getNodes().get(0).getDiscoveryStats();
|
|
0 commit comments