Skip to content

Conversation

@zuotingbing
Copy link

@zuotingbing zuotingbing commented May 31, 2017

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

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")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no explanation of the change you are proposing. Please don't open PRs in this way

Copy link
Author

@zuotingbing zuotingbing May 31, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to add assert(resolve(before) === after) to check before and after.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mind if I ask to update the PR description with the reason for ^ in more details? We could focus on the topic more easily if there are details. This saves time for all of us (author and reviewers). Also, it helps to understand later when someone revisits this PR

Copy link
Author

@zuotingbing zuotingbing Jun 1, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes let me make it clear. the function assertResolves(before: String, after: String) have two params, it means we need to check the before value whether equals the after value which we want when we call Utils.resolveURI(uri), right? otherwise the different value of before: String make no sense.
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.
Thanks!

Copy link
Member

@HyukjinKwon HyukjinKwon Jun 1, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My question would be, what this change targets (e.g., adding missing test cases). If this tests the same thing before/after, I wonder if it is worth changing this.

It is probably okay to add missing cases that does not change the existing tests but this changes the existing regression test cases.

Are there missing test cases for this that detect the regressions within Spark's Utils.resolveURI?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the before: String targets in assertResolves(before: String, after: String) ?
It seems to me that the different values of before: String test more different cases of Utils.resolveURI. if we do not use before: String to check, why add the params of before: String

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we do use it in assert(new URI(Utils.resolveURIs(before)) === new URI(after)).

different cases of Utils.resolveURI

I think we should identify the cases.

If the only reason is just meant to make the test code prettier but change the existing tests for no reason, I would go -1.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry for my pool english. could we ask more people to review this and get more opinions? @vanzin

Copy link
Author

@zuotingbing zuotingbing Jun 1, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, let me identify the cases between resolveURI and resolveURIs. what i meant is we should check assert(resolve(before) === after) also in test("resolveURI")

@zuotingbing zuotingbing changed the title Lack of the most important case about the test of resolveURI in UtilsSuite, and add it as needed. Lack of an important case about the test of resolveURI in UtilsSuite, and add it as needed. Jun 1, 2017
@zuotingbing zuotingbing changed the title Lack of an important case about the test of resolveURI in UtilsSuite, and add it as needed. [SPARK-20936][CORE]Lack of an important case about the test of resolveURI in UtilsSuite, and add it as needed. Jun 1, 2017
zuotingbing added 2 commits June 1, 2017 14:44
…r) === after)] and [assert(resolve(after) === after)] duplicate each other,delete one.

2. little fixs make the suit clear.
@SparkQA
Copy link

SparkQA commented Jun 1, 2017

Test build #3771 has finished for PR 18158 at commit 9455fb2.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the change is OK @HyukjinKwon -- we do want to check that before resolves to after and this case seems missed in this fixture. Or do I miss something? The rest of the change is just for consistency

Copy link
Member

@HyukjinKwon HyukjinKwon Jun 2, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for asking me. The initial change proposed looked testing several duplicated test cases and also changing existing test cases to me (I meant it looked changing what it tested before). I am fine with the current status.

@srowen
Copy link
Member

srowen commented Jun 3, 2017

Merged to master

@asfgit asfgit closed this in 887cf0e Jun 3, 2017
@zuotingbing zuotingbing deleted the spark-UtilsSuite branch June 8, 2017 02:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants