diff --git a/fireflies/src/test/java/com/salesforce/apollo/fireflies/ChurnTest.java b/fireflies/src/test/java/com/salesforce/apollo/fireflies/ChurnTest.java index 9825e45f6..fab24a1bd 100644 --- a/fireflies/src/test/java/com/salesforce/apollo/fireflies/ChurnTest.java +++ b/fireflies/src/test/java/com/salesforce/apollo/fireflies/ChurnTest.java @@ -29,6 +29,7 @@ import java.time.Duration; import java.util.*; import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ExecutorService; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; @@ -52,6 +53,7 @@ public class ChurnTest { private MetricRegistry node0Registry; private MetricRegistry registry; private List views; + private ExecutorService executor; @BeforeAll public static void beforeClass() throws Exception { @@ -79,6 +81,9 @@ public void after() { gateways.forEach(e -> e.close(Duration.ofSeconds(0))); gateways.clear(); + if (executor != null) { + executor.shutdown(); + } } @Test @@ -260,6 +265,7 @@ public void churn() throws Exception { } private void initialize() { + executor = UnsafeExecutors.newVirtualThreadPerTaskExecutor(); var parameters = Parameters.newBuilder().setMaximumTxfr(20).build(); registry = new MetricRegistry(); node0Registry = new MetricRegistry(); @@ -282,14 +288,15 @@ private void initialize() { .setMetrics( new ServerConnectionCacheMetricsImpl( frist.getAndSet(false) ? node0Registry - : registry))); + : registry)), + executor); var gateway = new LocalServer(gatewayPrefix, node).router(ServerConnectionCache.newBuilder() .setTarget(200) .setMetrics( new ServerConnectionCacheMetricsImpl( frist.getAndSet(false) - ? node0Registry - : registry))); + ? node0Registry : registry)), + executor); comms.start(); communications.add(comms); diff --git a/fireflies/src/test/java/com/salesforce/apollo/fireflies/SwarmTest.java b/fireflies/src/test/java/com/salesforce/apollo/fireflies/SwarmTest.java index 0e4f93dc6..632cc0613 100644 --- a/fireflies/src/test/java/com/salesforce/apollo/fireflies/SwarmTest.java +++ b/fireflies/src/test/java/com/salesforce/apollo/fireflies/SwarmTest.java @@ -29,6 +29,7 @@ import java.time.Duration; import java.util.*; import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ExecutorService; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; @@ -62,6 +63,7 @@ public class SwarmTest { private MetricRegistry node0Registry; private MetricRegistry registry; private List views; + private ExecutorService executor; @BeforeAll public static void beforeClass() throws Exception { @@ -89,6 +91,9 @@ public void after() { gateways.forEach(e -> e.close(Duration.ofSeconds(1))); gateways.clear(); + if (executor != null) { + executor.shutdown(); + } } @Test @@ -204,6 +209,7 @@ public void swarm() throws Exception { } private void initialize() { + executor = UnsafeExecutors.newVirtualThreadPerTaskExecutor(); var parameters = Parameters.newBuilder() .setMaxPending(50) .setMaximumTxfr(20) @@ -235,14 +241,15 @@ private void initialize() { .setMetrics( new ServerConnectionCacheMetricsImpl( frist.getAndSet(false) ? node0Registry - : registry))); + : registry)), + executor); var gateway = new LocalServer(gatewayPrefix, node).router(ServerConnectionCache.newBuilder() .setTarget(200) .setMetrics( new ServerConnectionCacheMetricsImpl( frist.getAndSet(false) - ? node0Registry - : registry))); + ? node0Registry : registry)), + executor); comms.start(); communications.add(comms);