Skip to content
Permalink
Browse files

add a unit test for medium type

  • Loading branch information...
yuzhu committed May 12, 2019
1 parent 4999ec4 commit 6af70f8fa26e2e09dbdf992d926bd63239fe98e6
@@ -266,7 +266,7 @@ public void createBlockLowerTier() throws Exception {
}

/**
* Tests the {@link BlockWorker#createBlockRemote(long, long, String, long)} method.
* Tests the {@link BlockWorker#createBlockRemote(long, long, String, String, long)} method.
*/
@Test
public void createBlockRemote() throws Exception {
@@ -61,6 +61,7 @@
private static final long BLOCK_ID1 = 1000;
private static final long BLOCK_ID2 = 1001;
private static final long TEMP_BLOCK_ID = 1003;
private static final long TEMP_BLOCK_ID2 = 1004;
private static final long BLOCK_SIZE = 512;
private static final long FREE_SPACE_TIMEOUT_MS = 100;
private static final String FIRST_TIER_ALIAS = TieredBlockStoreTestUtils.TIER_ALIAS[0];
@@ -71,6 +72,7 @@
private StorageDir mTestDir1;
private StorageDir mTestDir2;
private StorageDir mTestDir3;
private StorageDir mTestDir4;
private Evictor mEvictor;

/** Rule to create a new temporary folder during each test. */
@@ -106,6 +108,7 @@ public void before() throws Exception {
mTestDir1 = mMetaManager.getTier(FIRST_TIER_ALIAS).getDir(0);
mTestDir2 = mMetaManager.getTier(FIRST_TIER_ALIAS).getDir(1);
mTestDir3 = mMetaManager.getTier(SECOND_TIER_ALIAS).getDir(1);
mTestDir4 = mMetaManager.getTier(SECOND_TIER_ALIAS).getDir(0);
}

/**
@@ -394,6 +397,22 @@ public void createBlockMetaWithoutEviction() throws Exception {
assertEquals(mTestDir1, tempBlockMeta.getParentDir());
}

@Test
public void createBlockMetaWithMediumType() throws Exception {
BlockStoreLocation loc = mBlockStore.getMedium("MEM");
TempBlockMeta tempBlockMeta = mBlockStore.createBlock(SESSION_ID1, TEMP_BLOCK_ID,
loc,1 );
assertEquals(1, tempBlockMeta.getBlockSize());
assertEquals(mTestDir1, tempBlockMeta.getParentDir());

BlockStoreLocation loc2 = mBlockStore.getMedium("SSD");
TempBlockMeta tempBlockMeta2 = mBlockStore.createBlock(SESSION_ID1, TEMP_BLOCK_ID2,
loc2,1 );
assertEquals(1, tempBlockMeta2.getBlockSize());
assertEquals(mTestDir4, tempBlockMeta2.getParentDir());

}

/**
* Tests that when creating a block, if the space of the target location is currently taken by
* another block being locked, this creation operation will fail until the lock released.

0 comments on commit 6af70f8

Please sign in to comment.
You can’t perform that action at this time.