You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zookeeper.apache.org by dd...@apache.org on 2021/03/06 20:01:40 UTC
[zookeeper] 03/03: ZOOKEEPER-4199: Avoid thread leak in
QuorumRequestPipelineTest
This is an automated email from the ASF dual-hosted git repository.
ddiederen pushed a commit to branch branch-3.7
in repository https://gitbox.apache.org/repos/asf/zookeeper.git
commit 658a700c14f304319ad06462310b00ecbc89f392
Author: Damien Diederen <dd...@crosstwine.com>
AuthorDate: Thu Feb 18 08:40:55 2021 +0000
ZOOKEEPER-4199: Avoid thread leak in QuorumRequestPipelineTest
`QuorumRequestPipelineTest` hosts parameterized tests which explicitly call `QuorumBase.setUp(boolean)`.
This patch overrides the argument-less `QuorumBase.setUp()` with an empty body, as the former is annotated `BeforeEach`-otherwise causing the runtime to start a fresh 5-ensemble before each test.
Without the override, one such extraneous ensemble is created and immediately leaked for each combination of test method + parameters.
The test consequently requires 4000+ simultaneous threads to complete, and while Linux happily handles that load, macOS Catalina's per-process limit of 2048 threads effectively causes the JVM to "crash" or lock up.
The solution is copied verbatim from another parameterized subclass of `QuorumBase`, `EagerACLFilterTest`.
Author: Damien Diederen <dd...@crosstwine.com>
Reviewers: Enrico Olivelli <eo...@apache.org>, Mate Szalay-Beko <sy...@apache.org>
Closes #1591 from ztzg/ZOOKEEPER-4199-thread-leak-qrp-test
---
.../apache/zookeeper/server/quorum/QuorumRequestPipelineTest.java | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/zookeeper-server/src/test/java/org/apache/zookeeper/server/quorum/QuorumRequestPipelineTest.java b/zookeeper-server/src/test/java/org/apache/zookeeper/server/quorum/QuorumRequestPipelineTest.java
index 8a463c0..0888d6f 100644
--- a/zookeeper-server/src/test/java/org/apache/zookeeper/server/quorum/QuorumRequestPipelineTest.java
+++ b/zookeeper-server/src/test/java/org/apache/zookeeper/server/quorum/QuorumRequestPipelineTest.java
@@ -36,6 +36,7 @@ import org.apache.zookeeper.data.Stat;
import org.apache.zookeeper.server.quorum.QuorumPeer.ServerState;
import org.apache.zookeeper.test.QuorumBase;
import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
@@ -59,6 +60,13 @@ public class QuorumRequestPipelineTest extends QuorumBase {
Arguments.of(ServerState.OBSERVING));
}
+ @BeforeEach
+ @Override
+ public void setUp() {
+ //since parameterized test methods need a parameterized setUp method
+ //the inherited method has to be overridden with an empty function body
+ }
+
public void setUp(ServerState serverState) throws Exception {
CountdownWatcher clientWatch = new CountdownWatcher();
super.setUp(true);