sofastack / sofa-boot

SOFABoot is a framework that enhances Spring Boot and fully compatible with it, provides readiness check, class isolation, etc.
https://www.sofastack.tech/sofa-boot/docs/Home
Apache License 2.0
4.95k stars 1.26k forks source link

Flaky test fix hangs test suite #1123

Closed msalman-abid closed 1 year ago

msalman-abid commented 1 year ago

Describe the bug

Flaky test com.alipay.sofa.common.boot.logging.test.DefaultLevelTest#testDefaultLevel reported by the UIUC tool nondex. The particular testcase crashes due to multiple instances of the testcase fork trying to write to the same stream (as far as I understand):

Command: mvn edu.illinois:nondex-maven-plugin:2.1.1:nondex -pl sofa-boot-project/sofa-boot-starters/log-sofa-boot-starter -DnondexRuns=10 -Dtest=com.alipay.sofa.common.boot.logging.test.DefaultLevelTest#testDefaultLevel

Output:

Corrupted STDOUT by directly writing to native stream in forked JVM 1. Stream 'Error occurred during initialization of VM'.
java.lang.IllegalArgumentException: Stream stdin corrupted. Expected comma after third character in command 'Error occurred during initialization of VM'.
    at org.apache.maven.plugin.surefire.booterclient.output.ForkClient$OperationalData.<init>(ForkClient.java:507)
    at org.apache.maven.plugin.surefire.booterclient.output.ForkClient.processLine(ForkClient.java:210)
    at org.apache.maven.plugin.surefire.booterclient.output.ForkClient.consumeLine(ForkClient.java:177)
    at org.apache.maven.plugin.surefire.booterclient.output.ThreadedStreamConsumer$Pumper.run(ThreadedStreamConsumer.java:88)

This is a known issue with the surefire plugin, mentioned in this StackOverflow thread.

As per the thread, I updated the plugin version to 3.0.0-M5, and all existing testcases pass for mvn test, but the original command for nondex hangs on the second test fork, with only the first one returning an output. Please advise.

To Reproduce

Steps to reproduce the behavior:

  1. Update version for the maven.surefire.plugin to '3.0.0-M5' from '2.22.2' in both occurences
  2. Add the <forkNode implementation="org.apache.maven.plugin.surefire.extensions.SurefireForkNodeFactory"/> line at line 436 in file .../sofa-boot/sofa-boot-project/sofa-boot-parent/pom.xml
  3. Clean and re-build project
  4. Run nondex command
  5. See error

Expected behavior

Testcase should always pass, and not exhibit flaky behavior. Concurrent testcases should not hang on a shared resource.

Screenshots

N/A

Environment:

Additional context

Add any other context about the problem here.