shauryachats commented on code in PR #18467:
URL: https://github.com/apache/pinot/pull/18467#discussion_r3263671674
##########
pinot-server/src/test/java/org/apache/pinot/server/predownload/PredownloadSchedulerTest.java:
##########
@@ -216,22 +217,25 @@ public void
getSegmentsInfoWithoutCrypterName(PredownloadZKClient predownloadZkC
_predownloadScheduler.getSegmentsInfo();
}
- public void loadSegmentsFromLocal() {
- // Only segment 3 will be loaded
- SegmentDirectory segmentDirectory = mock(SegmentDirectory.class);
- SegmentMetadataImpl segmentMetadata = mock(SegmentMetadataImpl.class);
- when(segmentDirectory.getSegmentMetadata()).thenReturn(segmentMetadata);
- when(segmentDirectory.getDiskSizeBytes()).thenReturn(DISK_SIZE_BYTES);
- when(segmentMetadata.getCrc()).thenReturn(String.valueOf(CRC));
+ public void loadSegmentsFromLocal()
+ throws Exception {
+ // Only segment 3 will be loaded — create a real creation.meta with
matching CRC
+ File seg3Dir =
Files.createTempDirectory("predownload-seg3-predownload-seg3-").toFile();
+ File creationMeta = new File(seg3Dir, "creation.meta");
+ try (DataOutputStream dos = new DataOutputStream(new
FileOutputStream(creationMeta))) {
+ dos.writeLong(CRC);
+ dos.writeLong(0L);
+ }
when(_predownloadTableInfo.loadSegmentFromLocal(eq(_predownloadSegmentInfoList.get(2)))).thenAnswer(
invocation -> {
-
_predownloadSegmentInfoList.get(2).updateSegmentInfoFromLocal(segmentDirectory);
+
_predownloadSegmentInfoList.get(2).updateSegmentInfoFromLocal(seg3Dir);
return true;
});
when(_predownloadTableInfo.loadSegmentFromLocal(eq(_predownloadSegmentInfoList.get(0)))).thenReturn(false);
when(_predownloadTableInfo.loadSegmentFromLocal(eq(_predownloadSegmentInfoList.get(1)))).thenReturn(false);
_predownloadScheduler.loadSegmentsFromLocal();
+ FileUtils.deleteQuietly(seg3Dir);
Review Comment:
Can we put this in `finally`? If
`_predownloadScheduler.loadSegmentsFromLocal()` throws, this would not be
executed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]