Knotx / knotx-junit5

JUnit 5 support and extensions for Vert.x projects
https://knotx.io
Apache License 2.0
0 stars 4 forks source link

Tests not pass on Windows WSL (Ubuntu) #31

Closed tomaszmichalak closed 5 years ago

tomaszmichalak commented 5 years ago

Describe the bug Tests fails with NoSuchElementException when run gradlew build on WSL. It looks that there is a problem with ports allocation. Full execution log:

***************************************
* Building [knotx-junit5] using gradle with deploy []
***************************************
To honour the JVM settings for this build a new JVM will be forked. Please consider using the daemon: https://docs.gradle.org/5.4.1/userguide/gradle_daemon.html.
Daemon will be stopped at the end of the build stopping after processing

> Configure project :
Connecting with user: tomasz.michalak

> Task :test

io.knotx.junit5.KnotxExtensionTest > callServerWithRandomPortFromRandomSection(Vertx, Integer) FAILED
    org.junit.jupiter.api.extension.ParameterResolutionException
        Caused by: java.util.NoSuchElementException

7 tests completed, 1 failed, 6 skipped

> Task :test FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':test'.
> There were failing tests. See the report at: file:///home/tmichalak/knotx/knotx-junit5/build/reports/tests/test/index.html

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.4.1/userguide/command_line_interface.html#sec:command_line_warnings

To Reproduce Steps to reproduce the behavior:

  1. Go to knotx-aggregator/development
  2. Run ./pull-all.sh -r {KNOTX_HOME_DIR} -b master -f
  3. Run ./pull-all.sh -r {KNOTX_HOME_DIR} -b master -f

or simply:

  1. git clone git@github.com:Knotx/knotx-junit5.git
  2. ./gradlew build

Expected behavior Tests passses.

tMaxx commented 5 years ago

Could you please attach the output of ./gradlew --version?

tMaxx commented 5 years ago

Mystery more-less solved. Behavior seen here and in #32 is a byproduct of how free ports are currently being discovered/assigned.

Free port discovery is done through a third-party library (FreePortFinder), which does it in a pretty weird way, but it makes sure the port is available with 100% certainty. But on WSL it has the tendency to crash JVM, as WSL is not a standard Linux environment. Fix would need to implement part of the functionality of this library (currently in progress).