1717package org .apache .spark .deploy .k8s .integrationtest
1818
1919import java .io .File
20+ import java .net .URI
2021import java .nio .file .Paths
2122import java .util .UUID
2223import java .util .regex .Pattern
2324
2425import scala .collection .JavaConverters ._
25-
2626import com .google .common .io .PatternFilenameFilter
2727import io .fabric8 .kubernetes .api .model .{Container , Pod }
2828import org .scalatest .{BeforeAndAfter , BeforeAndAfterAll , FunSuite }
@@ -39,6 +39,7 @@ private[spark] class KubernetesSuite extends FunSuite with BeforeAndAfterAll wit
3939 private val APP_LOCATOR_LABEL = UUID .randomUUID().toString.replaceAll(" -" , " " )
4040 private var kubernetesTestComponents : KubernetesTestComponents = _
4141 private var sparkAppConf : SparkAppConf = _
42+ private var remoteExamplesJarUri : URI = _
4243
4344 private val driverImage = System .getProperty(
4445 " spark.docker.test.driverImage" ,
@@ -50,7 +51,6 @@ private[spark] class KubernetesSuite extends FunSuite with BeforeAndAfterAll wit
5051 " spark.docker.test.initContainerImage" ,
5152 " spark-init:latest" )
5253
53-
5454 override def beforeAll (): Unit = {
5555 testBackend.initialize()
5656 kubernetesTestComponents = new KubernetesTestComponents (testBackend.getKubernetesClient)
@@ -67,6 +67,8 @@ private[spark] class KubernetesSuite extends FunSuite with BeforeAndAfterAll wit
6767 .set(" spark.kubernetes.driver.label.spark-app-locator" , APP_LOCATOR_LABEL )
6868 .set(" spark.kubernetes.executor.label.spark-app-locator" , APP_LOCATOR_LABEL )
6969 kubernetesTestComponents.createNamespace()
70+ remoteExamplesJarUri = SparkExamplesFileServerRunner
71+ .launchServerAndGetUriForExamplesJar(kubernetesTestComponents)
7072 }
7173
7274 after {
@@ -97,6 +99,11 @@ private[spark] class KubernetesSuite extends FunSuite with BeforeAndAfterAll wit
9799 runSparkPiAndVerifyCompletion(appArgs = Array (" 5" ))
98100 }
99101
102+ test(" Run SparkPi using the remote example jar." ) {
103+ sparkAppConf.set(" spark.kubernetes.initContainer.image" , initContainerImage)
104+ runSparkPiAndVerifyCompletion(appResource = remoteExamplesJarUri.toString)
105+ }
106+
100107 test(" Run SparkPi with custom driver pod name, labels, annotations, and environment variables." ) {
101108 sparkAppConf
102109 .set(" spark.kubernetes.driver.pod.name" , " spark-integration-spark-pi" )
@@ -163,8 +170,8 @@ private[spark] class KubernetesSuite extends FunSuite with BeforeAndAfterAll wit
163170
164171 createTestSecret()
165172
166- runSparkPageRankAndVerifyCompletion (
167- appArgs = Array ( CONTAINER_LOCAL_DOWNLOADED_PAGE_RANK_DATA_FILE ) ,
173+ runSparkPiAndVerifyCompletion (
174+ appResource = remoteExamplesJarUri.toString ,
168175 driverPodChecker = (driverPod : Pod ) => {
169176 doBasicDriverPodCheck(driverPod)
170177 checkTestSecret(driverPod, withInitContainer = true )
@@ -188,7 +195,6 @@ private[spark] class KubernetesSuite extends FunSuite with BeforeAndAfterAll wit
188195 driverPodChecker,
189196 executorPodChecker)
190197 }
191-
192198 private def runSparkPageRankAndVerifyCompletion (
193199 appResource : String = CONTAINER_LOCAL_SPARK_DISTRO_EXAMPLES_JAR ,
194200 driverPodChecker : Pod => Unit = doBasicDriverPodCheck,
0 commit comments