TestKit and Worker API - ST when debug is enabled

Hi everyone. I have recently improved my plugin to take advantage of the new Worker API. I’ve noticed, however, that my TestKit tests produce a disturbing (albeit harmless) stack trace when GradleRunner#withDebug(true) is used. The task being tested uses the PROCESS IsolationMode, and that does not appear to shutdown cleanly when the test is run this way.

I have tried to create a very simple plugin project to illustrate the issue. Please download the attachment, or clone/fork my repo: https://github.com/DPUkyle/gradle-worker-poc

To recreate the problem, just run gradlew clean test. To prevent the ST from appearing, navigate to com/kylemoore/dummy/DummyPluginIntegrationTest.groovy, comment line 45 and rerun. No more ST!

While this is harmless, I did spend a lot of time debugging my own libraries and plugin to figure out why the spawned Daemon Worker Client was not shutting down. Am I doing something wrong? If nothing else, I hope other plugin authors see this post and don’t spend unnecessary amounts of time fretting over the issue.

Thanks in advance,

Kyle

For sake of completeness, here is the ST from Gradle 4.4.1:

org.gradle.process.internal.ExecException: Process 'Gradle Worker Daemon 1' finished with non-zero exit value 143
        at org.gradle.process.internal.DefaultExecHandle$ExecResultImpl.assertNormalExitValue(DefaultExecHandle.java:382)
        at org.gradle.process.internal.worker.DefaultWorkerProcess.waitForStop(DefaultWorkerProcess.java:190)
        at org.gradle.process.internal.worker.DefaultWorkerProcessBuilder$MemoryRequestingWorkerProcess.waitForStop(DefaultWorkerProcessBuilder.java:228)
        at org.gradle.process.internal.worker.DefaultMultiRequestWorkerProcessBuilder$1.invoke(DefaultMultiRequestWorkerProcessBuilder.java:144)
        at com.sun.proxy.$Proxy58.stop(Unknown Source)
        at org.gradle.workers.internal.WorkerDaemonClient.stop(WorkerDaemonClient.java:61)
        at org.gradle.internal.concurrent.CompositeStoppable.stop(CompositeStoppable.java:98)
        at org.gradle.workers.internal.WorkerDaemonClientsManager.stopWorkers(WorkerDaemonClientsManager.java:139)
        at org.gradle.workers.internal.WorkerDaemonClientsManager.stop(WorkerDaemonClientsManager.java:108)
        at org.gradle.internal.concurrent.CompositeStoppable.stop(CompositeStoppable.java:98)
        at org.gradle.internal.service.DefaultServiceRegistry$ManagedObjectProvider.stop(DefaultServiceRegistry.java:592)
        at org.gradle.internal.concurrent.CompositeStoppable.stop(CompositeStoppable.java:98)
        at org.gradle.internal.service.DefaultServiceRegistry$ManagedObjectProvider.stop(DefaultServiceRegistry.java:592)
        at org.gradle.internal.concurrent.CompositeStoppable.stop(CompositeStoppable.java:98)
        at org.gradle.internal.service.DefaultServiceRegistry$ManagedObjectProvider.stop(DefaultServiceRegistry.java:592)
        at org.gradle.internal.concurrent.CompositeStoppable.stop(CompositeStoppable.java:98)
        at org.gradle.internal.service.DefaultServiceRegistry$OwnServices.stop(DefaultServiceRegistry.java:518)
        at org.gradle.internal.service.DefaultServiceRegistry$CachingProvider.stop(DefaultServiceRegistry.java:1017)
        at org.gradle.internal.concurrent.CompositeStoppable.stop(CompositeStoppable.java:98)
        at org.gradle.internal.service.DefaultServiceRegistry$CompositeProvider.stop(DefaultServiceRegistry.java:1078)
        at org.gradle.internal.concurrent.CompositeStoppable.stop(CompositeStoppable.java:98)
        at org.gradle.internal.service.DefaultServiceRegistry.close(DefaultServiceRegistry.java:265)
        at org.gradle.internal.concurrent.CompositeStoppable$2.stop(CompositeStoppable.java:83)
        at org.gradle.internal.concurrent.CompositeStoppable.stop(CompositeStoppable.java:98)
        at org.gradle.internal.service.scopes.DefaultGradleUserHomeScopeServiceRegistry.close(DefaultGradleUserHomeScopeServiceRegistry.java:62)
        at org.gradle.internal.concurrent.CompositeStoppable$2.stop(CompositeStoppable.java:83)
        at org.gradle.internal.concurrent.CompositeStoppable.stop(CompositeStoppable.java:98)
        at org.gradle.internal.service.DefaultServiceRegistry$ManagedObjectProvider.stop(DefaultServiceRegistry.java:592)
        at org.gradle.internal.concurrent.CompositeStoppable.stop(CompositeStoppable.java:98)
        at org.gradle.internal.service.DefaultServiceRegistry$OwnServices.stop(DefaultServiceRegistry.java:518)
        at org.gradle.internal.service.DefaultServiceRegistry$CachingProvider.stop(DefaultServiceRegistry.java:1017)
        at org.gradle.internal.concurrent.CompositeStoppable.stop(CompositeStoppable.java:98)
        at org.gradle.internal.service.DefaultServiceRegistry$CompositeProvider.stop(DefaultServiceRegistry.java:1078)
        at org.gradle.internal.concurrent.CompositeStoppable.stop(CompositeStoppable.java:98)
        at org.gradle.internal.service.DefaultServiceRegistry.close(DefaultServiceRegistry.java:265)
        at org.gradle.internal.concurrent.CompositeStoppable$2.stop(CompositeStoppable.java:83)
        at org.gradle.internal.concurrent.CompositeStoppable.stop(CompositeStoppable.java:98)
        at org.gradle.tooling.internal.provider.DefaultConnection.shutdown(DefaultConnection.java:154)
        at org.gradle.tooling.internal.consumer.connection.ShutdownAwareConsumerConnection.stop(ShutdownAwareConsumerConnection.java:35)
        at org.gradle.tooling.internal.consumer.connection.ParameterValidatingConsumerConnection.stop(ParameterValidatingConsumerConnection.java:35)
        at org.gradle.internal.concurrent.CompositeStoppable.stop(CompositeStoppable.java:98)
        at org.gradle.tooling.internal.consumer.loader.CachingToolingImplementationLoader.close(CachingToolingImplementationLoader.java:53)
        at org.gradle.internal.concurrent.CompositeStoppable$2.stop(CompositeStoppable.java:83)
        at org.gradle.internal.concurrent.CompositeStoppable.stop(CompositeStoppable.java:98)
        at org.gradle.tooling.internal.consumer.loader.SynchronizedToolingImplementationLoader.close(SynchronizedToolingImplementationLoader.java:63)
        at org.gradle.internal.concurrent.CompositeStoppable$2.stop(CompositeStoppable.java:83)
        at org.gradle.internal.concurrent.CompositeStoppable.stop(CompositeStoppable.java:98)
        at org.gradle.internal.service.DefaultServiceRegistry$ManagedObjectProvider.stop(DefaultServiceRegistry.java:592)
        at org.gradle.internal.concurrent.CompositeStoppable.stop(CompositeStoppable.java:98)
        at org.gradle.internal.service.DefaultServiceRegistry$OwnServices.stop(DefaultServiceRegistry.java:518)
        at org.gradle.internal.service.DefaultServiceRegistry$CachingProvider.stop(DefaultServiceRegistry.java:1017)
        at org.gradle.internal.concurrent.CompositeStoppable.stop(CompositeStoppable.java:98)
        at org.gradle.internal.service.DefaultServiceRegistry.close(DefaultServiceRegistry.java:265)
        at org.gradle.tooling.internal.consumer.ConnectorServices.close(ConnectorServices.java:49)
        at org.gradle.tooling.internal.consumer.DefaultGradleConnector.close(DefaultGradleConnector.java:57)
        at org.gradle.testkit.runner.internal.ToolingApiGradleExecutor$1.run(ToolingApiGradleExecutor.java:75)
        at java.lang.Thread.run(Thread.java:748)

Thanks for reporting! After some investigation, it’s due to some incorrect configuration when forking a new process when withDebug(true). A short-term process should be forked instead of a long-live process. Therefore we have to force kill it when the build finishes. That’s why we got a 143 (SIGTERM). This won’t affect your tests except for some annoying stacktrace. You can ignore it on your side. We’ll fix it soon.

I’ve created https://github.com/gradle/gradle/issues/4201 to track it.

1 Like