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

Disable ssl test for staging server if current classpath contains the jetty shaded classes #573

Open
wants to merge 6 commits into
base: branch-2.2-kubernetes
Choose a base branch
from
Open
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
58 changes: 58 additions & 0 deletions resource-managers/kubernetes/core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,64 @@
<scope>test</scope>
</dependency>

<!-- Jetty dependencies promoted to compile here so they are shaded
and inlined into spark-core jar -->
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-plus</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-security</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-http</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-continuation</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-proxy</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-client</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlets</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>${javaxservlet.version}</version>
</dependency>

<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-client</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,22 +75,43 @@ class ResourceStagingServerSuite extends SparkFunSuite with BeforeAndAfter with
runUploadAndDownload(SSLOptions(), serverPort)
}

/**
* This test will run only if the current classpath does not contain
* the shaded jetty classes.
*
* If you rely on the spark-core.jar in your classpath, this test will not run.
*
* If you rely on the spark-core module (without shading), this test will be run.
*
* @see https://github.com/apache-spark-on-k8s/spark/issues/463
*
*/
test("Enable SSL on the server") {
val keyStoreAndTrustStore = SSLUtils.generateKeyStoreTrustStorePair(
ipAddress = "127.0.0.1",
keyStorePassword = "keyStore",
keyPassword = "key",
trustStorePassword = "trustStore")
val sslOptions = SSLOptions(
enabled = true,
keyStore = Some(keyStoreAndTrustStore.keyStore),
keyStorePassword = Some("keyStore"),
keyPassword = Some("key"),
trustStore = Some(keyStoreAndTrustStore.trustStore),
trustStorePassword = Some("trustStore"))
sslOptionsProvider.setOptions(sslOptions)
val serverPort = startServer()
runUploadAndDownload(sslOptions, serverPort)

def testEnableSslOnServer(): Unit = {
val keyStoreAndTrustStore = SSLUtils.generateKeyStoreTrustStorePair(
ipAddress = "127.0.0.1",
keyStorePassword = "keyStore",
keyPassword = "key",
trustStorePassword = "trustStore")
val sslOptions = SSLOptions(
enabled = true,
keyStore = Some(keyStoreAndTrustStore.keyStore),
keyStorePassword = Some("keyStore"),
keyPassword = Some("key"),
trustStore = Some(keyStoreAndTrustStore.trustStore),
trustStorePassword = Some("trustStore"))
sslOptionsProvider.setOptions(sslOptions)
val serverPort = startServer()
runUploadAndDownload(sslOptions, serverPort)
}

try {
Utils.classForName("org.spark_project.jetty.util.ssl.SslContextFactory")
}
catch {
case e: ClassNotFoundException => testEnableSslOnServer()
}
}

private def runUploadAndDownload(sslOptions: SSLOptions, serverPort: Int): Unit = {
Expand Down