This repository was archived by the owner on Jan 9, 2020. It is now read-only.
forked from apache/spark
-
Notifications
You must be signed in to change notification settings - Fork 117
Restructure the test backends #248
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...scala/org/apache/spark/deploy/kubernetes/integrationtest/backend/GCE/GCETestBackend.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| /* | ||
| * 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. | ||
| */ | ||
| package org.apache.spark.deploy.kubernetes.integrationtest.backend.GCE | ||
|
|
||
| import io.fabric8.kubernetes.client.{ConfigBuilder, DefaultKubernetesClient} | ||
|
|
||
| import org.apache.spark.deploy.kubernetes.config.resolveK8sMaster | ||
| import org.apache.spark.deploy.kubernetes.integrationtest.backend.IntegrationTestBackend | ||
| import org.apache.spark.deploy.kubernetes.integrationtest.constants.GCE_TEST_BACKEND | ||
|
|
||
| private[spark] class GCETestBackend(val master: String) extends IntegrationTestBackend { | ||
| private var defaultClient: DefaultKubernetesClient = _ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
|
|
||
| override def initialize(): Unit = { | ||
| var k8ConfBuilder = new ConfigBuilder() | ||
| .withApiVersion("v1") | ||
| .withMasterUrl(resolveK8sMaster(master)) | ||
| defaultClient = new DefaultKubernetesClient(k8ConfBuilder.build) | ||
| } | ||
|
|
||
| override def getKubernetesClient(): DefaultKubernetesClient = { | ||
| defaultClient | ||
| } | ||
|
|
||
| override def name(): String = GCE_TEST_BACKEND | ||
| } | ||
42 changes: 42 additions & 0 deletions
42
...a/org/apache/spark/deploy/kubernetes/integrationtest/backend/IntegrationTestBackend.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| /* | ||
| * 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. | ||
| */ | ||
|
|
||
| package org.apache.spark.deploy.kubernetes.integrationtest.backend | ||
|
|
||
| import io.fabric8.kubernetes.client.DefaultKubernetesClient | ||
|
|
||
| import org.apache.spark.deploy.kubernetes.integrationtest.backend.GCE.GCETestBackend | ||
| import org.apache.spark.deploy.kubernetes.integrationtest.backend.minikube.{Minikube, MinikubeTestBackend} | ||
| import org.apache.spark.deploy.kubernetes.integrationtest.docker.SparkDockerImageBuilder | ||
|
|
||
| private[spark] trait IntegrationTestBackend { | ||
| def name(): String | ||
| def initialize(): Unit | ||
| def getKubernetesClient(): DefaultKubernetesClient | ||
| def cleanUp(): Unit = {} | ||
| } | ||
|
|
||
| private[spark] object IntegrationTestBackendFactory { | ||
| def getTestBackend(): IntegrationTestBackend = { | ||
| Option(System.getProperty("spark.kubernetes.test.master")).map { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pass the system property's value into the constructor of |
||
| master => | ||
| new GCETestBackend(master) | ||
| }.getOrElse { | ||
| new MinikubeTestBackend() | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
...apache/spark/deploy/kubernetes/integrationtest/backend/minikube/MinikubeTestBackend.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| /* | ||
| * 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. | ||
| */ | ||
| package org.apache.spark.deploy.kubernetes.integrationtest.backend.minikube | ||
|
|
||
| import io.fabric8.kubernetes.client.DefaultKubernetesClient | ||
|
|
||
| import org.apache.spark.deploy.kubernetes.integrationtest.backend.IntegrationTestBackend | ||
| import org.apache.spark.deploy.kubernetes.integrationtest.constants.MINIKUBE_TEST_BACKEND | ||
| import org.apache.spark.deploy.kubernetes.integrationtest.docker.SparkDockerImageBuilder | ||
|
|
||
| private[spark] class MinikubeTestBackend extends IntegrationTestBackend { | ||
| private var defaultClient: DefaultKubernetesClient = _ | ||
|
|
||
| override def initialize(): Unit = { | ||
| Minikube.startMinikube() | ||
| new SparkDockerImageBuilder(Minikube.getDockerEnv).buildSparkDockerImages() | ||
| defaultClient = Minikube.getKubernetesClient | ||
| } | ||
|
|
||
| override def getKubernetesClient(): DefaultKubernetesClient = { | ||
| defaultClient | ||
| } | ||
|
|
||
| override def cleanUp(): Unit = { | ||
| if (!System.getProperty("spark.docker.test.persistMinikube", "false").toBoolean) { | ||
| Minikube.deleteMinikube() | ||
| } | ||
| } | ||
|
|
||
| override def name(): String = MINIKUBE_TEST_BACKEND | ||
|
|
||
|
|
||
| } |
22 changes: 22 additions & 0 deletions
22
...n-tests/src/test/scala/org/apache/spark/deploy/kubernetes/integrationtest/constants.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| /* | ||
| * 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. | ||
| */ | ||
| package org.apache.spark.deploy.kubernetes.integrationtest | ||
|
|
||
| package object constants { | ||
| val MINIKUBE_TEST_BACKEND = "minikube" | ||
| val GCE_TEST_BACKEND = "gce" | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
valand set inline here.There was a problem hiding this comment.
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
cleanUpafter the tests correct?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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
valinstead of avarthat's set inbeforeAll():There was a problem hiding this comment.
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.