Skip to content

Commit

Permalink
Add unit tests for read flow of RemoteClusterStateService
Browse files Browse the repository at this point in the history
Signed-off-by: Shivansh Arora <hishiv@amazon.com>
  • Loading branch information
shiv0408 committed Jun 23, 2024
1 parent 9729a92 commit 47fc840
Show file tree
Hide file tree
Showing 6 changed files with 444 additions and 162 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,6 @@ PublishWithJoinResponse handleIncomingRemotePublishRequest(RemotePublishRequest
)
);
ClusterState clusterState = remoteClusterStateService.getClusterStateUsingDiff(
request.getClusterName(),
manifest,
lastSeen,
transportService.getLocalNode().getId()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
Expand Down Expand Up @@ -563,7 +564,16 @@ public static class Builder {
private List<String> clusterStateCustomUpdated;
private List<String> clusterStateCustomDeleted;

public Builder() {}
public Builder() {
customMetadataUpdated = Collections.emptyList();
customMetadataDeleted = Collections.emptyList();
indicesUpdated = Collections.emptyList();
indicesDeleted = Collections.emptyList();
indicesRoutingUpdated = Collections.emptyList();
indicesRoutingDeleted = Collections.emptyList();
clusterStateCustomUpdated = Collections.emptyList();
clusterStateCustomDeleted = Collections.emptyList();
}

public Builder fromStateUUID(String fromStateUUID) {
this.fromStateUUID = fromStateUUID;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1319,13 +1319,9 @@ public ClusterState getClusterStateForManifest(

}

public ClusterState getClusterStateUsingDiff(
String clusterName,
ClusterMetadataManifest manifest,
ClusterState previousState,
String localNodeId
) throws IOException {
assert manifest.getDiffManifest() != null;
public ClusterState getClusterStateUsingDiff(ClusterMetadataManifest manifest, ClusterState previousState, String localNodeId)
throws IOException {
assert manifest.getDiffManifest() != null : "Diff manifest null which is required for downloading cluster state";
ClusterStateDiffManifest diff = manifest.getDiffManifest();
List<UploadedIndexMetadata> updatedIndices = diff.getIndicesUpdated().stream().map(idx -> {
Optional<UploadedIndexMetadata> uploadedIndexMetadataOptional = manifest.getIndices()
Expand Down
Loading

0 comments on commit 47fc840

Please sign in to comment.