prashant-ramcharan / courgette-jvm

Multiprocess | Parallel Cucumber-JVM | Parallelize your Java Cucumber tests on a feature level or on a scenario level.
MIT License
132 stars 38 forks source link

Gradle MessageIOException and build failure #64

Closed rselias closed 6 years ago

rselias commented 6 years ago

Because Maven Surefire isn't compatible with libraries that call System.exit(), I'm switching my project from Maven to Gradle, but I'm still having difficulty running Courgette. I can run Cucumber runners normally with Gradle, so it isn't the Gradle installation. To make sure it wasn't an issue with my project, I cloned your example project. If I go into that directory and run gradle runScenariosUsingJUnit, the test runs and at the end throws the following exception.

The build also fails after the exception, and seems to be indicating it's due to Courgette's use of System.exit(1) when not every scenario passes. If I remove the example scenario that is meant to fail, the exception is still thrown but the build does not fail.

I am running Gradle 4.8.1 on Windows 8.1

gradle : Unexpected exception thrown.
At line:1 char:1
+ gradle runScenariosUsingJUnit 2>&1 > log.txt
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (Unexpected exception thrown.:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

org.gradle.internal.remote.internal.MessageIOException: Could not write '/127.0.0.1:60069'.

    at org.gradle.internal.remote.internal.inet.SocketConnection.flush(SocketConnection.java:134)

    at org.gradle.internal.remote.internal.hub.MessageHub$ConnectionDispatch.run(MessageHub.java:325)

    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)

    at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)

    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)

    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)

    at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)

    at java.lang.Thread.run(Thread.java:748)

Caused by: java.io.IOException: An existing connection was forcibly closed by the remote host

    at sun.nio.ch.SocketDispatcher.write0(Native Method)

    at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:51)

    at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93)

    at sun.nio.ch.IOUtil.write(IOUtil.java:51)

    at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:471)

    at org.gradle.internal.remote.internal.inet.SocketConnection$SocketOutputStream.writeWithNonBlockingRetry(SocketCon
nection.java:272)

    at org.gradle.internal.remote.internal.inet.SocketConnection$SocketOutputStream.writeBufferToChannel(SocketConnecti
on.java:260)

    at org.gradle.internal.remote.internal.inet.SocketConnection$SocketOutputStream.flush(SocketConnection.java:254)

    at org.gradle.internal.remote.internal.inet.SocketConnection.flush(SocketConnection.java:132)

    ... 7 more

> Task :runScenariosUsingJUnit FAILED

FAILURE: 
Build failed with an exception.

* What went wrong:

Execution failed for task ':runScenariosUsingJUnit'.

> 
Process 'Gradle Test Executor 6' finished with non-zero exit value 1

  This problem might be caused by incorrect test process configuration.

  Please refer to the test execution section in the user guide at 
https://docs.gradle.org/4.8.1/userguide/java_plugin.html#sec:test_execution

* 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

BUILD FAILED
 in 33s

3 actionable tasks: 1 executed, 2 up-to-date
prashant-ramcharan commented 6 years ago

Hi @rselias, this is a known issue with Gradle and Windows OS and it is indeed related to System.exit()

This Gradle exception will not cause Courgette to fail and will not mark the build as a failure unless there was an actual test failure.

This Gradle exception will simply be written to the console and will not have any impact on the overall build result - whether running locally or in a CI tool.

prashant-ramcharan commented 6 years ago

Because the Junit run notifier is not updated, Courgette has to use System.exit() to set the build result.

But as previously mentioned, the thrown Gradle exception will not influence the Courgette build result.

prashant-ramcharan commented 6 years ago

Although this is a limitation on Gradle and Windows OS, it will not affect the way Courgette-JVM runs or reports.

I will however add this as a note in the known issues section of the README.

prashant-ramcharan commented 6 years ago

Will add a workaround to this message even though it's an issue with Windows and Gradle and not Courgette directly.

prashant-ramcharan commented 6 years ago

The Gradle MessageIOException will no longer appear at the end of the test run.

This is now released in version 2.4.2