Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MINOR][TESTS] Replace JVM assert with JUnit Assert in tests #26581

Closed
wants to merge 2 commits into from

Conversation

srowen
Copy link
Member

@srowen srowen commented Nov 18, 2019

What changes were proposed in this pull request?

Use JUnit assertions in tests uniformly, not JVM assert() statements.

Why are the changes needed?

assert() statements do not produce as useful errors when they fail, and, if they were somehow disabled, would fail to test anything.

Does this PR introduce any user-facing change?

No. The assertion logic should be identical.

How was this patch tested?

Existing tests.

@dongjoon-hyun
Copy link
Member

Is this all? It seems that we have more instances.

@srowen
Copy link
Member Author

srowen commented Nov 18, 2019

That's all IntelliJ found in the Java test code. There may be some in non-test code, but some are possibly legitimate. There are, I think, cases where assert() is used for argument checking in non-test code and that's not really what it's for, but a separate thing.

Yeah there are some in Scala tests too, I'll fix those. They're not obvious as scalatest uses assert() too, but we can look for use of scala.Predef.assert()

@SparkQA
Copy link

SparkQA commented Nov 18, 2019

Test build #114032 has finished for PR 26581 at commit e0c572b.

  • This patch fails to build.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Nov 18, 2019

Test build #114027 has finished for PR 26581 at commit 2219d2e.

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

@srowen
Copy link
Member Author

srowen commented Nov 18, 2019

(PS to be clear the latest test failed; its result just came first. I'll investigate)

@dongjoon-hyun
Copy link
Member

It seems that both Jenkins/GitHubAction fails due to scala.reflect.macros.TypecheckException: not found: value assertionsHelper.

[error] /home/jenkins/workspace/SparkPullRequestBuilder/core/src/test/scala/org/apache/spark/executor/ExecutorSuite.scala:570: exception during macro expansion: 
[error] scala.reflect.macros.TypecheckException: not found: value assertionsHelper
[error] 	at scala.reflect.macros.contexts.Typers.$anonfun$typecheck$3(Typers.scala:44)
[error] 	at scala.reflect.macros.contexts.Typers.$anonfun$typecheck$2(Typers.scala:38)
[error] 	at scala.reflect.macros.contexts.Typers.doTypecheck$1(Typers.scala:37)
[error] 	at scala.reflect.macros.contexts.Typers.$anonfun$typecheck$7(Typers.scala:50)
[error] 	at scala.reflect.internal.Trees.wrappingIntoTerm(Trees.scala:1756)
[error] 	at scala.reflect.internal.Trees.wrappingIntoTerm$(Trees.scala:1753)
[error] 	at scala.reflect.internal.SymbolTable.wrappingIntoTerm(SymbolTable.scala:28)
[error] 	at scala.reflect.macros.contexts.Typers.typecheck(Typers.scala:50)
[error] 	at scala.reflect.macros.contexts.Typers.typecheck$(Typers.scala:32)
[error] 	at scala.reflect.macros.contexts.Context.typecheck(Context.scala:18)
[error] 	at scala.reflect.macros.contexts.Context.typecheck(Context.scala:18)
[error] 	at scala.reflect.macros.Typers.typeCheck(Typers.scala:70)
[error] 	at scala.reflect.macros.Typers.typeCheck$(Typers.scala:69)
[error] 	at scala.reflect.macros.contexts.Context.typeCheck(Context.scala:18)
[error] 	at org.scalactic.MacroOwnerRepair.repairOwners(MacroOwnerRepair.scala:35)
[error] 	at org.scalactic.BooleanMacro.genMacro(BooleanMacro.scala:837)
[error] 	at org.scalatest.AssertionsMacro$.assert(AssertionsMacro.scala:34)
[error] 	at sun.reflect.GeneratedMethodAccessor19.invoke(Unknown Source)
[error] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[error] 	at java.lang.reflect.Method.invoke(Method.java:498)
[error] 	at scala.reflect.macros.runtime.JavaReflectionRuntimes$JavaReflectionResolvers.$anonfun$resolveJavaReflectionRuntime$6(JavaReflectionRuntimes.scala:51)
[error] 	at scala.tools.nsc.typechecker.Macros.macroExpandWithRuntime(Macros.scala:824)
[error]           Assertions.assert(TaskContext.get().asInstanceOf[TaskContextImpl].fetchFailed.isDefined)
[error]                            ^

@SparkQA
Copy link

SparkQA commented Nov 19, 2019

Test build #114040 has finished for PR 26581 at commit 90fd917.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@HyukjinKwon
Copy link
Member

retest this please

@SparkQA
Copy link

SparkQA commented Nov 19, 2019

Test build #114056 has finished for PR 26581 at commit 90fd917.

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

@srowen
Copy link
Member Author

srowen commented Nov 20, 2019

PS @dongjoon-hyun is this failure 'normal'?

https://github.com/apache/spark/runs/311900764

gzip: stdin: unexpected end of file
tar: Child returned status 1
tar: Error is not recoverable: exiting now
Using `mvn` from path: /home/runner/work/spark/spark/build/apache-maven-3.6.2/bin/mvn
./build/mvn: line 172: /home/runner/work/spark/spark/build/apache-maven-3.6.2/bin/mvn: No such file or directory

Just can't download maven?

@SparkQA
Copy link

SparkQA commented Nov 20, 2019

Test build #114167 has finished for PR 26581 at commit a5b6e9e.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@dongjoon-hyun
Copy link
Member

dongjoon-hyun commented Nov 20, 2019

Yes. It's a normal Maven Download failure. I'll try to cache the maven directory, too. Thanks!

@SparkQA
Copy link

SparkQA commented Nov 20, 2019

Test build #114174 has finished for PR 26581 at commit a599dd6.

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

@srowen srowen closed this in 1febd37 Nov 20, 2019
@srowen
Copy link
Member Author

srowen commented Nov 20, 2019

Merged to master

@srowen srowen deleted the assertToJUnit branch November 24, 2019 23:24
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