Alluxio / Community

New Contributor Tasks for Alluxio
20 stars 38 forks source link

Improve DefaultBlockWorkerTest.getStoreMeta #589

Closed LuQQiu closed 3 years ago

LuQQiu commented 3 years ago

Improve DefaultBlockWorkerTest.getStoreMeta() to actually testing the content of the returned store metadata instead of using meaningless

    verify(mBlockStore, times(2)).getBlockStoreMeta(); // 1 is called at metrics registration
    verify(mBlockStore).getBlockStoreMetaFull();

An example is that we can test the store capacity information

    BlockStoreMeta storeMeta = mBlockWorker.getStoreMeta();
    assertEquals(STORAGE_SIZE * 2, storeMeta.getCapacityBytes());
    Map<String, Long> capacityBytesOnTiers = storeMeta.getCapacityBytesOnTiers();
    assertTrue(capacityBytesOnTiers.containsKey("MEM"));
    assertEquals(STORAGE_SIZE, (long) capacityBytesOnTiers.get("MEM"));
    assertTrue(capacityBytesOnTiers.containsKey("HDD"));
    assertEquals(STORAGE_SIZE, (long) capacityBytesOnTiers.get("HDD"));
    assertEquals(0, storeMeta.getUsedBytes());
    assertTrue(capacityBytesOnTiers.containsKey("MEM"));
    assertEquals(STORAGE_SIZE, (long) capacityBytesOnTiers.get("MEM"));
    assertTrue(capacityBytesOnTiers.containsKey("HDD"));
    assertEquals(STORAGE_SIZE, (long) capacityBytesOnTiers.get("HDD"));

Task1: Test the contents of BlockStoreMeta returned by .getBlockStoreMeta() and getBlockStoreMetaFull() on an empty block store and see if the results are expected.

Task2: Create new test blocks to test if block store has new blocks or other new changes, is the BlockStoreMeta reflected the changes correctly.

Time estimate: 1 week