Skip to content

Commit 6c0ff81

Browse files
committed
SPARK-1365: Fix RateLimitedOutputStream test
This test needs to be fixed. It currently depends on Thread.sleep() having exact-timing semantics, which is not a valid assumption.
1 parent d666053 commit 6c0ff81

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

streaming/src/test/scala/org/apache/spark/streaming/util/RateLimitedOutputStreamSuite.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ class RateLimitedOutputStreamSuite extends FunSuite {
3636
val stream = new RateLimitedOutputStream(underlying, desiredBytesPerSec = 10000)
3737
val elapsedNs = benchmark { stream.write(data.getBytes("UTF-8")) }
3838

39-
// We accept anywhere from 4.0 to 4.99999 seconds since the value is rounded down.
40-
assert(SECONDS.convert(elapsedNs, NANOSECONDS) === 4)
39+
val seconds = SECONDS.convert(elapsedNs, NANOSECONDS)
40+
assert(seconds >= 4, s"Seconds value ($seconds) is less than 4.")
41+
assert(seconds <= 30, s"Took more than 30 seconds ($seconds) to write data.")
4142
assert(underlying.toString("UTF-8") === data)
4243
}
4344
}

0 commit comments

Comments
 (0)