Skip to content

Commit 7da0493

Browse files
committed
Fix tests
It seems that the tests assume we can keep opening UI ports. Our existing default for spark.ports.maxRetries does not tolerate this, however, so the test process throws an exception and returns exit code 1.
1 parent 523c30e commit 7da0493

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

core/src/main/scala/org/apache/spark/util/Utils.scala

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,11 +1335,15 @@ private[spark] object Utils extends Logging {
13351335
* Default number of retries in binding to a port.
13361336
*/
13371337
val portMaxRetries: Int = {
1338-
// SparkEnv may be null during tests
1339-
Option(SparkEnv.get)
1340-
.flatMap(_.conf.getOption("spark.ports.maxRetries"))
1341-
.map(_.toInt)
1342-
.getOrElse(16)
1338+
if (sys.props.contains("spark.testing")) {
1339+
// Set a higher number of retries for tests...
1340+
sys.props.get("spark.ports.maxRetries").map(_.toInt).getOrElse(100)
1341+
} else {
1342+
Option(SparkEnv.get)
1343+
.flatMap(_.conf.getOption("spark.ports.maxRetries"))
1344+
.map(_.toInt)
1345+
.getOrElse(16)
1346+
}
13431347
}
13441348

13451349
/**

project/SparkBuild.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ object TestSettings {
330330
fork := true,
331331
javaOptions in Test += "-Dspark.test.home=" + sparkHome,
332332
javaOptions in Test += "-Dspark.testing=1",
333+
javaOptions in Test += "-Dspark.ports.maxRetries=100",
333334
javaOptions in Test += "-Dsun.io.serialization.extendedDebugInfo=true",
334335
javaOptions in Test ++= System.getProperties.filter(_._1 startsWith "spark")
335336
.map { case (k,v) => s"-D$k=$v" }.toSeq,

0 commit comments

Comments
 (0)