Skip to content

Commit

Permalink
Add unit tests for block heartbeat reporter.
Browse files Browse the repository at this point in the history
  • Loading branch information
calvinjia committed Jun 27, 2015
1 parent 711c063 commit e5f3834
Showing 1 changed file with 19 additions and 2 deletions.
Expand Up @@ -38,7 +38,7 @@ public void generateReportEmptyTest() {


// Tests a report is correctly generated after moving blocks // Tests a report is correctly generated after moving blocks
@Test @Test
public void generateReportSimpleMoveTest() { public void generateReportMoveTest() {
Long block1 = 1L; Long block1 = 1L;
Long block2 = 2L; Long block2 = 2L;
Long block3 = 3L; Long block3 = 3L;
Expand Down Expand Up @@ -90,7 +90,7 @@ public void generateReportStateClearTest() {


// Tests a report is correctly generated after removing blocks // Tests a report is correctly generated after removing blocks
@Test @Test
public void generateReportSimpleRemoveTest() { public void generateReportRemoveTest() {
Long block1 = 1L; Long block1 = 1L;
Long block2 = 2L; Long block2 = 2L;
Long block3 = 3L; Long block3 = 3L;
Expand All @@ -110,4 +110,21 @@ public void generateReportSimpleRemoveTest() {
Map<Long, List<Long>> addedBlocks = report.getAddedBlocks(); Map<Long, List<Long>> addedBlocks = report.getAddedBlocks();
Assert.assertTrue(addedBlocks.isEmpty()); Assert.assertTrue(addedBlocks.isEmpty());
} }

// Tests a report is correctly generated after moving and then removing a block
@Test
public void generateReportMoveThenRemoveTest() {
Long block1 = 1L;
moveBlock(block1, MEM_LOC);
removeBlock(block1);

// The block should not be in the added blocks list
BlockHeartbeatReport report = mReporter.generateReport();
Assert.assertTrue(report.getAddedBlocks().get(MEM_LOC.getStorageDirId()).isEmpty());

// The block should be in the removed blocks list
List<Long> removedBlocks = report.getRemovedBlocks();
Assert.assertEquals(removedBlocks.size(), 1);
Assert.assertTrue(removedBlocks.contains(block1));
}
} }

0 comments on commit e5f3834

Please sign in to comment.