Skip to content
This repository has been archived by the owner on Jan 9, 2020. It is now read-only.

Fix k8s integration tests #44

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

# Set everything to be logged to the file target/integration-tests.log
log4j.rootCategory=INFO, file
log4j.appender.file=org.apache.log4j.FileAppender
log4j.appender.file.append=true
log4j.appender.file.file=target/integration-tests.log
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yy/MM/dd HH:mm:ss.SSS} %t %p %c{1}: %m%n

# Ignore messages below warning level from a few verbose libraries.
log4j.logger.com.sun.jersey=WARN
log4j.logger.org.apache.hadoop=WARN
log4j.logger.org.eclipse.jetty=WARN
log4j.logger.org.mortbay=WARN
log4j.logger.org.spark_project.jetty=WARN
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is needed for each sub module. Otherwise it would throw errors like the one mentioned in https://issues.apache.org/jira/browse/SPARK-17543.

I guess it's because scalatest-maven-plugin sets the log4j.configuration property to file:src/test/resources/log4j.properties. See https://github.com/apache/spark/blob/v2.1.0/pom.xml#L2019

Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import org.apache.spark.deploy.kubernetes.Client
import org.apache.spark.deploy.kubernetes.integrationtest.docker.SparkDockerImageBuilder
import org.apache.spark.deploy.kubernetes.integrationtest.minikube.Minikube
import org.apache.spark.deploy.kubernetes.integrationtest.restapis.SparkRestApiV1
import org.apache.spark.internal.Logging
import org.apache.spark.status.api.v1.{ApplicationStatus, StageStatus}
import org.apache.spark.util.Utils

Expand Down Expand Up @@ -82,8 +83,15 @@ private[spark] class KubernetesSuite extends SparkFunSuite with BeforeAndAfter {

before {
Eventually.eventually(TIMEOUT, INTERVAL) {
assert(minikubeKubernetesClient.pods().list().getItems.isEmpty)
assert(minikubeKubernetesClient.services().list().getItems.isEmpty)
val podsList = minikubeKubernetesClient.pods().list()
assert(podsList == null
|| podsList.getItems == null
|| podsList.getItems.isEmpty
)
val servicesList = minikubeKubernetesClient.services().list()
assert(servicesList == null
|| servicesList.getItems == null
|| servicesList.getItems.isEmpty)
}
}

Expand Down Expand Up @@ -139,6 +147,9 @@ private[spark] class KubernetesSuite extends SparkFunSuite with BeforeAndAfter {
}

test("Run a simple example") {
// We'll make assertions based on spark rest api, so we need to turn on
// spark.ui.enabled explicitly since the scalatest-maven-plugin would set it
// to false by default.
val sparkConf = new SparkConf(true)
.setMaster(s"k8s://https://${Minikube.getMinikubeIp}:8443")
.set("spark.kubernetes.submit.caCertFile", clientConfig.getCaCertFile)
Expand All @@ -152,6 +163,8 @@ private[spark] class KubernetesSuite extends SparkFunSuite with BeforeAndAfter {
.set("spark.executor.cores", "1")
.set("spark.executors.instances", "1")
.set("spark.app.id", "spark-pi")
.set("spark.ui.enabled", "true")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think other tests need this too - wherever we invoke expectationsForStaticAllocation(). Although, part of improving the integration tests would be to find something other than the UI to rely on for checking the correctness.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! Updated.

.set("spark.testing", "false")
val mainAppResource = s"file://$EXAMPLES_JAR"

new Client(
Expand All @@ -174,6 +187,8 @@ private[spark] class KubernetesSuite extends SparkFunSuite with BeforeAndAfter {
"--num-executors", "1",
"--upload-jars", HELPER_JAR,
"--class", MAIN_CLASS,
"--conf", "spark.ui.enabled=true",
"--conf", "spark.testing=false",
"--conf", s"spark.kubernetes.submit.caCertFile=${clientConfig.getCaCertFile}",
"--conf", s"spark.kubernetes.submit.clientKeyFile=${clientConfig.getClientKeyFile}",
"--conf", s"spark.kubernetes.submit.clientCertFile=${clientConfig.getClientCertFile}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,4 @@ private[spark] class SparkDockerImageBuilder(private val dockerEnv: Map[String,
dockerClient.build(Paths.get("target", "docker", "driver"), "spark-driver")
dockerClient.build(Paths.get("target", "docker", "executor"), "spark-executor")
}

}
}