Fix exceptions in primitive performance tests and ensure single client tests are supported

Change-Id: I5f2493bd4029ee5f87fbb99e231abe3f36a0c1d5
diff --git a/apps/test/primitive-perf/src/main/java/org/onosproject/primitiveperf/PrimitivePerfApp.java b/apps/test/primitive-perf/src/main/java/org/onosproject/primitiveperf/PrimitivePerfApp.java
index 207d197..5e8900a 100644
--- a/apps/test/primitive-perf/src/main/java/org/onosproject/primitiveperf/PrimitivePerfApp.java
+++ b/apps/test/primitive-perf/src/main/java/org/onosproject/primitiveperf/PrimitivePerfApp.java
@@ -235,9 +235,11 @@
         }
 
         // Create a worker pool and start the workers for this node.
-        workers = Executors.newFixedThreadPool(workerCount, groupedThreads("onos/primitive-perf", "worker-%d"));
-        for (int i = 0; i < workerCount; i++) {
-            workers.submit(new Runner(UUID.randomUUID().toString(), UUID.randomUUID().toString()));
+        if (workerCount > 0) {
+            workers = Executors.newFixedThreadPool(workerCount, groupedThreads("onos/primitive-perf", "worker-%d"));
+            for (int i = 0; i < workerCount; i++) {
+                workers.submit(new Runner(UUID.randomUUID().toString(), UUID.randomUUID().toString()));
+            }
         }
         log.info("Started test run");
     }
@@ -248,10 +250,13 @@
             reporterTask = null;
         }
 
-        try {
-            workers.awaitTermination(10, TimeUnit.MILLISECONDS);
-        } catch (InterruptedException e) {
-            log.warn("Failed to stop worker", e);
+        if (workers != null) {
+            workers.shutdown();
+            try {
+                workers.awaitTermination(10, TimeUnit.MILLISECONDS);
+            } catch (InterruptedException e) {
+                log.warn("Failed to stop worker", e);
+            }
         }
 
         sampleCollector.recordSample(0, 0);