Skip to content
Snippets Groups Projects
Commit 37f963ac authored by caoxuewen's avatar caoxuewen Committed by Sean Owen
Browse files

[SPARK-20518][CORE] Supplement the new blockidsuite unit tests

## What changes were proposed in this pull request?

This PR adds the new unit tests to support ShuffleDataBlockId , ShuffleIndexBlockId , TempShuffleBlockId , TempLocalBlockId

## How was this patch tested?

The new unit test.

Author: caoxuewen <cao.xuewen@zte.com.cn>

Closes #17794 from heary-cao/blockidsuite.
parent 63d90e7d
No related branches found
No related tags found
No related merge requests found
......@@ -17,6 +17,8 @@
package org.apache.spark.storage
import java.util.UUID
import org.apache.spark.SparkFunSuite
class BlockIdSuite extends SparkFunSuite {
......@@ -67,6 +69,32 @@ class BlockIdSuite extends SparkFunSuite {
assertSame(id, BlockId(id.toString))
}
test("shuffle data") {
val id = ShuffleDataBlockId(4, 5, 6)
assertSame(id, ShuffleDataBlockId(4, 5, 6))
assertDifferent(id, ShuffleDataBlockId(6, 5, 6))
assert(id.name === "shuffle_4_5_6.data")
assert(id.asRDDId === None)
assert(id.shuffleId === 4)
assert(id.mapId === 5)
assert(id.reduceId === 6)
assert(!id.isShuffle)
assertSame(id, BlockId(id.toString))
}
test("shuffle index") {
val id = ShuffleIndexBlockId(7, 8, 9)
assertSame(id, ShuffleIndexBlockId(7, 8, 9))
assertDifferent(id, ShuffleIndexBlockId(9, 8, 9))
assert(id.name === "shuffle_7_8_9.index")
assert(id.asRDDId === None)
assert(id.shuffleId === 7)
assert(id.mapId === 8)
assert(id.reduceId === 9)
assert(!id.isShuffle)
assertSame(id, BlockId(id.toString))
}
test("broadcast") {
val id = BroadcastBlockId(42)
assertSame(id, BroadcastBlockId(42))
......@@ -101,6 +129,30 @@ class BlockIdSuite extends SparkFunSuite {
assertSame(id, BlockId(id.toString))
}
test("temp local") {
val id = TempLocalBlockId(new UUID(5, 2))
assertSame(id, TempLocalBlockId(new UUID(5, 2)))
assertDifferent(id, TempLocalBlockId(new UUID(5, 3)))
assert(id.name === "temp_local_00000000-0000-0005-0000-000000000002")
assert(id.asRDDId === None)
assert(id.isBroadcast === false)
assert(id.id.getMostSignificantBits() === 5)
assert(id.id.getLeastSignificantBits() === 2)
assert(!id.isShuffle)
}
test("temp shuffle") {
val id = TempShuffleBlockId(new UUID(1, 2))
assertSame(id, TempShuffleBlockId(new UUID(1, 2)))
assertDifferent(id, TempShuffleBlockId(new UUID(1, 3)))
assert(id.name === "temp_shuffle_00000000-0000-0001-0000-000000000002")
assert(id.asRDDId === None)
assert(id.isBroadcast === false)
assert(id.id.getMostSignificantBits() === 1)
assert(id.id.getLeastSignificantBits() === 2)
assert(!id.isShuffle)
}
test("test") {
val id = TestBlockId("abc")
assertSame(id, TestBlockId("abc"))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment