aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorShivaram Venkataraman <shivaram@cs.berkeley.edu>2016-07-19 19:28:08 -0700
committerShivaram Venkataraman <shivaram@cs.berkeley.edu>2016-07-19 19:28:08 -0700
commitfc23263623d5dcd1167fa93c094fe41ace77c326 (patch)
tree57ce42fdbaee938b7079ad438ca6513846a73b1a /core
parent9674af6f6f81066139ea675de724f951bd0d49c9 (diff)
downloadspark-fc23263623d5dcd1167fa93c094fe41ace77c326.tar.gz
spark-fc23263623d5dcd1167fa93c094fe41ace77c326.tar.bz2
spark-fc23263623d5dcd1167fa93c094fe41ace77c326.zip
[SPARK-10683][SPARK-16510][SPARKR] Move SparkR include jar test to SparkSubmitSuite
## What changes were proposed in this pull request? This change moves the include jar test from R to SparkSubmitSuite and uses a dynamically compiled jar. This helps us remove the binary jar from the R package and solves both the CRAN warnings and the lack of source being available for this jar. ## How was this patch tested? SparkR unit tests, SparkSubmitSuite, check-cran.sh Author: Shivaram Venkataraman <shivaram@cs.berkeley.edu> Closes #14243 from shivaram/sparkr-jar-move.
Diffstat (limited to 'core')
-rw-r--r--core/src/main/scala/org/apache/spark/api/r/RUtils.scala9
-rw-r--r--core/src/test/scala/org/apache/spark/deploy/SparkSubmitSuite.scala38
2 files changed, 47 insertions, 0 deletions
diff --git a/core/src/main/scala/org/apache/spark/api/r/RUtils.scala b/core/src/main/scala/org/apache/spark/api/r/RUtils.scala
index 16157414fd..77825e75e5 100644
--- a/core/src/main/scala/org/apache/spark/api/r/RUtils.scala
+++ b/core/src/main/scala/org/apache/spark/api/r/RUtils.scala
@@ -38,6 +38,15 @@ private[spark] object RUtils {
}
/**
+ * Check if SparkR is installed before running tests that use SparkR.
+ */
+ def isSparkRInstalled: Boolean = {
+ localSparkRPackagePath.filter { pkgDir =>
+ new File(Seq(pkgDir, "SparkR").mkString(File.separator)).exists
+ }.isDefined
+ }
+
+ /**
* Get the list of paths for R packages in various deployment modes, of which the first
* path is for the SparkR package itself. The second path is for R packages built as
* part of Spark Packages, if any exist. Spark Packages can be provided through the
diff --git a/core/src/test/scala/org/apache/spark/deploy/SparkSubmitSuite.scala b/core/src/test/scala/org/apache/spark/deploy/SparkSubmitSuite.scala
index 0b020592b0..b2bc886108 100644
--- a/core/src/test/scala/org/apache/spark/deploy/SparkSubmitSuite.scala
+++ b/core/src/test/scala/org/apache/spark/deploy/SparkSubmitSuite.scala
@@ -32,6 +32,7 @@ import org.apache.spark.api.r.RUtils
import org.apache.spark.deploy.SparkSubmit._
import org.apache.spark.deploy.SparkSubmitUtils.MavenCoordinate
import org.apache.spark.internal.Logging
+import org.apache.spark.TestUtils.JavaSourceFromString
import org.apache.spark.util.{ResetSystemProperties, Utils}
// Note: this suite mixes in ResetSystemProperties because SparkSubmit.main() sets a bunch
@@ -417,6 +418,8 @@ class SparkSubmitSuite
// See https://gist.github.com/shivaram/3a2fecce60768a603dac for a error log
ignore("correctly builds R packages included in a jar with --packages") {
assume(RUtils.isRInstalled, "R isn't installed on this machine.")
+ // Check if the SparkR package is installed
+ assume(RUtils.isSparkRInstalled, "SparkR is not installed in this build.")
val main = MavenCoordinate("my.great.lib", "mylib", "0.1")
val sparkHome = sys.props.getOrElse("spark.test.home", fail("spark.test.home is not set!"))
val rScriptDir =
@@ -435,6 +438,41 @@ class SparkSubmitSuite
}
}
+ test("include an external JAR in SparkR") {
+ assume(RUtils.isRInstalled, "R isn't installed on this machine.")
+ val sparkHome = sys.props.getOrElse("spark.test.home", fail("spark.test.home is not set!"))
+ // Check if the SparkR package is installed
+ assume(RUtils.isSparkRInstalled, "SparkR is not installed in this build.")
+ val rScriptDir =
+ Seq(sparkHome, "R", "pkg", "inst", "tests", "testthat", "jarTest.R").mkString(File.separator)
+ assert(new File(rScriptDir).exists)
+
+ // compile a small jar containing a class that will be called from R code.
+ val tempDir = Utils.createTempDir()
+ val srcDir = new File(tempDir, "sparkrtest")
+ srcDir.mkdirs()
+ val excSource = new JavaSourceFromString(new File(srcDir, "DummyClass").getAbsolutePath,
+ """package sparkrtest;
+ |
+ |public class DummyClass implements java.io.Serializable {
+ | public static String helloWorld(String arg) { return "Hello " + arg; }
+ | public static int addStuff(int arg1, int arg2) { return arg1 + arg2; }
+ |}
+ """.stripMargin)
+ val excFile = TestUtils.createCompiledClass("DummyClass", srcDir, excSource, Seq.empty)
+ val jarFile = new File(tempDir, "sparkRTestJar-%s.jar".format(System.currentTimeMillis()))
+ val jarURL = TestUtils.createJar(Seq(excFile), jarFile, directoryPrefix = Some("sparkrtest"))
+
+ val args = Seq(
+ "--name", "testApp",
+ "--master", "local",
+ "--jars", jarURL.toString,
+ "--verbose",
+ "--conf", "spark.ui.enabled=false",
+ rScriptDir)
+ runSparkSubmit(args)
+ }
+
test("resolves command line argument paths correctly") {
val jars = "/jar1,/jar2" // --jars
val files = "hdfs:/file1,file2" // --files