You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by pw...@apache.org on 2014/04/01 01:25:52 UTC

git commit: SPARK-1365 [HOTFIX] Fix RateLimitedOutputStream test

Repository: spark
Updated Branches:
  refs/heads/master 5731af5be -> 33b3c2a8c


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 <pw...@gmail.com>

Closes #277 from pwendell/rate-limited-stream and squashes the following commits:

6c0ff81 [Patrick Wendell] SPARK-1365: Fix RateLimitedOutputStream test


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/33b3c2a8
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/33b3c2a8
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/33b3c2a8

Branch: refs/heads/master
Commit: 33b3c2a8c6c71b89744834017a183ea855e1697c
Parents: 5731af5
Author: Patrick Wendell <pw...@gmail.com>
Authored: Mon Mar 31 16:25:43 2014 -0700
Committer: Patrick Wendell <pw...@gmail.com>
Committed: Mon Mar 31 16:25:43 2014 -0700

----------------------------------------------------------------------
 .../spark/streaming/util/RateLimitedOutputStreamSuite.scala     | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/33b3c2a8/streaming/src/test/scala/org/apache/spark/streaming/util/RateLimitedOutputStreamSuite.scala
----------------------------------------------------------------------
diff --git a/streaming/src/test/scala/org/apache/spark/streaming/util/RateLimitedOutputStreamSuite.scala b/streaming/src/test/scala/org/apache/spark/streaming/util/RateLimitedOutputStreamSuite.scala
index 7d18a0f..9ebf7b4 100644
--- a/streaming/src/test/scala/org/apache/spark/streaming/util/RateLimitedOutputStreamSuite.scala
+++ b/streaming/src/test/scala/org/apache/spark/streaming/util/RateLimitedOutputStreamSuite.scala
@@ -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)
   }
 }