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

A couple of improvements to ReplSuite:

- Use collect instead of toArray
- Disable the "running on Mesos" test when MESOS_HOME is not set
parent 28d6f231
No related branches found
No related tags found
No related merge requests found
......@@ -39,9 +39,9 @@ class ReplSuite extends FunSuite {
test ("external vars") {
val output = runInterpreter("local", """
var v = 7
sc.parallelize(1 to 10).map(x => v).toArray.reduceLeft(_+_)
sc.parallelize(1 to 10).map(x => v).collect.reduceLeft(_+_)
v = 10
sc.parallelize(1 to 10).map(x => v).toArray.reduceLeft(_+_)
sc.parallelize(1 to 10).map(x => v).collect.reduceLeft(_+_)
""")
assertDoesNotContain("error:", output)
assertDoesNotContain("Exception", output)
......@@ -54,7 +54,7 @@ class ReplSuite extends FunSuite {
class C {
def foo = 5
}
sc.parallelize(1 to 10).map(x => (new C).foo).toArray.reduceLeft(_+_)
sc.parallelize(1 to 10).map(x => (new C).foo).collect.reduceLeft(_+_)
""")
assertDoesNotContain("error:", output)
assertDoesNotContain("Exception", output)
......@@ -64,7 +64,7 @@ class ReplSuite extends FunSuite {
test ("external functions") {
val output = runInterpreter("local", """
def double(x: Int) = x + x
sc.parallelize(1 to 10).map(x => double(x)).toArray.reduceLeft(_+_)
sc.parallelize(1 to 10).map(x => double(x)).collect.reduceLeft(_+_)
""")
assertDoesNotContain("error:", output)
assertDoesNotContain("Exception", output)
......@@ -75,9 +75,9 @@ class ReplSuite extends FunSuite {
val output = runInterpreter("local", """
var v = 7
def getV() = v
sc.parallelize(1 to 10).map(x => getV()).toArray.reduceLeft(_+_)
sc.parallelize(1 to 10).map(x => getV()).collect.reduceLeft(_+_)
v = 10
sc.parallelize(1 to 10).map(x => getV()).toArray.reduceLeft(_+_)
sc.parallelize(1 to 10).map(x => getV()).collect.reduceLeft(_+_)
""")
assertDoesNotContain("error:", output)
assertDoesNotContain("Exception", output)
......@@ -92,9 +92,9 @@ class ReplSuite extends FunSuite {
val output = runInterpreter("local", """
var array = new Array[Int](5)
val broadcastArray = sc.broadcast(array)
sc.parallelize(0 to 4).map(x => broadcastArray.value(x)).toArray
sc.parallelize(0 to 4).map(x => broadcastArray.value(x)).collect
array(0) = 5
sc.parallelize(0 to 4).map(x => broadcastArray.value(x)).toArray
sc.parallelize(0 to 4).map(x => broadcastArray.value(x)).collect
""")
assertDoesNotContain("error:", output)
assertDoesNotContain("Exception", output)
......@@ -103,23 +103,27 @@ class ReplSuite extends FunSuite {
}
test ("running on Mesos") {
val output = runInterpreter("localquiet", """
var v = 7
def getV() = v
sc.parallelize(1 to 10).map(x => getV()).toArray.reduceLeft(_+_)
v = 10
sc.parallelize(1 to 10).map(x => getV()).toArray.reduceLeft(_+_)
var array = new Array[Int](5)
val broadcastArray = sc.broadcast(array)
sc.parallelize(0 to 4).map(x => broadcastArray.value(x)).toArray
array(0) = 5
sc.parallelize(0 to 4).map(x => broadcastArray.value(x)).toArray
""")
assertDoesNotContain("error:", output)
assertDoesNotContain("Exception", output)
assertContains("res0: Int = 70", output)
assertContains("res1: Int = 100", output)
assertContains("res2: Array[Int] = Array(0, 0, 0, 0, 0)", output)
assertContains("res4: Array[Int] = Array(0, 0, 0, 0, 0)", output)
if (System.getenv("MESOS_HOME") != null) {
val output = runInterpreter("localquiet", """
var v = 7
def getV() = v
sc.parallelize(1 to 10).map(x => getV()).collect.reduceLeft(_+_)
v = 10
sc.parallelize(1 to 10).map(x => getV()).collect.reduceLeft(_+_)
var array = new Array[Int](5)
val broadcastArray = sc.broadcast(array)
sc.parallelize(0 to 4).map(x => broadcastArray.value(x)).collect
array(0) = 5
sc.parallelize(0 to 4).map(x => broadcastArray.value(x)).collect
""")
assertDoesNotContain("error:", output)
assertDoesNotContain("Exception", output)
assertContains("res0: Int = 70", output)
assertContains("res1: Int = 100", output)
assertContains("res2: Array[Int] = Array(0, 0, 0, 0, 0)", output)
assertContains("res4: Array[Int] = Array(0, 0, 0, 0, 0)", output)
} else {
info("Skipping \"running on Mesos\" test because MESOS_HOME is not set");
}
}
}
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