-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use a local HTTP server to provide a place for "remote" jars to download in tests #29
Open
mccheah
wants to merge
1
commit into
master
Choose a base branch
from
remote-jars-tests
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
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 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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
.idea/ | ||
spark/ | ||
spark | ||
integration-test/target/ | ||
*.class | ||
*.log | ||
|
This file contains 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 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 @@ | ||
jars |
This file contains 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,4 @@ | ||
FROM nginx:alpine | ||
|
||
COPY jars /opt/spark/jars | ||
COPY nginx.conf /etc/nginx/nginx.conf |
This file contains 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,34 @@ | ||
user nginx; | ||
worker_processes 1; | ||
|
||
error_log /var/log/nginx/error.log warn; | ||
pid /var/run/nginx.pid; | ||
|
||
events { | ||
worker_connections 1024; | ||
} | ||
|
||
http { | ||
server { | ||
root /opt/spark/jars; | ||
location /ping { | ||
return 200 'pong'; | ||
add_header Content-Type text/plain; | ||
} | ||
} | ||
include /etc/nginx/mime.types; | ||
default_type application/octet-stream; | ||
|
||
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' | ||
'$status $body_bytes_sent "$http_referer" ' | ||
'"$http_user_agent" "$http_x_forwarded_for"'; | ||
|
||
access_log /var/log/nginx/access.log main; | ||
|
||
sendfile on; | ||
#tcp_nopush on; | ||
|
||
keepalive_timeout 65; | ||
|
||
#gzip on; | ||
} |
This file contains 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 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
122 changes: 122 additions & 0 deletions
122
...est/scala/org/apache/spark/deploy/k8s/integrationtest/SparkExamplesFileServerRunner.scala
This file contains 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,122 @@ | ||
/* | ||
* 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.k8s.integrationtest | ||
|
||
import java.net.{URI, URL} | ||
import java.nio.file.Paths | ||
import java.util.UUID | ||
|
||
import io.fabric8.kubernetes.api.model.{Endpoints, Pod, Service} | ||
import org.apache.http.client.utils.URIBuilder | ||
|
||
private[spark] object SparkExamplesFileServerRunner { | ||
|
||
private val fileServerImage = System.getProperty( | ||
"spark.docker.test.fileServerImage", "spark-examples-file-server:latest") | ||
private val fileServerExampleJarsDir = Paths.get("docker-file-server", "jars") | ||
require( | ||
fileServerExampleJarsDir | ||
.toFile | ||
.listFiles() | ||
.exists(file => file.getName.startsWith("spark-examples")), | ||
s"No spark-examples jar found in $fileServerExampleJarsDir.") | ||
require( | ||
fileServerExampleJarsDir | ||
.toFile | ||
.listFiles() | ||
.count(file => file.getName.startsWith("spark-examples")) == 1, | ||
s"Multiple spark-examples jars found in $fileServerExampleJarsDir.") | ||
private val fileServerExampleJar = Paths.get("docker-file-server", "jars") | ||
.toFile | ||
.listFiles() | ||
.filter(file => file.getName.startsWith("spark-examples"))(0) | ||
.getName | ||
private val fileServerPodLocatorLabelKey = "fileServerLocator" | ||
private val fileServerPodLocatorLabelValue = UUID.randomUUID().toString.replaceAll("-", "") | ||
private val fileServerName = "spark-examples-file-server" | ||
|
||
def launchServerAndGetUriForExamplesJar( | ||
kubernetesTestComponents: KubernetesTestComponents): URI = { | ||
val podReadinessWatcher = new SparkReadinessWatcher[Pod] | ||
Utils.tryWithResource( | ||
kubernetesTestComponents | ||
.kubernetesClient | ||
.pods() | ||
.withName(fileServerName) | ||
.watch(podReadinessWatcher)) { _ => | ||
kubernetesTestComponents.kubernetesClient.pods().createNew() | ||
.withNewMetadata() | ||
.withName(fileServerName) | ||
.addToLabels(fileServerPodLocatorLabelKey, fileServerPodLocatorLabelValue) | ||
.endMetadata() | ||
.withNewSpec() | ||
.addNewContainer() | ||
.withName("main") | ||
.withImage(fileServerImage) | ||
.withImagePullPolicy("Never") | ||
.withNewReadinessProbe() | ||
.withNewHttpGet() | ||
.withNewPort(80) | ||
.withPath("/ping") | ||
.endHttpGet() | ||
.endReadinessProbe() | ||
.endContainer() | ||
.endSpec() | ||
.done() | ||
podReadinessWatcher.waitUntilReady() | ||
} | ||
val endpointsReadinessWatcher = new SparkReadinessWatcher[Endpoints] | ||
Utils.tryWithResource( | ||
kubernetesTestComponents | ||
.kubernetesClient | ||
.endpoints() | ||
.withName(fileServerName) | ||
.watch(endpointsReadinessWatcher)) { _ => | ||
kubernetesTestComponents.kubernetesClient.services().createNew() | ||
.withNewMetadata() | ||
.withName(fileServerName) | ||
.endMetadata() | ||
.withNewSpec() | ||
.addToSelector(fileServerPodLocatorLabelKey, fileServerPodLocatorLabelValue) | ||
.addNewPort() | ||
.withName("file-server-port") | ||
.withNewTargetPort(80) | ||
.withPort(80) | ||
.endPort() | ||
.withType("NodePort") | ||
.endSpec() | ||
.done() | ||
endpointsReadinessWatcher.waitUntilReady() | ||
} | ||
val resolvedNodePort = kubernetesTestComponents | ||
.kubernetesClient | ||
.services() | ||
.withName(fileServerName) | ||
.get() | ||
.getSpec | ||
.getPorts | ||
.get(0) | ||
.getNodePort | ||
val masterHostname = URI.create(kubernetesTestComponents.clientConfig.getMasterUrl).getHost | ||
new URIBuilder() | ||
.setHost(masterHostname) | ||
.setPort(resolvedNodePort) | ||
.setScheme("http") | ||
.setPath(s"/$fileServerExampleJar") | ||
.build() | ||
} | ||
} |
This file contains 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
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.
In the current setup we're building Docker images both in Scala code if the user just runs
mvn
but also here as part of the script. We should fix this at a later time though ideally earlier rather than later; there's a bit of room for error right now.