Skip to content

Commit

Permalink
FIxed UTs
Browse files Browse the repository at this point in the history
Signed-off-by: Dhwanil Patel <[email protected]>
  • Loading branch information
dhwanilpatel committed Oct 18, 2023
1 parent ff37a66 commit 03167ad
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void testClusterMetadataManifestXContent() throws IOException {
Version.CURRENT,
"test-node-id",
false,
1,
ClusterMetadataManifest.CODEC_V0,
null,
Collections.singletonList(uploadedIndexMetadata),
"prev-cluster-uuid",
Expand All @@ -53,7 +53,7 @@ public void testClusterMetadataManifestXContent() throws IOException {
}
}

public void testClusterMetadataManifestXContentCodecV2() throws IOException {
public void testClusterMetadataManifestXContentCodecV1() throws IOException {
UploadedIndexMetadata uploadedIndexMetadata = new UploadedIndexMetadata("test-index", "test-uuid", "/test/upload/path");
ClusterMetadataManifest originalManifest = new ClusterMetadataManifest(
1L,
Expand All @@ -63,7 +63,7 @@ public void testClusterMetadataManifestXContentCodecV2() throws IOException {
Version.CURRENT,
"test-node-id",
false,
2,
ClusterMetadataManifest.CODEC_V1,
"test-global-metadata-file",
Collections.singletonList(uploadedIndexMetadata),
"prev-cluster-uuid",
Expand All @@ -75,7 +75,7 @@ public void testClusterMetadataManifestXContentCodecV2() throws IOException {
builder.endObject();

try (XContentParser parser = createParser(JsonXContent.jsonXContent, BytesReference.bytes(builder))) {
final ClusterMetadataManifest fromXContentManifest = ClusterMetadataManifest.fromXContentV2(parser);
final ClusterMetadataManifest fromXContentManifest = ClusterMetadataManifest.fromXContentV1(parser);
assertEquals(originalManifest, fromXContentManifest);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,9 +386,9 @@ public void testMigrationFromCodecV0ManifestToCodecV1Manifest() throws IOExcepti
Metadata newMetadata = Metadata.builder(previousClusterState.metadata()).put(indexMetadata, true).build();
ClusterState newClusterState = ClusterState.builder(previousClusterState).metadata(newMetadata).build();

// previous manifest with codec 1 and null global metadata
// previous manifest with codec 0 and null global metadata
final ClusterMetadataManifest previousManifest = ClusterMetadataManifest.builder()
.codecVersion(1)
.codecVersion(ClusterMetadataManifest.CODEC_V0)
.globalMetadataFileName(null)
.indices(Collections.emptyList())
.build();
Expand All @@ -402,8 +402,8 @@ public void testMigrationFromCodecV0ManifestToCodecV1Manifest() throws IOExcepti

// global metadata is updated
assertThat(manifestAfterUpdate.getGlobalMetadataFileName(), notNullValue());
// Manifest file with codec version with 2 is updated.
assertThat(manifestAfterUpdate.getCodecVersion(), is(2));
// Manifest file with codec version with 1 is updated.
assertThat(manifestAfterUpdate.getCodecVersion(), is(ClusterMetadataManifest.CODEC_V1));
}

public void testWriteIncrementalGlobalMetadataSuccess() throws IOException {
Expand Down Expand Up @@ -626,8 +626,7 @@ public void testReadLatestMetadataManifestSuccessButNoIndexMetadata() throws IOE
.nodeId("nodeA")
.opensearchVersion(VersionUtils.randomOpenSearchVersion(random()))
.previousClusterUUID("prev-cluster-uuid")
.globalMetadataFileName("global-metadata-file")
.codecVersion(1)
.codecVersion(ClusterMetadataManifest.CODEC_V0)
.build();

BlobContainer blobContainer = mockBlobStoreObjects();
Expand Down Expand Up @@ -684,8 +683,7 @@ public void testReadLatestMetadataManifestSuccess() throws IOException {
.clusterUUID("cluster-uuid")
.nodeId("nodeA")
.opensearchVersion(VersionUtils.randomOpenSearchVersion(random()))
.globalMetadataFileName("global-metadata")
.codecVersion(1)
.codecVersion(ClusterMetadataManifest.CODEC_V0)
.previousClusterUUID("prev-cluster-uuid")
.build();

Expand Down Expand Up @@ -732,8 +730,7 @@ public void testReadLatestIndexMetadataSuccess() throws IOException {
.nodeId("nodeA")
.opensearchVersion(VersionUtils.randomOpenSearchVersion(random()))
.previousClusterUUID("prev-cluster-uuid")
.globalMetadataFileName("global-metadata")
.codecVersion(1)
.codecVersion(ClusterMetadataManifest.CODEC_V0)
.build();

mockBlobContainer(mockBlobStoreObjects(), expectedManifest, Map.of(index.getUUID(), indexMetadata));
Expand Down

0 comments on commit 03167ad

Please sign in to comment.