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

Conversation

@foxish
Copy link
Member

@foxish foxish commented Apr 27, 2017

@mccheah @ash211

This merges into #243

@foxish
Copy link
Member Author

foxish commented Apr 28, 2017

@mccheah Could you please review this PR and #243 which this merges into? They're fairly small and should unblock some e2es tests I want to setup against GCE.

Copy link

@mccheah mccheah left a comment

Choose a reason for hiding this comment

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

Mostly minor changes. The overall approach is good.

import org.apache.spark.deploy.kubernetes.integrationtest.constants.GCE_TEST_BACKEND

class GCETestBackend extends IntegrationTestBackend {
val master = System.getProperty("spark.kubernetes.test.master")
Copy link

Choose a reason for hiding this comment

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

nit: Mark these as private

Copy link

Choose a reason for hiding this comment

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

Pass the system property through the constructor.

val defaultClient = new DefaultKubernetesClient(k8ClientConfig)

override def getKubernetesClient: DefaultKubernetesClient = {
return defaultClient
Copy link

Choose a reason for hiding this comment

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

No need for return keyword here. The return value could be on the same line as the function signature, without braces.


object IntegrationTestBackendFactory {
def getTestBackend: IntegrationTestBackend = {
Option(System.getProperty("spark.kubernetes.test.master")).map {
Copy link

Choose a reason for hiding this comment

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

Pass the system property's value into the constructor of GCEBackend, and GCEBackend shouldn't look up the system property itself.


override def afterAll(): Unit = {
kubernetesTestClient.cleanUp()
testBackend.cleanUp
Copy link

Choose a reason for hiding this comment

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

Nit: Use empty-paren for non-getter methods.

return defaultClient
}

override def cleanUp: Unit = {}
Copy link

Choose a reason for hiding this comment

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

Nit: Provide empty-paren for methods that aren't getters.

Copy link

Choose a reason for hiding this comment

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

cleanup can have a default implementation in the trait that is empty, and then it only has to be overridden in MinikubeTestBackend.

}

override def cleanUp: Unit = {}
override def name: String = GCE_TEST_BACKEND
Copy link

Choose a reason for hiding this comment

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

Nit: Empty-paren.

import org.apache.spark.deploy.kubernetes.integrationtest.docker.SparkDockerImageBuilder

class MinikubeTestBackend extends IntegrationTestBackend {
Minikube.startMinikube()
Copy link

Choose a reason for hiding this comment

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

Prefer if these were not set up in the constructor. Instead, IntegrationTestBackend should have an initialize method that the Minikube variant implements. Then, call initialize in beforeAll().

import org.apache.spark.deploy.kubernetes.integrationtest.backend.minikube.{Minikube, MinikubeTestBackend}
import org.apache.spark.deploy.kubernetes.integrationtest.docker.SparkDockerImageBuilder

abstract class IntegrationTestBackend {
Copy link

Choose a reason for hiding this comment

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

trait preferred over abstract class.

var k8ConfBuilder = new ConfigBuilder()
.withApiVersion("v1")
.withMasterUrl(resolveK8sMaster(master))
val k8ClientConfig = k8ConfBuilder.build
Copy link

Choose a reason for hiding this comment

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

No need to have a separate var for the builder - simply set the config val inline:


private[spark] class KubernetesSuite extends SparkFunSuite {
private var kubernetesTestClient: KubernetesTestClient = _
private var testBackend: IntegrationTestBackend = _
Copy link

Choose a reason for hiding this comment

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

If initialization is done in a separate method and not the constructor, then this can become a val and set inline here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe I'm misunderstanding this. I still need to keep a reference to it to later cleanUp after the tests correct?

Copy link

@mccheah mccheah Apr 29, 2017

Choose a reason for hiding this comment

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

Right but this can be a val instead of a var that's set in beforeAll():

private val testBackend = IntegrationTestBackendFactory...

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah! Got it. Thanks. Fixed.

val k8ClientConfig = k8ConfBuilder.build
val defaultClient = new DefaultKubernetesClient(k8ClientConfig)
private[spark] class GCETestBackend(val master: String) extends IntegrationTestBackend {
private var defaultClient: DefaultKubernetesClient = _
Copy link

Choose a reason for hiding this comment

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

In the GCE case it's probably fine to initialize in the constructor - create a KubernetesClient should be fairly lightweight. What we wanted to avoid in the Minikube case was to have side effects in the constructor.

Copy link

@mccheah mccheah left a comment

Choose a reason for hiding this comment

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

Looks ok to merge into the dependent PR. We can continue reviewing on the downstream.

@mccheah mccheah merged commit d4d2e9c into multi-k8s-tests Apr 29, 2017
@mccheah mccheah deleted the restructure-integration-test branch April 29, 2017 02:33
mccheah pushed a commit that referenced this pull request May 2, 2017
* Part 1: making test code cluster-agnostic

* Final checked

* Move all test code into KubernetesTestComponents

* Addressed comments

* Fixed doc

* Restructure the test backends (#248)

* Restructured the test backends

* Address comments

* var -> val

* Comments

* removed deadcode
foxish added a commit that referenced this pull request Jul 24, 2017
* Part 1: making test code cluster-agnostic

* Final checked

* Move all test code into KubernetesTestComponents

* Addressed comments

* Fixed doc

* Restructure the test backends (#248)

* Restructured the test backends

* Address comments

* var -> val

* Comments

* removed deadcode
ifilonenko pushed a commit to ifilonenko/spark that referenced this pull request Feb 26, 2019
* Part 1: making test code cluster-agnostic

* Final checked

* Move all test code into KubernetesTestComponents

* Addressed comments

* Fixed doc

* Restructure the test backends (apache-spark-on-k8s#248)

* Restructured the test backends

* Address comments

* var -> val

* Comments

* removed deadcode

(cherry picked from commit 6b489c2)
ifilonenko pushed a commit to ifilonenko/spark that referenced this pull request Feb 26, 2019
puneetloya pushed a commit to puneetloya/spark that referenced this pull request Mar 11, 2019
* Part 1: making test code cluster-agnostic

* Final checked

* Move all test code into KubernetesTestComponents

* Addressed comments

* Fixed doc

* Restructure the test backends (apache-spark-on-k8s#248)

* Restructured the test backends

* Address comments

* var -> val

* Comments

* removed deadcode
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants