Add E2E testing for testtool
[netconf.git] / netconf / tools / netconf-testtool / src / main / java / org / opendaylight / netconf / test / tool / ScaleUtil.java
index f67c96e2f4399de2c4fffaccd43b76a1f5d9f849..5a65a5f88741d50ae1a7dd9f4c917e49e1d6fe01 100644 (file)
@@ -36,7 +36,7 @@ import org.opendaylight.netconf.test.tool.config.ConfigurationBuilder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-@SuppressFBWarnings({"DM_EXIT", "DM_DEFAULT_ENCODING"})
+@SuppressFBWarnings({"DM_EXIT", "DM_DEFAULT_ENCODING", "SLF4J_LOGGER_SHOULD_BE_FINAL"})
 public final class ScaleUtil {
     private static final ScheduledExecutorService EXECUTOR = new LoggingWrapperExecutor(4);
     private static final Semaphore SEMAPHORE = new Semaphore(0);
@@ -64,32 +64,19 @@ public final class ScaleUtil {
 
         while (true) {
             root.warn("Starting scale test with {} devices", params.deviceCount);
-            final ScheduledFuture timeoutGuardFuture = EXECUTOR.schedule(new TimeoutGuard(), TIMEOUT, TimeUnit.MINUTES);
+            final ScheduledFuture<?> timeoutGuardFuture = EXECUTOR.schedule(new TimeoutGuard(), TIMEOUT,
+                TimeUnit.MINUTES);
             final Configuration configuration = new ConfigurationBuilder().from(params).build();
             final NetconfDeviceSimulator netconfDeviceSimulator = new NetconfDeviceSimulator(configuration);
-            try {
-                final List<Integer> openDevices = netconfDeviceSimulator.start();
-                if (openDevices.size() == 0) {
-                    root.error("Failed to start any simulated devices, exiting...");
-                    System.exit(1);
-                }
 
-                if (params.distroFolder == null) {
-                    root.error("Distro folder is not set, exiting...");
-                    System.exit(1);
-                }
+            final List<Integer> openDevices = netconfDeviceSimulator.start();
+            if (openDevices.size() == 0) {
+                root.error("Failed to start any simulated devices, exiting...");
+                System.exit(1);
+            }
 
-                final Main.ConfigGenerator configGenerator = new Main.ConfigGenerator(
-                        params.distroFolder, openDevices);
-                final List<File> generated = configGenerator.generate(
-                        params.ssh, params.generateConfigBatchSize,
-                        params.generateConfigsTimeout, params.generateConfigsAddress,
-                        params.devicesPerPort);
-                configGenerator.updateFeatureFile(generated);
-                configGenerator.changeLoadOrder();
-            } catch (final Exception e) {
-                root.error("Unhandled exception", e);
-                netconfDeviceSimulator.close();
+            if (params.distroFolder == null) {
+                root.error("Distro folder is not set, exiting...");
                 System.exit(1);
             }
 
@@ -178,7 +165,7 @@ public final class ScaleUtil {
         deleteFolder(new File(params.distroFolder.getAbsoluteFile() + "/data"));
     }
 
-    private static void deleteFolder(File folder) {
+    private static void deleteFolder(final File folder) {
         File[] files = folder.listFiles();
         if (files != null) { //some JVMs return null for empty dirs
             for (File f : files) {
@@ -199,8 +186,8 @@ public final class ScaleUtil {
     private static class ScaleVerifyCallable implements Callable<Void> {
         private static final Logger LOG = LoggerFactory.getLogger(ScaleVerifyCallable.class);
 
-        private static final String RESTCONF_URL
-                = "http://127.0.0.1:8181/restconf/operational/network-topology:network-topology/topology/topology-netconf/";
+        private static final String RESTCONF_URL = "http://127.0.0.1:8181/restconf/operational/"
+                + "network-topology:network-topology/topology/topology-netconf/";
         private static final Pattern PATTERN = Pattern.compile("connected");
 
         private final AsyncHttpClient asyncHttpClient = new AsyncHttpClient(new Builder()
@@ -269,19 +256,19 @@ public final class ScaleUtil {
 
     @SuppressWarnings("checkstyle:illegalCatch")
     public static class LoggingWrapperExecutor extends ScheduledThreadPoolExecutor {
-        public LoggingWrapperExecutor(int corePoolSize) {
+        public LoggingWrapperExecutor(final int corePoolSize) {
             super(corePoolSize);
         }
 
         @Override
-        public <V> ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit) {
+        public <V> ScheduledFuture<V> schedule(final Callable<V> callable, final long delay, final TimeUnit unit) {
             return super.schedule(new LogOnExceptionCallable<>(callable), delay, unit);
         }
 
         private static class LogOnExceptionCallable<T> implements Callable<T> {
             private final Callable<T> theCallable;
 
-            LogOnExceptionCallable(Callable<T> theCallable) {
+            LogOnExceptionCallable(final Callable<T> theCallable) {
                 this.theCallable = theCallable;
             }