Fixing tests
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/private/luca.frosini/infrastructure-tests@150900 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
78a999a6d6
commit
473e4f0d68
7
pom.xml
7
pom.xml
|
@ -125,7 +125,12 @@
|
|||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.accounting</groupId>
|
||||
<artifactId>accounting-aggregator-se-plugin</artifactId>
|
||||
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,208 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.aggregator.plugin;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
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;
|
||||
|
||||
public class AggregatorAccountingPluginSmartExecutorSchedulerTest extends ScopedTest {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(AggregatorAccountingPluginSmartExecutorSchedulerTest.class);
|
||||
|
||||
private SmartExecutorProxy proxy;
|
||||
|
||||
@Before
|
||||
public void before() throws Exception{
|
||||
//ScopeProvider.instance.reset(); // Comment this to run the test. this line has been added to avoid unwanted launch
|
||||
//SecurityTokenProvider.instance.set(TestUtility.TOKEN);
|
||||
//ScopeProvider.instance.set("/gcube/devNext");
|
||||
proxy = ExecutorPlugin.getExecutorProxy("Accouting-Aggregator-Plugin").build();
|
||||
Assert.assertNotNull(proxy);
|
||||
|
||||
}
|
||||
|
||||
public UUID scheduleTest(Scheduling scheduling) throws Exception {
|
||||
|
||||
Map<String, Object> inputs = new HashMap<String, Object>();
|
||||
logger.debug("Inputs : {}", inputs);
|
||||
inputs.put("type","DAILY");
|
||||
//period to be processed
|
||||
inputs.put("interval",3);
|
||||
//change to time
|
||||
inputs.put("startTime", 14);
|
||||
//specify bucket
|
||||
inputs.put("bucket","accounting_service");
|
||||
//current scope
|
||||
inputs.put("currentScope",false);
|
||||
//specify user for save to workspace
|
||||
inputs.put("user","alessandro.pieve");
|
||||
//specify a recovery 0 default recovery and aggregate, 1 only aggregate, 2 only recovery
|
||||
inputs.put("recovery",0);
|
||||
|
||||
|
||||
//optional if present interval is not considered and elaborate a specificy step
|
||||
//e.g if type is daily and set input.put("intervalStep",10), this plugin elaborate a 10 hour
|
||||
// inputs.put("intervalStep",24);
|
||||
//optional if exist and true no backup, but start elaborate immediately
|
||||
// inputs.put("backup",false);
|
||||
// inputs.put("typePersisted",1);
|
||||
LaunchParameter parameter = new LaunchParameter("Accouting-Aggregator-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 launch() {
|
||||
Map<String, Object> inputs = new HashMap<String, Object>();
|
||||
LaunchParameter launchParameter = new LaunchParameter("Test", inputs);
|
||||
try {
|
||||
proxy.launch(launchParameter);
|
||||
} catch (Exception e) {
|
||||
logger.error("Error launching sheduled task", e);
|
||||
//throw e;
|
||||
}
|
||||
|
||||
}
|
||||
@Test
|
||||
public void LaunchTest() throws Exception {
|
||||
|
||||
Map<String, Object> inputs = new HashMap<String, Object>();
|
||||
logger.debug("Inputs : {}", inputs);
|
||||
|
||||
//inputs.put("type","DAILY");
|
||||
inputs.put("type","MONTHLY");
|
||||
//period to be processed
|
||||
inputs.put("interval",1);
|
||||
//change to time
|
||||
//novembre 6
|
||||
//ottobre 7
|
||||
//settembre 8
|
||||
//agosto 9
|
||||
//luglio 10
|
||||
//giugno e' 11
|
||||
|
||||
|
||||
inputs.put("startTime",7);
|
||||
//inputs.put("startTime",173);
|
||||
inputs.put("intervalStep",4);
|
||||
|
||||
|
||||
|
||||
//specify bucket
|
||||
inputs.put("bucket","accounting_service");
|
||||
//current scope
|
||||
inputs.put("currentScope",false);
|
||||
//specify user for save to workspace
|
||||
inputs.put("user","alessandro.pieve");
|
||||
//specify a recovery 0 default recovery and aggregate, 1 only aggregate, 2 only recovery
|
||||
inputs.put("recovery",0);
|
||||
//optional if present interval is not considered and elaborate a specificy step
|
||||
//e.g if type is daily and set input.put("intervalStep",10), this plugin elaborate a 10 hour
|
||||
|
||||
//optional if exist and true no backup, but start elaborate immediately
|
||||
//inputs.put("backup",false);
|
||||
//inputs.put("typePersisted",1);
|
||||
|
||||
LaunchParameter parameter = new LaunchParameter("Accouting-Aggregator-Plugin", inputs);
|
||||
try {
|
||||
String uuidString = proxy.launch(parameter);
|
||||
logger.debug("Launched with UUID : {}", uuidString);
|
||||
} catch(Exception e){
|
||||
logger.error("Error launching sheduled task", e);
|
||||
throw e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void LaunchTestAutomatic() throws Exception {
|
||||
|
||||
Map<String, Object> inputs = new HashMap<String, Object>();
|
||||
logger.debug("Inputs : {}", inputs);
|
||||
|
||||
inputs.put("type","DAILY");
|
||||
//period to be processed
|
||||
inputs.put("interval",1);
|
||||
//change to time
|
||||
//load a file for start time
|
||||
inputs.put("pathFile","/home/gcube/SmartGears/startTime");
|
||||
|
||||
//specify bucket
|
||||
inputs.put("bucket","accounting_service");
|
||||
inputs.put("endScriptTime","18:30");
|
||||
//current scope
|
||||
inputs.put("currentScope",false);
|
||||
//specify user for save to workspace
|
||||
inputs.put("user","alessandro.pieve");
|
||||
//specify a recovery 0 default recovery and aggregate, 1 only aggregate, 2 only recovery
|
||||
inputs.put("recovery",0);
|
||||
|
||||
LaunchParameter parameter = new LaunchParameter("Accouting-Aggregator-Plugin", inputs);
|
||||
try {
|
||||
String uuidString = proxy.launch(parameter);
|
||||
logger.debug("Launched with UUID : {}", uuidString);
|
||||
} catch(Exception e){
|
||||
logger.error("Error launching sheduled task", e);
|
||||
throw e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void cronExpPreviousMustBeTerminated() throws Exception {
|
||||
CronExpression cronExpression = new CronExpression("0 0 2 * * ?"); // every day at 2:00
|
||||
Scheduling scheduling = new Scheduling(cronExpression, true);
|
||||
scheduling.setGlobal(true);
|
||||
UUID uuid = scheduleTest(scheduling);
|
||||
logger.debug("Launched with UUID : {}", uuid);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void unSchedule() throws Exception {
|
||||
//proxy.unSchedule("", true);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void stop() throws Exception {
|
||||
proxy.stop("Accouting-Aggregator-Plugin");
|
||||
}
|
||||
|
||||
}
|
|
@ -5,14 +5,10 @@ package org.gcube.documentstore.persistence;
|
|||
|
||||
import java.net.URL;
|
||||
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.documentstore.records.Record;
|
||||
import org.gcube.testutility.ScopedTest;
|
||||
import org.gcube.testutility.TestUsageRecord;
|
||||
import org.gcube.testutility.TestUtility;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -27,16 +23,6 @@ public class PersistenceCouchBaseTest extends ScopedTest {
|
|||
|
||||
private static final Logger logger = LoggerFactory.getLogger(PersistenceCouchBaseTest.class);
|
||||
|
||||
@Before
|
||||
public void before() throws Exception{
|
||||
SecurityTokenProvider.instance.set(TestUtility.TOKEN);
|
||||
}
|
||||
|
||||
@After
|
||||
public void after(){
|
||||
SecurityTokenProvider.instance.reset();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJsonNodeUsageRecordConversions() throws Exception {
|
||||
Record record = TestUsageRecord.createTestServiceUsageRecord();
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
package org.gcube.documentstore.records;
|
||||
|
||||
public class DSMapperTest {
|
||||
|
||||
}
|
|
@ -93,4 +93,8 @@ public class RecordUtilityTest {
|
|||
logger.trace("{}", RecordUtility.recordAggregationMapping);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue