@@ -895,6 +895,17 @@ class BlockManagerSuite extends SparkFunSuite with Matchers with BeforeAndAfterE
895895 val list = List .fill(2 )(new Array [Byte ](2000 ))
896896 val bigList = List .fill(8 )(new Array [Byte ](2000 ))
897897
898+ def getUpdatedBlocks (task : => Unit ): Seq [(BlockId , BlockStatus )] = {
899+ val context = TaskContext .empty()
900+ try {
901+ TaskContext .setTaskContext(context)
902+ task
903+ } finally {
904+ TaskContext .unset()
905+ }
906+ context.taskMetrics.updatedBlocks.getOrElse(Seq [(BlockId , BlockStatus )]())
907+ }
908+
898909 // 1 updated block (i.e. list1)
899910 val updatedBlocks1 =
900911 store.putIterator(" list1" , list.iterator, StorageLevel .MEMORY_ONLY , tellMaster = true )
@@ -954,6 +965,16 @@ class BlockManagerSuite extends SparkFunSuite with Matchers with BeforeAndAfterE
954965 assert(! store.diskStore.contains(" list3" ), " list3 was in disk store" )
955966 assert(! store.diskStore.contains(" list4" ), " list4 was in disk store" )
956967 assert(! store.diskStore.contains(" list5" ), " list5 was in disk store" )
968+
969+ // remove block - list2 should be removed from disk
970+ val updatedBlocks6 = getUpdatedBlocks {
971+ store.removeBlock(
972+ " list2" , tellMaster = true )
973+ }
974+ assert(updatedBlocks6.size === 1 )
975+ assert(updatedBlocks6.head._1 === TestBlockId (" list2" ))
976+ assert(updatedBlocks6.head._2.storageLevel == StorageLevel .NONE )
977+ assert(! store.diskStore.contains(" list2" ), " list2 was in disk store" )
957978 }
958979
959980 test(" query block statuses" ) {
0 commit comments