Chris Egerton created KAFKA-14244:
-------------------------------------

             Summary: Prevent unit/integration tests from terminating JVM
                 Key: KAFKA-14244
                 URL: https://issues.apache.org/jira/browse/KAFKA-14244
             Project: Kafka
          Issue Type: Improvement
          Components: unit tests
            Reporter: Chris Egerton
            Assignee: Chris Egerton


We've seen several cases of unit/integration tests invoking {{System::exit}} in 
the past, which terminates the CI build immediately and blocks us from 
collecting results for any not-yet-run tests.

In most cases, it's simple enough to use the appropriate wrapper class for 
calls to {{System::exit}} (which is available in both 
[Java|https://github.com/apache/kafka/blob/ff4c4d1365b189131a4f31b2dc49853f874c3ea5/clients/src/main/java/org/apache/kafka/common/utils/Exit.java]
 and 
[Scala|https://github.com/apache/kafka/blob/ff4c4d1365b189131a4f31b2dc49853f874c3ea5/core/src/main/scala/kafka/utils/Exit.scala]),
 but if the issue cannot be reproduced locally and instead only occurs during 
CI builds, it becomes difficult to identify exactly which test is causing the 
JVM to terminate.

In addition, there are some cases where, even though care is taken to use the 
correct wrapper class during testing, threads that are leaked during the test 
end up attempting to terminate the JVM after the wrapper class has been reset, 
which causes those attempts to actually succeed. See KAFKA-14242 for an example 
of one such test.

We can explore one or more of these potential improvements:
 * Always prevent calls to {{System::exit}} from succeeding during tests, both 
locally and in CI
 * Attempt to report which tests are responsible for invoking {{System::exit}} 
directly, so that they can be patched
 * Fail the build when {{System::exit}} is invoked by a test, in order to 
surface the issue (which can be either be indicative of poor testing logic, or 
a genuine bug) during CI builds



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to