Skip to content

Commit

Permalink
add unit test for setting default RDD name to its path (SPARK-12517)
Browse files Browse the repository at this point in the history
This change extends SparkContextSuite to verify that RDDs that are created using file paths have their
default name set to the path.
  • Loading branch information
wyaron committed Dec 24, 2015
1 parent 86efdad commit 081a723
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions core/src/test/scala/org/apache/spark/SparkContextSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,19 @@ class SparkContextSuite extends SparkFunSuite with LocalSparkContext {
}
}

test("Default path for file based RDDs is properly set (SPARK-12517)") {
sc = new SparkContext(new SparkConf().setAppName("test").setMaster("local"))

// Test textFile, wholeTextFiles and binaryFiles for default paths
val mockPath = "default/path/for/wholeTextFile/"
assert(sc.textFile(mockPath + "textFile").name == mockPath + "textFile")
assert(sc.wholeTextFiles(mockPath + "wholeTextFile").name == mockPath + "wholeTextFile")
assert(sc.binaryFiles(mockPath + "binaryFiles").name == mockPath + "binaryFiles")
assert(sc.hadoopFile(mockPath + "hadoopFile").name == mockPath + "hadoopFile")
assert(sc.newAPIHadoopFile(mockPath + "newAPIHadoopFile").name == mockPath + "newAPIHadoopFile")
sc.stop()
}

test("calling multiple sc.stop() must not throw any exception") {
noException should be thrownBy {
sc = new SparkContext(new SparkConf().setAppName("test").setMaster("local"))
Expand Down

0 comments on commit 081a723

Please sign in to comment.