Skip to content

Commit 18eceb7

Browse files
committed
Add more assertions
Signed-off-by: Sooraj Sinha <[email protected]>
1 parent 6d182de commit 18eceb7

File tree

3 files changed

+31
-13
lines changed

3 files changed

+31
-13
lines changed

server/src/main/java/org/opensearch/gateway/remote/RemoteClusterStateAttributesManager.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,11 @@ public CheckedRunnable<IOException> getAsyncMetadataReadAction(
130130
public DiffableUtils.MapDiff<String, ClusterState.Custom, Map<String, ClusterState.Custom>> getUpdatedCustoms(
131131
ClusterState clusterState,
132132
ClusterState previousClusterState,
133-
boolean includeEphemeral,
133+
boolean isWriteFull,
134134
boolean firstUploadForEphemeralMetadata
135135
) {
136-
if (!includeEphemeral) {
137-
// When includeEphemeral is false, we do not want store any custom objects
136+
if (!isWriteFull) {
137+
// When isWriteFull is false, we do not want store any custom objects
138138
return DiffableUtils.diff(
139139
Collections.emptyMap(),
140140
Collections.emptyMap(),

server/src/test/java/org/opensearch/gateway/remote/RemoteClusterStateAttributesManagerTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88

99
package org.opensearch.gateway.remote;
1010

11-
import java.util.Collections;
12-
import java.util.List;
13-
import java.util.Map;
1411
import org.opensearch.Version;
1512
import org.opensearch.action.LatchedActionListener;
1613
import org.opensearch.cluster.AbstractNamedDiffable;
@@ -43,6 +40,9 @@
4340
import org.junit.Before;
4441

4542
import java.io.IOException;
43+
import java.util.Collections;
44+
import java.util.List;
45+
import java.util.Map;
4646
import java.util.concurrent.CountDownLatch;
4747
import java.util.concurrent.atomic.AtomicReference;
4848

@@ -53,11 +53,11 @@
5353
import static org.opensearch.gateway.remote.model.RemoteClusterBlocksTests.randomClusterBlocks;
5454
import static org.opensearch.gateway.remote.model.RemoteDiscoveryNodes.DISCOVERY_NODES_FORMAT;
5555
import static org.opensearch.gateway.remote.model.RemoteDiscoveryNodesTests.getDiscoveryNodes;
56+
import static org.hamcrest.Matchers.is;
5657
import static org.mockito.ArgumentMatchers.anyIterable;
5758
import static org.mockito.ArgumentMatchers.anyString;
5859
import static org.mockito.Mockito.mock;
5960
import static org.mockito.Mockito.when;
60-
import static org.hamcrest.Matchers.is;
6161

6262
public class RemoteClusterStateAttributesManagerTests extends OpenSearchTestCase {
6363
private RemoteClusterStateAttributesManager remoteClusterStateAttributesManager;

server/src/test/java/org/opensearch/gateway/remote/RemoteClusterStateServiceTests.java

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,6 @@ public void setup() {
179179
when(repositoriesService.repository("routing_repository")).thenReturn(blobStoreRepository);
180180

181181
when(blobStoreRepository.getNamedXContentRegistry()).thenReturn(xContentRegistry);
182-
// TODO Make the publication flag parameterized
183-
publicationEnabled = true;
184-
Settings nodeSettings = Settings.builder().put(REMOTE_PUBLICATION_EXPERIMENTAL, publicationEnabled).build();
185-
FeatureFlags.initializeFeatureFlags(nodeSettings);
186182
remoteClusterStateService = new RemoteClusterStateService(
187183
"test-node-id",
188184
repositoriesServiceSupplier,
@@ -199,6 +195,9 @@ public void setup() {
199195
public void teardown() throws Exception {
200196
super.tearDown();
201197
remoteClusterStateService.close();
198+
publicationEnabled = false;
199+
Settings nodeSettings = Settings.builder().build();
200+
FeatureFlags.initializeFeatureFlags(nodeSettings);
202201
threadPool.shutdown();
203202
}
204203

@@ -272,9 +271,28 @@ public void testWriteFullMetadataSuccess() throws IOException {
272271
assertThat(manifest.getSettingsMetadata(), notNullValue());
273272
assertThat(manifest.getTemplatesMetadata(), notNullValue());
274273
assertFalse(manifest.getCustomMetadataMap().isEmpty());
274+
assertThat(manifest.getClusterBlocksMetadata(), nullValue());
275+
assertThat(manifest.getDiscoveryNodesMetadata(), nullValue());
276+
assertThat(manifest.getTransientSettingsMetadata(), nullValue());
277+
assertThat(manifest.getHashesOfConsistentSettings(), nullValue());
278+
assertThat(manifest.getClusterStateCustomMap().size(), is(0));
275279
}
276280

277281
public void testWriteFullMetadataSuccessPublicationEnabled() throws IOException {
282+
// TODO Make the publication flag parameterized
283+
publicationEnabled = true;
284+
Settings nodeSettings = Settings.builder().put(REMOTE_PUBLICATION_EXPERIMENTAL, publicationEnabled).build();
285+
FeatureFlags.initializeFeatureFlags(nodeSettings);
286+
remoteClusterStateService = new RemoteClusterStateService(
287+
"test-node-id",
288+
repositoriesServiceSupplier,
289+
settings,
290+
clusterService,
291+
() -> 0L,
292+
threadPool,
293+
List.of(new RemoteIndexPathUploader(threadPool, settings, repositoriesServiceSupplier, clusterSettings)),
294+
writableRegistry()
295+
);
278296
final ClusterState clusterState = generateClusterStateWithOneIndex().nodes(nodesWithLocalNodeClusterManager())
279297
.customs(Map.of(RepositoryCleanupInProgress.TYPE, new RepositoryCleanupInProgress(List.of(new Entry("test-repo", 10L)))))
280298
.build();
@@ -358,8 +376,8 @@ public void testWriteFullMetadataInParallelSuccess() throws IOException {
358376
assertThat(manifest.getStateUUID(), is(expectedManifest.getStateUUID()));
359377
assertThat(manifest.getPreviousClusterUUID(), is(expectedManifest.getPreviousClusterUUID()));
360378

361-
assertEquals(12, actionListenerArgumentCaptor.getAllValues().size());
362-
assertEquals(12, writeContextArgumentCaptor.getAllValues().size());
379+
assertEquals(7, actionListenerArgumentCaptor.getAllValues().size());
380+
assertEquals(7, writeContextArgumentCaptor.getAllValues().size());
363381

364382
byte[] writtenBytes = capturedWriteContext.get("metadata")
365383
.getStreamProvider(Integer.MAX_VALUE)

0 commit comments

Comments
 (0)