Refactoring Infrastructure Tests

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/private/luca.frosini/infrastructure-tests@151524 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2017-08-01 12:41:45 +00:00
parent 4603c4d080
commit bfc317f086
6 changed files with 23 additions and 193 deletions

56
pom.xml
View File

@ -62,6 +62,8 @@
<scope>provided</scope>
</dependency>
<!-- Document Store Lib -->
<dependency>
<groupId>org.gcube.data.publishing</groupId>
<artifactId>document-store-lib</artifactId>
@ -73,13 +75,6 @@
<version>[1.0.1-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.9.10</version>
<scope>test</scope>
</dependency>
<!--
<dependency>
<groupId>org.gcube.data.publishing</groupId>
@ -100,7 +95,9 @@
<scope>test</scope>
</dependency>
-->
<!-- END Document Store Lib -->
<!-- Accounting Libraries -->
<dependency>
<groupId>org.gcube.accounting</groupId>
<artifactId>accounting-lib</artifactId>
@ -121,23 +118,15 @@
<scope>test</scope>
</dependency>
-->
<dependency>
<groupId>org.gcube.accounting</groupId>
<artifactId>accounting-analytics-persistence-couchbase</artifactId>
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
<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>
<!-- Accounting Libraries -->
<dependency>
<groupId>org.gcube.vremanagement</groupId>
<artifactId>smart-executor</artifactId>
@ -152,31 +141,28 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.gcube.information-system</groupId>
<artifactId>is-sweeper-se-plugin</artifactId>
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.gcube.information-system</groupId>
<artifactId>is-exporter-se-plugin</artifactId>
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.acme</groupId>
<artifactId>HelloWorldPlugin</artifactId>
<version>[1.2.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
<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>
<dependency>
<groupId>org.gcube.information-system</groupId>
<artifactId>resource-registry-api</artifactId>
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
<artifactId>is-sweeper-se-plugin</artifactId>
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.gcube.information-system</groupId>
<artifactId>is-exporter-se-plugin</artifactId>
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
<scope>test</scope>
</dependency>

View File

@ -3,13 +3,6 @@
*/
package org.gcube.accounting.datamodel.usagerecords;
import java.util.concurrent.TimeUnit;
import org.gcube.accounting.datamodel.usagerecords.JobUsageRecord;
import org.gcube.accounting.datamodel.usagerecords.PortletUsageRecord;
import org.gcube.accounting.datamodel.usagerecords.ServiceUsageRecord;
import org.gcube.accounting.datamodel.usagerecords.StorageUsageRecord;
import org.gcube.accounting.datamodel.usagerecords.TaskUsageRecord;
import org.gcube.accounting.persistence.AccountingPersistence;
import org.gcube.accounting.persistence.AccountingPersistenceFactory;
import org.gcube.documentstore.exception.InvalidValueException;
@ -41,7 +34,7 @@ public class AccountingTest extends ScopedTest{
@After
public void after(){
try {
accountingPersistence.flush(1000, TimeUnit.MILLISECONDS);
accountingPersistence.flush();
} catch (Exception e) {
logger.error("Error flushing Buffered Records", e);
}

View File

@ -4,13 +4,7 @@
package org.gcube.documentstore.records;
import java.net.URI;
import org.gcube.accounting.datamodel.UsageRecord.OperationResult;
import org.gcube.accounting.datamodel.aggregation.AggregatedServiceUsageRecord;
import org.gcube.accounting.datamodel.aggregation.AggregatedStorageUsageRecord;
import org.gcube.accounting.datamodel.basetypes.AbstractStorageUsageRecord.DataType;
import org.gcube.accounting.datamodel.basetypes.AbstractStorageUsageRecord.OperationType;
import org.gcube.accounting.datamodel.usagerecords.ServiceUsageRecord;
import org.junit.Assert;
import org.junit.Test;

View File

@ -30,7 +30,7 @@ public class AggregationSchedulerTest extends ScopedTest {
private static final Logger logger = LoggerFactory.getLogger(AggregationSchedulerTest.class);
public static AggregationScheduler getAggregationScheduler(){
return new BufferAggregationScheduler(persistenceExecutor, "TEST");
return new BufferAggregationScheduler(persistenceExecutor);
}
public static PersistenceExecutor persistenceExecutor = new PersistenceExecutor(){

View File

@ -1,71 +0,0 @@
package org.gcube.informationsystem.socialdataindexer;
import java.util.HashMap;
import java.util.Map;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.informationsystem.resource_checker.utils.SendNotification;
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;
/**
* Launch the ResourceCheckerPlugin
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
*/
public class ResourceCheckerPluginSmartExecutorSchedulerTest {
private static Logger logger = LoggerFactory.getLogger(ResourceCheckerPluginSmartExecutorSchedulerTest.class);
private SmartExecutorProxy proxy;
@Before
public void before() throws Exception{
ScopeProvider.instance.set("/gcube");
SecurityTokenProvider.instance.set("2c56a96d-5f17-41a0-94a8-b8efa44d9e7c-98187548"); // gcube scope, ResourceCheckerPlugin application
proxy = ExecutorPlugin.getExecutorProxy("resource-checker-se-plugin").build();
Assert.assertNotNull(proxy);
}
@Test
public void cronExpPreviousMustBeTerminated() throws Exception {
//CronExpression cronExpression = new CronExpression("0 0 0/4 * * ? *"); // every 30 minutes starting from now
CronExpression cronExpression = new CronExpression("0 0 0/1 * * ?"); // every 30 minutes starting from now
Scheduling scheduling = new Scheduling(cronExpression, true);
scheduling.setGlobal(true);
Map<String, Object> inputs = new HashMap<String, Object>();
inputs.put("role", "Administrator");
logger.debug("Inputs : {}", inputs);
LaunchParameter parameter = new LaunchParameter("resource-checker-se-plugin", inputs);
Map<String, String> inputsNotification = new HashMap<String, String>();
inputsNotification.put("recipient", "costantino.perciante");
parameter.addPluginStateNotifications(SendNotification.class, inputsNotification);
parameter.setScheduling(scheduling);
try {
String uuidString = proxy.launch(parameter);
logger.info("Launched with UUID : {}" + uuidString);
} catch(Exception e){
logger.error("Error launching sheduled task" + e);
throw e;
}
}
//@Test
public void unSchedule() throws Exception {
String id = "c2918249-4644-47fb-b151-8f8448f67f05";
//proxy.unSchedule(id, true);
proxy.stop(id);
}
}

View File

@ -1,72 +0,0 @@
/**
*
*/
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.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)
*/
public class SocialDataIndexerPluginSmartExecutorSchedulerTest {
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<String, Object> inputs = new HashMap<String, Object>();
logger.debug("Inputs : {}", inputs);
inputs.put("scope", "gcube");
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);
}
}