Skip to content

Commit 18a5f8a

Browse files
authored
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.
1 parent 86835ae commit 18a5f8a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

interop-testing/src/main/java/io/grpc/testing/integration/StressTestClient.java

+8
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
import java.util.concurrent.ConcurrentHashMap;
6060
import java.util.concurrent.Executors;
6161
import java.util.concurrent.ScheduledExecutorService;
62+
import java.util.concurrent.atomic.AtomicLong;
6263
import java.util.logging.Level;
6364
import java.util.logging.Logger;
6465

@@ -91,6 +92,7 @@ public void run() {
9192
client.runStressTest();
9293
client.startMetricsLogging();
9394
client.blockUntilStressTestComplete();
95+
log.log(Level.INFO, "Total calls made: {0}", client.getTotalCallCount());
9496
} catch (Exception e) {
9597
log.log(Level.WARNING, "The stress test client encountered an error!", e);
9698
} finally {
@@ -117,6 +119,7 @@ public void run() {
117119
private Server metricsServer;
118120
private final Map<String, Metrics.GaugeResponse> gauges =
119121
new ConcurrentHashMap<>();
122+
private final AtomicLong totalCallCount = new AtomicLong(0);
120123

121124
private volatile boolean shutdown;
122125

@@ -410,6 +413,10 @@ private ManagedChannel createChannel(InetSocketAddress address) {
410413
return builder.build();
411414
}
412415

416+
private long getTotalCallCount() {
417+
return totalCallCount.get();
418+
}
419+
413420
private static String serverAddressesToString(List<InetSocketAddress> addresses) {
414421
List<String> tmp = new ArrayList<>();
415422
for (InetSocketAddress address : addresses) {
@@ -485,6 +492,7 @@ public void run() {
485492
}
486493

487494
testCasesSinceLastMetricsCollection++;
495+
totalCallCount.incrementAndGet();
488496

489497
double durationSecs = computeDurationSecs(lastMetricsCollectionTime);
490498
if (durationSecs >= METRICS_COLLECTION_INTERVAL_SECS) {

0 commit comments

Comments
 (0)