From daedd74db60b237e325d912dd1b15bd532e6a54c Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Thu, 26 May 2016 08:04:06 +0000 Subject: [PATCH] Added Social Data Indexer Plugin git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/private/luca.frosini/infrastructure-tests@128843 82a268e6-3cf1-43bd-a215-b396298e98cf --- ...dexerPluginSmartExecutorSchedulerTest.java | 72 +++++++++++++++++++ ...eeperPluginSmartExecutorSchedulerTest.java | 5 +- 2 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 src/test/java/org/gcube/informationsystem/socialdataindexer/SocialDataIndexerPluginSmartExecutorSchedulerTest.java diff --git a/src/test/java/org/gcube/informationsystem/socialdataindexer/SocialDataIndexerPluginSmartExecutorSchedulerTest.java b/src/test/java/org/gcube/informationsystem/socialdataindexer/SocialDataIndexerPluginSmartExecutorSchedulerTest.java new file mode 100644 index 0000000..b1005fb --- /dev/null +++ b/src/test/java/org/gcube/informationsystem/socialdataindexer/SocialDataIndexerPluginSmartExecutorSchedulerTest.java @@ -0,0 +1,72 @@ +/** + * + */ +package org.gcube.informationsystem.socialdataindexer; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import org.gcube.common.scope.api.ScopeProvider; +import org.gcube.testutility.ScopedTest; +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 SocialDataIndexerPluginSmartExecutorSchedulerTest extends ScopedTest { + + private static Logger logger = LoggerFactory.getLogger(SocialDataIndexerPluginSmartExecutorSchedulerTest.class); + + private SmartExecutorProxy proxy; + + @Before + public void before() throws Exception{ + super.before(); + //ScopeProvider.instance.reset(); // Comment this to run the test. this line has been added to avoid unwanted launch + ScopeProvider.instance.set("/gcube"); + proxy = ExecutorPlugin.getExecutorProxy("social-data-indexer-plugin").build(); + Assert.assertNotNull(proxy); + } + + public UUID scheduleTest(Scheduling scheduling, Long sleepTime) throws Exception { + Map inputs = new HashMap(); + logger.debug("Inputs : {}", inputs); + + LaunchParameter parameter = new LaunchParameter("social-data-indexer-plugin", 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); + } + +} diff --git a/src/test/java/org/gcube/informationsystem/sweeper/ISSweeperPluginSmartExecutorSchedulerTest.java b/src/test/java/org/gcube/informationsystem/sweeper/ISSweeperPluginSmartExecutorSchedulerTest.java index 0713c07..44465a1 100644 --- a/src/test/java/org/gcube/informationsystem/sweeper/ISSweeperPluginSmartExecutorSchedulerTest.java +++ b/src/test/java/org/gcube/informationsystem/sweeper/ISSweeperPluginSmartExecutorSchedulerTest.java @@ -32,7 +32,8 @@ public class ISSweeperPluginSmartExecutorSchedulerTest extends ScopedTest { @Before public void before() throws Exception{ 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"); proxy = ExecutorPlugin.getExecutorProxy(ISSweeperPluginDeclaration.NAME).build(); Assert.assertNotNull(proxy); } @@ -56,7 +57,7 @@ public class ISSweeperPluginSmartExecutorSchedulerTest extends ScopedTest { } - //@Test + @Test public void cronExpPreviousMustBeTerminated() throws Exception { CronExpression cronExpression = new CronExpression("0 */10 * * * ?"); // every 10 minutes starting from now Scheduling scheduling = new Scheduling(cronExpression, true);