Skip to content

Commit

Permalink
Fix TranslogTransferManagerTests
Browse files Browse the repository at this point in the history
  • Loading branch information
sachinpkale authored Sep 4, 2023
1 parent 84c6374 commit 5aedc39
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public void testReadMetadataNoFile() throws IOException {
.listAllInSortedOrder(any(BlobPath.class), eq(TranslogTransferMetadata.METADATA_PREFIX), anyInt(), any(ActionListener.class));

assertNull(translogTransferManager.readMetadata());
assertNoDownloadStats();
assertNoDownloadStats(false);
}

// This should happen most of the time - Just a single metadata file
Expand Down Expand Up @@ -307,7 +307,7 @@ public void testReadMetadataReadException() throws IOException {
when(transferService.downloadBlob(any(BlobPath.class), eq(mdFilename))).thenThrow(new IOException("Something went wrong"));

assertThrows(IOException.class, translogTransferManager::readMetadata);
assertNoDownloadStats();
assertNoDownloadStats(true);
}

public void testMetadataFileNameOrder() throws IOException {
Expand Down Expand Up @@ -339,7 +339,7 @@ public void testReadMetadataListException() throws IOException {
when(transferService.downloadBlob(any(BlobPath.class), any(String.class))).thenThrow(new IOException("Something went wrong"));

assertThrows(IOException.class, translogTransferManager::readMetadata);
assertNoDownloadStats();
assertNoDownloadStats(false);
}

public void testDownloadTranslog() throws IOException {
Expand Down Expand Up @@ -480,11 +480,15 @@ public void testDeleteTranslogFailure() throws Exception {
assertEquals(2, tracker.allUploaded().size());
}

private void assertNoDownloadStats() {
private void assertNoDownloadStats(boolean nonZeroUploadTime) {
assertEquals(0, remoteTranslogTransferTracker.getDownloadBytesSucceeded());
assertEquals(0, remoteTranslogTransferTracker.getTotalDownloadsSucceeded());
assertEquals(0, remoteTranslogTransferTracker.getTotalDownloadTimeInMillis());
assertEquals(0, remoteTranslogTransferTracker.getLastSuccessfulDownloadTimestamp());
if (nonZeroUploadTime) {
assertNotEquals(0, remoteTranslogTransferTracker.getTotalDownloadTimeInMillis());
} else {
assertEquals(0, remoteTranslogTransferTracker.getTotalDownloadTimeInMillis());
}
}

private void assertTlogCkpDownloadStats() {
Expand Down

0 comments on commit 5aedc39

Please sign in to comment.