Skip to content

Commit

Permalink
[SPARK-20518][CORE] Supplement the new blockidsuite unit tests
Browse files Browse the repository at this point in the history
## 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 apache#17794 from heary-cao/blockidsuite.
  • Loading branch information
heary-cao authored and liyichao committed May 24, 2017
1 parent 44baeb3 commit 49fa480
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions core/src/test/scala/org/apache/spark/storage/BlockIdSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package org.apache.spark.storage

import java.util.UUID

import org.apache.spark.SparkFunSuite

class BlockIdSuite extends SparkFunSuite {
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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"))
Expand Down

0 comments on commit 49fa480

Please sign in to comment.