From 18a5f8a90bb9b79daaceb6871c55efdc306a3ead Mon Sep 17 00:00:00 2001 From: Terry Wilson Date: Wed, 25 Oct 2023 14:19:32 -0700 Subject: [PATCH] interop-testing: Stress test log for total calls (#10626) Allows stress tests to make assertions based on the total amount of calls made by the stress test client. --- .../io/grpc/testing/integration/StressTestClient.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/interop-testing/src/main/java/io/grpc/testing/integration/StressTestClient.java b/interop-testing/src/main/java/io/grpc/testing/integration/StressTestClient.java index 8f2c734917..f09ee5aa56 100644 --- a/interop-testing/src/main/java/io/grpc/testing/integration/StressTestClient.java +++ b/interop-testing/src/main/java/io/grpc/testing/integration/StressTestClient.java @@ -59,6 +59,7 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.atomic.AtomicLong; import java.util.logging.Level; import java.util.logging.Logger; @@ -91,6 +92,7 @@ public class StressTestClient { client.runStressTest(); client.startMetricsLogging(); client.blockUntilStressTestComplete(); + log.log(Level.INFO, "Total calls made: {0}", client.getTotalCallCount()); } catch (Exception e) { log.log(Level.WARNING, "The stress test client encountered an error!", e); } finally { @@ -117,6 +119,7 @@ public class StressTestClient { private Server metricsServer; private final Map gauges = new ConcurrentHashMap<>(); + private final AtomicLong totalCallCount = new AtomicLong(0); private volatile boolean shutdown; @@ -410,6 +413,10 @@ public class StressTestClient { return builder.build(); } + private long getTotalCallCount() { + return totalCallCount.get(); + } + private static String serverAddressesToString(List addresses) { List tmp = new ArrayList<>(); for (InetSocketAddress address : addresses) { @@ -485,6 +492,7 @@ public class StressTestClient { } testCasesSinceLastMetricsCollection++; + totalCallCount.incrementAndGet(); double durationSecs = computeDurationSecs(lastMetricsCollectionTime); if (durationSecs >= METRICS_COLLECTION_INTERVAL_SECS) {