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

Running example locally via gradle task gives error #25

Closed j-shiels closed 6 years ago

j-shiels commented 6 years ago

getting the below error when executing the gradle tasks in the example:

Unexpected exception thrown.
org.gradle.internal.remote.internal.MessageIOException: Could not write '/127.0.0.1:58542'.
    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:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
    at java.lang.Thread.run(Thread.java:745)
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(SocketConnection.java:272)
    at org.gradle.internal.remote.internal.inet.SocketConnection$SocketOutputStream.writeBufferToChannel(SocketConnection.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

It runs fine using the junit runner within an IDE without any issue, so the issue does seem to be in the gradle execution of this.

have you seen this issue?

prashant-ramcharan commented 6 years ago
  1. What version of Gradle are you using?
  2. Are you using the Gradle wrapper (i.e. gradlew) or the system installed Gradle?
  3. What OS are you running?
j-shiels commented 6 years ago
  1. Gradle 4.1
  2. Gradle Wrapper
  3. Windows

should also note, the tests themselves in the example seem to run (although this is not the case with my own implementation in my projects - came back to the example to test a default implementation) but the last test hangs for longer than the others and then I get the error

Testing started at 17:35 ...
17:35:06: Executing external task 'runScenarios'...
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:compileTestJava
:processTestResources
:testClasses
:runScenarios
Starting ChromeDriver 2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f) on port 31264
Only local connections are allowed.
Starting ChromeDriver 2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f) on port 8575
Only local connections are allowed.
Starting ChromeDriver 2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f) on port 32845
Only local connections are allowed.
Starting ChromeDriver 2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f) on port 21225
Only local connections are allowed.
Starting ChromeDriver 2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f) on port 20975
Only local connections are allowed.
Feb 05, 2018 5:35:21 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
Feb 05, 2018 5:35:21 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
Feb 05, 2018 5:35:22 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
Feb 05, 2018 5:35:22 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
Feb 05, 2018 5:35:22 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
1 Scenarios (1 passed)
2 Steps (2 passed)
0m17.356s
1 Scenarios (1 passed)
2 Steps (2 passed)
0m17.302s
1 Scenarios (1 passed)
2 Steps (2 passed)
0m17.372s
1 Scenarios (1 passed)
2 Steps (2 passed)
0m17.328s
1 Scenarios (1 passed)
2 Steps (2 passed)
0m46.742s
Unexpected exception thrown.
org.gradle.internal.remote.internal.MessageIOException: Could not write '/127.0.0.1:60778'.
    at org.gradle.internal.remote.internal.inet.SocketConnection.flush(SocketConnection.java:121)
    at org.gradle.internal.remote.internal.hub.MessageHub$ConnectionDispatch.run(MessageHub.java:300)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
    at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
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(SocketConnection.java:259)
    at org.gradle.internal.remote.internal.inet.SocketConnection$SocketOutputStream.writeBufferToChannel(SocketConnection.java:247)
    at org.gradle.internal.remote.internal.inet.SocketConnection$SocketOutputStream.flush(SocketConnection.java:241)
    at org.gradle.internal.remote.internal.inet.SocketConnection.flush(SocketConnection.java:119)
    ... 6 more
BUILD SUCCESSFUL
Total time: 53.231 secs
17:36:00: External task execution finished 'runScenarios'.
prashant-ramcharan commented 6 years ago

This is related to this issue GRADLE-2759

Courgette-JVM has to call System.exit() to mark the build as successful or failed. For some reason, on Windows, Gradle throws this exception. This does not happen on Ubuntu / Mac OS systems.

The Gradle error itself will not cause the build to fail.

Although this exception is displayed, your CI build tool (i.e. Jenkins / Team City) will not fail the build based on this exception.

Did you say your tests don't run with your implementation -- meaning it doesn't run any test at all?

prashant-ramcharan commented 6 years ago

On further reflection, throwing an exception would give an unclear message when calling the runner from Gradle or JUnit.

The default parent runner would throw an initializationError which in this case isn't reflective of what actually happened.

Because Cucumber and JUnit runs one feature at a time it has access to the run notifier which updates the result of the feature. Courgette, however does not have access to the run notifier from separate threads, so we have to rely on using System.exit() to set the status once all tests are completed.

Courgette-JVM uses JUnit as the entry point for running multi-threaded instances of the Cucumber CLI. The Cucumber CLI calls System.exit() to return the state of the test run. This is no different to Courgette.

Having said all that, your tests should still run fine even though the Gradle exception is raised. Courgette only calls System.exit(status) when all tests / threads are complete and after that point, your build will still show as "BUILD SUCCESSFUL" or "BUILD FAILED"

Please confirm whether your tests are running at all? If not, kindly share the steps to reproduce.

prashant-ramcharan commented 6 years ago

Closing as no further response.