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.
This commit is contained in:
Terry Wilson 2023-10-25 14:19:32 -07:00 committed by GitHub
parent 86835ae817
commit 18a5f8a90b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 0 deletions

View File

@ -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<String, Metrics.GaugeResponse> 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<InetSocketAddress> addresses) {
List<String> 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) {