Bug 5580 - RestPerfClient: Invalid requests rate reported when a thread times out 95/36995/1
authorJakub Morvay <jmorvay@cisco.com>
Fri, 1 Apr 2016 08:57:25 +0000 (10:57 +0200)
committerJakub Morvay <jmorvay@cisco.com>
Fri, 1 Apr 2016 09:19:17 +0000 (11:19 +0200)
If some threads sending requests fail or time out, skip calculation of
requests per second value and do not log it.

Change-Id: Icec9cec729999d82671f47f383a6839aeaef6444
Signed-off-by: Jakub Morvay <jmorvay@cisco.com>
opendaylight/netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/client/http/perf/RestPerfClient.java

index 5f6f490afc02069bfef37e9f61ae75433f0efc15..6dc684780fdb4c8b4d7e6d097460235b17b8222c 100644 (file)
@@ -130,30 +130,37 @@ public class RestPerfClient {
         final ExecutorService executorService = Executors.newFixedThreadPool(threadAmount);
 
         LOG.info("Starting performance test");
+        boolean allThreadsCompleted = true;
         final Stopwatch started = Stopwatch.createStarted();
         try {
             final List<Future<Void>> futures = executorService.invokeAll(callables, parameters.timeout, TimeUnit.MINUTES);
             for (int i = 0; i < futures.size(); i++) {
                 Future<Void> future = futures.get(i);
                 if (future.isCancelled()) {
+                    allThreadsCompleted = false;
                     LOG.info("{}. thread timed out.", i + 1);
                 } else {
                     try {
                         future.get();
                     } catch (final ExecutionException e) {
+                        allThreadsCompleted = false;
                         LOG.info("{}. thread failed.", i + 1, e);
                     }
                 }
             }
         } catch (final InterruptedException e) {
+            allThreadsCompleted = false;
             LOG.warn("Unable to execute requests", e);
         }
         executorService.shutdownNow();
         started.stop();
 
         LOG.info("FINISHED. Execution time: {}", started);
-        LOG.info("Requests per second: {}", (parameters.editCount * 1000.0 / started.elapsed(TimeUnit.MILLISECONDS)));
-
+        // If some threads failed or timed out, skip calculation of requests per second value
+        // and do not log it
+        if(allThreadsCompleted) {
+            LOG.info("Requests per second: {}", (parameters.editCount * 1000.0 / started.elapsed(TimeUnit.MILLISECONDS)));
+        }
         System.exit(0);
     }