You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by sr...@apache.org on 2017/06/03 08:56:40 UTC
spark git commit: [SPARK-20936][CORE] Lack of an important case about
the test of resolveURI in UtilsSuite, and add it as needed.
Repository: spark
Updated Branches:
refs/heads/master 96e6ba6c2 -> 887cf0ec3
[SPARK-20936][CORE] Lack of an important case about the test of resolveURI in UtilsSuite, and add it as needed.
## What changes were proposed in this pull request?
1. add `assert(resolve(before) === after)` to check before and after in test of resolveURI.
the function `assertResolves(before: String, after: String)` have two params, it means we should check the before value whether equals the after value which we want.
e.g. the after value of Utils.resolveURI("hdfs:///root/spark.jar#app.jar").toString should be "hdfs:///root/spark.jar#app.jar" rather than "hdfs:/root/spark.jar#app.jar". we need `assert(resolve(before) === after)` to make it more safe.
2. identify the cases between resolveURI and resolveURIs.
3. delete duplicate cases and some small fix make this suit more clear.
## How was this patch tested?
unit tests
Author: zuotingbing <zu...@zte.com.cn>
Closes #18158 from zuotingbing/spark-UtilsSuite.
Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/887cf0ec
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/887cf0ec
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/887cf0ec
Branch: refs/heads/master
Commit: 887cf0ec33ccf5bb7936c48cb07e21d60945bee5
Parents: 96e6ba6
Author: zuotingbing <zu...@zte.com.cn>
Authored: Sat Jun 3 09:56:35 2017 +0100
Committer: Sean Owen <so...@cloudera.com>
Committed: Sat Jun 3 09:56:35 2017 +0100
----------------------------------------------------------------------
.../org/apache/spark/util/UtilsSuite.scala | 21 ++++++++++----------
1 file changed, 10 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/spark/blob/887cf0ec/core/src/test/scala/org/apache/spark/util/UtilsSuite.scala
----------------------------------------------------------------------
diff --git a/core/src/test/scala/org/apache/spark/util/UtilsSuite.scala b/core/src/test/scala/org/apache/spark/util/UtilsSuite.scala
index 3339d5b..f7bc8f8 100644
--- a/core/src/test/scala/org/apache/spark/util/UtilsSuite.scala
+++ b/core/src/test/scala/org/apache/spark/util/UtilsSuite.scala
@@ -461,19 +461,17 @@ class UtilsSuite extends SparkFunSuite with ResetSystemProperties with Logging {
def assertResolves(before: String, after: String): Unit = {
// This should test only single paths
assume(before.split(",").length === 1)
- // Repeated invocations of resolveURI should yield the same result
def resolve(uri: String): String = Utils.resolveURI(uri).toString
+ assert(resolve(before) === after)
assert(resolve(after) === after)
+ // Repeated invocations of resolveURI should yield the same result
assert(resolve(resolve(after)) === after)
assert(resolve(resolve(resolve(after))) === after)
- // Also test resolveURIs with single paths
- assert(new URI(Utils.resolveURIs(before)) === new URI(after))
- assert(new URI(Utils.resolveURIs(after)) === new URI(after))
}
val rawCwd = System.getProperty("user.dir")
val cwd = if (Utils.isWindows) s"/$rawCwd".replace("\\", "/") else rawCwd
assertResolves("hdfs:/root/spark.jar", "hdfs:/root/spark.jar")
- assertResolves("hdfs:///root/spark.jar#app.jar", "hdfs:/root/spark.jar#app.jar")
+ assertResolves("hdfs:///root/spark.jar#app.jar", "hdfs:///root/spark.jar#app.jar")
assertResolves("spark.jar", s"file:$cwd/spark.jar")
assertResolves("spark.jar#app.jar", s"file:$cwd/spark.jar#app.jar")
assertResolves("path to/file.txt", s"file:$cwd/path%20to/file.txt")
@@ -482,20 +480,19 @@ class UtilsSuite extends SparkFunSuite with ResetSystemProperties with Logging {
assertResolves("C:\\path to\\file.txt", "file:/C:/path%20to/file.txt")
}
assertResolves("file:/C:/path/to/file.txt", "file:/C:/path/to/file.txt")
- assertResolves("file:///C:/path/to/file.txt", "file:/C:/path/to/file.txt")
+ assertResolves("file:///C:/path/to/file.txt", "file:///C:/path/to/file.txt")
assertResolves("file:/C:/file.txt#alias.txt", "file:/C:/file.txt#alias.txt")
- assertResolves("file:foo", s"file:foo")
- assertResolves("file:foo:baby", s"file:foo:baby")
+ assertResolves("file:foo", "file:foo")
+ assertResolves("file:foo:baby", "file:foo:baby")
}
test("resolveURIs with multiple paths") {
def assertResolves(before: String, after: String): Unit = {
assume(before.split(",").length > 1)
- assert(Utils.resolveURIs(before) === after)
- assert(Utils.resolveURIs(after) === after)
- // Repeated invocations of resolveURIs should yield the same result
def resolve(uri: String): String = Utils.resolveURIs(uri)
+ assert(resolve(before) === after)
assert(resolve(after) === after)
+ // Repeated invocations of resolveURIs should yield the same result
assert(resolve(resolve(after)) === after)
assert(resolve(resolve(resolve(after))) === after)
}
@@ -511,6 +508,8 @@ class UtilsSuite extends SparkFunSuite with ResetSystemProperties with Logging {
s"hdfs:/jar1,file:/jar2,file:$cwd/jar3,file:/C:/pi.py%23py.pi,file:/C:/path%20to/jar4")
}
assertResolves(",jar1,jar2", s"file:$cwd/jar1,file:$cwd/jar2")
+ // Also test resolveURIs with single paths
+ assertResolves("hdfs:/root/spark.jar", "hdfs:/root/spark.jar")
}
test("nonLocalPaths") {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org