Skip to content

Commit e81c3fc

Browse files
committed
CR feedback, replace some magic values with option in the tests to improve readability.
1 parent 679fbe7 commit e81c3fc

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

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

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -187,29 +187,35 @@ class BlockManagerDecommissionUnitSuite extends SparkFunSuite with Matchers {
187187
try {
188188
bmDecomManager.start()
189189

190-
var previousRDDTime = Long.MaxValue
191-
var previousShuffleTime = Long.MaxValue
190+
var previousRDDTime: Option[Long] = None
191+
var previousShuffleTime: Option[Long] = None
192192

193193
// We don't check that all blocks are migrated because out mock is always returning an RDD.
194-
eventually(timeout(10.second), interval(10.milliseconds)) {
194+
eventually(timeout(100.second), interval(10.milliseconds)) {
195195
assert(bmDecomManager.shufflesToMigrate.isEmpty == true)
196196
verify(bm, least(1)).replicateBlock(
197197
mc.eq(storedBlockId1), mc.any(), mc.any(), mc.eq(Some(3)))
198198
verify(blockTransferService, times(2))
199199
.uploadBlockSync(mc.eq("host2"), mc.eq(bmPort), mc.eq("exec2"), mc.any(), mc.any(),
200200
mc.eq(StorageLevel.DISK_ONLY), mc.isNull())
201-
// Since we never "finish" the RDD blocks make sure the time is always moving forward.
201+
// Since we never "finish" the RDD blocks, make sure the time is always moving forward.
202202
assert(bmDecomManager.rddBlocksLeft)
203-
if (!(bmDecomManager.lastRDDMigrationTime > previousRDDTime)) {
204-
previousRDDTime = bmDecomManager.lastRDDMigrationTime
205-
assert(false)
203+
previousRDDTime match {
204+
case None =>
205+
previousRDDTime = Some(bmDecomManager.lastRDDMigrationTime)
206+
assert(false)
207+
case Some(t) =>
208+
assert(bmDecomManager.lastRDDMigrationTime > t)
206209
}
207210
// Since we do eventually finish the shuffle blocks make sure the shuffle blocks complete
208211
// and that the time keeps moving forward.
209212
assert(!bmDecomManager.shuffleBlocksLeft)
210-
if (!(bmDecomManager.lastShuffleMigrationTime > previousShuffleTime)) {
211-
previousShuffleTime = bmDecomManager.lastShuffleMigrationTime
212-
assert(false)
213+
previousShuffleTime match {
214+
case None =>
215+
previousShuffleTime = Some(bmDecomManager.lastShuffleMigrationTime)
216+
assert(false)
217+
case Some(t) =>
218+
assert(bmDecomManager.lastShuffleMigrationTime > t)
213219
}
214220
}
215221
} finally {

0 commit comments

Comments
 (0)