From d6cfd320008cfac7e15652485b772786f4627acd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Kohlschu=CC=88tter?= Date: Wed, 11 Sep 2024 19:00:24 +0200 Subject: [PATCH] test: common: Fix MassiveParallelTest to not fail under slow emulation Thisi test occassionally failed on qemu emulating Alpine Linux loongarch64. Reduce the number of connect calls, and stop the server after shutting down the threads repsonsible for accumulating requests. --- .../newsclub/net/unix/domain/MassiveParallelTest.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/junixsocket-common/src/test/java/org/newsclub/net/unix/domain/MassiveParallelTest.java b/junixsocket-common/src/test/java/org/newsclub/net/unix/domain/MassiveParallelTest.java index 800302da5..3fd330319 100644 --- a/junixsocket-common/src/test/java/org/newsclub/net/unix/domain/MassiveParallelTest.java +++ b/junixsocket-common/src/test/java/org/newsclub/net/unix/domain/MassiveParallelTest.java @@ -51,6 +51,7 @@ import com.kohlschutter.annotations.compiletime.SuppressFBWarnings; import com.kohlschutter.testutil.TestAbortedNotAnIssueException; +import com.kohlschutter.util.SystemPropertyUtil; @AFSocketCapabilityRequirement(AFSocketCapability.CAPABILITY_UNIX_DOMAIN) @SuppressWarnings({ @@ -72,9 +73,15 @@ public void testAcceptConnect() throws Exception { } // number of connections to perform // final int numConnections = 1_000; - final int numConnections = 10_000; + // final int numConnections = 10_000; // final int numConnections = 100_000; // final int numConnections = 1_000_000; + final int numConnections = SystemPropertyUtil.getIntSystemProperty( + "selftest.MassiveParallelTest.numConnections", 1000); + if (numConnections <= 0) { + throw new TestAbortedNotAnIssueException("Skipping test due to numConnections=" + + numConnections); + } // limit the number of concurrently active servers/clients // so we don't run out of file descriptors (the limit could be as low as 256) @@ -164,7 +171,6 @@ public void run() { } boolean stopped = server.cl.await(10, TimeUnit.SECONDS); - server.stop(); if (!stopped) { List remainingClients = esClients.shutdownNow(); List remainingServers = server.esServers.shutdownNow(); @@ -174,6 +180,7 @@ public void run() { + remainingClients.size()); } } + server.stop(); long elapsed = (System.currentTimeMillis() - startTime); int completed = server.completed.intValue();