{"action":"created","comment":{"url":"https://api.github.com/repos/datastax/spark-cassandra-connector/pulls/comments/26738643","id":26738643,"diff_hunk":"@@ -4,44 +4,36 @@ import org.scalatest.{FlatSpec, Matchers}\n \n class RateLimiterSpec extends FlatSpec with Matchers {\n \n-  // Warning, this test is timing-based.\n-  // It may fail if run on a heavily loaded system with unpredictable performance.\n-  // Increase allowedSystemInducedPause if you encounter any problems:\n-  val allowedSystemInducedPause = 250 // ms\n-\n   \"RateLimiter\" should \"not cause delays if rate is not exceeded\" in {\n-    val limiter = new RateLimiter(Long.MaxValue, 1000)\n-    val start1 = System.currentTimeMillis()\n-    for (i <- 1 to 1000000)\n-      limiter.maybeSleep(0)\n-    val end1 = System.currentTimeMillis()\n-    val referenceElapsed = end1 - start1\n-\n-    val start2 = System.currentTimeMillis()\n-    for (i <- 1 to 1000000)\n-      limiter.maybeSleep(1000)\n-    val end2 = System.currentTimeMillis()\n-    val testElapsed = end2 - start2\n-    testElapsed should be <= referenceElapsed + allowedSystemInducedPause\n+    var now: Long = 0\n+    def sleep(delay: Long) = throw new Exception(\"Sleep must never be called in this test\")","path":"spark-cassandra-connector/src/test/scala/com/datastax/spark/connector/writer/RateLimiterSpec.scala","position":24,"original_position":24,"commit_id":"137e2b8202295272f1adcf40bcc2066d5ad3d77f","original_commit_id":"137e2b8202295272f1adcf40bcc2066d5ad3d77f","user":{"login":"pedjak","id":132690,"avatar_url":"https://avatars.githubusercontent.com/u/132690?v=3","gravatar_id":"","url":"https://api.github.com/users/pedjak","html_url":"https://github.com/pedjak","followers_url":"https://api.github.com/users/pedjak/followers","following_url":"https://api.github.com/users/pedjak/following{/other_user}","gists_url":"https://api.github.com/users/pedjak/gists{/gist_id}","starred_url":"https://api.github.com/users/pedjak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pedjak/subscriptions","organizations_url":"https://api.github.com/users/pedjak/orgs","repos_url":"https://api.github.com/users/pedjak/repos","events_url":"https://api.github.com/users/pedjak/events{/privacy}","received_events_url":"https://api.github.com/users/pedjak/received_events","type":"User","site_admin":false},"body":"why not using ScalaMocks here instead? It is cleaner to me - you can check than assert that no interaction happened.","created_at":"2015-03-19T09:23:24Z","updated_at":"2015-03-19T09:23:24Z","html_url":"https://github.com/datastax/spark-cassandra-connector/pull/592#discussion_r26738643","pull_request_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/pulls/592","_links":{"self":{"href":"https://api.github.com/repos/datastax/spark-cassandra-connector/pulls/comments/26738643"},"html":{"href":"https://github.com/datastax/spark-cassandra-connector/pull/592#discussion_r26738643"},"pull_request":{"href":"https://api.github.com/repos/datastax/spark-cassandra-connector/pulls/592"}}},"pull_request":{"url":"https://api.github.com/repos/datastax/spark-cassandra-connector/pulls/592","id":31505262,"html_url":"https://github.com/datastax/spark-cassandra-connector/pull/592","diff_url":"https://github.com/datastax/spark-cassandra-connector/pull/592.diff","patch_url":"https://github.com/datastax/spark-cassandra-connector/pull/592.patch","issue_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/issues/592","number":592,"state":"open","locked":false,"title":"SPARKC-96: Allow RateLimiter to use an alternative time source and sleep...","user":{"login":"pkolaczk","id":1352795,"avatar_url":"https://avatars.githubusercontent.com/u/1352795?v=3","gravatar_id":"","url":"https://api.github.com/users/pkolaczk","html_url":"https://github.com/pkolaczk","followers_url":"https://api.github.com/users/pkolaczk/followers","following_url":"https://api.github.com/users/pkolaczk/following{/other_user}","gists_url":"https://api.github.com/users/pkolaczk/gists{/gist_id}","starred_url":"https://api.github.com/users/pkolaczk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pkolaczk/subscriptions","organizations_url":"https://api.github.com/users/pkolaczk/orgs","repos_url":"https://api.github.com/users/pkolaczk/repos","events_url":"https://api.github.com/users/pkolaczk/events{/privacy}","received_events_url":"https://api.github.com/users/pkolaczk/received_events","type":"User","site_admin":false},"body":"... method. Make the test independent from the wall-clock time nd JVM performance hiccups.","created_at":"2015-03-19T09:06:20Z","updated_at":"2015-03-19T09:23:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"74e87cf8cc193baa8fb405af41febd5d1fabe186","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/pulls/592/commits","review_comments_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/pulls/592/comments","review_comment_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/pulls/comments{/number}","comments_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/issues/592/comments","statuses_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/statuses/137e2b8202295272f1adcf40bcc2066d5ad3d77f","head":{"label":"datastax:SPARKC-96","ref":"SPARKC-96","sha":"137e2b8202295272f1adcf40bcc2066d5ad3d77f","user":{"login":"datastax","id":573369,"avatar_url":"https://avatars.githubusercontent.com/u/573369?v=3","gravatar_id":"","url":"https://api.github.com/users/datastax","html_url":"https://github.com/datastax","followers_url":"https://api.github.com/users/datastax/followers","following_url":"https://api.github.com/users/datastax/following{/other_user}","gists_url":"https://api.github.com/users/datastax/gists{/gist_id}","starred_url":"https://api.github.com/users/datastax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/datastax/subscriptions","organizations_url":"https://api.github.com/users/datastax/orgs","repos_url":"https://api.github.com/users/datastax/repos","events_url":"https://api.github.com/users/datastax/events{/privacy}","received_events_url":"https://api.github.com/users/datastax/received_events","type":"Organization","site_admin":false},"repo":{"id":21280887,"name":"spark-cassandra-connector","full_name":"datastax/spark-cassandra-connector","owner":{"login":"datastax","id":573369,"avatar_url":"https://avatars.githubusercontent.com/u/573369?v=3","gravatar_id":"","url":"https://api.github.com/users/datastax","html_url":"https://github.com/datastax","followers_url":"https://api.github.com/users/datastax/followers","following_url":"https://api.github.com/users/datastax/following{/other_user}","gists_url":"https://api.github.com/users/datastax/gists{/gist_id}","starred_url":"https://api.github.com/users/datastax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/datastax/subscriptions","organizations_url":"https://api.github.com/users/datastax/orgs","repos_url":"https://api.github.com/users/datastax/repos","events_url":"https://api.github.com/users/datastax/events{/privacy}","received_events_url":"https://api.github.com/users/datastax/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/datastax/spark-cassandra-connector","description":"If you write a Spark application that needs access to Cassandra, this library is for you","fork":false,"url":"https://api.github.com/repos/datastax/spark-cassandra-connector","forks_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/forks","keys_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/keys{/key_id}","collaborators_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/teams","hooks_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/hooks","issue_events_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/issues/events{/number}","events_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/events","assignees_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/assignees{/user}","branches_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/branches{/branch}","tags_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/tags","blobs_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/git/refs{/sha}","trees_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/git/trees{/sha}","statuses_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/statuses/{sha}","languages_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/languages","stargazers_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/stargazers","contributors_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/contributors","subscribers_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/subscribers","subscription_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/subscription","commits_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/commits{/sha}","git_commits_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/git/commits{/sha}","comments_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/comments{/number}","issue_comment_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/issues/comments{/number}","contents_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/contents/{+path}","compare_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/compare/{base}...{head}","merges_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/merges","archive_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/downloads","issues_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/issues{/number}","pulls_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/pulls{/number}","milestones_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/milestones{/number}","notifications_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/labels{/name}","releases_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/releases{/id}","created_at":"2014-06-27T15:45:54Z","updated_at":"2015-03-19T07:16:41Z","pushed_at":"2015-03-19T09:06:11Z","git_url":"git://github.com/datastax/spark-cassandra-connector.git","ssh_url":"git@github.com:datastax/spark-cassandra-connector.git","clone_url":"https://github.com/datastax/spark-cassandra-connector.git","svn_url":"https://github.com/datastax/spark-cassandra-connector","homepage":"","size":7723,"stargazers_count":436,"watchers_count":436,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":123,"mirror_url":null,"open_issues_count":11,"forks":123,"open_issues":11,"watchers":436,"default_branch":"master"}},"base":{"label":"datastax:master","ref":"master","sha":"227fff21099e087d34fad8fd2526424b8b5b09ea","user":{"login":"datastax","id":573369,"avatar_url":"https://avatars.githubusercontent.com/u/573369?v=3","gravatar_id":"","url":"https://api.github.com/users/datastax","html_url":"https://github.com/datastax","followers_url":"https://api.github.com/users/datastax/followers","following_url":"https://api.github.com/users/datastax/following{/other_user}","gists_url":"https://api.github.com/users/datastax/gists{/gist_id}","starred_url":"https://api.github.com/users/datastax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/datastax/subscriptions","organizations_url":"https://api.github.com/users/datastax/orgs","repos_url":"https://api.github.com/users/datastax/repos","events_url":"https://api.github.com/users/datastax/events{/privacy}","received_events_url":"https://api.github.com/users/datastax/received_events","type":"Organization","site_admin":false},"repo":{"id":21280887,"name":"spark-cassandra-connector","full_name":"datastax/spark-cassandra-connector","owner":{"login":"datastax","id":573369,"avatar_url":"https://avatars.githubusercontent.com/u/573369?v=3","gravatar_id":"","url":"https://api.github.com/users/datastax","html_url":"https://github.com/datastax","followers_url":"https://api.github.com/users/datastax/followers","following_url":"https://api.github.com/users/datastax/following{/other_user}","gists_url":"https://api.github.com/users/datastax/gists{/gist_id}","starred_url":"https://api.github.com/users/datastax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/datastax/subscriptions","organizations_url":"https://api.github.com/users/datastax/orgs","repos_url":"https://api.github.com/users/datastax/repos","events_url":"https://api.github.com/users/datastax/events{/privacy}","received_events_url":"https://api.github.com/users/datastax/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/datastax/spark-cassandra-connector","description":"If you write a Spark application that needs access to Cassandra, this library is for you","fork":false,"url":"https://api.github.com/repos/datastax/spark-cassandra-connector","forks_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/forks","keys_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/keys{/key_id}","collaborators_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/teams","hooks_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/hooks","issue_events_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/issues/events{/number}","events_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/events","assignees_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/assignees{/user}","branches_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/branches{/branch}","tags_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/tags","blobs_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/git/refs{/sha}","trees_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/git/trees{/sha}","statuses_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/statuses/{sha}","languages_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/languages","stargazers_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/stargazers","contributors_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/contributors","subscribers_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/subscribers","subscription_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/subscription","commits_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/commits{/sha}","git_commits_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/git/commits{/sha}","comments_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/comments{/number}","issue_comment_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/issues/comments{/number}","contents_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/contents/{+path}","compare_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/compare/{base}...{head}","merges_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/merges","archive_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/downloads","issues_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/issues{/number}","pulls_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/pulls{/number}","milestones_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/milestones{/number}","notifications_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/labels{/name}","releases_url":"https://api.github.com/repos/datastax/spark-cassandra-connector/releases{/id}","created_at":"2014-06-27T15:45:54Z","updated_at":"2015-03-19T07:16:41Z","pushed_at":"2015-03-19T09:06:11Z","git_url":"git://github.com/datastax/spark-cassandra-connector.git","ssh_url":"git@github.com:datastax/spark-cassandra-connector.git","clone_url":"https://github.com/datastax/spark-cassandra-connector.git","svn_url":"https://github.com/datastax/spark-cassandra-connector","homepage":"","size":7723,"stargazers_count":436,"watchers_count":436,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":123,"mirror_url":null,"open_issues_count":11,"forks":123,"open_issues":11,"watchers":436,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/datastax/spark-cassandra-connector/pulls/592"},"html":{"href":"https://github.com/datastax/spark-cassandra-connector/pull/592"},"issue":{"href":"https://api.github.com/repos/datastax/spark-cassandra-connector/issues/592"},"comments":{"href":"https://api.github.com/repos/datastax/spark-cassandra-connector/issues/592/comments"},"review_comments":{"href":"https://api.github.com/repos/datastax/spark-cassandra-connector/pulls/592/comments"},"review_comment":{"href":"https://api.github.com/repos/datastax/spark-cassandra-connector/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/datastax/spark-cassandra-connector/pulls/592/commits"},"statuses":{"href":"https://api.github.com/repos/datastax/spark-cassandra-connector/statuses/137e2b8202295272f1adcf40bcc2066d5ad3d77f"}}}}