Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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