Fixed bugs and tests
This commit is contained in:
parent
0df3020a02
commit
ba629b762a
7
pom.xml
7
pom.xml
|
@ -84,6 +84,13 @@
|
||||||
<version>1.0.13</version>
|
<version>1.0.13</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gcube.vremanagement</groupId>
|
||||||
|
<artifactId>hello-world-se-plugin</artifactId>
|
||||||
|
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -128,7 +128,6 @@ public class SmartExecutorClientImpl implements SmartExecutorClient {
|
||||||
GXHTTPStringRequest gxHTTPStringRequest = GXHTTPStringRequest.newRequest(address);
|
GXHTTPStringRequest gxHTTPStringRequest = GXHTTPStringRequest.newRequest(address);
|
||||||
gxHTTPStringRequest.from(SmartExecutorClient.class.getSimpleName());
|
gxHTTPStringRequest.from(SmartExecutorClient.class.getSimpleName());
|
||||||
gxHTTPStringRequest.header("Accept", GXConnection.APPLICATION_JSON_CHARSET_UTF_8);
|
gxHTTPStringRequest.header("Accept", GXConnection.APPLICATION_JSON_CHARSET_UTF_8);
|
||||||
gxHTTPStringRequest.header("Accept", "text/plain");
|
|
||||||
gxHTTPStringRequest.path(RestConstants.PLUGINS_PATH_PART);
|
gxHTTPStringRequest.path(RestConstants.PLUGINS_PATH_PART);
|
||||||
|
|
||||||
HttpURLConnection httpURLConnection = gxHTTPStringRequest.get();
|
HttpURLConnection httpURLConnection = gxHTTPStringRequest.get();
|
||||||
|
@ -157,7 +156,6 @@ public class SmartExecutorClientImpl implements SmartExecutorClient {
|
||||||
GXHTTPStringRequest gxHTTPStringRequest = GXHTTPStringRequest.newRequest(address);
|
GXHTTPStringRequest gxHTTPStringRequest = GXHTTPStringRequest.newRequest(address);
|
||||||
gxHTTPStringRequest.from(SmartExecutorClient.class.getSimpleName());
|
gxHTTPStringRequest.from(SmartExecutorClient.class.getSimpleName());
|
||||||
gxHTTPStringRequest.header("Accept", GXConnection.APPLICATION_JSON_CHARSET_UTF_8);
|
gxHTTPStringRequest.header("Accept", GXConnection.APPLICATION_JSON_CHARSET_UTF_8);
|
||||||
gxHTTPStringRequest.header("Accept", "text/plain");
|
|
||||||
gxHTTPStringRequest.path(RestConstants.PLUGINS_PATH_PART);
|
gxHTTPStringRequest.path(RestConstants.PLUGINS_PATH_PART);
|
||||||
gxHTTPStringRequest.path(name);
|
gxHTTPStringRequest.path(name);
|
||||||
gxHTTPStringRequest.path(RestConstants.EXECUTIONS_PATH_PART);
|
gxHTTPStringRequest.path(RestConstants.EXECUTIONS_PATH_PART);
|
||||||
|
@ -203,7 +201,7 @@ public class SmartExecutorClientImpl implements SmartExecutorClient {
|
||||||
logger.info("Going to launch plugin {} on {} with parameters {} ", pluginName, host, launchParameter);
|
logger.info("Going to launch plugin {} on {} with parameters {} ", pluginName, host, launchParameter);
|
||||||
GXHTTPStringRequest gxHTTPStringRequest = GXHTTPStringRequest.newRequest(address);
|
GXHTTPStringRequest gxHTTPStringRequest = GXHTTPStringRequest.newRequest(address);
|
||||||
gxHTTPStringRequest.from(SmartExecutorClient.class.getSimpleName());
|
gxHTTPStringRequest.from(SmartExecutorClient.class.getSimpleName());
|
||||||
gxHTTPStringRequest.header("Accept", GXConnection.APPLICATION_JSON_CHARSET_UTF_8);
|
gxHTTPStringRequest.header("Content-Type", GXConnection.APPLICATION_JSON_CHARSET_UTF_8);
|
||||||
gxHTTPStringRequest.header("Accept", "text/plain");
|
gxHTTPStringRequest.header("Accept", "text/plain");
|
||||||
gxHTTPStringRequest.path(RestConstants.PLUGINS_PATH_PART);
|
gxHTTPStringRequest.path(RestConstants.PLUGINS_PATH_PART);
|
||||||
gxHTTPStringRequest.path(pluginName);
|
gxHTTPStringRequest.path(pluginName);
|
||||||
|
@ -297,7 +295,7 @@ public class SmartExecutorClientImpl implements SmartExecutorClient {
|
||||||
|
|
||||||
GXHTTPStringRequest gxHTTPStringRequest = GXHTTPStringRequest.newRequest(address);
|
GXHTTPStringRequest gxHTTPStringRequest = GXHTTPStringRequest.newRequest(address);
|
||||||
gxHTTPStringRequest.from(SmartExecutorClient.class.getSimpleName());
|
gxHTTPStringRequest.from(SmartExecutorClient.class.getSimpleName());
|
||||||
gxHTTPStringRequest.header("Accept", GXConnection.APPLICATION_JSON_CHARSET_UTF_8);
|
gxHTTPStringRequest.header("Accept", "text/plain");
|
||||||
gxHTTPStringRequest.path(RestConstants.PLUGINS_PATH_PART);
|
gxHTTPStringRequest.path(RestConstants.PLUGINS_PATH_PART);
|
||||||
gxHTTPStringRequest.path(pluginName);
|
gxHTTPStringRequest.path(pluginName);
|
||||||
gxHTTPStringRequest.path(RestConstants.EXECUTIONS_PATH_PART);
|
gxHTTPStringRequest.path(RestConstants.EXECUTIONS_PATH_PART);
|
||||||
|
|
|
@ -1,22 +1,28 @@
|
||||||
package org.gcube.vremanagement.executor.client;
|
package org.gcube.vremanagement.executor.client;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.gcube.vremanagement.executor.json.SEMapper;
|
import org.gcube.vremanagement.executor.api.types.LaunchParameter;
|
||||||
|
import org.gcube.vremanagement.executor.api.types.Scheduling;
|
||||||
import org.gcube.vremanagement.executor.plugin.PluginDeclaration;
|
import org.gcube.vremanagement.executor.plugin.PluginDeclaration;
|
||||||
|
import org.gcube.vremanagement.executor.plugin.PluginStateEvolution;
|
||||||
|
import org.gcube.vremanagement.executor.plugin.ScheduledTask;
|
||||||
|
import org.gcube.vremanagement.helloworld.HelloWorldPlugin;
|
||||||
|
import org.gcube.vremanagement.helloworld.HelloWorldPluginDeclaration;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonParseException;
|
|
||||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Luca Frosini (ISTI - CNR)
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
*/
|
*/
|
||||||
public class SmartExecutorClientTest {
|
public class SmartExecutorClientTest extends ContextTest {
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(SmartExecutorClientTest.class);
|
private static Logger logger = LoggerFactory.getLogger(SmartExecutorClientTest.class);
|
||||||
|
|
||||||
|
@ -38,10 +44,68 @@ public class SmartExecutorClientTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
private LaunchParameter getLaunchParameter() {
|
||||||
public void testUnmarshallPluginList() throws JsonParseException, JsonMappingException, IOException {
|
Scheduling scheduling = new Scheduling(20);
|
||||||
String pluginList = "[{\"@class\":\"PluginDeclaration\",\"description\":\"Hello World Description\",\"supportedCapabilities\":{\"FakeKey\":\"FakeValue\"},\"version\":\"1.1.2\",\"name\":\"HelloWorld\"}]";
|
Map<String, Object> inputs = new HashMap<String, Object>();
|
||||||
List<PluginDeclaration> list = SEMapper.getInstance().unmarshalList(PluginDeclaration.class, pluginList);
|
inputs.put(HelloWorldPlugin.SLEEP_TIME, TimeUnit.SECONDS.toMillis(10));
|
||||||
logger.debug("{}", SEMapper.getInstance().marshal(PluginDeclaration.class, list));
|
inputs.put("TestUUID", UUID.randomUUID());
|
||||||
|
|
||||||
|
LaunchParameter launchParameter = new LaunchParameter(HelloWorldPluginDeclaration.NAME, inputs);
|
||||||
|
launchParameter.setScheduling(scheduling);
|
||||||
|
|
||||||
|
return launchParameter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @Test
|
||||||
|
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());
|
||||||
|
String host = smartExecutorClient.getHost();
|
||||||
|
Assert.assertTrue(host.contains("pc-frosini.isti.cnr.it"));
|
||||||
|
|
||||||
|
List<PluginDeclaration> plugins = smartExecutorClient.getPlugins();
|
||||||
|
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()));
|
||||||
|
|
||||||
|
|
||||||
|
List<ScheduledTask> orphans = smartExecutorClient.getOrphanScheduledLaunches();
|
||||||
|
for(ScheduledTask orphan : orphans) {
|
||||||
|
boolean removed = smartExecutorClient.delete(orphan.getUUID(), true);
|
||||||
|
Assert.assertTrue(removed);
|
||||||
|
}
|
||||||
|
orphans = smartExecutorClient.getOrphanScheduledLaunches();
|
||||||
|
Assert.assertTrue(orphans.size()==0);
|
||||||
|
|
||||||
|
|
||||||
|
LaunchParameter launchParameter = getLaunchParameter();
|
||||||
|
|
||||||
|
UUID executionIdentifier = smartExecutorClient.launch(launchParameter);
|
||||||
|
|
||||||
|
List<ScheduledTask> launches = smartExecutorClient.getScheduledLaunches();
|
||||||
|
Assert.assertTrue(launches.size()==1);
|
||||||
|
ScheduledTask scheduledTask = launches.get(0);
|
||||||
|
Assert.assertTrue(scheduledTask.getUUID().compareTo(executionIdentifier)==0);
|
||||||
|
|
||||||
|
PluginStateEvolution pluginStateEvolution = smartExecutorClient.getPluginStateEvolution(executionIdentifier);
|
||||||
|
Assert.assertTrue(pluginStateEvolution.getUUID().compareTo(executionIdentifier)==0);
|
||||||
|
|
||||||
|
|
||||||
|
pluginStateEvolution = smartExecutorClient.getPluginStateEvolution(executionIdentifier, 1);
|
||||||
|
Assert.assertTrue(pluginStateEvolution.getUUID().compareTo(executionIdentifier)==0);
|
||||||
|
|
||||||
|
boolean removed = smartExecutorClient.delete(executionIdentifier, true);
|
||||||
|
Assert.assertTrue(removed);
|
||||||
|
|
||||||
|
orphans = smartExecutorClient.getOrphanScheduledLaunches();
|
||||||
|
Assert.assertTrue(orphans.size()==0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue