{"action":"created","comment":{"url":"https://api.github.com/repos/marmbrus/spark/pulls/comments/49375472","id":49375472,"diff_hunk":"@@ -0,0 +1,143 @@\n+/*\n+ * Licensed to the Apache Software Foundation (ASF) under one or more\n+ * contributor license agreements.  See the NOTICE file distributed with\n+ * this work for additional information regarding copyright ownership.\n+ * The ASF licenses this file to You under the Apache License, Version 2.0\n+ * (the \"License\"); you may not use this file except in compliance with\n+ * the License.  You may obtain a copy of the License at\n+ *\n+ *    http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+\n+package org.apache.spark.streaming.kafka\n+\n+import scala.util.Try\n+\n+import kafka.common.TopicAndPartition\n+import org.apache.kafka.clients.producer.RecordMetadata\n+import org.scalatest.time.SpanSugar._\n+\n+import org.apache.spark.sql.StreamTest\n+import org.apache.spark.sql.execution.streaming.{Offset, Source}\n+import org.apache.spark.sql.streaming.OffsetSuite\n+import org.apache.spark.sql.test.SharedSQLContext\n+\n+\n+class KafkaSourceSuite extends StreamTest with SharedSQLContext with OffsetSuite {\n+\n+  import testImplicits._\n+\n+  private var testUtils: KafkaTestUtils = _\n+  private var kafkaParams: Map[String, String] = _\n+\n+  override val streamingTimout = 10.seconds\n+\n+  case class AddKafkaData(\n+      kafkaSource: KafkaSource,\n+      topic: String, data: Int*)(implicit multiPartitionCheck: Boolean = true) extends AddData {\n+\n+    override def addData(): Offset = {\n+      val sentMetadata = testUtils.sendMessages(topic, data.map{ _.toString}.toArray)\n+      val latestOffsetMap = sentMetadata\n+        .groupBy { _._2.partition }\n+        .map { case (partition, msgAndMetadata) =>\n+          val maxOffsetInPartition = msgAndMetadata.map(_._2).maxBy(_.offset).offset()\n+          (TopicAndPartition(topic, partition), maxOffsetInPartition + 1)\n+        }\n+\n+      def metadataToStr(m: (String, RecordMetadata)): String = {\n+        s\"Sent ${m._1} to partition ${m._2.partition()}, offset ${m._2.offset()}\"\n+      }\n+\n+      assert(latestOffsetMap.size > 1,\n+        s\"Added data does not test multiple partitions: \" + sentMetadata.map(metadataToStr))","path":"external/kafka/src/test/scala/org/apache/spark/streaming/kafka/KafkaSourceSuite.scala","position":59,"original_position":59,"commit_id":"97c4aa5287964e880092706de4a5b20f0b740029","original_commit_id":"97c4aa5287964e880092706de4a5b20f0b740029","user":{"login":"marmbrus","id":527,"avatar_url":"https://avatars.githubusercontent.com/u/527?v=3","gravatar_id":"","url":"https://api.github.com/users/marmbrus","html_url":"https://github.com/marmbrus","followers_url":"https://api.github.com/users/marmbrus/followers","following_url":"https://api.github.com/users/marmbrus/following{/other_user}","gists_url":"https://api.github.com/users/marmbrus/gists{/gist_id}","starred_url":"https://api.github.com/users/marmbrus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marmbrus/subscriptions","organizations_url":"https://api.github.com/users/marmbrus/orgs","repos_url":"https://api.github.com/users/marmbrus/repos","events_url":"https://api.github.com/users/marmbrus/events{/privacy}","received_events_url":"https://api.github.com/users/marmbrus/received_events","type":"User","site_admin":false},"body":"What does this mean?  Should we test this?","created_at":"2016-01-11T20:40:38Z","updated_at":"2016-01-11T20:40:38Z","html_url":"https://github.com/marmbrus/spark/pull/24#discussion_r49375472","pull_request_url":"https://api.github.com/repos/marmbrus/spark/pulls/24","_links":{"self":{"href":"https://api.github.com/repos/marmbrus/spark/pulls/comments/49375472"},"html":{"href":"https://github.com/marmbrus/spark/pull/24#discussion_r49375472"},"pull_request":{"href":"https://api.github.com/repos/marmbrus/spark/pulls/24"}}},"pull_request":{"url":"https://api.github.com/repos/marmbrus/spark/pulls/24","id":55297798,"html_url":"https://github.com/marmbrus/spark/pull/24","diff_url":"https://github.com/marmbrus/spark/pull/24.diff","patch_url":"https://github.com/marmbrus/spark/pull/24.patch","issue_url":"https://api.github.com/repos/marmbrus/spark/issues/24","number":24,"state":"open","locked":false,"title":"[WIP] Kafka Source","user":{"login":"tdas","id":663212,"avatar_url":"https://avatars.githubusercontent.com/u/663212?v=3","gravatar_id":"","url":"https://api.github.com/users/tdas","html_url":"https://github.com/tdas","followers_url":"https://api.github.com/users/tdas/followers","following_url":"https://api.github.com/users/tdas/following{/other_user}","gists_url":"https://api.github.com/users/tdas/gists{/gist_id}","starred_url":"https://api.github.com/users/tdas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tdas/subscriptions","organizations_url":"https://api.github.com/users/tdas/orgs","repos_url":"https://api.github.com/users/tdas/repos","events_url":"https://api.github.com/users/tdas/events{/privacy}","received_events_url":"https://api.github.com/users/tdas/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-01-07T04:06:14Z","updated_at":"2016-01-11T20:40:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5b4d2ac992e1bc9a935df5bee6279952f233ea92","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/marmbrus/spark/pulls/24/commits","review_comments_url":"https://api.github.com/repos/marmbrus/spark/pulls/24/comments","review_comment_url":"https://api.github.com/repos/marmbrus/spark/pulls/comments{/number}","comments_url":"https://api.github.com/repos/marmbrus/spark/issues/24/comments","statuses_url":"https://api.github.com/repos/marmbrus/spark/statuses/97c4aa5287964e880092706de4a5b20f0b740029","head":{"label":"tdas:streaming-df-kafka","ref":"streaming-df-kafka","sha":"97c4aa5287964e880092706de4a5b20f0b740029","user":{"login":"tdas","id":663212,"avatar_url":"https://avatars.githubusercontent.com/u/663212?v=3","gravatar_id":"","url":"https://api.github.com/users/tdas","html_url":"https://github.com/tdas","followers_url":"https://api.github.com/users/tdas/followers","following_url":"https://api.github.com/users/tdas/following{/other_user}","gists_url":"https://api.github.com/users/tdas/gists{/gist_id}","starred_url":"https://api.github.com/users/tdas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tdas/subscriptions","organizations_url":"https://api.github.com/users/tdas/orgs","repos_url":"https://api.github.com/users/tdas/repos","events_url":"https://api.github.com/users/tdas/events{/privacy}","received_events_url":"https://api.github.com/users/tdas/received_events","type":"User","site_admin":false},"repo":{"id":17603343,"name":"spark","full_name":"tdas/spark","owner":{"login":"tdas","id":663212,"avatar_url":"https://avatars.githubusercontent.com/u/663212?v=3","gravatar_id":"","url":"https://api.github.com/users/tdas","html_url":"https://github.com/tdas","followers_url":"https://api.github.com/users/tdas/followers","following_url":"https://api.github.com/users/tdas/following{/other_user}","gists_url":"https://api.github.com/users/tdas/gists{/gist_id}","starred_url":"https://api.github.com/users/tdas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tdas/subscriptions","organizations_url":"https://api.github.com/users/tdas/orgs","repos_url":"https://api.github.com/users/tdas/repos","events_url":"https://api.github.com/users/tdas/events{/privacy}","received_events_url":"https://api.github.com/users/tdas/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tdas/spark","description":"Mirror of Apache Spark","fork":true,"url":"https://api.github.com/repos/tdas/spark","forks_url":"https://api.github.com/repos/tdas/spark/forks","keys_url":"https://api.github.com/repos/tdas/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tdas/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tdas/spark/teams","hooks_url":"https://api.github.com/repos/tdas/spark/hooks","issue_events_url":"https://api.github.com/repos/tdas/spark/issues/events{/number}","events_url":"https://api.github.com/repos/tdas/spark/events","assignees_url":"https://api.github.com/repos/tdas/spark/assignees{/user}","branches_url":"https://api.github.com/repos/tdas/spark/branches{/branch}","tags_url":"https://api.github.com/repos/tdas/spark/tags","blobs_url":"https://api.github.com/repos/tdas/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tdas/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tdas/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/tdas/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tdas/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/tdas/spark/languages","stargazers_url":"https://api.github.com/repos/tdas/spark/stargazers","contributors_url":"https://api.github.com/repos/tdas/spark/contributors","subscribers_url":"https://api.github.com/repos/tdas/spark/subscribers","subscription_url":"https://api.github.com/repos/tdas/spark/subscription","commits_url":"https://api.github.com/repos/tdas/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/tdas/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/tdas/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/tdas/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/tdas/spark/contents/{+path}","compare_url":"https://api.github.com/repos/tdas/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tdas/spark/merges","archive_url":"https://api.github.com/repos/tdas/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tdas/spark/downloads","issues_url":"https://api.github.com/repos/tdas/spark/issues{/number}","pulls_url":"https://api.github.com/repos/tdas/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/tdas/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/tdas/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tdas/spark/labels{/name}","releases_url":"https://api.github.com/repos/tdas/spark/releases{/id}","created_at":"2014-03-10T18:19:48Z","updated_at":"2015-04-24T21:16:02Z","pushed_at":"2016-01-11T20:11:45Z","git_url":"git://github.com/tdas/spark.git","ssh_url":"git@github.com:tdas/spark.git","clone_url":"https://github.com/tdas/spark.git","svn_url":"https://github.com/tdas/spark","homepage":null,"size":137884,"stargazers_count":1,"watchers_count":1,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":3,"forks":2,"open_issues":3,"watchers":1,"default_branch":"master"}},"base":{"label":"marmbrus:streaming-df","ref":"streaming-df","sha":"d2fc93471686cdbd6185b2e6db9fdbaa40234ee2","user":{"login":"marmbrus","id":527,"avatar_url":"https://avatars.githubusercontent.com/u/527?v=3","gravatar_id":"","url":"https://api.github.com/users/marmbrus","html_url":"https://github.com/marmbrus","followers_url":"https://api.github.com/users/marmbrus/followers","following_url":"https://api.github.com/users/marmbrus/following{/other_user}","gists_url":"https://api.github.com/users/marmbrus/gists{/gist_id}","starred_url":"https://api.github.com/users/marmbrus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marmbrus/subscriptions","organizations_url":"https://api.github.com/users/marmbrus/orgs","repos_url":"https://api.github.com/users/marmbrus/repos","events_url":"https://api.github.com/users/marmbrus/events{/privacy}","received_events_url":"https://api.github.com/users/marmbrus/received_events","type":"User","site_admin":false},"repo":{"id":17230869,"name":"spark","full_name":"marmbrus/spark","owner":{"login":"marmbrus","id":527,"avatar_url":"https://avatars.githubusercontent.com/u/527?v=3","gravatar_id":"","url":"https://api.github.com/users/marmbrus","html_url":"https://github.com/marmbrus","followers_url":"https://api.github.com/users/marmbrus/followers","following_url":"https://api.github.com/users/marmbrus/following{/other_user}","gists_url":"https://api.github.com/users/marmbrus/gists{/gist_id}","starred_url":"https://api.github.com/users/marmbrus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marmbrus/subscriptions","organizations_url":"https://api.github.com/users/marmbrus/orgs","repos_url":"https://api.github.com/users/marmbrus/repos","events_url":"https://api.github.com/users/marmbrus/events{/privacy}","received_events_url":"https://api.github.com/users/marmbrus/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/marmbrus/spark","description":"Mirror of Apache Spark","fork":true,"url":"https://api.github.com/repos/marmbrus/spark","forks_url":"https://api.github.com/repos/marmbrus/spark/forks","keys_url":"https://api.github.com/repos/marmbrus/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/marmbrus/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/marmbrus/spark/teams","hooks_url":"https://api.github.com/repos/marmbrus/spark/hooks","issue_events_url":"https://api.github.com/repos/marmbrus/spark/issues/events{/number}","events_url":"https://api.github.com/repos/marmbrus/spark/events","assignees_url":"https://api.github.com/repos/marmbrus/spark/assignees{/user}","branches_url":"https://api.github.com/repos/marmbrus/spark/branches{/branch}","tags_url":"https://api.github.com/repos/marmbrus/spark/tags","blobs_url":"https://api.github.com/repos/marmbrus/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/marmbrus/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/marmbrus/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/marmbrus/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/marmbrus/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/marmbrus/spark/languages","stargazers_url":"https://api.github.com/repos/marmbrus/spark/stargazers","contributors_url":"https://api.github.com/repos/marmbrus/spark/contributors","subscribers_url":"https://api.github.com/repos/marmbrus/spark/subscribers","subscription_url":"https://api.github.com/repos/marmbrus/spark/subscription","commits_url":"https://api.github.com/repos/marmbrus/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/marmbrus/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/marmbrus/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/marmbrus/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/marmbrus/spark/contents/{+path}","compare_url":"https://api.github.com/repos/marmbrus/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/marmbrus/spark/merges","archive_url":"https://api.github.com/repos/marmbrus/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/marmbrus/spark/downloads","issues_url":"https://api.github.com/repos/marmbrus/spark/issues{/number}","pulls_url":"https://api.github.com/repos/marmbrus/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/marmbrus/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/marmbrus/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/marmbrus/spark/labels{/name}","releases_url":"https://api.github.com/repos/marmbrus/spark/releases{/id}","created_at":"2014-02-27T00:22:54Z","updated_at":"2014-11-27T06:21:59Z","pushed_at":"2016-01-11T20:11:46Z","git_url":"git://github.com/marmbrus/spark.git","ssh_url":"git@github.com:marmbrus/spark.git","clone_url":"https://github.com/marmbrus/spark.git","svn_url":"https://github.com/marmbrus/spark","homepage":null,"size":177626,"stargazers_count":2,"watchers_count":2,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":3,"forks":2,"open_issues":3,"watchers":2,"default_branch":"catalyst"}},"_links":{"self":{"href":"https://api.github.com/repos/marmbrus/spark/pulls/24"},"html":{"href":"https://github.com/marmbrus/spark/pull/24"},"issue":{"href":"https://api.github.com/repos/marmbrus/spark/issues/24"},"comments":{"href":"https://api.github.com/repos/marmbrus/spark/issues/24/comments"},"review_comments":{"href":"https://api.github.com/repos/marmbrus/spark/pulls/24/comments"},"review_comment":{"href":"https://api.github.com/repos/marmbrus/spark/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/marmbrus/spark/pulls/24/commits"},"statuses":{"href":"https://api.github.com/repos/marmbrus/spark/statuses/97c4aa5287964e880092706de4a5b20f0b740029"}}}}