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-client@122952 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2016-02-09 14:19:13 +00:00
parent 8d929ce7e5
commit ed8e34325d
3 changed files with 16 additions and 19 deletions

View File

@ -9,7 +9,7 @@ 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.client.plugins.ExecutorPlugin;
@ -35,7 +35,7 @@ public class DefaultExecutorTest {
@Before
public void init(){
ScopeProvider.instance.set("/gcube");
SecurityTokenProvider.instance.set("82a84741-debe-4c90-a907-c429c8272071");
proxy = ExecutorPlugin.getExecutorProxy().build();
Assert.assertNotNull(proxy);
}

View File

@ -9,9 +9,9 @@ import java.util.Map;
import org.acme.HelloWorldPlugin;
import org.acme.HelloWorldPluginDeclaration;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.clients.ProxyBuilderImpl;
import org.gcube.common.clients.exceptions.DiscoveryException;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.vremanagement.executor.api.SmartExecutor;
import org.gcube.vremanagement.executor.api.types.LaunchParameter;
import org.gcube.vremanagement.executor.client.plugins.ExecutorPlugin;
@ -22,6 +22,7 @@ import org.gcube.vremanagement.executor.client.plugins.query.filter.SpecificEndp
import org.gcube.vremanagement.executor.client.proxies.SmartExecutorProxy;
import org.gcube.vremanagement.executor.client.util.Tuple;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -34,6 +35,11 @@ public class QueriedClientTest {
private static Logger logger = LoggerFactory.getLogger(QueriedClientTest.class);
@Before
public void before() throws Exception{
SecurityTokenProvider.instance.set("82a84741-debe-4c90-a907-c429c8272071");
}
private void launchTest(SmartExecutorProxy proxy) throws Exception {
Map<String, Object> inputs = new HashMap<String, Object>();
inputs.put("Hello", "World");
@ -50,7 +56,6 @@ public class QueriedClientTest {
@Test
public void testNoConditions() throws Exception {
ScopeProvider.instance.set("/gcube");
SmartExecutorProxy proxy = ExecutorPlugin.getExecutorProxy(HelloWorldPluginDeclaration.NAME).build();
Assert.assertNotNull(proxy);
@ -65,7 +70,6 @@ public class QueriedClientTest {
@Test
public void testWithSingleRighConditions() throws Exception {
ScopeProvider.instance.set("/gcube");
HelloWorldPluginDeclaration helloWorldPluginDeclaration = new HelloWorldPluginDeclaration();
Map<String,String> map = helloWorldPluginDeclaration.getSupportedCapabilities();
Tuple<String, String> tuple = new Tuple<String, String>();
@ -86,7 +90,6 @@ public class QueriedClientTest {
@Test
public void testWithMultipleRighConditions() throws Exception {
ScopeProvider.instance.set("/gcube");
HelloWorldPluginDeclaration helloWorldPluginDeclaration = new HelloWorldPluginDeclaration();
Map<String,String> map = helloWorldPluginDeclaration.getSupportedCapabilities();
@ -113,7 +116,6 @@ public class QueriedClientTest {
@Test
public void testWithUnsatisfiedConditions() {
ScopeProvider.instance.set("/gcube");
Tuple<String, String> tuple = new Tuple<String, String>("Unsatisfied", "Condition");
SmartExecutorProxy proxy = ExecutorPlugin.getExecutorProxy(HelloWorldPluginDeclaration.NAME, tuple).build();
Assert.assertNotNull(proxy);
@ -127,8 +129,6 @@ public class QueriedClientTest {
@SuppressWarnings("unchecked")
@Test
public void testWithPersonalfilters() throws Exception {
ScopeProvider.instance.set("/gcube");
ExecutorPlugin executorPlugin = new ExecutorPlugin();
SmartExecutorPluginQuery query = new SmartExecutorPluginQuery(executorPlugin);
HelloWorldPluginDeclaration helloWorldPluginDeclaration = new HelloWorldPluginDeclaration();
@ -155,7 +155,6 @@ public class QueriedClientTest {
@Test
public void testManagedPersonalfilters() throws Exception {
ScopeProvider.instance.set("/gcube");
HelloWorldPluginDeclaration helloWorldPluginDeclaration = new HelloWorldPluginDeclaration();
Map<String,String> map = helloWorldPluginDeclaration.getSupportedCapabilities();
@SuppressWarnings("unchecked")
@ -180,8 +179,6 @@ public class QueriedClientTest {
@SuppressWarnings("unchecked")
@Test
public void testWithListfilters() throws Exception {
ScopeProvider.instance.set("/gcube");
ExecutorPlugin executorPlugin = new ExecutorPlugin();
SmartExecutorPluginQuery query = new SmartExecutorPluginQuery(executorPlugin);
HelloWorldPluginDeclaration helloWorldPluginDeclaration = new HelloWorldPluginDeclaration();
@ -212,8 +209,6 @@ public class QueriedClientTest {
@SuppressWarnings("unchecked")
@Test
public void testWithSpecificSelection() throws Exception {
ScopeProvider.instance.set("/gcube");
ExecutorPlugin executorPlugin = new ExecutorPlugin();
SmartExecutorPluginQuery query = new SmartExecutorPluginQuery(executorPlugin);
HelloWorldPluginDeclaration helloWorldPluginDeclaration = new HelloWorldPluginDeclaration();

View File

@ -5,11 +5,12 @@ package org.gcube.vremanagement.executor.client;
import java.util.List;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
//import org.gcube.dataanalysis.executor.plugin.GenericWorkerPluginDeclaration;
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.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -22,14 +23,15 @@ public class SmartGenericWorkerDiscoveryQuery {
private static Logger logger = LoggerFactory.getLogger(SmartGenericWorkerDiscoveryQuery.class);
@Before
public void before() throws Exception{
SecurityTokenProvider.instance.set("82a84741-debe-4c90-a907-c429c8272071");
}
@SuppressWarnings("unchecked")
@Test
public void testGenericWorkerDiscoveryQuery() throws Exception {
//GenericWorkerPluginDeclaration gwpd = new GenericWorkerPluginDeclaration();
ScopeProvider.instance.set("/gcube");
ExecutorPlugin executorPlugin = new ExecutorPlugin();
SmartExecutorPluginQuery query = new SmartExecutorPluginQuery(executorPlugin);
@ -46,7 +48,7 @@ public class SmartGenericWorkerDiscoveryQuery {
/* Used to add extra filter to ServiceEndpoint discovery */
query.setServiceEndpointQueryFilter(null);
List<String> nodes = query.discoverEndpoints(new ListEndpointDiscoveryFilter());
logger.debug("Found the following nodes: "+nodes+" in scope "+ScopeProvider.instance.get());
logger.debug("Found the following nodes: {}", nodes);
}