diff --git a/src/test/java/org/gcube/vremanagement/executor/client/SmartExecutorClientTest.java b/src/test/java/org/gcube/vremanagement/executor/client/SmartExecutorClientTest.java index 04e5a42..4ec5c63 100644 --- a/src/test/java/org/gcube/vremanagement/executor/client/SmartExecutorClientTest.java +++ b/src/test/java/org/gcube/vremanagement/executor/client/SmartExecutorClientTest.java @@ -9,6 +9,7 @@ import java.util.concurrent.TimeUnit; import org.gcube.vremanagement.executor.api.types.LaunchParameter; import org.gcube.vremanagement.executor.api.types.Scheduling; +import org.gcube.vremanagement.executor.client.query.Discover; import org.gcube.vremanagement.executor.plugin.PluginDeclaration; import org.gcube.vremanagement.executor.plugin.PluginStateEvolution; import org.gcube.vremanagement.executor.plugin.ScheduledTask; @@ -46,10 +47,10 @@ public class SmartExecutorClientTest extends ContextTest { private LaunchParameter getLaunchParameter() { Scheduling scheduling = new Scheduling(20); - Map inputs = new HashMap(); + Map inputs = new HashMap(); inputs.put(HelloWorldPlugin.SLEEP_TIME, TimeUnit.SECONDS.toMillis(10)); inputs.put("TestUUID", UUID.randomUUID()); - + LaunchParameter launchParameter = new LaunchParameter(HelloWorldPluginDeclaration.NAME, inputs); launchParameter.setScheduling(scheduling); @@ -60,20 +61,21 @@ public class SmartExecutorClientTest extends ContextTest { public void testServiceInteraction() throws IOException { HelloWorldPluginDeclaration helloWorldPluginDeclaration = new HelloWorldPluginDeclaration(); logger.debug("Going to test smart executor using {} plugin", helloWorldPluginDeclaration.getName()); - SmartExecutorClient smartExecutorClient = SmartExecutorClientFactory.getClient(helloWorldPluginDeclaration.getName()); + SmartExecutorClient smartExecutorClient = SmartExecutorClientFactory + .getClient(helloWorldPluginDeclaration.getName()); String host = smartExecutorClient.getHost(); Assert.assertTrue(host.contains("pc-frosini.isti.cnr.it")); List plugins = smartExecutorClient.getPlugins(); - Assert.assertTrue(plugins.size()==1); + Assert.assertTrue(plugins.size() == 1); PluginDeclaration pluginDeclaration = plugins.get(0); - - Assert.assertTrue(pluginDeclaration.getName().compareTo(helloWorldPluginDeclaration.getName())==0); - Assert.assertTrue(pluginDeclaration.getDescription().compareTo(helloWorldPluginDeclaration.getDescription())==0); - Assert.assertTrue(pluginDeclaration.getVersion().compareTo(helloWorldPluginDeclaration.getVersion())==0); - Assert.assertTrue(pluginDeclaration.getSupportedCapabilities().equals(helloWorldPluginDeclaration.getSupportedCapabilities())); - + Assert.assertTrue(pluginDeclaration.getName().compareTo(helloWorldPluginDeclaration.getName()) == 0); + Assert.assertTrue( + pluginDeclaration.getDescription().compareTo(helloWorldPluginDeclaration.getDescription()) == 0); + Assert.assertTrue(pluginDeclaration.getVersion().compareTo(helloWorldPluginDeclaration.getVersion()) == 0); + Assert.assertTrue(pluginDeclaration.getSupportedCapabilities() + .equals(helloWorldPluginDeclaration.getSupportedCapabilities())); List orphans = smartExecutorClient.getOrphanScheduledLaunches(); for(ScheduledTask orphan : orphans) { @@ -81,31 +83,57 @@ public class SmartExecutorClientTest extends ContextTest { Assert.assertTrue(removed); } orphans = smartExecutorClient.getOrphanScheduledLaunches(); - Assert.assertTrue(orphans.size()==0); - + Assert.assertTrue(orphans.size() == 0); LaunchParameter launchParameter = getLaunchParameter(); UUID executionIdentifier = smartExecutorClient.launch(launchParameter); List launches = smartExecutorClient.getScheduledLaunches(); - Assert.assertTrue(launches.size()==1); + Assert.assertTrue(launches.size() == 1); ScheduledTask scheduledTask = launches.get(0); - Assert.assertTrue(scheduledTask.getUUID().compareTo(executionIdentifier)==0); + Assert.assertTrue(scheduledTask.getUUID().compareTo(executionIdentifier) == 0); PluginStateEvolution pluginStateEvolution = smartExecutorClient.getPluginStateEvolution(executionIdentifier); - Assert.assertTrue(pluginStateEvolution.getUUID().compareTo(executionIdentifier)==0); - + Assert.assertTrue(pluginStateEvolution.getUUID().compareTo(executionIdentifier) == 0); pluginStateEvolution = smartExecutorClient.getPluginStateEvolution(executionIdentifier, 1); - Assert.assertTrue(pluginStateEvolution.getUUID().compareTo(executionIdentifier)==0); + Assert.assertTrue(pluginStateEvolution.getUUID().compareTo(executionIdentifier) == 0); boolean removed = smartExecutorClient.delete(executionIdentifier, true); Assert.assertTrue(removed); orphans = smartExecutorClient.getOrphanScheduledLaunches(); - Assert.assertTrue(orphans.size()==0); + Assert.assertTrue(orphans.size() == 0); } + @Test + public void uiTest() throws IOException { + List hosts2Contect = Discover.getInstancesAddress(); + boolean first = true; + for(String host : hosts2Contect) { + logger.debug("Host {}", SmartExecutorClientImpl.getHostFromCompleteURL(host)); + SmartExecutorClientImpl client = new SmartExecutorClientImpl(); + client.setAddress(host); + List plugins = client.getPlugins(); + for(PluginDeclaration p : plugins) { + logger.debug("\tPlugin {}", p); + client.setPluginName(p.getName()); + List tasks = client.getScheduledLaunches(); + for(ScheduledTask t : tasks) { + logger.debug("\t\tTask {}", t); + } + + } + if(first) { + first = false; + List orphansTasks = client.getOrphanScheduledLaunches(); + for(ScheduledTask t : orphansTasks) { + logger.debug("Orphan Tasks {}" + t); + } + } + } + } + }