From 6475ddff64bb897769a968479148460e7f09a801 Mon Sep 17 00:00:00 2001
From: Damien Diederen
Date: Thu, 4 Feb 2021 11:48:39 +0100
Subject: [PATCH] ZOOKEEPER-4199: Avoid thread leak in
QuorumRequestPipelineTest
`QuorumRequestPipelineTest` hosts parameterized tests which explicitly
calls `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`.
---
.../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 8a463c07b18..0888d6fb505 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.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 static Stream data() throws Exception {
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);