Skip to content

Commit 37f963a

Browse files
heary-caosrowen
authored andcommitted
[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 <[email protected]> Closes #17794 from heary-cao/blockidsuite.
1 parent 63d90e7 commit 37f963a

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

core/src/test/scala/org/apache/spark/storage/BlockIdSuite.scala

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
package org.apache.spark.storage
1919

20+
import java.util.UUID
21+
2022
import org.apache.spark.SparkFunSuite
2123

2224
class BlockIdSuite extends SparkFunSuite {
@@ -67,6 +69,32 @@ class BlockIdSuite extends SparkFunSuite {
6769
assertSame(id, BlockId(id.toString))
6870
}
6971

72+
test("shuffle data") {
73+
val id = ShuffleDataBlockId(4, 5, 6)
74+
assertSame(id, ShuffleDataBlockId(4, 5, 6))
75+
assertDifferent(id, ShuffleDataBlockId(6, 5, 6))
76+
assert(id.name === "shuffle_4_5_6.data")
77+
assert(id.asRDDId === None)
78+
assert(id.shuffleId === 4)
79+
assert(id.mapId === 5)
80+
assert(id.reduceId === 6)
81+
assert(!id.isShuffle)
82+
assertSame(id, BlockId(id.toString))
83+
}
84+
85+
test("shuffle index") {
86+
val id = ShuffleIndexBlockId(7, 8, 9)
87+
assertSame(id, ShuffleIndexBlockId(7, 8, 9))
88+
assertDifferent(id, ShuffleIndexBlockId(9, 8, 9))
89+
assert(id.name === "shuffle_7_8_9.index")
90+
assert(id.asRDDId === None)
91+
assert(id.shuffleId === 7)
92+
assert(id.mapId === 8)
93+
assert(id.reduceId === 9)
94+
assert(!id.isShuffle)
95+
assertSame(id, BlockId(id.toString))
96+
}
97+
7098
test("broadcast") {
7199
val id = BroadcastBlockId(42)
72100
assertSame(id, BroadcastBlockId(42))
@@ -101,6 +129,30 @@ class BlockIdSuite extends SparkFunSuite {
101129
assertSame(id, BlockId(id.toString))
102130
}
103131

132+
test("temp local") {
133+
val id = TempLocalBlockId(new UUID(5, 2))
134+
assertSame(id, TempLocalBlockId(new UUID(5, 2)))
135+
assertDifferent(id, TempLocalBlockId(new UUID(5, 3)))
136+
assert(id.name === "temp_local_00000000-0000-0005-0000-000000000002")
137+
assert(id.asRDDId === None)
138+
assert(id.isBroadcast === false)
139+
assert(id.id.getMostSignificantBits() === 5)
140+
assert(id.id.getLeastSignificantBits() === 2)
141+
assert(!id.isShuffle)
142+
}
143+
144+
test("temp shuffle") {
145+
val id = TempShuffleBlockId(new UUID(1, 2))
146+
assertSame(id, TempShuffleBlockId(new UUID(1, 2)))
147+
assertDifferent(id, TempShuffleBlockId(new UUID(1, 3)))
148+
assert(id.name === "temp_shuffle_00000000-0000-0001-0000-000000000002")
149+
assert(id.asRDDId === None)
150+
assert(id.isBroadcast === false)
151+
assert(id.id.getMostSignificantBits() === 1)
152+
assert(id.id.getLeastSignificantBits() === 2)
153+
assert(!id.isShuffle)
154+
}
155+
104156
test("test") {
105157
val id = TestBlockId("abc")
106158
assertSame(id, TestBlockId("abc"))

0 commit comments

Comments
 (0)