{"action":"created","comment":{"url":"https://api.github.com/repos/apache/spark/pulls/comments/253246628","pull_request_review_id":199326577,"id":253246628,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI1MzI0NjYyOA==","diff_hunk":"@@ -0,0 +1,185 @@\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+package org.apache.spark.deploy.k8s.integrationtest\n+\n+import java.io.{File, PrintWriter}\n+\n+import scala.collection.JavaConverters._\n+\n+import io.fabric8.kubernetes.api.model._\n+import io.fabric8.kubernetes.api.model.storage.StorageClassBuilder\n+import org.scalatest.Tag\n+import org.scalatest.concurrent.Eventually\n+\n+import org.apache.spark.deploy.k8s.integrationtest.KubernetesSuite._\n+\n+private[spark] trait PVTestsSuite { k8sSuite: KubernetesSuite =>\n+  import PVTestsSuite._\n+\n+  private def setupLocalStorage(): Unit = {\n+    val scBuilder = new StorageClassBuilder()\n+      .withKind(\"StorageClass\")\n+      .withApiVersion(\"storage.k8s.io/v1\")\n+      .withNewMetadata()\n+        .withName(STORAGE_NAME)\n+      .endMetadata()\n+      .withProvisioner(\"kubernetes.io/no-provisioner\")\n+      .withVolumeBindingMode(\"WaitForFirstConsumer\")\n+\n+    val pvBuilder = new PersistentVolumeBuilder()\n+      .withKind(\"PersistentVolume\")\n+      .withApiVersion(\"v1\")\n+      .withNewMetadata()\n+        .withName(\"test-local-pv\")\n+      .endMetadata()\n+      .withNewSpec()\n+        .withCapacity(Map(\"storage\" -> new QuantityBuilder().withAmount(\"1Gi\").build()).asJava)\n+        .withAccessModes(\"ReadWriteOnce\")\n+        .withPersistentVolumeReclaimPolicy(\"Retain\")\n+        .withStorageClassName(\"test-local-storage\")\n+        .withLocal(new LocalVolumeSourceBuilder().withPath(HOST_PATH).build())\n+          .withNewNodeAffinity()\n+            .withNewRequired()\n+              .withNodeSelectorTerms(new NodeSelectorTermBuilder()\n+                .withMatchExpressions(new NodeSelectorRequirementBuilder()\n+                  .withKey(\"kubernetes.io/hostname\")\n+                  .withOperator(\"In\")\n+                  .withValues(\"minikube\").build()).build())\n+            .endRequired()\n+          .endNodeAffinity()\n+      .endSpec()\n+\n+    val pvcBuilder = new PersistentVolumeClaimBuilder()\n+      .withKind(\"PersistentVolumeClaim\")\n+      .withApiVersion(\"v1\")\n+      .withNewMetadata()\n+        .withName(PVC_NAME)\n+      .endMetadata()\n+      .withNewSpec()\n+        .withAccessModes(\"ReadWriteOnce\")\n+        .withStorageClassName(\"test-local-storage\")\n+        .withResources(new ResourceRequirementsBuilder()\n+        .withRequests(Map(\"storage\" -> new QuantityBuilder()\n+          .withAmount(\"1Gi\").build()).asJava).build())\n+      .endSpec()\n+\n+    kubernetesTestComponents\n+      .kubernetesClient\n+      .storage()\n+      .storageClasses()\n+      .create(scBuilder.build())\n+\n+    kubernetesTestComponents\n+      .kubernetesClient\n+      .persistentVolumes()\n+      .create(pvBuilder.build())\n+\n+    kubernetesTestComponents\n+      .kubernetesClient\n+      .persistentVolumeClaims()\n+      .create(pvcBuilder.build())\n+  }\n+\n+  private def deleteLocalStorage(): Unit = {\n+    kubernetesTestComponents\n+      .kubernetesClient\n+      .persistentVolumeClaims()\n+      .withName(PVC_NAME)\n+      .delete()\n+\n+    kubernetesTestComponents\n+      .kubernetesClient\n+      .persistentVolumes()\n+      .withName(PV_NAME)\n+      .delete()\n+\n+    kubernetesTestComponents\n+      .kubernetesClient\n+      .storage()\n+      .storageClasses()\n+      .withName(STORAGE_NAME)\n+      .delete()\n+  }\n+\n+  private def checkPVs(pod: Pod, file: String) = {\n+    Eventually.eventually(TIMEOUT, INTERVAL) {\n+      implicit val podName: String = pod.getMetadata.getName\n+      implicit val components: KubernetesTestComponents = kubernetesTestComponents\n+      val contents = Utils.executeCommand(\"cat\", s\"$CONTAINER_MOUNT_PATH/$file\")\n+      assert(contents.toString.trim.equals(FILE_CONTENTS))\n+    }\n+  }\n+\n+  private def createTempFile(): String = {\n+    val filename = try {\n+      val f = File.createTempFile(\"tmp\", \".txt\", new File(HOST_PATH))","path":"resource-managers/kubernetes/integration-tests/src/test/scala/org/apache/spark/deploy/k8s/integrationtest/PVTestsSuite.scala","position":129,"original_position":129,"commit_id":"c85cbaa7484c0cd1841bda517108905b4f4c55ac","original_commit_id":"c85cbaa7484c0cd1841bda517108905b4f4c55ac","user":{"login":"skonto","id":7945591,"node_id":"MDQ6VXNlcjc5NDU1OTE=","avatar_url":"https://avatars1.githubusercontent.com/u/7945591?v=4","gravatar_id":"","url":"https://api.github.com/users/skonto","html_url":"https://github.com/skonto","followers_url":"https://api.github.com/users/skonto/followers","following_url":"https://api.github.com/users/skonto/following{/other_user}","gists_url":"https://api.github.com/users/skonto/gists{/gist_id}","starred_url":"https://api.github.com/users/skonto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/skonto/subscriptions","organizations_url":"https://api.github.com/users/skonto/orgs","repos_url":"https://api.github.com/users/skonto/repos","events_url":"https://api.github.com/users/skonto/events{/privacy}","received_events_url":"https://api.github.com/users/skonto/received_events","type":"User","site_admin":false},"body":"thanx again @shaneknapp I will try it locally as well.","created_at":"2019-02-02T01:31:15Z","updated_at":"2019-02-02T01:31:15Z","html_url":"https://github.com/apache/spark/pull/23514#discussion_r253246628","pull_request_url":"https://api.github.com/repos/apache/spark/pulls/23514","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/253246628"},"html":{"href":"https://github.com/apache/spark/pull/23514#discussion_r253246628"},"pull_request":{"href":"https://api.github.com/repos/apache/spark/pulls/23514"}},"in_reply_to_id":253233480},"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/23514","id":243859821,"node_id":"MDExOlB1bGxSZXF1ZXN0MjQzODU5ODIx","html_url":"https://github.com/apache/spark/pull/23514","diff_url":"https://github.com/apache/spark/pull/23514.diff","patch_url":"https://github.com/apache/spark/pull/23514.patch","issue_url":"https://api.github.com/repos/apache/spark/issues/23514","number":23514,"state":"open","locked":false,"title":"[SPARK-24902][K8s] Add PV integration tests","user":{"login":"skonto","id":7945591,"node_id":"MDQ6VXNlcjc5NDU1OTE=","avatar_url":"https://avatars1.githubusercontent.com/u/7945591?v=4","gravatar_id":"","url":"https://api.github.com/users/skonto","html_url":"https://github.com/skonto","followers_url":"https://api.github.com/users/skonto/followers","following_url":"https://api.github.com/users/skonto/following{/other_user}","gists_url":"https://api.github.com/users/skonto/gists{/gist_id}","starred_url":"https://api.github.com/users/skonto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/skonto/subscriptions","organizations_url":"https://api.github.com/users/skonto/orgs","repos_url":"https://api.github.com/users/skonto/repos","events_url":"https://api.github.com/users/skonto/events{/privacy}","received_events_url":"https://api.github.com/users/skonto/received_events","type":"User","site_admin":false},"body":"## What changes were proposed in this pull request?\r\n\r\n- Adds persistent volume integration tests\r\n- Updates fabric8io client to 4.1.1, in order to contain the latest k8s model.\r\n  That translates to supporting k8s >= 1.9 model. Current version 4.1.0 supports only up to 1.9.\r\n  Tests require volumeNodeAffinity as described [here](https://github.com/fabric8io/kubernetes-client/issues/1234).\r\n  Given that Spark 3.0.0 will be out  in several months from now, it seems a reasonable update.\r\n- Adds a custom tag to the test to exclude it if it is run against a cloud backend.\r\n- Assumes default fs type for the host, AFAIK that is ext4.\r\n\r\n## How was this patch tested?\r\nManually run the tests against minikube as usual:\r\n```\r\n[INFO] --- scalatest-maven-plugin:1.0:test (integration-test) @ spark-kubernetes-integration-tests_2.12 ---\r\nDiscovery starting.\r\nDiscovery completed in 192 milliseconds.\r\nRun starting. Expected test count is: 16\r\nKubernetesSuite:\r\n- Run SparkPi with no resources\r\n- Run SparkPi with a very long application name.\r\n- Use SparkLauncher.NO_RESOURCE\r\n- Run SparkPi with a master URL without a scheme.\r\n- Run SparkPi with an argument.\r\n- Run SparkPi with custom labels, annotations, and environment variables.\r\n- Run extraJVMOptions check on driver\r\n- Run SparkRemoteFileTest using a remote data file\r\n- Run SparkPi with env and mount secrets.\r\n- Run PySpark on simple pi.py example\r\n- Run PySpark with Python2 to test a pyfiles example\r\n- Run PySpark with Python3 to test a pyfiles example\r\n- Run PySpark with memory customization\r\n- Run in client mode.\r\n- Start pod creation from template\r\n- Test PVs with local storage\r\n```\r\n","created_at":"2019-01-10T23:03:07Z","updated_at":"2019-02-02T01:31:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8dfe255c26be2d9890284cf0901ac92a352cfc8a","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/spark/pulls/23514/commits","review_comments_url":"https://api.github.com/repos/apache/spark/pulls/23514/comments","review_comment_url":"https://api.github.com/repos/apache/spark/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/spark/issues/23514/comments","statuses_url":"https://api.github.com/repos/apache/spark/statuses/c85cbaa7484c0cd1841bda517108905b4f4c55ac","head":{"label":"skonto:pvctests","ref":"pvctests","sha":"c85cbaa7484c0cd1841bda517108905b4f4c55ac","user":{"login":"skonto","id":7945591,"node_id":"MDQ6VXNlcjc5NDU1OTE=","avatar_url":"https://avatars1.githubusercontent.com/u/7945591?v=4","gravatar_id":"","url":"https://api.github.com/users/skonto","html_url":"https://github.com/skonto","followers_url":"https://api.github.com/users/skonto/followers","following_url":"https://api.github.com/users/skonto/following{/other_user}","gists_url":"https://api.github.com/users/skonto/gists{/gist_id}","starred_url":"https://api.github.com/users/skonto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/skonto/subscriptions","organizations_url":"https://api.github.com/users/skonto/orgs","repos_url":"https://api.github.com/users/skonto/repos","events_url":"https://api.github.com/users/skonto/events{/privacy}","received_events_url":"https://api.github.com/users/skonto/received_events","type":"User","site_admin":false},"repo":{"id":48892104,"node_id":"MDEwOlJlcG9zaXRvcnk0ODg5MjEwNA==","name":"spark","full_name":"skonto/spark","private":false,"owner":{"login":"skonto","id":7945591,"node_id":"MDQ6VXNlcjc5NDU1OTE=","avatar_url":"https://avatars1.githubusercontent.com/u/7945591?v=4","gravatar_id":"","url":"https://api.github.com/users/skonto","html_url":"https://github.com/skonto","followers_url":"https://api.github.com/users/skonto/followers","following_url":"https://api.github.com/users/skonto/following{/other_user}","gists_url":"https://api.github.com/users/skonto/gists{/gist_id}","starred_url":"https://api.github.com/users/skonto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/skonto/subscriptions","organizations_url":"https://api.github.com/users/skonto/orgs","repos_url":"https://api.github.com/users/skonto/repos","events_url":"https://api.github.com/users/skonto/events{/privacy}","received_events_url":"https://api.github.com/users/skonto/received_events","type":"User","site_admin":false},"html_url":"https://github.com/skonto/spark","description":"Mirror of Apache Spark","fork":true,"url":"https://api.github.com/repos/skonto/spark","forks_url":"https://api.github.com/repos/skonto/spark/forks","keys_url":"https://api.github.com/repos/skonto/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/skonto/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/skonto/spark/teams","hooks_url":"https://api.github.com/repos/skonto/spark/hooks","issue_events_url":"https://api.github.com/repos/skonto/spark/issues/events{/number}","events_url":"https://api.github.com/repos/skonto/spark/events","assignees_url":"https://api.github.com/repos/skonto/spark/assignees{/user}","branches_url":"https://api.github.com/repos/skonto/spark/branches{/branch}","tags_url":"https://api.github.com/repos/skonto/spark/tags","blobs_url":"https://api.github.com/repos/skonto/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/skonto/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/skonto/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/skonto/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/skonto/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/skonto/spark/languages","stargazers_url":"https://api.github.com/repos/skonto/spark/stargazers","contributors_url":"https://api.github.com/repos/skonto/spark/contributors","subscribers_url":"https://api.github.com/repos/skonto/spark/subscribers","subscription_url":"https://api.github.com/repos/skonto/spark/subscription","commits_url":"https://api.github.com/repos/skonto/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/skonto/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/skonto/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/skonto/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/skonto/spark/contents/{+path}","compare_url":"https://api.github.com/repos/skonto/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/skonto/spark/merges","archive_url":"https://api.github.com/repos/skonto/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/skonto/spark/downloads","issues_url":"https://api.github.com/repos/skonto/spark/issues{/number}","pulls_url":"https://api.github.com/repos/skonto/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/skonto/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/skonto/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/skonto/spark/labels{/name}","releases_url":"https://api.github.com/repos/skonto/spark/releases{/id}","deployments_url":"https://api.github.com/repos/skonto/spark/deployments","created_at":"2016-01-01T23:02:52Z","updated_at":"2019-01-11T13:19:21Z","pushed_at":"2019-01-29T23:36:51Z","git_url":"git://github.com/skonto/spark.git","ssh_url":"git@github.com:skonto/spark.git","clone_url":"https://github.com/skonto/spark.git","svn_url":"https://github.com/skonto/spark","homepage":null,"size":277001,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"fbc3c5e8a33c28e46d839a2d1db81d9a89b29327","user":{"login":"apache","id":47359,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ3MzU5","avatar_url":"https://avatars0.githubusercontent.com/u/47359?v=4","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":17165658,"node_id":"MDEwOlJlcG9zaXRvcnkxNzE2NTY1OA==","name":"spark","full_name":"apache/spark","private":false,"owner":{"login":"apache","id":47359,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ3MzU5","avatar_url":"https://avatars0.githubusercontent.com/u/47359?v=4","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/apache/spark","description":"Apache Spark","fork":false,"url":"https://api.github.com/repos/apache/spark","forks_url":"https://api.github.com/repos/apache/spark/forks","keys_url":"https://api.github.com/repos/apache/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/spark/teams","hooks_url":"https://api.github.com/repos/apache/spark/hooks","issue_events_url":"https://api.github.com/repos/apache/spark/issues/events{/number}","events_url":"https://api.github.com/repos/apache/spark/events","assignees_url":"https://api.github.com/repos/apache/spark/assignees{/user}","branches_url":"https://api.github.com/repos/apache/spark/branches{/branch}","tags_url":"https://api.github.com/repos/apache/spark/tags","blobs_url":"https://api.github.com/repos/apache/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/spark/languages","stargazers_url":"https://api.github.com/repos/apache/spark/stargazers","contributors_url":"https://api.github.com/repos/apache/spark/contributors","subscribers_url":"https://api.github.com/repos/apache/spark/subscribers","subscription_url":"https://api.github.com/repos/apache/spark/subscription","commits_url":"https://api.github.com/repos/apache/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/spark/contents/{+path}","compare_url":"https://api.github.com/repos/apache/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/spark/merges","archive_url":"https://api.github.com/repos/apache/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/spark/downloads","issues_url":"https://api.github.com/repos/apache/spark/issues{/number}","pulls_url":"https://api.github.com/repos/apache/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/spark/labels{/name}","releases_url":"https://api.github.com/repos/apache/spark/releases{/id}","deployments_url":"https://api.github.com/repos/apache/spark/deployments","created_at":"2014-02-25T08:00:08Z","updated_at":"2019-02-02T00:41:42Z","pushed_at":"2019-02-02T00:38:34Z","git_url":"git://github.com/apache/spark.git","ssh_url":"git@github.com:apache/spark.git","clone_url":"https://github.com/apache/spark.git","svn_url":"https://github.com/apache/spark","homepage":"","size":293219,"stargazers_count":20455,"watchers_count":20455,"language":"Scala","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":17995,"mirror_url":null,"archived":false,"open_issues_count":439,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":17995,"open_issues":439,"watchers":20455,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/23514"},"html":{"href":"https://github.com/apache/spark/pull/23514"},"issue":{"href":"https://api.github.com/repos/apache/spark/issues/23514"},"comments":{"href":"https://api.github.com/repos/apache/spark/issues/23514/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/spark/pulls/23514/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/spark/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/spark/pulls/23514/commits"},"statuses":{"href":"https://api.github.com/repos/apache/spark/statuses/c85cbaa7484c0cd1841bda517108905b4f4c55ac"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"skonto"}}