[SPARK-18093][SQL] Fix default value test in SQLConfSuite to work rega…

…rdless of warehouse dir's existence

## What changes were proposed in this pull request?
Appending a trailing slash, if there already isn't one for the
sake comparison of the two paths. It doesn't take away from
the essence of the check, but removes any potential mismatch
due to lack of trailing slash.

## How was this patch tested?
Ran unit tests and they passed.

Author: Mark Grover <mark@apache.org>

Closes #15623 from markgrover/spark-18093.
This commit is contained in:
Mark Grover 2016-10-26 09:07:30 -07:00 committed by Marcelo Vanzin
parent 3c023570b2
commit 4bee954079

View file

@ -215,12 +215,15 @@ class SQLConfSuite extends QueryTest with SharedSQLContext {
}
test("default value of WAREHOUSE_PATH") {
val original = spark.conf.get(SQLConf.WAREHOUSE_PATH)
try {
// to get the default value, always unset it
spark.conf.unset(SQLConf.WAREHOUSE_PATH.key)
assert(new Path(Utils.resolveURI("spark-warehouse")).toString ===
spark.sessionState.conf.warehousePath + "/")
// JVM adds a trailing slash if the directory exists and leaves it as-is, if it doesn't
// In our comparison, strip trailing slash off of both sides, to account for such cases
assert(new Path(Utils.resolveURI("spark-warehouse")).toString.stripSuffix("/") === spark
.sessionState.conf.warehousePath.stripSuffix("/"))
} finally {
sql(s"set ${SQLConf.WAREHOUSE_PATH}=$original")
}