refs #2222: Move infrastructure tests outside of components junit tests
https://support.d4science.org/issues/2222 git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/is-sweeper-se-plugin@124063 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
3f12bc77b2
commit
c62e1e92dd
11
pom.xml
11
pom.xml
|
@ -69,17 +69,6 @@
|
|||
</dependency>
|
||||
|
||||
<!-- Test dependencies -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.core</groupId>
|
||||
<artifactId>common-encryption</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.vremanagement</groupId>
|
||||
<artifactId>smart-executor-client</artifactId>
|
||||
<version>[1.3.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
|
|
|
@ -6,7 +6,6 @@ import java.util.Map;
|
|||
import org.gcube.common.authorization.client.Constants;
|
||||
import org.gcube.common.authorization.library.AuthorizationEntry;
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.vremanagement.executor.plugin.Plugin;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -41,13 +40,13 @@ public class ISSweeperPlugin extends Plugin<ISSweeperPluginDeclaration> {
|
|||
/**{@inheritDoc}*/
|
||||
@Override
|
||||
public void launch(Map<String, Object> inputs) throws Exception {
|
||||
logger.debug("Launching {} execution", ISSweeperPluginDeclaration.NAME);
|
||||
// No inputs needed
|
||||
|
||||
String token = SecurityTokenProvider.instance.get();
|
||||
AuthorizationEntry authorizationEntry = Constants.authorizationService().get(token);
|
||||
String scope = authorizationEntry.getContext();
|
||||
ScopeProvider.instance.set(scope);
|
||||
logger.debug("Launching {} execution on scope {}",
|
||||
ISSweeperPluginDeclaration.NAME, scope);
|
||||
|
||||
Sweeper sweeper = new Sweeper();
|
||||
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
package org.gcube.informationsystem.sweeper;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||
*/
|
||||
public class ISSweeperPluginTest {
|
||||
|
||||
/**
|
||||
* Logger
|
||||
*/
|
||||
private static Logger logger = LoggerFactory.getLogger(ISSweeperPluginTest.class);
|
||||
|
||||
@Before
|
||||
public void beforeTest(){
|
||||
SecurityTokenProvider.instance.set("82a84741-debe-4c90-a907-c429c8272071");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLaunch() throws Exception {
|
||||
logger.debug("Starting to test launch");
|
||||
Map<String, Object> inputs = new HashMap<String, Object>();
|
||||
ISSweeperPlugin couchDBQueryPlugin = new ISSweeperPlugin(null);
|
||||
couchDBQueryPlugin.launch(inputs);
|
||||
logger.debug("-------------- launch test finished");
|
||||
}
|
||||
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.informationsystem.sweeper;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.vremanagement.executor.api.types.LaunchParameter;
|
||||
import org.gcube.vremanagement.executor.api.types.Scheduling;
|
||||
import org.gcube.vremanagement.executor.client.plugins.ExecutorPlugin;
|
||||
import org.gcube.vremanagement.executor.client.proxies.SmartExecutorProxy;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.quartz.CronExpression;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||
*/
|
||||
public class SmartExecutorSchedulerTest {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(SmartExecutorSchedulerTest.class);
|
||||
|
||||
private SmartExecutorProxy proxy;
|
||||
|
||||
@Before
|
||||
public void before() throws Exception{
|
||||
SecurityTokenProvider.instance.set("82a84741-debe-4c90-a907-c429c8272071");
|
||||
ScopeProvider.instance.set("/gcube/devsec");
|
||||
proxy = ExecutorPlugin.getExecutorProxy(ISSweeperPluginDeclaration.NAME).build();
|
||||
Assert.assertNotNull(proxy);
|
||||
}
|
||||
|
||||
public UUID scheduleTest(Scheduling scheduling, Long sleepTime) throws Exception {
|
||||
Map<String, Object> inputs = new HashMap<String, Object>();
|
||||
logger.debug("Inputs : {}", inputs);
|
||||
|
||||
LaunchParameter parameter = new LaunchParameter(ISSweeperPluginDeclaration.NAME, inputs);
|
||||
parameter.setScheduling(scheduling);
|
||||
|
||||
try {
|
||||
String uuidString = proxy.launch(parameter);
|
||||
return UUID.fromString(uuidString);
|
||||
} catch(Exception e){
|
||||
logger.error("Error launching sheduled task", e);
|
||||
throw e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cronExpPreviousMustBeTerminated() throws Exception {
|
||||
CronExpression cronExpression = new CronExpression("0 */10 * * * ?"); // every 10 minutes starting from now
|
||||
Scheduling scheduling = new Scheduling(cronExpression, true);
|
||||
scheduling.setGlobal(true);
|
||||
UUID uuid = scheduleTest(scheduling, new Long(1000*60)); // 1 min
|
||||
logger.debug("Launched with UUID : {}", uuid);
|
||||
}
|
||||
|
||||
//@Test
|
||||
public void unSchedule() throws Exception {
|
||||
proxy.unSchedule(null, true);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue