Fixing tests
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/private/luca.frosini/infrastructure-tests@131745 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
bc85d91d0d
commit
fe6c2a0609
34
pom.xml
34
pom.xml
|
@ -22,12 +22,35 @@
|
||||||
<url>https://svn.d4science.research-infrastructures.eu/gcube//private/luca.frosini/${project.artifactId}</url>
|
<url>https://svn.d4science.research-infrastructures.eu/gcube//private/luca.frosini/${project.artifactId}</url>
|
||||||
</scm>
|
</scm>
|
||||||
|
|
||||||
|
<dependencyManagement>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gcube.distribution</groupId>
|
||||||
|
<artifactId>gcube-bom</artifactId>
|
||||||
|
<version>LATEST</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</dependencyManagement>
|
||||||
|
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gcube.common</groupId>
|
||||||
|
<artifactId>authorization-client</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gcube.common</groupId>
|
||||||
|
<artifactId>common-authorization</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.data.publishing</groupId>
|
<groupId>org.gcube.data.publishing</groupId>
|
||||||
<artifactId>document-store-lib</artifactId>
|
<artifactId>document-store-lib</artifactId>
|
||||||
<version>[1.1.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -65,7 +88,6 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.accounting</groupId>
|
<groupId>org.gcube.accounting</groupId>
|
||||||
<artifactId>accounting-lib</artifactId>
|
<artifactId>accounting-lib</artifactId>
|
||||||
<version>[2.2.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
|
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
@ -89,6 +111,9 @@
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.vremanagement</groupId>
|
<groupId>org.gcube.vremanagement</groupId>
|
||||||
|
@ -118,7 +143,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.acme</groupId>
|
<groupId>org.acme</groupId>
|
||||||
<artifactId>HelloWorldPlugin</artifactId>
|
<artifactId>HelloWorldPlugin</artifactId>
|
||||||
<version>[1.1.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
<version>[1.2.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!--
|
<!--
|
||||||
|
@ -140,20 +165,17 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.resources</groupId>
|
<groupId>org.gcube.resources</groupId>
|
||||||
<artifactId>registry-publisher</artifactId>
|
<artifactId>registry-publisher</artifactId>
|
||||||
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.core</groupId>
|
<groupId>org.gcube.core</groupId>
|
||||||
<artifactId>common-encryption</artifactId>
|
<artifactId>common-encryption</artifactId>
|
||||||
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>slf4j-api</artifactId>
|
<artifactId>slf4j-api</artifactId>
|
||||||
<version>1.7.5</version>
|
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -7,7 +7,6 @@ import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
|
||||||
import org.gcube.testutility.ScopedTest;
|
import org.gcube.testutility.ScopedTest;
|
||||||
import org.gcube.vremanagement.executor.api.types.LaunchParameter;
|
import org.gcube.vremanagement.executor.api.types.LaunchParameter;
|
||||||
import org.gcube.vremanagement.executor.api.types.Scheduling;
|
import org.gcube.vremanagement.executor.api.types.Scheduling;
|
||||||
|
@ -33,7 +32,7 @@ public class ISSweeperPluginSmartExecutorSchedulerTest extends ScopedTest {
|
||||||
public void before() throws Exception{
|
public void before() throws Exception{
|
||||||
super.before();
|
super.before();
|
||||||
//ScopeProvider.instance.reset(); // Comment this to run the test. this line has been added to avoid unwanted launch
|
//ScopeProvider.instance.reset(); // Comment this to run the test. this line has been added to avoid unwanted launch
|
||||||
ScopeProvider.instance.set("/gcube");
|
//ScopeProvider.instance.set("/gcube/devsec");
|
||||||
proxy = ExecutorPlugin.getExecutorProxy(ISSweeperPluginDeclaration.NAME).build();
|
proxy = ExecutorPlugin.getExecutorProxy(ISSweeperPluginDeclaration.NAME).build();
|
||||||
Assert.assertNotNull(proxy);
|
Assert.assertNotNull(proxy);
|
||||||
}
|
}
|
||||||
|
@ -41,7 +40,7 @@ public class ISSweeperPluginSmartExecutorSchedulerTest extends ScopedTest {
|
||||||
public UUID scheduleTest(Scheduling scheduling) throws Exception {
|
public UUID scheduleTest(Scheduling scheduling) throws Exception {
|
||||||
Map<String, Object> inputs = new HashMap<String, Object>();
|
Map<String, Object> inputs = new HashMap<String, Object>();
|
||||||
logger.debug("Inputs : {}", inputs);
|
logger.debug("Inputs : {}", inputs);
|
||||||
inputs.put(ISSweeperPlugin.EXPIRING_MINUTES_TIMEOUT, 15);
|
inputs.put(ISSweeperPlugin.EXPIRING_MINUTES_TIMEOUT, 30);
|
||||||
inputs.put(ISSweeperPlugin.DEAD_DAYS_TIMEOUT, 3);
|
inputs.put(ISSweeperPlugin.DEAD_DAYS_TIMEOUT, 3);
|
||||||
|
|
||||||
LaunchParameter parameter = new LaunchParameter(ISSweeperPluginDeclaration.NAME, inputs);
|
LaunchParameter parameter = new LaunchParameter(ISSweeperPluginDeclaration.NAME, inputs);
|
||||||
|
|
|
@ -3,6 +3,18 @@
|
||||||
*/
|
*/
|
||||||
package org.gcube.test;
|
package org.gcube.test;
|
||||||
|
|
||||||
|
import java.io.StringWriter;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.gcube.common.resources.gcore.GenericResource;
|
||||||
|
import org.gcube.common.resources.gcore.Resource;
|
||||||
|
import org.gcube.common.resources.gcore.Resources;
|
||||||
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
|
import org.gcube.informationsystem.publisher.RegistryPublisherFactory;
|
||||||
|
import org.gcube.informationsystem.publisher.ScopedPublisher;
|
||||||
|
import org.gcube.informationsystem.publisher.exception.RegistryNotFoundException;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -24,4 +36,46 @@ public class TempTest {
|
||||||
logger.error("Not found", e);
|
logger.error("Not found", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void publishScopedResource(Resource resource, List<String> scopes) throws RegistryNotFoundException, Exception {
|
||||||
|
StringWriter stringWriter = new StringWriter();
|
||||||
|
Resources.marshal(resource, stringWriter);
|
||||||
|
|
||||||
|
ScopedPublisher scopedPublisher = RegistryPublisherFactory.scopedPublisher();
|
||||||
|
try {
|
||||||
|
logger.debug("Trying to publish to {}:\n{}", scopes, stringWriter);
|
||||||
|
scopedPublisher.create(resource, scopes);
|
||||||
|
} catch (RegistryNotFoundException e) {
|
||||||
|
logger.error("The resource was not published", e);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void anotherTest(){
|
||||||
|
ScopeProvider.instance.set("/gcube");
|
||||||
|
try {
|
||||||
|
|
||||||
|
GenericResource a = new GenericResource();
|
||||||
|
|
||||||
|
List<String> b = new LinkedList<>();
|
||||||
|
String scope = ScopeProvider.instance.get();
|
||||||
|
b.add(scope);
|
||||||
|
|
||||||
|
a.newProfile().name(UUID.randomUUID().toString()).type("FHN-nodes").description("FHN node");
|
||||||
|
a.profile().newBody("<name>Nunzio</name>");
|
||||||
|
|
||||||
|
try {
|
||||||
|
publishScopedResource(a,b);
|
||||||
|
} catch (Exception e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
logger.debug("OK");
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("Not found", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
package org.gcube.testutility;
|
package org.gcube.testutility;
|
||||||
|
|
||||||
//import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
//import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||||
|
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
@ -16,13 +17,13 @@ public class ScopedTest {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void before() throws Exception{
|
public void before() throws Exception{
|
||||||
//SecurityTokenProvider.instance.set(TestUtility.TOKEN);
|
SecurityTokenProvider.instance.set(TestUtility.TOKEN);
|
||||||
ScopeProvider.instance.set("/gcube/devNext");
|
ScopeProvider.instance.set("/gcube/devNext/NextNext");
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
public void after() throws Exception{
|
public void after() throws Exception{
|
||||||
//SecurityTokenProvider.instance.reset();
|
SecurityTokenProvider.instance.reset();
|
||||||
ScopeProvider.instance.reset();
|
ScopeProvider.instance.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,10 +5,9 @@ package org.gcube.testutility;
|
||||||
|
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
|
|
||||||
/*import org.gcube.common.authorization.client.Constants;
|
|
||||||
import org.gcube.common.authorization.library.AuthorizationEntry;
|
import org.gcube.common.authorization.library.AuthorizationEntry;
|
||||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||||
*/
|
import org.gcube.common.authorization.client.Constants;
|
||||||
import org.gcube.common.resources.gcore.Resource;
|
import org.gcube.common.resources.gcore.Resource;
|
||||||
import org.gcube.common.resources.gcore.Resources;
|
import org.gcube.common.resources.gcore.Resources;
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
|
@ -24,7 +23,7 @@ import org.slf4j.LoggerFactory;
|
||||||
*/
|
*/
|
||||||
public class TestUtility {
|
public class TestUtility {
|
||||||
|
|
||||||
public static final String TOKEN = "";
|
public static final String TOKEN = "7c66c94c-7f6e-49cd-9a34-909cd3832f3e-98187548";
|
||||||
public static final String PARENT_TOKEN = "";
|
public static final String PARENT_TOKEN = "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -33,23 +32,16 @@ public class TestUtility {
|
||||||
private static Logger logger = LoggerFactory.getLogger(TestUtility.class);
|
private static Logger logger = LoggerFactory.getLogger(TestUtility.class);
|
||||||
|
|
||||||
public static String getScope(){
|
public static String getScope(){
|
||||||
return ScopeProvider.instance.get();
|
|
||||||
//return getScopeFromToken();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
public static String getScopeFromToken(){
|
|
||||||
String token = SecurityTokenProvider.instance.get();
|
String token = SecurityTokenProvider.instance.get();
|
||||||
AuthorizationEntry authorizationEntry;
|
AuthorizationEntry authorizationEntry;
|
||||||
try {
|
try {
|
||||||
authorizationEntry = Constants.authorizationService().get(token);
|
authorizationEntry = Constants.authorizationService().get(token);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException(e);
|
return ScopeProvider.instance.get();
|
||||||
}
|
}
|
||||||
String scope = authorizationEntry.getContext();
|
String scope = authorizationEntry.getContext();
|
||||||
return scope;
|
return scope;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Publish the provided resource on current scope
|
* Publish the provided resource on current scope
|
||||||
|
|
|
@ -7,10 +7,10 @@ import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.acme.HWPluginStateNotification;
|
||||||
import org.acme.HelloWorldPlugin;
|
import org.acme.HelloWorldPlugin;
|
||||||
import org.acme.HelloWorldPluginDeclaration;
|
import org.acme.HelloWorldPluginDeclaration;
|
||||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
import org.gcube.testutility.ScopedTest;
|
||||||
import org.gcube.testutility.TestUtility;
|
|
||||||
import org.gcube.vremanagement.executor.api.types.LaunchParameter;
|
import org.gcube.vremanagement.executor.api.types.LaunchParameter;
|
||||||
import org.gcube.vremanagement.executor.api.types.Scheduling;
|
import org.gcube.vremanagement.executor.api.types.Scheduling;
|
||||||
import org.gcube.vremanagement.executor.client.plugins.ExecutorPlugin;
|
import org.gcube.vremanagement.executor.client.plugins.ExecutorPlugin;
|
||||||
|
@ -29,22 +29,22 @@ import org.slf4j.LoggerFactory;
|
||||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class DefaultExecutorTest {
|
public class DefaultExecutorTest extends ScopedTest {
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(DefaultExecutorTest.class);
|
private static Logger logger = LoggerFactory.getLogger(DefaultExecutorTest.class);
|
||||||
|
|
||||||
private SmartExecutorProxy proxy;
|
private SmartExecutorProxy proxy;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void before(){
|
public void before() throws Exception{
|
||||||
SecurityTokenProvider.instance.set(TestUtility.TOKEN);
|
super.before();
|
||||||
proxy = ExecutorPlugin.getExecutorProxy().build();
|
proxy = ExecutorPlugin.getExecutorProxy().build();
|
||||||
Assert.assertNotNull(proxy);
|
Assert.assertNotNull(proxy);
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
public void after(){
|
public void after() throws Exception{
|
||||||
SecurityTokenProvider.instance.reset();
|
super.after();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -63,7 +63,7 @@ public class DefaultExecutorTest {
|
||||||
public void getState() {
|
public void getState() {
|
||||||
String executionIdentifier = UUID.randomUUID().toString();
|
String executionIdentifier = UUID.randomUUID().toString();
|
||||||
try {
|
try {
|
||||||
proxy.getState(executionIdentifier);
|
proxy.getStateEvolution(executionIdentifier);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Assert.assertEquals(PluginInstanceNotFoundException.class, e.getCause().getClass());
|
Assert.assertEquals(PluginInstanceNotFoundException.class, e.getCause().getClass());
|
||||||
}
|
}
|
||||||
|
@ -77,17 +77,21 @@ public class DefaultExecutorTest {
|
||||||
long sleepTime = 10000; // 1000 millisec * 10 = 10 sec
|
long sleepTime = 10000; // 1000 millisec * 10 = 10 sec
|
||||||
inputs.put(HelloWorldPlugin.SLEEP_TIME, sleepTime);
|
inputs.put(HelloWorldPlugin.SLEEP_TIME, sleepTime);
|
||||||
LaunchParameter launchParameter = new LaunchParameter(HelloWorldPluginDeclaration.NAME, inputs);
|
LaunchParameter launchParameter = new LaunchParameter(HelloWorldPluginDeclaration.NAME, inputs);
|
||||||
|
|
||||||
|
Map<String, String> notificationInputs = new HashMap<String, String>();
|
||||||
|
notificationInputs.put("Hello", "Hello World Notification:) :)");
|
||||||
|
launchParameter.addPluginStateNotifications(HWPluginStateNotification.class, notificationInputs);
|
||||||
try {
|
try {
|
||||||
String executionIdentifier = proxy.launch(launchParameter);
|
String executionIdentifier = proxy.launch(launchParameter);
|
||||||
|
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000); // 1 sec
|
||||||
Assert.assertEquals(PluginState.RUNNING, proxy.getState(executionIdentifier));
|
Assert.assertEquals(PluginState.RUNNING, proxy.getStateEvolution(executionIdentifier).getPluginState());
|
||||||
|
|
||||||
Thread.sleep(4000);
|
Thread.sleep(4000); // 4 sec (total : 5 sec)
|
||||||
Assert.assertEquals(PluginState.RUNNING, proxy.getState(executionIdentifier));
|
Assert.assertEquals(PluginState.RUNNING, proxy.getStateEvolution(executionIdentifier).getPluginState());
|
||||||
|
|
||||||
Thread.sleep(6000);
|
Thread.sleep(6000); // 6 sec (total : 11 sec)
|
||||||
Assert.assertEquals(PluginState.DONE, proxy.getState(executionIdentifier));
|
Assert.assertEquals(PluginState.DONE, proxy.getStateEvolution(executionIdentifier).getPluginState());
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("testOk Exception", e);
|
logger.error("testOk Exception", e);
|
||||||
|
@ -104,23 +108,34 @@ public class DefaultExecutorTest {
|
||||||
|
|
||||||
Map<String, Object> inputs = new HashMap<String, Object>();
|
Map<String, Object> inputs = new HashMap<String, Object>();
|
||||||
inputs.put("Hello", "World");
|
inputs.put("Hello", "World");
|
||||||
long sleepTime = 10000; // 1000 millisec * 10 = 10 sec
|
long sleepTime = 20000; // 1000 millisec * 20 = 20 sec
|
||||||
inputs.put(HelloWorldPlugin.SLEEP_TIME, sleepTime);
|
inputs.put(HelloWorldPlugin.SLEEP_TIME, sleepTime);
|
||||||
// Every 5 minutes, for 12 times (one hour totally).
|
// Every 5 minutes, for 12 times (one hour totally).
|
||||||
Scheduling scheduling = new Scheduling(60*5,12,false);
|
Scheduling scheduling = new Scheduling(60*5,12,true);
|
||||||
LaunchParameter launchParameter = new LaunchParameter(HelloWorldPluginDeclaration.NAME, inputs, scheduling);
|
scheduling.setGlobal(false);
|
||||||
|
|
||||||
|
LaunchParameter launchParameter = new LaunchParameter(HelloWorldPluginDeclaration.NAME, inputs, scheduling);
|
||||||
|
Map<String, String> notificationInputs = new HashMap<String, String>();
|
||||||
|
notificationInputs.put("Hello", "Hello World Notification:) :)");
|
||||||
|
launchParameter.addPluginStateNotifications(HWPluginStateNotification.class, notificationInputs);
|
||||||
try {
|
try {
|
||||||
String executionIdentifier = proxy.launch(launchParameter);
|
String executionIdentifier = proxy.launch(launchParameter);
|
||||||
|
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000); // 2 sec
|
||||||
Assert.assertEquals(PluginState.RUNNING, proxy.getState(executionIdentifier));
|
Assert.assertEquals(PluginState.RUNNING, proxy.getStateEvolution(executionIdentifier).getPluginState());
|
||||||
|
|
||||||
Thread.sleep(4000);
|
Thread.sleep(4000); // 8 sec (total : 10 sec)
|
||||||
Assert.assertEquals(PluginState.RUNNING, proxy.getState(executionIdentifier));
|
Assert.assertEquals(PluginState.RUNNING, proxy.getStateEvolution(executionIdentifier).getPluginState());
|
||||||
|
|
||||||
Thread.sleep(6000);
|
Thread.sleep(6000); // 12 sec (total : 22 sec)
|
||||||
Assert.assertEquals(PluginState.DONE, proxy.getState(executionIdentifier));
|
Assert.assertEquals(PluginState.DONE, proxy.getStateEvolution(executionIdentifier).getPluginState());
|
||||||
|
|
||||||
|
Thread.sleep(1000*60*5); // After 5 minutes the thread should be active again
|
||||||
|
Assert.assertEquals(PluginState.RUNNING, proxy.getStateEvolution(executionIdentifier).getPluginState());
|
||||||
|
Assert.assertEquals(PluginState.RUNNING, proxy.getIterationStateEvolution(executionIdentifier, 1).getPluginState());
|
||||||
|
|
||||||
|
logger.debug("Trying to stop scheduled task");
|
||||||
|
proxy.unSchedule(executionIdentifier, true);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("testOk Exception", e);
|
logger.error("testOk Exception", e);
|
||||||
|
@ -136,29 +151,55 @@ public class DefaultExecutorTest {
|
||||||
|
|
||||||
Map<String, Object> inputs = new HashMap<String, Object>();
|
Map<String, Object> inputs = new HashMap<String, Object>();
|
||||||
inputs.put("Hello", "World");
|
inputs.put("Hello", "World");
|
||||||
long sleepTime = 10000; // 1000 millisec * 10 = 10 sec
|
long sleepTime = 20000; // 1000 millisec * 20 = 20 sec
|
||||||
inputs.put(HelloWorldPlugin.SLEEP_TIME, sleepTime);
|
inputs.put(HelloWorldPlugin.SLEEP_TIME, sleepTime);
|
||||||
// Every 5 minutes, for 12 times (one hour totally).
|
// Every 5 minutes, for 12 times (one hour totally).
|
||||||
Scheduling scheduling = new Scheduling(60*5,12,true);
|
Scheduling scheduling = new Scheduling(60*5,12,true);
|
||||||
LaunchParameter launchParameter = new LaunchParameter(HelloWorldPluginDeclaration.NAME, inputs, scheduling);
|
scheduling.setGlobal(true);
|
||||||
|
|
||||||
|
LaunchParameter launchParameter = new LaunchParameter(HelloWorldPluginDeclaration.NAME, inputs, scheduling);
|
||||||
|
Map<String, String> notificationInputs = new HashMap<String, String>();
|
||||||
|
notificationInputs.put("Hello", "Hello World Notification:) :)");
|
||||||
|
launchParameter.addPluginStateNotifications(HWPluginStateNotification.class, notificationInputs);
|
||||||
try {
|
try {
|
||||||
String executionIdentifier = proxy.launch(launchParameter);
|
String executionIdentifier = proxy.launch(launchParameter);
|
||||||
|
logger.debug("Task Lauched with ID : {}", executionIdentifier);
|
||||||
Thread.sleep(1000);
|
|
||||||
Assert.assertEquals(PluginState.RUNNING, proxy.getState(executionIdentifier));
|
|
||||||
|
|
||||||
Thread.sleep(4000);
|
Thread.sleep(1000); // 2 sec
|
||||||
Assert.assertEquals(PluginState.RUNNING, proxy.getState(executionIdentifier));
|
Assert.assertEquals(PluginState.RUNNING, proxy.getStateEvolution(executionIdentifier).getPluginState());
|
||||||
|
|
||||||
Thread.sleep(6000);
|
Thread.sleep(4000); // 8 sec (total : 10 sec)
|
||||||
Assert.assertEquals(PluginState.DONE, proxy.getState(executionIdentifier));
|
Assert.assertEquals(PluginState.RUNNING, proxy.getStateEvolution(executionIdentifier).getPluginState());
|
||||||
|
|
||||||
|
Thread.sleep(6000); // 12 sec (total : 22 sec)
|
||||||
|
Assert.assertEquals(PluginState.DONE, proxy.getStateEvolution(executionIdentifier).getPluginState());
|
||||||
|
|
||||||
|
Thread.sleep(1000*60*5); // After 5 minutes the thread should be active again
|
||||||
|
Assert.assertEquals(PluginState.RUNNING, proxy.getStateEvolution(executionIdentifier).getPluginState());
|
||||||
|
Assert.assertEquals(PluginState.RUNNING, proxy.getIterationStateEvolution(executionIdentifier, 1).getPluginState());
|
||||||
|
|
||||||
|
proxy.stop(executionIdentifier);
|
||||||
|
|
||||||
|
|
||||||
|
Thread.sleep(1000*60*5); // After 5 minutes the thread should be active again. Goign to unschedule globally
|
||||||
|
logger.debug("Trying to stop scheduled task");
|
||||||
|
Assert.assertTrue(proxy.unSchedule(executionIdentifier, false));
|
||||||
|
|
||||||
|
|
||||||
|
Thread.sleep(1000*60);
|
||||||
|
Assert.assertTrue(proxy.unSchedule(executionIdentifier, true));
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("testOk Exception", e);
|
logger.error("testOk Exception", e);
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUnschedule() throws Exception {
|
||||||
|
//proxy.unSchedule("542ddb03-d8d7-4913-8700-2acfa74c7485", true);
|
||||||
|
//proxy.unSchedule("37d8f020-cdeb-4b2c-b245-4deabc1fe149", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class QueriedClientTest {
|
||||||
LaunchParameter launchParameter = new LaunchParameter(HelloWorldPluginDeclaration.NAME, inputs);
|
LaunchParameter launchParameter = new LaunchParameter(HelloWorldPluginDeclaration.NAME, inputs);
|
||||||
try {
|
try {
|
||||||
String executionIdentifier = proxy.launch(launchParameter);
|
String executionIdentifier = proxy.launch(launchParameter);
|
||||||
proxy.getState(executionIdentifier);
|
proxy.getStateEvolution(executionIdentifier);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue