Skip to content

Commit

Permalink
update test
Browse files Browse the repository at this point in the history
  • Loading branch information
zhli1142015 committed Jun 24, 2020
1 parent a6760e1 commit b9057ec
Showing 1 changed file with 16 additions and 1 deletion.
Expand Up @@ -165,12 +165,17 @@ class HistoryServerDiskManagerSuite extends SparkFunSuite with BeforeAndAfter {
val dstA = leaseA.commit("app1", None)
assert(manager.free() === 0)
assert(manager.committed() === 3)
// Listing store tracks dstA now.
assert(store.read(classOf[ApplicationStoreInfo], dstA.getAbsolutePath).size === 3)

// Simulate: service restarts, new disk manager (manager1) is initialized.
val manager1 = mockManager()
// Simulate: leveldb compaction before restart, directory size reduces.
// Simulate: event KVstore compaction before restart, directory size reduces.
doReturn(2L).when(manager1).sizeOf(meq(dstA))
doReturn(2L).when(manager1).sizeOf(meq(new File(testDir, "apps")))
manager1.initialize()
// "ApplicationStoreInfo.size" is updated for dstA.
assert(store.read(classOf[ApplicationStoreInfo], dstA.getAbsolutePath).size === 2)
assert(manager1.free() === 1)
// If "ApplicationStoreInfo.size" is not correctly updated, "IllegalStateException"
// would be thrown.
Expand All @@ -179,14 +184,24 @@ class HistoryServerDiskManagerSuite extends SparkFunSuite with BeforeAndAfter {
doReturn(2L).when(manager1).sizeOf(meq(leaseB.tmpPath))
val dstB = leaseB.commit("app2", None)
assert(manager1.committed() === 2)
// Listing store tracks dstB only, dstA is evicted by "makeRoom()".
assert(store.read(classOf[ApplicationStoreInfo], dstB.getAbsolutePath).size === 2)

val manager2 = mockManager()
// Simulate: cache entities are written after replaying, directory size increases.
doReturn(3L).when(manager2).sizeOf(meq(dstB))
doReturn(3L).when(manager2).sizeOf(meq(new File(testDir, "apps")))
manager2.initialize()
// "ApplicationStoreInfo.size" is updated for dstB.
assert(store.read(classOf[ApplicationStoreInfo], dstB.getAbsolutePath).size === 3)
assert(manager2.free() === 0)
val leaseC = manager2.lease(2)
doReturn(2L).when(manager2).sizeOf(meq(leaseC.tmpPath))
val dstC = leaseC.commit("app3", None)
assert(manager2.free() === 1)
assert(manager2.committed() === 2)
// Listing store tracks dstC only, dstB is evicted by "makeRoom()".
assert(store.read(classOf[ApplicationStoreInfo], dstC.getAbsolutePath).size === 2)
}

}

0 comments on commit b9057ec

Please sign in to comment.