SPARK-1365 [HOTFIX] 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. Author: Patrick Wendell <pwendell@gmail.com> Closes #277 from pwendell/rate-limited-stream and squashes the following commits: 6c0ff81 [Patrick Wendell] SPARK-1365: Fix RateLimitedOutputStream test
This commit is contained in:
parent
5731af5be6
commit
33b3c2a8c6
|
@ -36,8 +36,9 @@ class RateLimitedOutputStreamSuite extends FunSuite {
|
|||
val stream = new RateLimitedOutputStream(underlying, desiredBytesPerSec = 10000)
|
||||
val elapsedNs = benchmark { stream.write(data.getBytes("UTF-8")) }
|
||||
|
||||
// We accept anywhere from 4.0 to 4.99999 seconds since the value is rounded down.
|
||||
assert(SECONDS.convert(elapsedNs, NANOSECONDS) === 4)
|
||||
val seconds = SECONDS.convert(elapsedNs, NANOSECONDS)
|
||||
assert(seconds >= 4, s"Seconds value ($seconds) is less than 4.")
|
||||
assert(seconds <= 30, s"Took more than 30 seconds ($seconds) to write data.")
|
||||
assert(underlying.toString("UTF-8") === data)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue