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

Commit d3bdf0c

Browse files
committed
disable ssl test for staging server if current classpath contains the jetty shaded classes
1 parent 7e8e8b4 commit d3bdf0c

File tree

1 file changed

+36
-15
lines changed

1 file changed

+36
-15
lines changed

resource-managers/kubernetes/core/src/test/scala/org/apache/spark/deploy/rest/k8s/ResourceStagingServerSuite.scala

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -75,22 +75,43 @@ class ResourceStagingServerSuite extends SparkFunSuite with BeforeAndAfter with
7575
runUploadAndDownload(SSLOptions(), serverPort)
7676
}
7777

78+
/**
79+
* This test will run only if the current classpath does not contain
80+
* the shaded jetty classes.
81+
*
82+
* If you rely on the spark-core.jar in your classpath, this test will not run.
83+
*
84+
* If you rely on the spark-core module (without shading), this test will be run.
85+
*
86+
* @see https://github.com/apache-spark-on-k8s/spark/issues/463
87+
*
88+
*/
7889
test("Enable SSL on the server") {
79-
val keyStoreAndTrustStore = SSLUtils.generateKeyStoreTrustStorePair(
80-
ipAddress = "127.0.0.1",
81-
keyStorePassword = "keyStore",
82-
keyPassword = "key",
83-
trustStorePassword = "trustStore")
84-
val sslOptions = SSLOptions(
85-
enabled = true,
86-
keyStore = Some(keyStoreAndTrustStore.keyStore),
87-
keyStorePassword = Some("keyStore"),
88-
keyPassword = Some("key"),
89-
trustStore = Some(keyStoreAndTrustStore.trustStore),
90-
trustStorePassword = Some("trustStore"))
91-
sslOptionsProvider.setOptions(sslOptions)
92-
val serverPort = startServer()
93-
runUploadAndDownload(sslOptions, serverPort)
90+
91+
def testEnableSslOnServer(): Unit = {
92+
val keyStoreAndTrustStore = SSLUtils.generateKeyStoreTrustStorePair(
93+
ipAddress = "127.0.0.1",
94+
keyStorePassword = "keyStore",
95+
keyPassword = "key",
96+
trustStorePassword = "trustStore")
97+
val sslOptions = SSLOptions(
98+
enabled = true,
99+
keyStore = Some(keyStoreAndTrustStore.keyStore),
100+
keyStorePassword = Some("keyStore"),
101+
keyPassword = Some("key"),
102+
trustStore = Some(keyStoreAndTrustStore.trustStore),
103+
trustStorePassword = Some("trustStore"))
104+
sslOptionsProvider.setOptions(sslOptions)
105+
val serverPort = startServer()
106+
runUploadAndDownload(sslOptions, serverPort)
107+
}
108+
109+
try {
110+
Class.forName("org.spark_project.jetty.util.ssl.SslContextFactory")
111+
}
112+
catch {
113+
case e: ClassNotFoundException => testEnableSslOnServer()
114+
}
94115
}
95116

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

0 commit comments

Comments
 (0)