Refactoring tests

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/private/luca.frosini/infrastructure-tests@178376 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2019-02-28 15:28:11 +00:00
parent b2b51c2fab
commit 7f41965489
33 changed files with 682 additions and 702 deletions

View File

@ -149,14 +149,14 @@
<dependency>
<groupId>org.gcube.vremanagement</groupId>
<artifactId>smart-executor</artifactId>
<version>[1.4.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
<version>[2.0.0-SNAPSHOT,3.0.0-SNAPSHOT)</version>
<scope>test</scope>
<type>war</type>
</dependency>
<dependency>
<groupId>org.gcube.vremanagement</groupId>
<artifactId>smart-executor-client</artifactId>
<version>[1.3.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
<version>[2.0.0-SNAPSHOT,3.0.0-SNAPSHOT)</version>
<scope>test</scope>
</dependency>
@ -179,14 +179,14 @@
<scope>test</scope>
</dependency>
<!-- 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.gcube.information-system</groupId>
<artifactId>resource-registry</artifactId>

View File

@ -12,11 +12,12 @@ import org.gcube.accounting.aggregator.plugin.AccountingAggregatorPlugin.Elabora
import org.gcube.accounting.aggregator.utility.Utility;
import org.gcube.accounting.datamodel.usagerecords.ServiceUsageRecord;
import org.gcube.accounting.datamodel.usagerecords.StorageUsageRecord;
import org.gcube.testutility.ScopedTest;
import org.gcube.testutility.ContextTest;
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.gcube.vremanagement.executor.client.SmartExecutorClient;
import org.gcube.vremanagement.executor.client.SmartExecutorClientFactory;
import org.gcube.vremanagement.executor.json.SEMapper;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@ -24,17 +25,17 @@ import org.quartz.CronExpression;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class AggregatorAccountingPluginSmartExecutorSchedulerTest extends ScopedTest {
public class AggregatorAccountingPluginSmartExecutorSchedulerTest extends ContextTest {
private static Logger logger = LoggerFactory.getLogger(AggregatorAccountingPluginSmartExecutorSchedulerTest.class);
private SmartExecutorProxy proxy;
private SmartExecutorClient smartExecutorClient;
@Before
public void before() throws Exception {
setContext(ROOT);
proxy = ExecutorPlugin.getExecutorProxy(AccountingAggregatorPluginDeclaration.NAME).build();
Assert.assertNotNull(proxy);
setContext("/gcube");
smartExecutorClient = SmartExecutorClientFactory.create(AccountingAggregatorPluginDeclaration.NAME);
Assert.assertNotNull(smartExecutorClient);
}
@ -44,7 +45,7 @@ public class AggregatorAccountingPluginSmartExecutorSchedulerTest extends Scoped
launchParameter.setScheduling(scheduling);
try {
String uuidString = proxy.launch(launchParameter);
String uuidString = smartExecutorClient.launch(SEMapper.marshal(launchParameter));
logger.debug("Launched with UUID : {}", uuidString);
} catch (Exception e) {
logger.error("Error while launching {}", e);
@ -125,7 +126,7 @@ public class AggregatorAccountingPluginSmartExecutorSchedulerTest extends Scoped
Scheduling scheduling = new Scheduling(cronExpression, true);
scheduling.setGlobal(false);
ScopedTest.setContext(ROOT);
ContextTest.setContextByName("/gcube");
Map<String, Object> inputs = getMonthlyAggregateInputs();
launch(scheduling, inputs);
}
@ -172,12 +173,12 @@ public class AggregatorAccountingPluginSmartExecutorSchedulerTest extends Scoped
@Test
public void unSchedule() throws Exception {
proxy.unSchedule("d06fc539-af83-4dae-a274-c721b4710fcd", true);
smartExecutorClient.delete("d06fc539-af83-4dae-a274-c721b4710fcd", true);
}
@Test
public void stop() throws Exception {
proxy.stop("91178b6e-811f-410d-9cff-ef7b4a7a2475");
smartExecutorClient.delete("91178b6e-811f-410d-9cff-ef7b4a7a2475", true);
}
}

View File

@ -5,7 +5,7 @@ package org.gcube.accounting.analytics.persistence;
import org.gcube.accounting.analytics.persistence.couchbase.AccountingPersistenceQueryCouchBase;
import org.gcube.accounting.persistence.AccountingPersistenceConfiguration;
import org.gcube.testutility.ScopedTest;
import org.gcube.testutility.ContextTest;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -14,7 +14,7 @@ import org.slf4j.LoggerFactory;
* @author Luca Frosini (ISTI - CNR)
*
*/
public class AccountingPersistenceQueryConfigurationTest extends ScopedTest {
public class AccountingPersistenceQueryConfigurationTest extends ContextTest {
private static Logger logger = LoggerFactory.getLogger(AccountingPersistenceQueryConfigurationTest.class);
@ -35,7 +35,7 @@ public class AccountingPersistenceQueryConfigurationTest extends ScopedTest {
.getProperty(AccountingPersistenceConfiguration.USERNAME_PROPERTY_KEY);
String password = persitenceConfiguration
.getProperty(AccountingPersistenceConfiguration.PASSWORD_PROPERTY_KEY);
logger.debug("{} {} - {} : {}", ScopedTest.getCurrentContext(), uri, username, password);
logger.debug("{} {} - {} : {}", ContextTest.getCurrentContext(), uri, username, password);
} catch (IndexOutOfBoundsException e) {
logger.debug("No AccountingPersistenceConfiguration : \n {} {} \n\n", e.getClass().getName(),
e.getMessage());

View File

@ -21,7 +21,7 @@ import org.gcube.accounting.datamodel.usagerecords.ServiceUsageRecord;
import org.gcube.accounting.datamodel.usagerecords.StorageUsageRecord;
import org.gcube.accounting.datamodel.usagerecords.TestUsageRecord;
import org.gcube.documentstore.records.AggregatedRecord;
import org.gcube.testutility.ScopedTest;
import org.gcube.testutility.ContextTest;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@ -32,7 +32,7 @@ import org.slf4j.LoggerFactory;
* @author Luca Frosini (ISTI - CNR)
*
*/
public class AccountingPersistenceQueryFactoryTest extends ScopedTest {
public class AccountingPersistenceQueryFactoryTest extends ContextTest {
private static Logger logger = LoggerFactory
.getLogger(AccountingPersistenceQueryFactoryTest.class);

View File

@ -16,7 +16,7 @@ import org.gcube.accounting.analytics.TemporalConstraint;
import org.gcube.accounting.analytics.TemporalConstraint.AggregationMode;
import org.gcube.accounting.analytics.persistence.AccountingPersistenceBackendQueryConfiguration;
import org.gcube.accounting.datamodel.aggregation.AggregatedStorageUsageRecord;
import org.gcube.testutility.ScopedTest;
import org.gcube.testutility.ContextTest;
import org.json.JSONObject;
import org.junit.Before;
import org.junit.Test;
@ -27,7 +27,7 @@ import org.slf4j.LoggerFactory;
* @author Luca Frosini (ISTI - CNR)
*
*/
public class AccountingPersistenceQueryCouchBaseTest extends ScopedTest {
public class AccountingPersistenceQueryCouchBaseTest extends ContextTest {
private static Logger logger = LoggerFactory.getLogger(AccountingPersistenceQueryCouchBaseTest.class);

View File

@ -9,7 +9,7 @@ import java.util.concurrent.TimeUnit;
import org.gcube.accounting.aggregator.aggregation.AggregationType;
import org.gcube.accounting.aggregator.utility.Utility;
import org.gcube.accounting.analytics.persistence.AccountingPersistenceBackendQueryConfiguration;
import org.gcube.testutility.ScopedTest;
import org.gcube.testutility.ContextTest;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -22,7 +22,7 @@ import com.couchbase.client.java.view.ViewQuery;
import com.couchbase.client.java.view.ViewResult;
import com.couchbase.client.java.view.ViewRow;
public class RemoveOldRecords extends ScopedTest {
public class RemoveOldRecords extends ContextTest {
private static final Logger logger = LoggerFactory.getLogger(RemoveOldRecords.class);

View File

@ -8,7 +8,7 @@ import org.gcube.accounting.persistence.AccountingPersistenceFactory;
import org.gcube.documentstore.exception.InvalidValueException;
import org.gcube.documentstore.exception.NotAggregatableRecordsExceptions;
import org.gcube.documentstore.persistence.PersistenceBackendFactory;
import org.gcube.testutility.ScopedTest;
import org.gcube.testutility.ContextTest;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@ -19,7 +19,7 @@ import org.slf4j.LoggerFactory;
* @author Luca Frosini (ISTI - CNR)
*
*/
public class AccountingTest extends ScopedTest{
public class AccountingTest extends ContextTest{
private static Logger logger = LoggerFactory.getLogger(AccountingTest.class);
@ -27,7 +27,7 @@ public class AccountingTest extends ScopedTest{
@Before
public void before() throws Exception{
PersistenceBackendFactory.forceImmediateRediscovery(ScopedTest.getCurrentContext());
PersistenceBackendFactory.forceImmediateRediscovery(ContextTest.getCurrentContext());
accountingPersistence = AccountingPersistenceFactory.getPersistence();
}

View File

@ -3,24 +3,17 @@
*/
package org.gcube.accounting.datamodel.usagerecords;
import java.util.Set;
import org.gcube.documentstore.exception.InvalidValueException;
import org.gcube.testutility.ScopedTest;
import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.gcube.testutility.ContextTest;
/**
* @author Luca Frosini (ISTI - CNR)
*
*/
public class JobUsageRecordScopedTest extends ScopedTest {
private static Logger logger = LoggerFactory.getLogger(JobUsageRecordScopedTest.class);
public class JobUsageRecordScopedTest extends ContextTest {
/*
private static Logger logger = LoggerFactory.getLogger(JobUsageRecordScopedTest.class);
@Test
public void testRequiredFieldsScoped() throws InvalidValueException{
JobUsageRecord usageRecord = TestUsageRecord.createTestJobUsageRecord();

View File

@ -3,24 +3,17 @@
*/
package org.gcube.accounting.datamodel.usagerecords;
import java.util.Set;
import org.gcube.documentstore.exception.InvalidValueException;
import org.gcube.testutility.ScopedTest;
import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.gcube.testutility.ContextTest;
/**
* @author Luca Frosini (ISTI - CNR)
*
*/
public class ServiceUsageRecordScopedTest extends ScopedTest {
public class ServiceUsageRecordScopedTest extends ContextTest {
/*
private static Logger logger = LoggerFactory.getLogger(ServiceUsageRecordScopedTest.class);
/*
@Test
public void testRequiredFieldsScoped() throws InvalidValueException{
ServiceUsageRecord usageRecord = TestUsageRecord.createTestServiceUsageRecord();

View File

@ -3,24 +3,17 @@
*/
package org.gcube.accounting.datamodel.usagerecords;
import java.util.Set;
import org.gcube.documentstore.exception.InvalidValueException;
import org.gcube.testutility.ScopedTest;
import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.gcube.testutility.ContextTest;
/**
* @author Luca Frosini (ISTI - CNR)
*
*/
public class StorageUsageRecordScopedTest extends ScopedTest {
private static Logger logger = LoggerFactory.getLogger(StorageUsageRecordScopedTest.class);
public class StorageUsageRecordScopedTest extends ContextTest {
/*
private static Logger logger = LoggerFactory.getLogger(StorageUsageRecordScopedTest.class);
@Test
public void testRequiredFieldsScoped() throws InvalidValueException{
StorageUsageRecord usageRecord = TestUsageRecord.createTestStorageUsageRecord();

View File

@ -15,7 +15,7 @@ import org.gcube.common.resources.gcore.ServiceEndpoint.Runtime;
import org.gcube.common.resources.gcore.common.Platform;
import org.gcube.common.resources.gcore.utils.Group;
import org.gcube.documentstore.persistence.PersistenceBackend;
import org.gcube.testutility.ScopedTest;
import org.gcube.testutility.ContextTest;
import org.gcube.testutility.TestUtility;
import org.junit.Assert;
import org.slf4j.Logger;
@ -25,7 +25,7 @@ import org.slf4j.LoggerFactory;
* @author Luca Frosini (ISTI - CNR)
*
*/
public class AccountingPersistenceConfigurationTest extends ScopedTest {
public class AccountingPersistenceConfigurationTest extends ContextTest {
private static final Logger logger = LoggerFactory.getLogger(AccountingPersistenceConfigurationTest.class);
@ -143,7 +143,7 @@ public class AccountingPersistenceConfigurationTest extends ScopedTest {
String uri = persitenceConfiguration.getProperty(AccountingPersistenceConfiguration.URL_PROPERTY_KEY);
String username = persitenceConfiguration.getProperty(AccountingPersistenceConfiguration.USERNAME_PROPERTY_KEY);
String password = persitenceConfiguration.getProperty(AccountingPersistenceConfiguration.PASSWORD_PROPERTY_KEY);
logger.debug("{} - {} - {} - {}", ScopedTest.getCurrentContext(), uri, username, password);
logger.debug("{} - {} - {} - {}", ContextTest.getCurrentContext(), uri, username, password);
}catch(IndexOutOfBoundsException e){
logger.debug("No AccountingPersistenceConfiguration : \n {} {} \n\n", e.getClass().getName(), e.getMessage());
} catch(Exception e){

View File

@ -15,7 +15,7 @@ import org.gcube.documentstore.persistence.PersistenceBackendFactory;
import org.gcube.documentstore.persistence.PersistenceCouchBase;
import org.gcube.informationsystem.publisher.RegistryPublisher;
import org.gcube.informationsystem.publisher.RegistryPublisherFactory;
import org.gcube.testutility.ScopedTest;
import org.gcube.testutility.ContextTest;
import org.junit.Assert;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -24,7 +24,7 @@ import org.slf4j.LoggerFactory;
* @author Luca Frosini (ISTI - CNR)
*
*/
public class PersistenceCouchBaseTest extends ScopedTest {
public class PersistenceCouchBaseTest extends ContextTest {
private static final Logger logger = LoggerFactory.getLogger(PersistenceCouchBaseTest.class);
@ -39,7 +39,7 @@ public class PersistenceCouchBaseTest extends ScopedTest {
RegistryPublisher registryPublisher = RegistryPublisherFactory.create();
try {
logger.debug("Trying to publish to {}:\n{}",ScopedTest.getCurrentContext(), stringWriter);
logger.debug("Trying to publish to {}:\n{}",ContextTest.getCurrentContext(), stringWriter);
registryPublisher.create(resource);
} catch (Exception e) {
logger.error("The resource was not published", e);
@ -56,7 +56,7 @@ public class PersistenceCouchBaseTest extends ScopedTest {
String id = resource.id();
logger.debug("Trying to remove {} with ID {} from {}",
resource.getClass().getSimpleName(), id,
ScopedTest.getCurrentContext());
ContextTest.getCurrentContext());
registryPublisher.remove(resource);
@ -73,12 +73,13 @@ public class PersistenceCouchBaseTest extends ScopedTest {
PersistenceCouchBase.class);
unPublishResource(serviceEndpoint);
}catch(IndexOutOfBoundsException e){
ScopedTest.setContext(ALTERNATIVE_TEST_SCOPE);
String currentContext = ContextTest.getCurrentContext();
ContextTest.setContextByName("/gcube/devsec");
AccountingPersistenceConfiguration persitenceConfiguration = new AccountingPersistenceConfiguration(PersistenceCouchBase.class);
serviceEndpoint = persitenceConfiguration.getServiceEndpoint(
AccountingPersistenceConfiguration.SERVICE_ENDPOINT_CATEGORY, AccountingPersistenceConfiguration.SERVICE_ENDPOINT_NAME,
PersistenceCouchBase.class);
ScopedTest.setContext(DEFAULT_TEST_SCOPE);
ContextTest.setContextByName(currentContext);
}
long startTime = Calendar.getInstance().getTimeInMillis();
@ -88,7 +89,7 @@ public class PersistenceCouchBaseTest extends ScopedTest {
}
logger.debug("Going to check First Time");
PersistenceBackend first = PersistenceBackendFactory.getPersistenceBackend(ScopedTest.getCurrentContext());
PersistenceBackend first = PersistenceBackendFactory.getPersistenceBackend(ContextTest.getCurrentContext());
logger.debug("First {} : {}", PersistenceBackend.class.getSimpleName(), first);
publishResource(serviceEndpoint);
@ -100,7 +101,7 @@ public class PersistenceCouchBaseTest extends ScopedTest {
}
logger.debug("Going to check Second Time");
PersistenceBackend second = PersistenceBackendFactory.getPersistenceBackend(ScopedTest.getCurrentContext());
PersistenceBackend second = PersistenceBackendFactory.getPersistenceBackend(ContextTest.getCurrentContext());
logger.debug("Second {} : {}", PersistenceBackend.class.getSimpleName(), second);
Assert.assertNotEquals(first, second);

View File

@ -2,7 +2,6 @@ package org.gcube.authorization;
import static org.gcube.common.authorization.client.Constants.authorizationService;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
@ -10,7 +9,6 @@ import java.util.ArrayList;
import org.gcube.common.authorization.client.Binder;
import org.gcube.common.authorization.client.Constants;
import org.gcube.common.authorization.library.AuthorizationEntry;
import org.gcube.common.authorization.library.provider.ClientInfo;
import org.gcube.common.authorization.library.provider.ContainerInfo;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.authorization.library.provider.UserInfo;
@ -60,6 +58,8 @@ public class ContextAuthorizationTest extends ContextTest {
}
@Test
public void generateUserToken() throws Exception {
String currentContext = ContextUtility.getCurrentContext();

View File

@ -3,7 +3,7 @@
*/
package org.gcube.discovery;
import org.gcube.testutility.ScopedTest;
import org.gcube.testutility.ContextTest;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -12,7 +12,7 @@ import org.slf4j.LoggerFactory;
* @author Luca Frosini (ISTI - CNR)
*
*/
public class ServiceEndpointInfo extends ScopedTest {
public class ServiceEndpointInfo extends ContextTest {
private static final Logger logger = LoggerFactory.getLogger(ServiceEndpointInfo.class);

View File

@ -8,7 +8,7 @@ import java.util.concurrent.TimeUnit;
import org.gcube.accounting.datamodel.UsageRecord;
import org.gcube.accounting.datamodel.usagerecords.TestUsageRecord;
import org.gcube.documentstore.exception.InvalidValueException;
import org.gcube.testutility.ScopedTest;
import org.gcube.testutility.ContextTest;
import org.gcube.testutility.StressTestUtility;
import org.gcube.testutility.TestOperation;
import org.junit.Test;
@ -19,7 +19,7 @@ import org.slf4j.LoggerFactory;
* @author Luca Frosini (ISTI - CNR)
*
*/
public class PersistenceBackendMonitorTest extends ScopedTest {
public class PersistenceBackendMonitorTest extends ContextTest {
private static final Logger logger = LoggerFactory.getLogger(PersistenceBackendMonitorTest.class);
@ -29,7 +29,7 @@ public class PersistenceBackendMonitorTest extends ScopedTest {
@Test
public void parsingTest() throws Exception {
PersistenceBackendFactory.setFallbackLocation(null);
final PersistenceBackend persistence = PersistenceBackendFactory.getPersistenceBackend(ScopedTest.getCurrentContext());
final PersistenceBackend persistence = PersistenceBackendFactory.getPersistenceBackend(ContextTest.getCurrentContext());
StressTestUtility.stressTest(new TestOperation() {
@ -60,7 +60,7 @@ public class PersistenceBackendMonitorTest extends ScopedTest {
persistence.flush();
logger.debug(" END -----------------------------------------------");
PersistenceBackend persistenceBackend = PersistenceBackendFactory.getPersistenceBackend(ScopedTest.getCurrentContext());
PersistenceBackend persistenceBackend = PersistenceBackendFactory.getPersistenceBackend(ContextTest.getCurrentContext());
if(persistenceBackend instanceof FallbackPersistenceBackend) {
/* This line has no sense in real scenario is only used to avoid null pointer exception in test because
@ -78,7 +78,7 @@ public class PersistenceBackendMonitorTest extends ScopedTest {
@Test
public void singleParsingTest() throws Exception {
PersistenceBackendFactory.setFallbackLocation(null);
PersistenceBackend persistenceBackend = PersistenceBackendFactory.getPersistenceBackend(ScopedTest.getCurrentContext());
PersistenceBackend persistenceBackend = PersistenceBackendFactory.getPersistenceBackend(ContextTest.getCurrentContext());
if(persistenceBackend instanceof FallbackPersistenceBackend) {
/* This line has no sense in real scenario is only used to avoid null pointer exception in test because
* the test has no time to get the real persistence

View File

@ -9,7 +9,7 @@ import java.util.Calendar;
import org.gcube.accounting.datamodel.UsageRecord;
import org.gcube.accounting.datamodel.usagerecords.TestUsageRecord;
import org.gcube.accounting.persistence.AccountingPersistenceFactory;
import org.gcube.testutility.ScopedTest;
import org.gcube.testutility.ContextTest;
import org.gcube.testutility.StressTestUtility;
import org.gcube.testutility.TestOperation;
import org.junit.Assert;
@ -21,14 +21,14 @@ import org.slf4j.LoggerFactory;
* @author Luca Frosini (ISTI - CNR)
*
*/
public class PersistenceBackendTest extends ScopedTest {
public class PersistenceBackendTest extends ContextTest {
private static Logger logger = LoggerFactory.getLogger(PersistenceBackendTest.class);
public static PersistenceBackend getPersistence() throws Exception{
AccountingPersistenceFactory.initAccountingPackages();
PersistenceBackendFactory.setFallbackLocation(null);
return PersistenceBackendFactory.getPersistenceBackend(ScopedTest.getCurrentContext());
return PersistenceBackendFactory.getPersistenceBackend(ContextTest.getCurrentContext());
}
@Test

View File

@ -8,7 +8,7 @@ import org.gcube.accounting.persistence.AccountingPersistenceFactory;
import org.gcube.common.authorization.client.exceptions.ObjectNotFound;
import org.gcube.documentstore.records.DSMapper;
import org.gcube.documentstore.records.Record;
import org.gcube.testutility.ScopedTest;
import org.gcube.testutility.ContextTest;
import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger;
@ -21,7 +21,7 @@ import com.fasterxml.jackson.databind.JsonNode;
* @author Luca Frosini (ISTI - CNR)
*
*/
public class PersistenceCouchBaseTest extends ScopedTest {
public class PersistenceCouchBaseTest extends ContextTest {
private static final Logger logger = LoggerFactory.getLogger(PersistenceCouchBaseTest.class);
@ -29,8 +29,8 @@ public class PersistenceCouchBaseTest extends ScopedTest {
@Test
public void persistenceIsCouchBase() throws ObjectNotFound, Exception {
PersistenceBackendFactory.setFallbackLocation(null);
FallbackPersistenceBackend fallbackPersistenceBackend = PersistenceBackendFactory.createFallback(ScopedTest.getCurrentContext());
PersistenceBackend persistenceBackend = PersistenceBackendFactory.rediscoverPersistenceBackend(fallbackPersistenceBackend, ScopedTest.getCurrentContext());
FallbackPersistenceBackend fallbackPersistenceBackend = PersistenceBackendFactory.createFallback(ContextTest.getCurrentContext());
PersistenceBackend persistenceBackend = PersistenceBackendFactory.rediscoverPersistenceBackend(fallbackPersistenceBackend, ContextTest.getCurrentContext());
Assert.assertTrue(persistenceBackend instanceof PersistenceCouchBase);
}
@ -40,7 +40,7 @@ public class PersistenceCouchBaseTest extends ScopedTest {
AccountingPersistenceFactory.initAccountingPackages();
PersistenceBackendFactory.setFallbackLocation(null);
String context = ScopedTest.getCurrentContext();
String context = ContextTest.getCurrentContext();
PersistenceBackendFactory.forceImmediateRediscovery(context);
PersistenceBackend persistenceBackend = PersistenceBackendFactory.getPersistenceBackend(context);
Assert.assertTrue(persistenceBackend instanceof PersistenceCouchBase);

View File

@ -13,14 +13,14 @@ import java.util.Calendar;
import org.gcube.accounting.datamodel.usagerecords.TestUsageRecord;
import org.gcube.accounting.persistence.AccountingPersistence;
import org.gcube.accounting.persistence.AccountingPersistenceFactory;
import org.gcube.testutility.ScopedTest;
import org.gcube.testutility.ContextTest;
import org.junit.Test;
/**
* @author Luca Frosini (ISTI - CNR)
*
*/
public class RenameFileTest extends ScopedTest {
public class RenameFileTest extends ContextTest {
private final static String ELABORATION_FILE_SUFFIX = ".ELABORATION";

View File

@ -13,7 +13,7 @@ import org.gcube.accounting.datamodel.usagerecords.TestUsageRecord;
import org.gcube.documentstore.persistence.PersistenceExecutor;
import org.gcube.documentstore.records.AggregatedRecord;
import org.gcube.documentstore.records.Record;
import org.gcube.testutility.ScopedTest;
import org.gcube.testutility.ContextTest;
import org.gcube.testutility.StressTestUtility;
import org.gcube.testutility.TestOperation;
import org.junit.Assert;
@ -25,7 +25,7 @@ import org.slf4j.LoggerFactory;
* @author Luca Frosini (ISTI - CNR)
*
*/
public class AggregationSchedulerTest extends ScopedTest {
public class AggregationSchedulerTest extends ContextTest {
private static final Logger logger = LoggerFactory.getLogger(AggregationSchedulerTest.class);

View File

@ -8,15 +8,12 @@ import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.gcube.common.clients.ProxyBuilderImpl;
import org.gcube.testutility.ScopedTest;
import org.gcube.vremanagement.executor.api.SmartExecutor;
import org.gcube.testutility.ContextTest;
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.plugins.query.SmartExecutorPluginQuery;
import org.gcube.vremanagement.executor.client.plugins.query.filter.SpecificEndpointDiscoveryFilter;
import org.gcube.vremanagement.executor.client.proxies.SmartExecutorProxy;
import org.gcube.vremanagement.executor.client.SmartExecutorClient;
import org.gcube.vremanagement.executor.client.SmartExecutorClientFactory;
import org.gcube.vremanagement.executor.json.SEMapper;
import org.gcube.vremanagement.executor.plugin.PluginStateEvolution;
import org.junit.Assert;
import org.junit.Test;
@ -30,10 +27,10 @@ import com.fasterxml.jackson.databind.ObjectMapper;
/**
* @author Luca Frosini (ISTI - CNR)
*/
public class ISExporterPluginSmartExecutorSchedulerTest extends ScopedTest {
public class ISExporterPluginSmartExecutorSchedulerTest extends ContextTest {
private static Logger logger = LoggerFactory.getLogger(ISExporterPluginSmartExecutorSchedulerTest.class);
/*
public UUID scheduleTest(Scheduling scheduling) throws Exception {
Map<String, Object> inputs = new HashMap<String, Object>();
inputs.put(ISExporterPlugin.FILTERED_REPORT, true);
@ -46,9 +43,9 @@ public class ISExporterPluginSmartExecutorSchedulerTest extends ScopedTest {
}
try {
SmartExecutorProxy proxy = ExecutorPlugin.getExecutorProxy(ISExporterPluginDeclaration.NAME).build();
Assert.assertNotNull(proxy);
String uuidString = proxy.launch(parameter);
SmartExecutorClient smartExecutorClient = SmartExecutorClientFactory.create(ISExporterPluginDeclaration.NAME);
Assert.assertNotNull(smartExecutorClient);
String uuidString = smartExecutorClient.launch(SEMapper.marshal(parameter));
return UUID.fromString(uuidString);
} catch(Exception e){
logger.error("Error launching sheduled task", e);
@ -83,7 +80,7 @@ public class ISExporterPluginSmartExecutorSchedulerTest extends ScopedTest {
String token = jsonNode.get(context).asText();
ScopedTest.setContext(token);
ContextTest.setContext(token);
CronExpression cronExpression = new CronExpression(contextSecondMinutes.get(context) + " 0/1 * * ?"); // every hour at contextSecondMinutes.get(token)
Scheduling scheduling = new Scheduling(cronExpression, true);
@ -106,18 +103,18 @@ public class ISExporterPluginSmartExecutorSchedulerTest extends ScopedTest {
@Test
public void cronExpPreviousMustBeTerminated() throws Exception {
Map<String, String> tokenMinutes = new HashMap<>();
tokenMinutes.put(ScopedTest.GCUBE, "0");
tokenMinutes.put(ScopedTest.GCUBE_DEVSEC, "12");
tokenMinutes.put(ScopedTest.GCUBE_DEVSEC_DEVVRE, "24");
tokenMinutes.put(ScopedTest.GCUBE_DEVNEXT, "36");
tokenMinutes.put(ScopedTest.GCUBE_DEVNEXT_NEXTNEXT, "48");
Map<String, String> context_minutes = new HashMap<>();
context_minutes.put("/gcube", "0");
context_minutes.put("/gcube/devsec", "12");
context_minutes.put("/gcube/devsec/devVRE", "24");
context_minutes.put("/gcube/devNext", "36");
context_minutes.put("/gcube/devNext/NextNext", "48");
for(String token : tokenMinutes.keySet()){
for(String context : context_minutes.keySet()){
logger.info("\n\n\n-------------------------------------------------------------------------");
ScopedTest.setContext(token);
ContextTest.setContextByName(context);
CronExpression cronExpression = new CronExpression("0 " + tokenMinutes.get(token) + " 0/1 * * ?"); // every hour at tokenMinutes.get(token) minutes
CronExpression cronExpression = new CronExpression("0 " + context_minutes.get(context) + " 0/1 * * ?"); // every hour at tokenMinutes.get(token) minutes
Scheduling scheduling = new Scheduling(cronExpression, true);
scheduling.setGlobal(true);
@ -132,13 +129,14 @@ public class ISExporterPluginSmartExecutorSchedulerTest extends ScopedTest {
@Test
public void getState() throws Exception {
SmartExecutorProxy proxy = ExecutorPlugin.getExecutorProxy(ISExporterPluginDeclaration.NAME).build();
Assert.assertNotNull(proxy);
SmartExecutorClient smartExecutorClient = SmartExecutorClientFactory.create(ISExporterPluginDeclaration.NAME);
Assert.assertNotNull(smartExecutorClient);
PluginStateEvolution pluginStateEvolution = proxy.getStateEvolution("");
PluginStateEvolution pluginStateEvolution = SEMapper.unmarshal(PluginStateEvolution.class, smartExecutorClient.getPluginStateEvolution("", 1));
logger.debug("{}", pluginStateEvolution);
}
/*
@Test
public void stop() throws Exception {
ExecutorPlugin runExecutorPlugin = new ExecutorPlugin();
@ -181,6 +179,6 @@ public class ISExporterPluginSmartExecutorSchedulerTest extends ScopedTest {
}
}
*/
}

View File

@ -7,11 +7,13 @@ import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.gcube.testutility.ScopedTest;
import org.gcube.accounting.aggregator.plugin.AccountingAggregatorPluginDeclaration;
import org.gcube.testutility.ContextTest;
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.gcube.vremanagement.executor.client.SmartExecutorClient;
import org.gcube.vremanagement.executor.client.SmartExecutorClientFactory;
import org.gcube.vremanagement.executor.json.SEMapper;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@ -22,16 +24,18 @@ import org.slf4j.LoggerFactory;
/**
* @author Luca Frosini (ISTI - CNR)
*/
public class ISSweeperPluginSmartExecutorSchedulerTest extends ScopedTest {
public class ISSweeperPluginSmartExecutorSchedulerTest extends ContextTest {
private static Logger logger = LoggerFactory.getLogger(ISSweeperPluginSmartExecutorSchedulerTest.class);
private SmartExecutorProxy proxy;
private SmartExecutorClient smartExecutorClient;
@Before
public void before() throws Exception{
proxy = ExecutorPlugin.getExecutorProxy(ISSweeperPluginDeclaration.NAME).build();
Assert.assertNotNull(proxy);
public void before() throws Exception {
setContext("/gcube");
smartExecutorClient = SmartExecutorClientFactory.create(AccountingAggregatorPluginDeclaration.NAME);
Assert.assertNotNull(smartExecutorClient);
}
public UUID scheduleTest(Scheduling scheduling) throws Exception {
@ -46,7 +50,7 @@ public class ISSweeperPluginSmartExecutorSchedulerTest extends ScopedTest {
}
try {
String uuidString = proxy.launch(parameter);
String uuidString = smartExecutorClient.launch(SEMapper.marshal(parameter));
return UUID.fromString(uuidString);
} catch(Exception e){
logger.error("Error launching sheduled task", e);
@ -67,7 +71,7 @@ public class ISSweeperPluginSmartExecutorSchedulerTest extends ScopedTest {
//@Test
public void unSchedule() throws Exception {
proxy.unSchedule(null, true);
smartExecutorClient.delete("", true);
}
}

View File

@ -3,7 +3,7 @@ package org.gcube.informationsystem.sweeper;
import java.util.HashMap;
import java.util.Map;
import org.gcube.testutility.ScopedTest;
import org.gcube.testutility.ContextTest;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -11,7 +11,7 @@ import org.slf4j.LoggerFactory;
/**
* @author Luca Frosini (ISTI - CNR)
*/
public class ISSweeperPluginTest extends ScopedTest {
public class ISSweeperPluginTest extends ContextTest {
/**
* Logger

View File

@ -11,7 +11,7 @@ import org.gcube.informationsystem.publisher.RegistryPublisherFactory;
import org.gcube.resources.discovery.client.api.DiscoveryClient;
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
import org.gcube.resources.discovery.icclient.ICFactory;
import org.gcube.testutility.ScopedTest;
import org.gcube.testutility.ContextTest;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -20,7 +20,7 @@ import org.slf4j.LoggerFactory;
* @author Luca Frosini (ISTI - CNR)
*
*/
public class RemoveGoodRITest extends ScopedTest {
public class RemoveGoodRITest extends ContextTest {
private static final Logger logger = LoggerFactory.getLogger(RemoveGoodRITest.class);

View File

@ -88,13 +88,13 @@ public class Lock {
type = LockType.S;
HttpResponse lockResponse = Proxy.createHttpRequest(HttpMethod.PUT, contentType, lockURI);
// HttpResponse lockResponse = Proxy.createHttpRequest(HttpMethod.PUT, contentType, lockURI);
}
public void delete() {
HttpResponse lockResponse = Proxy.createHttpRequest(HttpMethod.DELETE, null, lockURI);
// HttpResponse lockResponse = Proxy.createHttpRequest(HttpMethod.DELETE, null, lockURI);
}
}

View File

@ -11,12 +11,12 @@ import java.util.List;
import java.util.UUID;
import org.gcube.common.resources.gcore.GCoreEndpoint;
import org.gcube.common.resources.gcore.GenericResource;
import org.gcube.common.resources.gcore.HostingNode;
import org.gcube.common.resources.gcore.Resource;
import org.gcube.common.resources.gcore.Resources;
import org.gcube.informationsystem.resourceregistry.api.exceptions.AvailableInAnotherContextException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
import org.gcube.common.resources.gcore.ServiceEndpoint;
import org.gcube.common.resources.gcore.Software;
import org.gcube.informationsystem.resourceregistry.client.ResourceRegistryClient;
import org.gcube.informationsystem.resourceregistry.client.ResourceRegistryClientFactory;
import org.gcube.informationsystem.utils.ISMapper;
@ -24,10 +24,10 @@ import org.gcube.resourcemanagement.model.reference.entities.resources.EService;
import org.gcube.resources.discovery.client.api.DiscoveryClient;
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
import org.gcube.resources.discovery.icclient.ICFactory;
import org.gcube.testutility.ScopedTest;
import org.gcube.testutility.ContextTest;
import org.junit.Test;
public class Statistics extends ScopedTest {
public class Statistics extends ContextTest {
private File directory;
@ -84,10 +84,23 @@ public class Statistics extends ScopedTest {
printLineToFile(stringBuffer.toString(), statisticsFile);
}
private void addToCSV(Resource r, File statisticsFile, boolean addHeader) throws IOException {
StringBuffer stringBuffer = new StringBuffer();
if(addHeader) {
stringBuffer.append(r.getClass().getSimpleName());
stringBuffer.append("(byte size)");
printLineToFile(stringBuffer.toString(), statisticsFile);
stringBuffer = new StringBuffer();
}
String unmarshalledR = getUnmarshalledResource(r);
final byte[] grUTF8Bytes = unmarshalledR.getBytes("UTF-8");
stringBuffer.append(grUTF8Bytes.length);
printLineToFile(stringBuffer.toString(), statisticsFile);
}
@Test
public void test() throws Exception {
ScopedTest.setContext(GCUBE);
ContextTest.setContextByName("/gcube");
boolean first = true;
@ -141,4 +154,58 @@ public class Statistics extends ScopedTest {
}
public <R extends Resource> void analizeInstances(Class<R> clz) throws IOException {
boolean first = true;
File statisticsFile = new File(directory, clz.getSimpleName() + ".csv");
if(statisticsFile.exists()) {
statisticsFile.delete();
}
DiscoveryClient<R> client = ICFactory.clientFor(clz);
SimpleQuery query = ICFactory.queryFor(clz);
List<R> instances = client.submit(query);
for(R r : instances){
addToCSV(r, statisticsFile, first);
first= false;
}
}
@Test
public void generateStatistics() throws Exception {
// directory = new File("/home/lucafrosini/Dropbox/Dottorato/Review Tesi/Statistiche/" + ScopedTest.getCurrentContext());
directory = new File("/home/lucafrosini/Desktop/Statistiche/" + ContextTest.getCurrentContext());
if(!directory.exists()) {
directory.mkdirs();
}
List<Class<? extends Resource>> classes = new ArrayList<>();
classes.add(GCoreEndpoint.class);
classes.add(HostingNode.class);
classes.add(ServiceEndpoint.class);
classes.add(GenericResource.class);
classes.add(Software.class);
for(Class<? extends Resource> clz : classes) {
analizeInstances(clz);
}
}
@Test
public void generateStatisticsForContexts() throws Exception {
List<String> contexts = new ArrayList<>();
contexts.add("/d4science.research-infrastructures.eu");
contexts.add("/d4science.research-infrastructures.eu/gCubeApps");
contexts.add("/d4science.research-infrastructures.eu/SoBigData");
contexts.add("/d4science.research-infrastructures.eu/ParthenosVO");
for(String token : contexts) {
ContextTest.setContextByName(token);
generateStatistics();
}
}
}

View File

@ -0,0 +1,87 @@
/**
*
*/
package org.gcube.testutility;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import org.gcube.common.authorization.client.Constants;
import org.gcube.common.authorization.client.exceptions.ObjectNotFound;
import org.gcube.common.authorization.library.AuthorizationEntry;
import org.gcube.common.authorization.library.provider.AuthorizationProvider;
import org.gcube.common.authorization.library.provider.ClientInfo;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.authorization.library.utils.Caller;
import org.gcube.common.scope.api.ScopeProvider;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author Luca Frosini (ISTI - CNR)
*
*/
public class ContextTest {
private static final Logger logger = LoggerFactory.getLogger(ContextTest.class);
protected static Properties properties;
protected static final String PROPERTIES_FILENAME = "token.properties";
public static final String DEFAULT_TEST_SCOPE_NAME;
static {
properties = new Properties();
InputStream input = ContextTest.class.getClassLoader().getResourceAsStream(PROPERTIES_FILENAME);
try {
// load the properties file
properties.load(input);
} catch(IOException e) {
throw new RuntimeException(e);
}
DEFAULT_TEST_SCOPE_NAME = "/gcube/devsec";
}
public static String getCurrentContext() throws ObjectNotFound, Exception {
return getCurrentContext(SecurityTokenProvider.instance.get());
}
public static String getCurrentContext(String token) throws ObjectNotFound, Exception {
AuthorizationEntry authorizationEntry = Constants.authorizationService().get(token);
String context = authorizationEntry.getContext();
logger.info("Context of token {} is {}", token, context);
return context;
}
public static void setContextByName(String fullContextName) throws ObjectNotFound, Exception {
String token = ContextTest.properties.getProperty(fullContextName);
setContext(token);
}
public static void setContext(String token) throws ObjectNotFound, Exception {
SecurityTokenProvider.instance.set(token);
AuthorizationEntry authorizationEntry = Constants.authorizationService().get(token);
ClientInfo clientInfo = authorizationEntry.getClientInfo();
logger.debug("User : {} - Type : {}", clientInfo.getId(), clientInfo.getType().name());
String qualifier = authorizationEntry.getQualifier();
Caller caller = new Caller(clientInfo, qualifier);
AuthorizationProvider.instance.set(caller);
ScopeProvider.instance.set(getCurrentContext(token));
}
@BeforeClass
public static void beforeClass() throws Exception {
setContextByName(DEFAULT_TEST_SCOPE_NAME);
}
@AfterClass
public static void afterClass() throws Exception {
SecurityTokenProvider.instance.reset();
ScopeProvider.instance.reset();
}
}

View File

@ -1,106 +0,0 @@
/**
*
*/
package org.gcube.testutility;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
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.junit.AfterClass;
import org.junit.BeforeClass;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author Luca Frosini (ISTI - CNR)
*
*/
public class ScopedTest {
private static final Logger logger = LoggerFactory.getLogger(ScopedTest.class);
protected static final String PROPERTIES_FILENAME = "token.properties";
private static final String GCUBE_DEVNEXT_VARNAME = "GCUBE_DEVNEXT";
public static final String GCUBE_DEVNEXT;
private static final String GCUBE_DEVNEXT_NEXTNEXT_VARNAME = "GCUBE_DEVNEXT_NEXTNEXT";
public static final String GCUBE_DEVNEXT_NEXTNEXT;
public static final String GCUBE_DEVSEC_VARNAME = "GCUBE_DEVSEC";
public static final String GCUBE_DEVSEC;
public static final String GCUBE_DEVSEC_DEVVRE_VARNAME = "GCUBE_DEVSEC_DEVVRE";
public static final String GCUBE_DEVSEC_DEVVRE;
public static final String GCUBE_VARNAME = "GCUBE";
public static final String GCUBE;
public static final String ROOT_VARNAME = "ROOT";
public static final String ROOT;
public static final String DEFAULT_TEST_SCOPE;
public static final String ALTERNATIVE_TEST_SCOPE;
static {
Properties properties = new Properties();
InputStream input = ScopedTest.class.getClassLoader().getResourceAsStream(PROPERTIES_FILENAME);
try {
// load the properties file
properties.load(input);
} catch (IOException e) {
throw new RuntimeException(e);
}
GCUBE_DEVNEXT = properties.getProperty(GCUBE_DEVNEXT_VARNAME);
GCUBE_DEVNEXT_NEXTNEXT = properties.getProperty(GCUBE_DEVNEXT_NEXTNEXT_VARNAME);
GCUBE_DEVSEC = properties.getProperty(GCUBE_DEVSEC_VARNAME);
GCUBE_DEVSEC_DEVVRE = properties.getProperty(GCUBE_DEVSEC_DEVVRE_VARNAME);
GCUBE = properties.getProperty(GCUBE_VARNAME);
ROOT = properties.getProperty(ROOT_VARNAME);
DEFAULT_TEST_SCOPE = GCUBE_DEVNEXT;
ALTERNATIVE_TEST_SCOPE = GCUBE_DEVNEXT_NEXTNEXT;
}
public static String getCurrentContext() throws Exception{
String token = SecurityTokenProvider.instance.get();
return getCurrentContext(token);
}
public static String getCurrentContext(String token) throws Exception{
AuthorizationEntry authorizationEntry = Constants.authorizationService().get(token);
String context = authorizationEntry.getContext();
logger.info("Context of token {} is {}", token, context);
return context;
}
public static void setContext(String token) throws Exception{
SecurityTokenProvider.instance.set(token);
ScopeProvider.instance.set(getCurrentContext(token));
}
@BeforeClass
public static void beforeClass() throws Exception{
setContext(DEFAULT_TEST_SCOPE);
}
@AfterClass
public static void afterClass() throws Exception{
SecurityTokenProvider.instance.reset();
ScopeProvider.instance.reset();
}
}

View File

@ -38,7 +38,7 @@ public class TestUtility {
RegistryPublisher registryPublisher = RegistryPublisherFactory.create();
try {
logger.debug("Trying to publish to {}:\n{}", ScopedTest.getCurrentContext(), stringWriter);
logger.debug("Trying to publish to {}:\n{}", ContextTest.getCurrentContext(), stringWriter);
registryPublisher.create(resource);
} catch (Exception e) {
logger.error("The resource was not published", e);
@ -59,7 +59,7 @@ public class TestUtility {
RegistryPublisher registryPublisher = RegistryPublisherFactory.create();
String id = resource.id();
logger.debug("Trying to remove {} with ID {} from {}", resource.getClass().getSimpleName(), id, ScopedTest.getCurrentContext());
logger.debug("Trying to remove {} with ID {} from {}", resource.getClass().getSimpleName(), id, ContextTest.getCurrentContext());
registryPublisher.remove(resource);

View File

@ -9,13 +9,13 @@ import java.util.Calendar;
import java.util.Map;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
*/
import org.gcube.testutility.ScopedTest;
import org.gcube.testutility.ContextTest;
/**
* @author Luca Frosini (ISTI - CNR)
*
*/
public class GCoreEndPointCreationTest extends ScopedTest {
public class GCoreEndPointCreationTest extends ContextTest {
//private static Logger logger = LoggerFactory.getLogger(GCoreEndPointCreationTest.class);

View File

@ -8,7 +8,7 @@ import java.util.concurrent.TimeUnit;
import org.acme.HWPluginStateNotification;
import org.acme.HelloWorldPlugin;
import org.acme.HelloWorldPluginDeclaration;
import org.gcube.testutility.ScopedTest;
import org.gcube.testutility.ContextTest;
import org.gcube.vremanagement.executor.api.rest.SmartExecutor;
import org.gcube.vremanagement.executor.api.types.LaunchParameter;
import org.gcube.vremanagement.executor.api.types.Scheduling;
@ -26,7 +26,7 @@ import org.slf4j.LoggerFactory;
/**
* @author Luca Frosini (ISTI - CNR)
*/
public class DefaultExecutorTest extends ScopedTest {
public class DefaultExecutorTest extends ContextTest {
private static Logger logger = LoggerFactory.getLogger(DefaultExecutorTest.class);

View File

@ -4,21 +4,16 @@
package org.gcube.vremanagement.executor.rest.client;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.acme.HelloWorldPlugin;
import org.acme.HelloWorldPluginDeclaration;
import org.gcube.common.clients.exceptions.DiscoveryException;
import org.gcube.testutility.ScopedTest;
import org.gcube.testutility.ContextTest;
import org.gcube.vremanagement.executor.api.rest.SmartExecutor;
import org.gcube.vremanagement.executor.api.types.LaunchParameter;
import org.gcube.vremanagement.executor.client.Constants;
import org.gcube.vremanagement.executor.client.SmartExecutorClientFactory;
import org.gcube.vremanagement.executor.client.query.Discover;
import org.gcube.vremanagement.executor.client.query.filter.impl.RandomGCoreEndpointQueryFilter;
import org.gcube.vremanagement.executor.client.query.filter.impl.SpecificGCoreEndpointQueryFilter;
import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger;
@ -28,7 +23,7 @@ import org.slf4j.LoggerFactory;
* @author Luca Frosini (ISTI - CNR)
*
*/
public class QueriedClientTest extends ScopedTest {
public class QueriedClientTest extends ContextTest {
private static Logger logger = LoggerFactory.getLogger(QueriedClientTest.class);
@ -59,8 +54,7 @@ public class QueriedClientTest extends ScopedTest {
HelloWorldPluginDeclaration helloWorldPluginDeclaration = new HelloWorldPluginDeclaration();
Map<String,String> capabilities = helloWorldPluginDeclaration.getSupportedCapabilities();
SmartExecutor smartExecutor = SmartExecutorClientFactory.create(HelloWorldPluginDeclaration.NAME, capabilities,
null, null);
SmartExecutor smartExecutor = SmartExecutorClientFactory.create(HelloWorldPluginDeclaration.NAME, capabilities);
Assert.assertNotNull(smartExecutor);
try {
@ -76,8 +70,7 @@ public class QueriedClientTest extends ScopedTest {
Map<String,String> capabilities = helloWorldPluginDeclaration.getSupportedCapabilities();
capabilities.put("Version", helloWorldPluginDeclaration.getVersion());
SmartExecutor smartExecutor = SmartExecutorClientFactory.create(HelloWorldPluginDeclaration.NAME, capabilities,
null, null);
SmartExecutor smartExecutor = SmartExecutorClientFactory.create(HelloWorldPluginDeclaration.NAME, capabilities);
Assert.assertNotNull(smartExecutor);
launchTest(smartExecutor);
@ -90,7 +83,7 @@ public class QueriedClientTest extends ScopedTest {
try {
SmartExecutor smartExecutor = SmartExecutorClientFactory.create(HelloWorldPluginDeclaration.NAME,
capabilities, null, null);
capabilities);
Assert.assertNull(smartExecutor);
} catch(DiscoveryException e) {
// OK
@ -98,7 +91,7 @@ public class QueriedClientTest extends ScopedTest {
throw e;
}
}
/*
@Test
public void testManagedPersonalfilters() throws Exception {
HelloWorldPluginDeclaration helloWorldPluginDeclaration = new HelloWorldPluginDeclaration();
@ -128,5 +121,5 @@ public class QueriedClientTest extends ScopedTest {
}
}
*/
}

View File

@ -3,218 +3,197 @@
*/
package org.gcube.vremanagement.executor.soap.client;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import org.acme.HWPluginStateNotification;
import org.acme.HelloWorldPlugin;
import org.acme.HelloWorldPluginDeclaration;
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.gcube.vremanagement.executor.exception.PluginInstanceNotFoundException;
import org.gcube.vremanagement.executor.exception.PluginNotFoundException;
import org.gcube.vremanagement.executor.json.SEMapper;
import org.gcube.vremanagement.executor.plugin.PluginState;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.gcube.testutility.ContextTest;
/**
* @author Luca Frosini (ISTI - CNR)
*/
@SuppressWarnings("deprecation")
public class DefaultExecutorTest extends ScopedTest {
private static Logger logger = LoggerFactory.getLogger(DefaultExecutorTest.class);
private SmartExecutorProxy proxy;
@Before
public void before() throws Exception{
proxy = ExecutorPlugin.getExecutorProxy(HelloWorldPluginDeclaration.NAME).build();
Assert.assertNotNull(proxy);
}
@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) {
Assert.assertEquals(PluginNotFoundException.class, e.getCause().getClass());
}
}
@Test
public void getState() throws Exception {
String executionIdentifier = UUID.randomUUID().toString();
try {
proxy.getStateEvolution(executionIdentifier);
} catch (Exception e) {
Assert.assertEquals(PluginInstanceNotFoundException.class, e.getCause().getClass());
}
}
@Test
public void testOk() throws Exception {
Map<String, Object> inputs = new HashMap<String, Object>();
inputs.put("Hello", "World");
long sleepTime = TimeUnit.SECONDS.toMillis(10);
inputs.put(HelloWorldPlugin.SLEEP_TIME, sleepTime);
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 {
String executionIdentifier = proxy.launch(launchParameter);
logger.debug("Execution Identifier {}", executionIdentifier);
Thread.sleep(TimeUnit.SECONDS.toMillis(1)); // 1 sec
Assert.assertEquals(PluginState.RUNNING, proxy.getStateEvolution(executionIdentifier).getPluginState());
Thread.sleep(TimeUnit.SECONDS.toMillis(4)); // 1 + 4 sec (total : 5 sec)
Assert.assertEquals(PluginState.RUNNING, proxy.getStateEvolution(executionIdentifier).getPluginState());
Thread.sleep(TimeUnit.SECONDS.toMillis(6)); // 5 + 6 sec (total : 11 sec)
Assert.assertEquals(PluginState.DONE, proxy.getStateEvolution(executionIdentifier).getPluginState());
} catch (Exception e) {
logger.error("testOk Exception", e);
throw e;
}
}
@Test
public void testSerilization() throws Exception {
Map<String, Object> inputs = new HashMap<String, Object>();
inputs.put("Hello", "World");
long sleepTime = TimeUnit.SECONDS.toMillis(20);
inputs.put(HelloWorldPlugin.SLEEP_TIME, sleepTime);
int minuteinterval = 2;
// Every 5 minutes, for 12 times (one hour totally).
Scheduling scheduling = new Scheduling(60*minuteinterval,12,true);
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);
logger.debug(SEMapper.marshal(launchParameter));
}
public class DefaultExecutorTest extends ContextTest {
@Test
public void testScheduledTaskNotPersisted() throws Exception {
Map<String, Object> inputs = new HashMap<String, Object>();
inputs.put("Hello", "World");
long sleepTime = TimeUnit.SECONDS.toMillis(10);
inputs.put(HelloWorldPlugin.SLEEP_TIME, sleepTime);
int minuteinterval = 2;
// Every 5 minutes, for 12 times (one hour totally).
Scheduling scheduling = new Scheduling(60*minuteinterval,12,true);
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 {
String executionIdentifier = proxy.launch(launchParameter);
Thread.sleep(TimeUnit.SECONDS.toMillis(1));
Assert.assertEquals(PluginState.RUNNING, proxy.getStateEvolution(executionIdentifier).getPluginState());
Thread.sleep(TimeUnit.SECONDS.toMillis(4));
Assert.assertEquals(PluginState.RUNNING, proxy.getStateEvolution(executionIdentifier).getPluginState());
Thread.sleep(TimeUnit.SECONDS.toMillis(6));
Assert.assertEquals(PluginState.DONE, proxy.getStateEvolution(executionIdentifier).getPluginState());
// Thread.sleep(1000*60*minuteinterval); // 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) {
logger.error("testOk Exception", e);
throw e;
}
}
//@Test
public void testScheduledTaskPersisted() throws Exception {
proxy = ExecutorPlugin.getExecutorProxy((new HelloWorldPluginDeclaration()).getName()).build();
Assert.assertNotNull(proxy);
Map<String, Object> inputs = new HashMap<String, Object>();
inputs.put("Hello", "World");
long sleepTime = TimeUnit.SECONDS.toMillis(20); // 1000 millisec * 20 = 20 sec
inputs.put(HelloWorldPlugin.SLEEP_TIME, sleepTime);
// Every 5 minutes, for 12 times (one hour totally).
Scheduling scheduling = new Scheduling(60*5,2,true);
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 {
String executionIdentifier = proxy.launch(launchParameter);
logger.debug("Task Lauched with ID : {}", executionIdentifier);
Thread.sleep(TimeUnit.SECONDS.toMillis(1));
Assert.assertEquals(PluginState.RUNNING, proxy.getStateEvolution(executionIdentifier).getPluginState());
Thread.sleep(TimeUnit.SECONDS.toMillis(4));
Assert.assertEquals(PluginState.RUNNING, proxy.getStateEvolution(executionIdentifier).getPluginState());
Thread.sleep(TimeUnit.SECONDS.toMillis(6));
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) {
logger.error("testOk Exception", 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);
}
// private static Logger logger = LoggerFactory.getLogger(DefaultExecutorTest.class);
//
// private SmartExecutorProxy proxy;
//
// @Before
// public void before() throws Exception{
// proxy = ExecutorPlugin.getExecutorProxy(HelloWorldPluginDeclaration.NAME).build();
// Assert.assertNotNull(proxy);
// }
//
// @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) {
// Assert.assertEquals(PluginNotFoundException.class, e.getCause().getClass());
// }
// }
//
// @Test
// public void getState() throws Exception {
// String executionIdentifier = UUID.randomUUID().toString();
// try {
// proxy.getStateEvolution(executionIdentifier);
// } catch (Exception e) {
// Assert.assertEquals(PluginInstanceNotFoundException.class, e.getCause().getClass());
// }
// }
//
// @Test
// public void testOk() throws Exception {
// Map<String, Object> inputs = new HashMap<String, Object>();
// inputs.put("Hello", "World");
// long sleepTime = TimeUnit.SECONDS.toMillis(10);
// inputs.put(HelloWorldPlugin.SLEEP_TIME, sleepTime);
// 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 {
// String executionIdentifier = proxy.launch(launchParameter);
// logger.debug("Execution Identifier {}", executionIdentifier);
//
// Thread.sleep(TimeUnit.SECONDS.toMillis(1)); // 1 sec
// Assert.assertEquals(PluginState.RUNNING, proxy.getStateEvolution(executionIdentifier).getPluginState());
//
//
// Thread.sleep(TimeUnit.SECONDS.toMillis(4)); // 1 + 4 sec (total : 5 sec)
// Assert.assertEquals(PluginState.RUNNING, proxy.getStateEvolution(executionIdentifier).getPluginState());
//
// Thread.sleep(TimeUnit.SECONDS.toMillis(6)); // 5 + 6 sec (total : 11 sec)
// Assert.assertEquals(PluginState.DONE, proxy.getStateEvolution(executionIdentifier).getPluginState());
//
// } catch (Exception e) {
// logger.error("testOk Exception", e);
// throw e;
// }
//
// }
//
// @Test
// public void testSerilization() throws Exception {
// Map<String, Object> inputs = new HashMap<String, Object>();
// inputs.put("Hello", "World");
// long sleepTime = TimeUnit.SECONDS.toMillis(20);
// inputs.put(HelloWorldPlugin.SLEEP_TIME, sleepTime);
// int minuteinterval = 2;
// // Every 5 minutes, for 12 times (one hour totally).
// Scheduling scheduling = new Scheduling(60*minuteinterval,12,true);
// 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);
//
//
//
// logger.debug(SEMapper.marshal(launchParameter));
// }
//
//
// @Test
// public void testScheduledTaskNotPersisted() throws Exception {
// Map<String, Object> inputs = new HashMap<String, Object>();
// inputs.put("Hello", "World");
// long sleepTime = TimeUnit.SECONDS.toMillis(10);
// inputs.put(HelloWorldPlugin.SLEEP_TIME, sleepTime);
// int minuteinterval = 2;
// // Every 5 minutes, for 12 times (one hour totally).
// Scheduling scheduling = new Scheduling(60*minuteinterval,12,true);
// 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 {
// String executionIdentifier = proxy.launch(launchParameter);
//
// Thread.sleep(TimeUnit.SECONDS.toMillis(1));
// Assert.assertEquals(PluginState.RUNNING, proxy.getStateEvolution(executionIdentifier).getPluginState());
//
// Thread.sleep(TimeUnit.SECONDS.toMillis(4));
// Assert.assertEquals(PluginState.RUNNING, proxy.getStateEvolution(executionIdentifier).getPluginState());
//
// Thread.sleep(TimeUnit.SECONDS.toMillis(6));
// Assert.assertEquals(PluginState.DONE, proxy.getStateEvolution(executionIdentifier).getPluginState());
//
// // Thread.sleep(1000*60*minuteinterval); // 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) {
// logger.error("testOk Exception", e);
// throw e;
// }
//
// }
//
// //@Test
// public void testScheduledTaskPersisted() throws Exception {
// proxy = ExecutorPlugin.getExecutorProxy((new HelloWorldPluginDeclaration()).getName()).build();
// Assert.assertNotNull(proxy);
//
// Map<String, Object> inputs = new HashMap<String, Object>();
// inputs.put("Hello", "World");
// long sleepTime = TimeUnit.SECONDS.toMillis(20); // 1000 millisec * 20 = 20 sec
// inputs.put(HelloWorldPlugin.SLEEP_TIME, sleepTime);
// // Every 5 minutes, for 12 times (one hour totally).
// Scheduling scheduling = new Scheduling(60*5,2,true);
// 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 {
// String executionIdentifier = proxy.launch(launchParameter);
// logger.debug("Task Lauched with ID : {}", executionIdentifier);
//
// Thread.sleep(TimeUnit.SECONDS.toMillis(1));
// Assert.assertEquals(PluginState.RUNNING, proxy.getStateEvolution(executionIdentifier).getPluginState());
//
// Thread.sleep(TimeUnit.SECONDS.toMillis(4));
// Assert.assertEquals(PluginState.RUNNING, proxy.getStateEvolution(executionIdentifier).getPluginState());
//
// Thread.sleep(TimeUnit.SECONDS.toMillis(6));
// 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) {
// logger.error("testOk Exception", 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);
// }
}

View File

@ -3,238 +3,215 @@
*/
package org.gcube.vremanagement.executor.soap.client;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.acme.HelloWorldPlugin;
import org.acme.HelloWorldPluginDeclaration;
import org.gcube.common.clients.ProxyBuilderImpl;
import org.gcube.common.clients.exceptions.DiscoveryException;
import org.gcube.testutility.ScopedTest;
import org.gcube.vremanagement.executor.api.SmartExecutor;
import org.gcube.vremanagement.executor.api.types.LaunchParameter;
import org.gcube.vremanagement.executor.client.plugins.ExecutorPlugin;
import org.gcube.vremanagement.executor.client.plugins.query.SmartExecutorPluginQuery;
import org.gcube.vremanagement.executor.client.plugins.query.filter.ListEndpointDiscoveryFilter;
import org.gcube.vremanagement.executor.client.plugins.query.filter.RandomEndpointDiscoveryFilter;
import org.gcube.vremanagement.executor.client.plugins.query.filter.SpecificEndpointDiscoveryFilter;
import org.gcube.vremanagement.executor.client.proxies.SmartExecutorProxy;
import org.gcube.vremanagement.executor.client.util.Tuple;
import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.gcube.testutility.ContextTest;
/**
* @author Luca Frosini (ISTI - CNR)
*
*/
@SuppressWarnings("deprecation")
public class QueriedClientTest extends ScopedTest {
public class QueriedClientTest extends ContextTest {
private static Logger logger = LoggerFactory.getLogger(QueriedClientTest.class);
private void launchTest(SmartExecutorProxy proxy) throws Exception {
Map<String, Object> inputs = new HashMap<String, Object>();
inputs.put("Hello", "World");
long sleepTime = 10000;
inputs.put(HelloWorldPlugin.SLEEP_TIME, sleepTime);
LaunchParameter launchParameter = new LaunchParameter(HelloWorldPluginDeclaration.NAME, inputs);
try {
String executionIdentifier = proxy.launch(launchParameter);
proxy.getStateEvolution(executionIdentifier);
} catch (Exception e) {
throw e;
}
}
@Test
public void testNoConditions() throws Exception {
SmartExecutorProxy proxy = ExecutorPlugin.getExecutorProxy(HelloWorldPluginDeclaration.NAME).build();
Assert.assertNotNull(proxy);
try {
launchTest(proxy);
} catch (Exception e) {
logger.error("testNoConditions Exception", e);
throw e;
}
}
@Test
public void testWithSingleRightConditions() throws Exception {
HelloWorldPluginDeclaration helloWorldPluginDeclaration = new HelloWorldPluginDeclaration();
Map<String,String> map = helloWorldPluginDeclaration.getSupportedCapabilities();
Tuple<String, String> tuple = new Tuple<String, String>();
for(String key : map.keySet()){
tuple = new Tuple<String, String>(key, map.get(key));
break; // Get only the first
}
SmartExecutorProxy proxy = ExecutorPlugin.getExecutorProxy(HelloWorldPluginDeclaration.NAME, tuple).build();
Assert.assertNotNull(proxy);
try {
launchTest(proxy);
} catch (Exception e) {
logger.error("testWithSingleRighConditions Exception", e);
throw e;
}
}
@Test
public void testWithMultipleRightConditions() throws Exception {
HelloWorldPluginDeclaration helloWorldPluginDeclaration = new HelloWorldPluginDeclaration();
Map<String,String> map = helloWorldPluginDeclaration.getSupportedCapabilities();
@SuppressWarnings("unchecked")
Tuple<String, String>[] tuples = new Tuple[map.size()+1];
int i = 0;
for(String key : map.keySet()){
tuples[i] = new Tuple<String, String>(key, map.get(key));
++i;
}
tuples[i] = new Tuple<String, String>("Version", helloWorldPluginDeclaration.getVersion());
SmartExecutorProxy proxy = ExecutorPlugin.getExecutorProxy(HelloWorldPluginDeclaration.NAME, tuples).build();
Assert.assertNotNull(proxy);
try {
launchTest(proxy);
} catch (Exception e) {
logger.error("testWithMultipleRighConditions Exception", e);
throw e;
}
}
@Test
public void testWithUnsatisfiedConditions() {
Tuple<String, String> tuple = new Tuple<String, String>("Unsatisfied", "Condition");
SmartExecutorProxy proxy = ExecutorPlugin.getExecutorProxy(HelloWorldPluginDeclaration.NAME, tuple).build();
Assert.assertNotNull(proxy);
try {
launchTest(proxy);
} catch (Exception e) {
Assert.assertEquals(DiscoveryException.class, e.getClass());
}
}
@SuppressWarnings("unchecked")
@Test
public void testWithPersonalfilters() throws Exception {
ExecutorPlugin executorPlugin = new ExecutorPlugin();
SmartExecutorPluginQuery query = new SmartExecutorPluginQuery(executorPlugin);
HelloWorldPluginDeclaration helloWorldPluginDeclaration = new HelloWorldPluginDeclaration();
Map<String,String> map = helloWorldPluginDeclaration.getSupportedCapabilities();
Tuple<String, String> tuple = new Tuple<String, String>();
for(String key : map.keySet()){
tuple = new Tuple<String, String>(key, map.get(key));
break; // Get only the first
}
query.addConditions(HelloWorldPluginDeclaration.NAME, tuple);
query.setServiceEndpointQueryFilter(null);
query.setEndpointDiscoveryFilter(null);
SmartExecutorProxy proxy = new ProxyBuilderImpl<SmartExecutor, SmartExecutorProxy>(executorPlugin, query).build();
try {
launchTest(proxy);
} catch (Exception e) {
logger.error("testWithPersonalfilters Exception", e);
throw e;
}
}
@Test
public void testManagedPersonalfilters() throws Exception {
HelloWorldPluginDeclaration helloWorldPluginDeclaration = new HelloWorldPluginDeclaration();
Map<String,String> map = helloWorldPluginDeclaration.getSupportedCapabilities();
@SuppressWarnings("unchecked")
Tuple<String, String>[] tuples = new Tuple[map.size()];
int i = 0;
for(String key : map.keySet()){
tuples[i] = new Tuple<String, String>(key, map.get(key));
++i;
}
SmartExecutorProxy proxy = ExecutorPlugin.getExecutorProxy(HelloWorldPluginDeclaration.NAME, tuples, null, new RandomEndpointDiscoveryFilter()).build();
Assert.assertNotNull(proxy);
try {
launchTest(proxy);
} catch (Exception e) {
logger.error("testManagedPersonalfilters Exception", e);
throw e;
}
}
@SuppressWarnings("unchecked")
@Test
public void testWithListfilters() throws Exception {
ExecutorPlugin executorPlugin = new ExecutorPlugin();
SmartExecutorPluginQuery query = new SmartExecutorPluginQuery(executorPlugin);
HelloWorldPluginDeclaration helloWorldPluginDeclaration = new HelloWorldPluginDeclaration();
Map<String,String> map = helloWorldPluginDeclaration.getSupportedCapabilities();
Tuple<String, String> tuple = new Tuple<String, String>();
for(String key : map.keySet()){
tuple = new Tuple<String, String>(key, map.get(key));
break; // Get only the first
}
query.addConditions(HelloWorldPluginDeclaration.NAME, tuple);
query.setServiceEndpointQueryFilter(null);
query.setEndpointDiscoveryFilter(new ListEndpointDiscoveryFilter());
SmartExecutorProxy proxy = new ProxyBuilderImpl<SmartExecutor, SmartExecutorProxy>(executorPlugin, query).build();
try {
launchTest(proxy);
} catch (Exception e) {
logger.error("testWithListfilters Exception", e);
throw e;
}
}
@SuppressWarnings("unchecked")
@Test
public void testWithSpecificSelection() throws Exception {
ExecutorPlugin executorPlugin = new ExecutorPlugin();
SmartExecutorPluginQuery query = new SmartExecutorPluginQuery(executorPlugin);
HelloWorldPluginDeclaration helloWorldPluginDeclaration = new HelloWorldPluginDeclaration();
Map<String,String> map = helloWorldPluginDeclaration.getSupportedCapabilities();
Tuple<String, String> tuple = new Tuple<String, String>();
for(String key : map.keySet()){
tuple = new Tuple<String, String>(key, map.get(key));
break; // Get only the first
}
query.addConditions(HelloWorldPluginDeclaration.NAME, tuple);
query.setServiceEndpointQueryFilter(null);
List<String> endpoints = query.discoverEndpoints(new ListEndpointDiscoveryFilter());
for(String endpoint : endpoints){
ExecutorPlugin runExecutorPlugin = new ExecutorPlugin();
SmartExecutorPluginQuery runQuery = new SmartExecutorPluginQuery(runExecutorPlugin);
runQuery.addConditions(HelloWorldPluginDeclaration.NAME, tuple);
SpecificEndpointDiscoveryFilter sedf = new SpecificEndpointDiscoveryFilter(endpoint);
runQuery.setEndpointDiscoveryFilter(sedf);
SmartExecutorProxy proxy = new ProxyBuilderImpl<SmartExecutor, SmartExecutorProxy>(runExecutorPlugin, runQuery).build();
try {
launchTest(proxy);
} catch (Exception e) {
logger.error("testWithSpecificSelection Exception", e);
throw e;
}
}
}
// private static Logger logger = LoggerFactory.getLogger(QueriedClientTest.class);
//
// private void launchTest(SmartExecutorProxy proxy) throws Exception {
// Map<String, Object> inputs = new HashMap<String, Object>();
// inputs.put("Hello", "World");
// long sleepTime = 10000;
// inputs.put(HelloWorldPlugin.SLEEP_TIME, sleepTime);
// LaunchParameter launchParameter = new LaunchParameter(HelloWorldPluginDeclaration.NAME, inputs);
// try {
// String executionIdentifier = proxy.launch(launchParameter);
// proxy.getStateEvolution(executionIdentifier);
// } catch (Exception e) {
// throw e;
// }
// }
//
// @Test
// public void testNoConditions() throws Exception {
// SmartExecutorProxy proxy = ExecutorPlugin.getExecutorProxy(HelloWorldPluginDeclaration.NAME).build();
// Assert.assertNotNull(proxy);
//
// try {
// launchTest(proxy);
// } catch (Exception e) {
// logger.error("testNoConditions Exception", e);
// throw e;
// }
//
// }
//
// @Test
// public void testWithSingleRightConditions() throws Exception {
// HelloWorldPluginDeclaration helloWorldPluginDeclaration = new HelloWorldPluginDeclaration();
// Map<String,String> map = helloWorldPluginDeclaration.getSupportedCapabilities();
// Tuple<String, String> tuple = new Tuple<String, String>();
// for(String key : map.keySet()){
// tuple = new Tuple<String, String>(key, map.get(key));
// break; // Get only the first
// }
// SmartExecutorProxy proxy = ExecutorPlugin.getExecutorProxy(HelloWorldPluginDeclaration.NAME, tuple).build();
// Assert.assertNotNull(proxy);
//
// try {
// launchTest(proxy);
// } catch (Exception e) {
// logger.error("testWithSingleRighConditions Exception", e);
// throw e;
// }
// }
//
// @Test
// public void testWithMultipleRightConditions() throws Exception {
// HelloWorldPluginDeclaration helloWorldPluginDeclaration = new HelloWorldPluginDeclaration();
// Map<String,String> map = helloWorldPluginDeclaration.getSupportedCapabilities();
//
// @SuppressWarnings("unchecked")
// Tuple<String, String>[] tuples = new Tuple[map.size()+1];
// int i = 0;
// for(String key : map.keySet()){
// tuples[i] = new Tuple<String, String>(key, map.get(key));
// ++i;
// }
//
// tuples[i] = new Tuple<String, String>("Version", helloWorldPluginDeclaration.getVersion());
//
// SmartExecutorProxy proxy = ExecutorPlugin.getExecutorProxy(HelloWorldPluginDeclaration.NAME, tuples).build();
// Assert.assertNotNull(proxy);
//
// try {
// launchTest(proxy);
// } catch (Exception e) {
// logger.error("testWithMultipleRighConditions Exception", e);
// throw e;
// }
// }
//
// @Test
// public void testWithUnsatisfiedConditions() {
// Tuple<String, String> tuple = new Tuple<String, String>("Unsatisfied", "Condition");
// SmartExecutorProxy proxy = ExecutorPlugin.getExecutorProxy(HelloWorldPluginDeclaration.NAME, tuple).build();
// Assert.assertNotNull(proxy);
// try {
// launchTest(proxy);
// } catch (Exception e) {
// Assert.assertEquals(DiscoveryException.class, e.getClass());
// }
// }
//
// @SuppressWarnings("unchecked")
// @Test
// public void testWithPersonalfilters() throws Exception {
// ExecutorPlugin executorPlugin = new ExecutorPlugin();
// SmartExecutorPluginQuery query = new SmartExecutorPluginQuery(executorPlugin);
// HelloWorldPluginDeclaration helloWorldPluginDeclaration = new HelloWorldPluginDeclaration();
// Map<String,String> map = helloWorldPluginDeclaration.getSupportedCapabilities();
// Tuple<String, String> tuple = new Tuple<String, String>();
// for(String key : map.keySet()){
// tuple = new Tuple<String, String>(key, map.get(key));
// break; // Get only the first
// }
//
// query.addConditions(HelloWorldPluginDeclaration.NAME, tuple);
// query.setServiceEndpointQueryFilter(null);
// query.setEndpointDiscoveryFilter(null);
//
// SmartExecutorProxy proxy = new ProxyBuilderImpl<SmartExecutor, SmartExecutorProxy>(executorPlugin, query).build();
//
// try {
// launchTest(proxy);
// } catch (Exception e) {
// logger.error("testWithPersonalfilters Exception", e);
// throw e;
// }
// }
//
// @Test
// public void testManagedPersonalfilters() throws Exception {
// HelloWorldPluginDeclaration helloWorldPluginDeclaration = new HelloWorldPluginDeclaration();
// Map<String,String> map = helloWorldPluginDeclaration.getSupportedCapabilities();
// @SuppressWarnings("unchecked")
// Tuple<String, String>[] tuples = new Tuple[map.size()];
// int i = 0;
// for(String key : map.keySet()){
// tuples[i] = new Tuple<String, String>(key, map.get(key));
// ++i;
// }
//
// SmartExecutorProxy proxy = ExecutorPlugin.getExecutorProxy(HelloWorldPluginDeclaration.NAME, tuples, null, new RandomEndpointDiscoveryFilter()).build();
// Assert.assertNotNull(proxy);
//
// try {
// launchTest(proxy);
// } catch (Exception e) {
// logger.error("testManagedPersonalfilters Exception", e);
// throw e;
// }
// }
//
// @SuppressWarnings("unchecked")
// @Test
// public void testWithListfilters() throws Exception {
// ExecutorPlugin executorPlugin = new ExecutorPlugin();
// SmartExecutorPluginQuery query = new SmartExecutorPluginQuery(executorPlugin);
// HelloWorldPluginDeclaration helloWorldPluginDeclaration = new HelloWorldPluginDeclaration();
// Map<String,String> map = helloWorldPluginDeclaration.getSupportedCapabilities();
// Tuple<String, String> tuple = new Tuple<String, String>();
// for(String key : map.keySet()){
// tuple = new Tuple<String, String>(key, map.get(key));
// break; // Get only the first
// }
//
// query.addConditions(HelloWorldPluginDeclaration.NAME, tuple);
// query.setServiceEndpointQueryFilter(null);
// query.setEndpointDiscoveryFilter(new ListEndpointDiscoveryFilter());
//
// SmartExecutorProxy proxy = new ProxyBuilderImpl<SmartExecutor, SmartExecutorProxy>(executorPlugin, query).build();
//
// try {
// launchTest(proxy);
// } catch (Exception e) {
// logger.error("testWithListfilters Exception", e);
// throw e;
// }
// }
//
//
//
//
// @SuppressWarnings("unchecked")
// @Test
// public void testWithSpecificSelection() throws Exception {
// ExecutorPlugin executorPlugin = new ExecutorPlugin();
// SmartExecutorPluginQuery query = new SmartExecutorPluginQuery(executorPlugin);
// HelloWorldPluginDeclaration helloWorldPluginDeclaration = new HelloWorldPluginDeclaration();
// Map<String,String> map = helloWorldPluginDeclaration.getSupportedCapabilities();
// Tuple<String, String> tuple = new Tuple<String, String>();
// for(String key : map.keySet()){
// tuple = new Tuple<String, String>(key, map.get(key));
// break; // Get only the first
// }
//
// query.addConditions(HelloWorldPluginDeclaration.NAME, tuple);
// query.setServiceEndpointQueryFilter(null);
// List<String> endpoints = query.discoverEndpoints(new ListEndpointDiscoveryFilter());
//
// for(String endpoint : endpoints){
//
// ExecutorPlugin runExecutorPlugin = new ExecutorPlugin();
// SmartExecutorPluginQuery runQuery = new SmartExecutorPluginQuery(runExecutorPlugin);
// runQuery.addConditions(HelloWorldPluginDeclaration.NAME, tuple);
//
// SpecificEndpointDiscoveryFilter sedf = new SpecificEndpointDiscoveryFilter(endpoint);
// runQuery.setEndpointDiscoveryFilter(sedf);
// SmartExecutorProxy proxy = new ProxyBuilderImpl<SmartExecutor, SmartExecutorProxy>(runExecutorPlugin, runQuery).build();
//
// try {
// launchTest(proxy);
// } catch (Exception e) {
// logger.error("testWithSpecificSelection Exception", e);
// throw e;
// }
// }
// }
}