From 74806f6c2d2335a07ceb6bdfa8e426d0cc0e8b0a Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Tue, 9 Feb 2016 14:20:26 +0000 Subject: [PATCH] refs #2112: Port SmartExecutor to be compliant with new Authorization https://support.d4science.org/issues/2112 git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/vre-management/smart-executor@122953 82a268e6-3cf1-43bd-a215-b396298e98cf --- .classpath | 1 - .../executor/SmartExecutorInitializator.java | 42 ++++++++++--------- .../ScheduledTaskConfiguration.java | 4 -- .../jsonbased/JSONLaunchParameter.java | 16 +++---- ...SmartExecutorPersistenceConfiguration.java | 4 +- .../SmartExecutorPersistenceConnector.java | 4 -- .../SmartExecutorPersistenceFactory.java | 23 ++++++---- .../couchdb/CouchDBPersistenceConnector.java | 8 ++-- .../PluginStateEvolutionObjectNode.java | 4 +- ...SmartExecutorPersistenceConnectorTest.java | 15 ++++--- .../pluginmanager/RunnablePluginTest.java | 7 ++-- .../SmartExecutorSchedulerTest.java | 5 +-- 12 files changed, 65 insertions(+), 68 deletions(-) diff --git a/.classpath b/.classpath index d3c5af8..953de0b 100644 --- a/.classpath +++ b/.classpath @@ -25,7 +25,6 @@ - diff --git a/src/main/java/org/gcube/vremanagement/executor/SmartExecutorInitializator.java b/src/main/java/org/gcube/vremanagement/executor/SmartExecutorInitializator.java index 70b5110..6591f42 100644 --- a/src/main/java/org/gcube/vremanagement/executor/SmartExecutorInitializator.java +++ b/src/main/java/org/gcube/vremanagement/executor/SmartExecutorInitializator.java @@ -16,7 +16,6 @@ import org.gcube.common.resources.gcore.ServiceEndpoint.Property; 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.common.scope.api.ScopeProvider; import org.gcube.informationsystem.publisher.RegistryPublisher; import org.gcube.informationsystem.publisher.RegistryPublisherFactory; import org.gcube.informationsystem.publisher.exception.RegistryNotFoundException; @@ -47,6 +46,18 @@ public class SmartExecutorInitializator implements ApplicationManager { public static final long JOIN_TIMEOUT = 1000; + public static String getScope(){ + String token = SecurityTokenProvider.instance.get(); + AuthorizationEntry authorizationEntry; + try { + authorizationEntry = Constants.authorizationService().get(token); + } catch (Exception e) { + throw new RuntimeException(e); + } + String scope = authorizationEntry.getContext(); + return scope; + } + /** * Publish the provided resource on all Service Scopes retrieved from * Context @@ -61,8 +72,7 @@ public class SmartExecutorInitializator implements ApplicationManager { RegistryPublisher registryPublisher = RegistryPublisherFactory.create(); try { - String scope = ScopeProvider.instance.get(); - logger.debug("Trying to publish to {}:\n{}", scope, stringWriter); + logger.debug("Trying to publish to {}:\n{}", getScope(), stringWriter); registryPublisher.create(resource); } catch (Exception e) { logger.error("The resource was not published", e); @@ -83,7 +93,7 @@ public class SmartExecutorInitializator implements ApplicationManager { RegistryPublisher registryPublisher = RegistryPublisherFactory.create(); String id = resource.id(); - logger.debug("Trying to remove {} with ID {} from {}", resource.getClass().getSimpleName(), id, ScopeProvider.instance.get()); + logger.debug("Trying to remove {} with ID {} from {}", resource.getClass().getSimpleName(), id, getScope()); registryPublisher.remove(resource); @@ -211,16 +221,14 @@ public class SmartExecutorInitializator implements ApplicationManager { DiscoveryClient client = ICFactory.clientFor(ServiceEndpoint.class); List serviceEndpoints = client.submit(query); - String scope = ScopeProvider.instance.get(); - for (ServiceEndpoint serviceEndpoint : serviceEndpoints) { try { logger.debug("Trying to unpublish the old ServiceEndpoint with ID {} from scope {}", - serviceEndpoint.id(), scope); + serviceEndpoint.id(), getScope()); unPublishScopedResource(serviceEndpoint); } catch(Exception e){ logger.debug("Exception tryng to unpublish the old ServiceEndpoint with ID {} from scope {}", - serviceEndpoint.id(), scope, e); + serviceEndpoint.id(), getScope(), e); } } }catch(Exception e){ @@ -292,19 +300,13 @@ public class SmartExecutorInitializator implements ApplicationManager { */ @Override public void onShutdown(){ - String token = SecurityTokenProvider.instance.get(); - AuthorizationEntry authorizationEntry; - try { - authorizationEntry = Constants.authorizationService().get(token); - } catch (Exception e) { - throw new RuntimeException(e); - } - String scope = authorizationEntry.getContext(); + logger.trace( "\n-------------------------------------------------------\n" + "Smart Executor is Stopping on scope {}\n" - + "-------------------------------------------------------", scope); + + "-------------------------------------------------------", + getScope()); SmartExecutorScheduler.getInstance().stopAll(); @@ -314,13 +316,15 @@ public class SmartExecutorInitializator implements ApplicationManager { SmartExecutorPersistenceFactory.getPersistenceConnector().close(); } catch (Exception e) { logger.error("Unable to correctly close {} for scope {}", - SmartExecutorPersistenceConnector.class.getSimpleName(), scope, e); + SmartExecutorPersistenceConnector.class.getSimpleName(), + getScope(), e); } logger.trace( "\n-------------------------------------------------------\n" + "Smart Executor Stopped Successfully on scope {}\n" - + "-------------------------------------------------------", scope); + + "-------------------------------------------------------", + getScope()); } } diff --git a/src/main/java/org/gcube/vremanagement/executor/configuration/ScheduledTaskConfiguration.java b/src/main/java/org/gcube/vremanagement/executor/configuration/ScheduledTaskConfiguration.java index b69bf56..5b654f1 100644 --- a/src/main/java/org/gcube/vremanagement/executor/configuration/ScheduledTaskConfiguration.java +++ b/src/main/java/org/gcube/vremanagement/executor/configuration/ScheduledTaskConfiguration.java @@ -10,10 +10,6 @@ import org.gcube.vremanagement.executor.api.types.LaunchParameter; import org.gcube.vremanagement.executor.exception.SchedulePersistenceException; /** - * Every implementation MUST take in account to store/query the records - * on the current scope which is not passed as argument but MUST be retrieved - * using {#org.gcube.common.scope.api.ScopeProvider} facilities - * i.e. ScopeProvider.instance.get() * @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/ */ public interface ScheduledTaskConfiguration { diff --git a/src/main/java/org/gcube/vremanagement/executor/configuration/jsonbased/JSONLaunchParameter.java b/src/main/java/org/gcube/vremanagement/executor/configuration/jsonbased/JSONLaunchParameter.java index 2810075..d633b78 100644 --- a/src/main/java/org/gcube/vremanagement/executor/configuration/jsonbased/JSONLaunchParameter.java +++ b/src/main/java/org/gcube/vremanagement/executor/configuration/jsonbased/JSONLaunchParameter.java @@ -7,7 +7,7 @@ import java.text.ParseException; import java.util.HashMap; import java.util.Map; -import org.gcube.common.scope.api.ScopeProvider; +import org.gcube.vremanagement.executor.SmartExecutorInitializator; import org.gcube.vremanagement.executor.api.types.LaunchParameter; import org.gcube.vremanagement.executor.api.types.Scheduling; import org.gcube.vremanagement.executor.exception.ScopeNotMatchException; @@ -48,36 +48,36 @@ public class JSONLaunchParameter extends LaunchParameter { public JSONLaunchParameter(String pluginName, Map pluginCapabilities, Map inputs) { super(pluginName, pluginCapabilities, inputs); - this.scope = ScopeProvider.instance.get(); + this.scope = SmartExecutorInitializator.getScope(); } public JSONLaunchParameter(String pluginName, Map inputs, Scheduling scheduling) throws ParseException { super(pluginName, inputs, scheduling); - this.scope = ScopeProvider.instance.get(); + this.scope = SmartExecutorInitializator.getScope(); } public JSONLaunchParameter(String pluginName, Map pluginCapabilities, Map inputs, Scheduling scheduling) throws ParseException { super(pluginName, pluginCapabilities, inputs, scheduling); - this.scope = ScopeProvider.instance.get(); + this.scope = SmartExecutorInitializator.getScope(); } @Deprecated public JSONLaunchParameter(String pluginName, Map inputs, Scheduling scheduling, boolean persist) throws ParseException { super(pluginName, inputs, scheduling, persist); - this.scope = ScopeProvider.instance.get(); + this.scope = SmartExecutorInitializator.getScope(); } @Deprecated public JSONLaunchParameter(String pluginName, Map pluginCapabilities, Map inputs, Scheduling scheduling, boolean persist) throws ParseException { super(pluginName, pluginCapabilities, inputs, scheduling, persist); this.scheduling = new JSONScheduling(scheduling); - this.scope = ScopeProvider.instance.get(); + this.scope = SmartExecutorInitializator.getScope(); } public JSONLaunchParameter(LaunchParameter parameter) throws ParseException { super(parameter.getPluginName(), parameter.getPluginCapabilities(), parameter.getInputs(), parameter.getScheduling()); this.scheduling = new JSONScheduling(parameter.getScheduling()); - this.scope = ScopeProvider.instance.get(); + this.scope = SmartExecutorInitializator.getScope(); } public JSONLaunchParameter(JSONObject jsonObject) throws JSONException, ParseException, ScopeNotMatchException { @@ -113,7 +113,7 @@ public class JSONLaunchParameter extends LaunchParameter { this.usedBy = jsonObject.getString(USED_BY); } - this.scope = ScopeProvider.instance.get(); + this.scope = SmartExecutorInitializator.getScope(); if(jsonObject.has(SCOPE)){ String jsonScope = jsonObject.getString(SCOPE); if(jsonScope.compareTo(scope)!=0){ diff --git a/src/main/java/org/gcube/vremanagement/executor/persistence/SmartExecutorPersistenceConfiguration.java b/src/main/java/org/gcube/vremanagement/executor/persistence/SmartExecutorPersistenceConfiguration.java index 4e4565f..1f386f2 100644 --- a/src/main/java/org/gcube/vremanagement/executor/persistence/SmartExecutorPersistenceConfiguration.java +++ b/src/main/java/org/gcube/vremanagement/executor/persistence/SmartExecutorPersistenceConfiguration.java @@ -15,10 +15,10 @@ import org.gcube.common.resources.gcore.ServiceEndpoint; import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint; import org.gcube.common.resources.gcore.ServiceEndpoint.Property; import org.gcube.common.resources.gcore.utils.Group; -import org.gcube.common.scope.api.ScopeProvider; 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.vremanagement.executor.SmartExecutorInitializator; /** * @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/ @@ -126,7 +126,7 @@ public class SmartExecutorPersistenceConfiguration { List serviceEndpoints = client.submit(query); if(serviceEndpoints.size()>1){ query.addCondition(String.format("$resource/Profile/AccessPoint/Properties/Property/Name/text() eq '%s'", TARGET_SCOPE)); - query.addCondition(String.format("$resource/Profile/AccessPoint/Properties/Property/Value/text() eq '%s'", ScopeProvider.instance.get())); + query.addCondition(String.format("$resource/Profile/AccessPoint/Properties/Property/Value/text() eq '%s'", SmartExecutorInitializator.getScope())); serviceEndpoints = client.submit(query); } return serviceEndpoints.get(0); diff --git a/src/main/java/org/gcube/vremanagement/executor/persistence/SmartExecutorPersistenceConnector.java b/src/main/java/org/gcube/vremanagement/executor/persistence/SmartExecutorPersistenceConnector.java index af94aa2..fd6675b 100644 --- a/src/main/java/org/gcube/vremanagement/executor/persistence/SmartExecutorPersistenceConnector.java +++ b/src/main/java/org/gcube/vremanagement/executor/persistence/SmartExecutorPersistenceConnector.java @@ -11,10 +11,6 @@ import org.gcube.vremanagement.executor.plugin.PluginStateNotification; /** * Model the connector which create or open the connection to DB. - * Every implementation MUST take in account to store/query the records - * on the current scope which is not passed as argument but MUSt be retrieved - * using {#org.gcube.common.scope.api.ScopeProvider} facilities - * i.e. ScopeProvider.instance.get() * @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/ */ public abstract class SmartExecutorPersistenceConnector implements PluginStateNotification { diff --git a/src/main/java/org/gcube/vremanagement/executor/persistence/SmartExecutorPersistenceFactory.java b/src/main/java/org/gcube/vremanagement/executor/persistence/SmartExecutorPersistenceFactory.java index 1ab3bea..426d430 100644 --- a/src/main/java/org/gcube/vremanagement/executor/persistence/SmartExecutorPersistenceFactory.java +++ b/src/main/java/org/gcube/vremanagement/executor/persistence/SmartExecutorPersistenceFactory.java @@ -6,7 +6,7 @@ package org.gcube.vremanagement.executor.persistence; import java.util.HashMap; import java.util.Map; -import org.gcube.common.scope.api.ScopeProvider; +import org.gcube.vremanagement.executor.SmartExecutorInitializator; import org.gcube.vremanagement.executor.persistence.couchdb.CouchDBPersistenceConnector; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -42,28 +42,33 @@ public abstract class SmartExecutorPersistenceFactory { * @return the persistenceConnector */ public static synchronized SmartExecutorPersistenceConnector getPersistenceConnector() throws Exception { - String scope = ScopeProvider.instance.get(); - SmartExecutorPersistenceConnector persistence = getPersistenceConnector(scope); + SmartExecutorPersistenceConnector persistence = + getPersistenceConnector(SmartExecutorInitializator.getScope()); if(persistence==null){ logger.trace("Retrieving {} for scope {} not found on internal {}. Intializing it.", - SmartExecutorPersistenceConnector.class.getSimpleName(), scope, Map.class.getSimpleName()); + SmartExecutorPersistenceConnector.class.getSimpleName(), + SmartExecutorInitializator.getScope(), + Map.class.getSimpleName()); + String className = CouchDBPersistenceConnector.class.getSimpleName(); SmartExecutorPersistenceConfiguration configuration = - new SmartExecutorPersistenceConfiguration(CouchDBPersistenceConnector.class.getSimpleName()); + new SmartExecutorPersistenceConfiguration(className); + persistence = new CouchDBPersistenceConnector(configuration); - persistenceConnectors.put(scope, persistence); + persistenceConnectors.put(SmartExecutorInitializator.getScope(), + persistence); } return persistence; } public static synchronized void closePersistenceConnector() throws Exception { - String scope = ScopeProvider.instance.get(); - SmartExecutorPersistenceConnector persistence = getPersistenceConnector(scope); + SmartExecutorPersistenceConnector persistence = + getPersistenceConnector(SmartExecutorInitializator.getScope()); if(persistence!=null){ persistence.close(); - persistenceConnectors.remove(scope); + persistenceConnectors.remove(SmartExecutorInitializator.getScope()); } } diff --git a/src/main/java/org/gcube/vremanagement/executor/persistence/couchdb/CouchDBPersistenceConnector.java b/src/main/java/org/gcube/vremanagement/executor/persistence/couchdb/CouchDBPersistenceConnector.java index f1b0350..6dfa12d 100644 --- a/src/main/java/org/gcube/vremanagement/executor/persistence/couchdb/CouchDBPersistenceConnector.java +++ b/src/main/java/org/gcube/vremanagement/executor/persistence/couchdb/CouchDBPersistenceConnector.java @@ -28,7 +28,7 @@ import org.ektorp.http.StdHttpClient; import org.ektorp.http.StdHttpClient.Builder; import org.ektorp.impl.StdCouchDbConnector; import org.ektorp.impl.StdCouchDbInstance; -import org.gcube.common.scope.api.ScopeProvider; +import org.gcube.vremanagement.executor.SmartExecutorInitializator; import org.gcube.vremanagement.executor.api.types.LaunchParameter; import org.gcube.vremanagement.executor.configuration.ScheduledTaskConfiguration; import org.gcube.vremanagement.executor.configuration.jsonbased.JSONLaunchParameter; @@ -205,7 +205,7 @@ public class CouchDBPersistenceConnector extends SmartExecutorPersistenceConnect ViewQuery query = new ViewQuery().designDocId(String.format("%s%s", MAP_REDUCE__DESIGN, PLUGIN_STATE_DOCUMENT)); - String scope = ScopeProvider.instance.get(); + String scope = SmartExecutorInitializator.getScope(); ArrayNode startKey = new ObjectMapper().createArrayNode(); startKey.add(scope); ArrayNode endKey = new ObjectMapper().createArrayNode(); @@ -273,7 +273,7 @@ public class CouchDBPersistenceConnector extends SmartExecutorPersistenceConnect ViewQuery query = new ViewQuery().designDocId(String.format("%s%s", MAP_REDUCE__DESIGN, SCHEDULED_TASKS_DOCUMENT)); query = query.viewName(ORPHAN_VIEW); - String scope = ScopeProvider.instance.get(); + String scope = SmartExecutorInitializator.getScope(); ArrayNode startKey = new ObjectMapper().createArrayNode(); startKey.add(scope); ArrayNode endKey = new ObjectMapper().createArrayNode(); @@ -316,7 +316,7 @@ public class CouchDBPersistenceConnector extends SmartExecutorPersistenceConnect JSONObject obj = jlp.toJSON(); obj.append(TYPE_JSON_FIELD, SCHEDULED_TASK_TYPE); obj.append(USED_BY_FIELD, consumerID); - obj.append(ScheduledTaskConfiguration.SCOPE, ScopeProvider.instance.get()); + obj.append(ScheduledTaskConfiguration.SCOPE, SmartExecutorInitializator.getScope()); createItem(obj, uuid.toString()); } catch (Exception e) { logger.error("Error Adding Scheduled Task UUID : {}, Consumer : {}, LaunchParameter : {}", diff --git a/src/main/java/org/gcube/vremanagement/executor/persistence/couchdb/PluginStateEvolutionObjectNode.java b/src/main/java/org/gcube/vremanagement/executor/persistence/couchdb/PluginStateEvolutionObjectNode.java index 2f7331d..ffabda2 100644 --- a/src/main/java/org/gcube/vremanagement/executor/persistence/couchdb/PluginStateEvolutionObjectNode.java +++ b/src/main/java/org/gcube/vremanagement/executor/persistence/couchdb/PluginStateEvolutionObjectNode.java @@ -9,8 +9,8 @@ import java.util.UUID; import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.node.ObjectNode; import org.gcube.common.resources.gcore.GCoreEndpoint; -import org.gcube.common.scope.api.ScopeProvider; import org.gcube.smartgears.ContextProvider; +import org.gcube.vremanagement.executor.SmartExecutorInitializator; import org.gcube.vremanagement.executor.plugin.PluginDeclaration; import org.gcube.vremanagement.executor.plugin.PluginStateEvolution; @@ -76,7 +76,7 @@ public class PluginStateEvolutionObjectNode { } public static void addScope(ObjectNode objectNode){ - objectNode.put(SCOPE_FIELD, ScopeProvider.instance.get()); + objectNode.put(SCOPE_FIELD, SmartExecutorInitializator.getScope()); } public static ObjectNode getObjectMapper(PluginStateEvolution pluginStateEvolution){ diff --git a/src/test/java/org/gcube/vremanagement/executor/persistence/SmartExecutorPersistenceConnectorTest.java b/src/test/java/org/gcube/vremanagement/executor/persistence/SmartExecutorPersistenceConnectorTest.java index 806b327..de1539f 100644 --- a/src/test/java/org/gcube/vremanagement/executor/persistence/SmartExecutorPersistenceConnectorTest.java +++ b/src/test/java/org/gcube/vremanagement/executor/persistence/SmartExecutorPersistenceConnectorTest.java @@ -9,7 +9,7 @@ import java.util.List; import java.util.UUID; import org.acme.HelloWorldPluginDeclaration; -import org.gcube.common.scope.api.ScopeProvider; +import org.gcube.common.authorization.library.provider.SecurityTokenProvider; import org.gcube.vremanagement.executor.api.types.LaunchParameter; import org.gcube.vremanagement.executor.configuration.ScheduledTaskConfiguration; import org.gcube.vremanagement.executor.configuration.ScheduledTaskConfigurationFactory; @@ -17,6 +17,7 @@ import org.gcube.vremanagement.executor.persistence.couchdb.CouchDBPersistenceCo import org.gcube.vremanagement.executor.plugin.PluginState; import org.gcube.vremanagement.executor.plugin.PluginStateEvolution; import org.junit.Assert; +import org.junit.Before; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -29,13 +30,14 @@ public class SmartExecutorPersistenceConnectorTest { private static Logger logger = LoggerFactory.getLogger(SmartExecutorPersistenceConnectorTest.class); - public static final String[] SCOPES = new String[]{"/gcube", "/gcube/devsec"}; - public static final String GCUBE_SCOPE = SCOPES[0]; - public static final String GCUBE_DEVSEC_SCOPE = SCOPES[1]; + @Before + public void before() throws Exception{ + SecurityTokenProvider.instance.set("82a84741-debe-4c90-a907-c429c8272071"); + } + @Test public void getConnectionTest() throws Exception { - ScopeProvider.instance.set(GCUBE_DEVSEC_SCOPE); SmartExecutorPersistenceConnector persistenceConnector = SmartExecutorPersistenceFactory.getPersistenceConnector(); Assert.assertNotNull(persistenceConnector); Assert.assertEquals(CouchDBPersistenceConnector.class, persistenceConnector.getClass()); @@ -44,7 +46,6 @@ public class SmartExecutorPersistenceConnectorTest { @Test public void getPluginInstanceStateTest() throws Exception { - ScopeProvider.instance.set(GCUBE_DEVSEC_SCOPE); SmartExecutorPersistenceConnector persistenceConnector = SmartExecutorPersistenceFactory.getPersistenceConnector(); UUID uuid = UUID.randomUUID(); @@ -70,8 +71,6 @@ public class SmartExecutorPersistenceConnectorTest { @Test public void getAvailableScheduledTasksTest() throws Exception { - ScopeProvider.instance.set(GCUBE_DEVSEC_SCOPE); - ScheduledTaskConfiguration stc = ScheduledTaskConfigurationFactory.getLaunchConfiguration(); Assert.assertNotNull(stc); Assert.assertEquals(CouchDBPersistenceConnector.class, stc.getClass()); diff --git a/src/test/java/org/gcube/vremanagement/executor/pluginmanager/RunnablePluginTest.java b/src/test/java/org/gcube/vremanagement/executor/pluginmanager/RunnablePluginTest.java index 3b0d4ab..63b2af2 100644 --- a/src/test/java/org/gcube/vremanagement/executor/pluginmanager/RunnablePluginTest.java +++ b/src/test/java/org/gcube/vremanagement/executor/pluginmanager/RunnablePluginTest.java @@ -9,11 +9,10 @@ import java.util.UUID; import org.acme.HelloWorldPlugin; import org.acme.HelloWorldPluginDeclaration; -import org.gcube.common.scope.api.ScopeProvider; +import org.gcube.common.authorization.library.provider.SecurityTokenProvider; import org.gcube.vremanagement.executor.exception.InputsNullException; import org.gcube.vremanagement.executor.exception.InvalidInputsException; import org.gcube.vremanagement.executor.persistence.SmartExecutorPersistenceConnector; -import org.gcube.vremanagement.executor.persistence.SmartExecutorPersistenceConnectorTest; import org.gcube.vremanagement.executor.persistence.SmartExecutorPersistenceFactory; import org.gcube.vremanagement.executor.plugin.PluginState; import org.gcube.vremanagement.executor.plugin.PluginStateNotification; @@ -31,10 +30,10 @@ import org.slf4j.LoggerFactory; public class RunnablePluginTest { private static Logger logger = LoggerFactory.getLogger(SmartExecutorSchedulerTest.class); - @BeforeClass + @BeforeClass public static void prepare() throws Exception{ try { - ScopeProvider.instance.set(SmartExecutorPersistenceConnectorTest.GCUBE_DEVSEC_SCOPE); + SecurityTokenProvider.instance.set("82a84741-debe-4c90-a907-c429c8272071"); SmartExecutorPersistenceFactory.getPersistenceConnector(); } catch (Exception e) { logger.error("Unable to Create JDBCPersistenceConnector"); diff --git a/src/test/java/org/gcube/vremanagement/executor/pluginmanager/SmartExecutorSchedulerTest.java b/src/test/java/org/gcube/vremanagement/executor/pluginmanager/SmartExecutorSchedulerTest.java index b0cedbb..4e13581 100644 --- a/src/test/java/org/gcube/vremanagement/executor/pluginmanager/SmartExecutorSchedulerTest.java +++ b/src/test/java/org/gcube/vremanagement/executor/pluginmanager/SmartExecutorSchedulerTest.java @@ -10,13 +10,12 @@ import java.util.UUID; import org.acme.HelloWorldPlugin; import org.acme.HelloWorldPluginDeclaration; -import org.gcube.common.scope.api.ScopeProvider; +import org.gcube.common.authorization.library.provider.SecurityTokenProvider; import org.gcube.vremanagement.executor.api.types.LaunchParameter; import org.gcube.vremanagement.executor.api.types.Scheduling; import org.gcube.vremanagement.executor.exception.PluginStateNotRetrievedException; import org.gcube.vremanagement.executor.exception.UnableToInterruptTaskException; import org.gcube.vremanagement.executor.persistence.SmartExecutorPersistenceConnector; -import org.gcube.vremanagement.executor.persistence.SmartExecutorPersistenceConnectorTest; import org.gcube.vremanagement.executor.persistence.SmartExecutorPersistenceFactory; import org.gcube.vremanagement.executor.plugin.PluginState; import org.gcube.vremanagement.executor.scheduler.SmartExecutorScheduler; @@ -43,7 +42,7 @@ public class SmartExecutorSchedulerTest { @BeforeClass public static void prepare() throws Exception{ try { - ScopeProvider.instance.set(SmartExecutorPersistenceConnectorTest.GCUBE_DEVSEC_SCOPE); + SecurityTokenProvider.instance.set("82a84741-debe-4c90-a907-c429c8272071"); /* pc = new JDBCPersistenceConnector("."); SmartExecutorPersistenceConnector.setPersistenceConnector(pc);