Skip to content

Commit

Permalink
Update tests and CHANGELOG
Browse files Browse the repository at this point in the history
Signed-off-by: Bhumika Saini <[email protected]>
  • Loading branch information
Bhumika Saini committed Jun 15, 2023
1 parent 72fb904 commit 6431f82
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 9 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Change `com.amazonaws.sdk.ec2MetadataServiceEndpointOverride` to `aws.ec2MetadataServiceEndpoint` ([7372](https://github.com/opensearch-project/OpenSearch/pull/7372/))
- Change `com.amazonaws.sdk.stsEndpointOverride` to `aws.stsEndpointOverride` ([7372](https://github.com/opensearch-project/OpenSearch/pull/7372/))
- Align range and default value for deletes_pct_allowed in merge policy ([#7730](https://github.com/opensearch-project/OpenSearch/pull/7730))
- Rename QueryPhase actors like Suggest, Rescore to be processors rather than phase ([#8025](https://github.com/opensearch-project/OpenSearch/pull/8025))
- Rename QueryPhase actors like Suggest, Rescore to be processors rather than phase ([#8025](https://github.com/opensearch-project/OpenSearch/pull/8025))

### Deprecated

Expand Down Expand Up @@ -119,6 +119,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Compress and cache cluster state during validate join request ([#7321](https://github.com/opensearch-project/OpenSearch/pull/7321))
- [Snapshot Interop] Add Changes in Create Snapshot Flow for remote store interoperability. ([#7118](https://github.com/opensearch-project/OpenSearch/pull/7118))
- Add new query profile collector fields with concurrent search execution ([#7898](https://github.com/opensearch-project/OpenSearch/pull/7898))
- Add Lucene version to UploadedSegmentMetadata ([#8088](https://github.com/opensearch-project/OpenSearch/pull/8088))

### Deprecated

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,7 @@ public long getLength() {
public static UploadedSegmentMetadata fromString(String uploadedFilename) {
String[] values = uploadedFilename.split(SEPARATOR);
UploadedSegmentMetadata metadata = new UploadedSegmentMetadata(values[0], values[1], values[2], Long.parseLong(values[3]));
if (values.length == 5) {
metadata.setWrittenBy(values[4]);
}
metadata.setWrittenBy(values[4]);

return metadata;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.apache.lucene.store.IndexOutput;
import org.apache.lucene.store.OutputStreamIndexOutput;
import org.apache.lucene.tests.util.LuceneTestCase;
import org.apache.lucene.util.Version;
import org.junit.After;
import org.junit.Before;
import org.opensearch.cluster.metadata.IndexMetadata;
Expand Down Expand Up @@ -95,14 +96,22 @@ public void testUploadedSegmentMetadataToString() {
"123456",
1234
);
assertEquals("abc::pqr::123456::1234", metadata.toString());
metadata.setWrittenBy(Version.LATEST);
assertEquals("abc::pqr::123456::1234::" + Version.LATEST, metadata.toString());
}

public void testUploadedSegmentMetadataFromString() {
RemoteSegmentStoreDirectory.UploadedSegmentMetadata metadata = RemoteSegmentStoreDirectory.UploadedSegmentMetadata.fromString(
"_0.cfe::_0.cfe__uuidxyz::4567::372000"
"_0.cfe::_0.cfe__uuidxyz::4567::372000::" + Version.LATEST
);
assertEquals("_0.cfe::_0.cfe__uuidxyz::4567::372000::" + Version.LATEST, metadata.toString());
}

public void testUploadedSegmentMetadataFromStringException() {
assertThrows(
ArrayIndexOutOfBoundsException.class,
() -> RemoteSegmentStoreDirectory.UploadedSegmentMetadata.fromString("_0.cfe::_0.cfe__uuidxyz::4567::372000")
);
assertEquals("_0.cfe::_0.cfe__uuidxyz::4567::372000", metadata.toString());
}

public void testGetMetadataFilename() {
Expand Down Expand Up @@ -181,6 +190,12 @@ private Map<String, String> getDummyMetadata(String prefix, int commitGeneration
+ randomIntBetween(1000, 5000)
+ "::"
+ randomIntBetween(512000, 1024000)
+ "::"
+ Version.MIN_SUPPORTED_MAJOR
+ "."
+ "0"
+ "."
+ "0"
);
metadata.put(
prefix + ".cfs",
Expand All @@ -193,6 +208,12 @@ private Map<String, String> getDummyMetadata(String prefix, int commitGeneration
+ randomIntBetween(1000, 5000)
+ "::"
+ randomIntBetween(512000, 1024000)
+ "::"
+ Version.MIN_SUPPORTED_MAJOR
+ "."
+ "0"
+ "."
+ "0"
);
metadata.put(
prefix + ".si",
Expand All @@ -205,6 +226,8 @@ private Map<String, String> getDummyMetadata(String prefix, int commitGeneration
+ randomIntBetween(1000, 5000)
+ "::"
+ randomIntBetween(512000, 1024000)
+ "::"
+ Version.LATEST
);
metadata.put(
"segments_" + commitGeneration,
Expand All @@ -218,6 +241,8 @@ private Map<String, String> getDummyMetadata(String prefix, int commitGeneration
+ randomIntBetween(1000, 5000)
+ "::"
+ randomIntBetween(1024, 5120)
+ "::"
+ Version.LATEST
);
return metadata;
}
Expand Down Expand Up @@ -574,8 +599,8 @@ public void testContainsFile() throws IOException {
);

Map<String, String> metadata = new HashMap<>();
metadata.put("_0.cfe", "_0.cfe::_0.cfe__" + UUIDs.base64UUID() + "::1234::512");
metadata.put("_0.cfs", "_0.cfs::_0.cfs__" + UUIDs.base64UUID() + "::2345::1024");
metadata.put("_0.cfe", "_0.cfe::_0.cfe__" + UUIDs.base64UUID() + "::1234::512::" + Version.LATEST);
metadata.put("_0.cfs", "_0.cfs::_0.cfs__" + UUIDs.base64UUID() + "::2345::1024::" + Version.LATEST);

when(remoteMetadataDirectory.openInput("metadata__1__5__abc", IOContext.DEFAULT)).thenReturn(createMetadataFileBytes(metadata, 1));

Expand Down

0 comments on commit 6431f82

Please sign in to comment.