Added test

This commit is contained in:
Luca Frosini 2019-09-26 12:53:25 +02:00
parent 8eecba49d4
commit dde826073e
1 changed files with 46 additions and 18 deletions

View File

@ -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;
@ -60,7 +61,8 @@ 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"));
@ -68,12 +70,12 @@ public class SmartExecutorClientTest extends ContextTest {
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.getDescription().compareTo(helloWorldPluginDeclaration.getDescription()) == 0);
Assert.assertTrue(pluginDeclaration.getVersion().compareTo(helloWorldPluginDeclaration.getVersion()) == 0);
Assert.assertTrue(pluginDeclaration.getSupportedCapabilities().equals(helloWorldPluginDeclaration.getSupportedCapabilities()));
Assert.assertTrue(pluginDeclaration.getSupportedCapabilities()
.equals(helloWorldPluginDeclaration.getSupportedCapabilities()));
List<ScheduledTask> orphans = smartExecutorClient.getOrphanScheduledLaunches();
for(ScheduledTask orphan : orphans) {
@ -83,7 +85,6 @@ public class SmartExecutorClientTest extends ContextTest {
orphans = smartExecutorClient.getOrphanScheduledLaunches();
Assert.assertTrue(orphans.size() == 0);
LaunchParameter launchParameter = getLaunchParameter();
UUID executionIdentifier = smartExecutorClient.launch(launchParameter);
@ -96,7 +97,6 @@ public class SmartExecutorClientTest extends ContextTest {
PluginStateEvolution pluginStateEvolution = smartExecutorClient.getPluginStateEvolution(executionIdentifier);
Assert.assertTrue(pluginStateEvolution.getUUID().compareTo(executionIdentifier) == 0);
pluginStateEvolution = smartExecutorClient.getPluginStateEvolution(executionIdentifier, 1);
Assert.assertTrue(pluginStateEvolution.getUUID().compareTo(executionIdentifier) == 0);
@ -108,4 +108,32 @@ public class SmartExecutorClientTest extends ContextTest {
}
@Test
public void uiTest() throws IOException {
List<String> hosts2Contect = Discover.getInstancesAddress();
boolean first = true;
for(String host : hosts2Contect) {
logger.debug("Host {}", SmartExecutorClientImpl.getHostFromCompleteURL(host));
SmartExecutorClientImpl client = new SmartExecutorClientImpl();
client.setAddress(host);
List<PluginDeclaration> plugins = client.getPlugins();
for(PluginDeclaration p : plugins) {
logger.debug("\tPlugin {}", p);
client.setPluginName(p.getName());
List<ScheduledTask> tasks = client.getScheduledLaunches();
for(ScheduledTask t : tasks) {
logger.debug("\t\tTask {}", t);
}
}
if(first) {
first = false;
List<ScheduledTask> orphansTasks = client.getOrphanScheduledLaunches();
for(ScheduledTask t : orphansTasks) {
logger.debug("Orphan Tasks {}" + t);
}
}
}
}
}