Skip to content
Snippets Groups Projects
Commit 96c895f6 authored by Matei Zaharia's avatar Matei Zaharia
Browse files

Fix StandaloneClusterReplSuite to allow running multiple tests

parent 5b5b5aed
No related branches found
No related tags found
No related merge requests found
......@@ -14,16 +14,6 @@ import spark.deploy.master.Master
import spark.deploy.worker.Worker
trait ReplSuiteMixin {
val localIp = "127.0.1.2"
val port = "7089"
val sparkUrl = s"spark://$localIp:$port"
def setupStandaloneCluster() {
future { Master.main(Array("-i", localIp, "-p", port, "--webui-port", "0")) }
Thread.sleep(2000)
future { Worker.main(Array(sparkUrl, "--webui-port", "0")) }
}
def runInterpreter(master: String, input: String): String = {
val in = new BufferedReader(new StringReader(input + "\n"))
val out = new StringWriter()
......@@ -42,10 +32,11 @@ trait ReplSuiteMixin {
spark.repl.Main.interp = interp
val separator = System.getProperty("path.separator")
interp.process(Array("-classpath", paths.mkString(separator)))
if (interp != null)
interp.closeInterpreter();
if (interp != null) {
interp.closeInterpreter()
}
// To avoid Akka rebinding to the same port, since it doesn't unbind immediately on shutdown
System.clearProperty("spark.master.port")
System.clearProperty("spark.driver.port")
return out.toString
}
......
......@@ -7,7 +7,7 @@ import org.scalatest.FunSuite
import com.google.common.io.Files
class StandaloneClusterReplSuite extends FunSuite with ReplSuiteMixin {
setupStandaloneCluster
val sparkUrl = "local-cluster[1,1,512]"
test("simple collect") {
val output = runInterpreter(sparkUrl, """
......@@ -98,6 +98,4 @@ class StandaloneClusterReplSuite extends FunSuite with ReplSuiteMixin {
assertContains("res0: Array[Int] = Array(0, 0, 0, 0, 0)", output)
assertContains("res2: Array[Int] = Array(5, 0, 0, 0, 0)", output)
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment