Skip to content

Commit

Permalink
Add more assertions
Browse files Browse the repository at this point in the history
Signed-off-by: Sooraj Sinha <[email protected]>
  • Loading branch information
soosinha committed Jun 15, 2024
1 parent 6d182de commit b57abbb
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,11 @@ public CheckedRunnable<IOException> getAsyncMetadataReadAction(
public DiffableUtils.MapDiff<String, ClusterState.Custom, Map<String, ClusterState.Custom>> getUpdatedCustoms(
ClusterState clusterState,
ClusterState previousClusterState,
boolean includeEphemeral,
boolean isWriteFull,
boolean firstUploadForEphemeralMetadata
) {
if (!includeEphemeral) {
// When includeEphemeral is false, we do not want store any custom objects
if (!isWriteFull) {
// When isWriteFull is false, we do not want store any custom objects
return DiffableUtils.diff(
Collections.emptyMap(),
Collections.emptyMap(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,6 @@ public void setup() {
when(repositoriesService.repository("routing_repository")).thenReturn(blobStoreRepository);

when(blobStoreRepository.getNamedXContentRegistry()).thenReturn(xContentRegistry);
// TODO Make the publication flag parameterized
publicationEnabled = true;
Settings nodeSettings = Settings.builder().put(REMOTE_PUBLICATION_EXPERIMENTAL, publicationEnabled).build();
FeatureFlags.initializeFeatureFlags(nodeSettings);
remoteClusterStateService = new RemoteClusterStateService(
"test-node-id",
repositoriesServiceSupplier,
Expand All @@ -199,6 +195,9 @@ public void setup() {
public void teardown() throws Exception {
super.tearDown();
remoteClusterStateService.close();
publicationEnabled = false;
Settings nodeSettings = Settings.builder().build();
FeatureFlags.initializeFeatureFlags(nodeSettings);
threadPool.shutdown();
}

Expand Down Expand Up @@ -272,9 +271,28 @@ public void testWriteFullMetadataSuccess() throws IOException {
assertThat(manifest.getSettingsMetadata(), notNullValue());
assertThat(manifest.getTemplatesMetadata(), notNullValue());
assertFalse(manifest.getCustomMetadataMap().isEmpty());
assertThat(manifest.getClusterBlocksMetadata(), nullValue());
assertThat(manifest.getDiscoveryNodesMetadata(), nullValue());
assertThat(manifest.getTransientSettingsMetadata(), nullValue());
assertThat(manifest.getHashesOfConsistentSettings(), nullValue());
assertThat(manifest.getClusterStateCustomMap().size(), is(0));
}

public void testWriteFullMetadataSuccessPublicationEnabled() throws IOException {
// TODO Make the publication flag parameterized
publicationEnabled = true;
Settings nodeSettings = Settings.builder().put(REMOTE_PUBLICATION_EXPERIMENTAL, publicationEnabled).build();
FeatureFlags.initializeFeatureFlags(nodeSettings);
remoteClusterStateService = new RemoteClusterStateService(
"test-node-id",
repositoriesServiceSupplier,
settings,
clusterService,
() -> 0L,
threadPool,
List.of(new RemoteIndexPathUploader(threadPool, settings, repositoriesServiceSupplier, clusterSettings)),
writableRegistry()
);
final ClusterState clusterState = generateClusterStateWithOneIndex().nodes(nodesWithLocalNodeClusterManager())
.customs(Map.of(RepositoryCleanupInProgress.TYPE, new RepositoryCleanupInProgress(List.of(new Entry("test-repo", 10L)))))
.build();
Expand Down Expand Up @@ -358,8 +376,8 @@ public void testWriteFullMetadataInParallelSuccess() throws IOException {
assertThat(manifest.getStateUUID(), is(expectedManifest.getStateUUID()));
assertThat(manifest.getPreviousClusterUUID(), is(expectedManifest.getPreviousClusterUUID()));

assertEquals(12, actionListenerArgumentCaptor.getAllValues().size());
assertEquals(12, writeContextArgumentCaptor.getAllValues().size());
assertEquals(7, actionListenerArgumentCaptor.getAllValues().size());
assertEquals(7, writeContextArgumentCaptor.getAllValues().size());

byte[] writtenBytes = capturedWriteContext.get("metadata")
.getStreamProvider(Integer.MAX_VALUE)
Expand Down

0 comments on commit b57abbb

Please sign in to comment.