From 37cf0ac5329cda3d6a7e62495cb03d7e07007f0e Mon Sep 17 00:00:00 2001 From: TVerdesOprea Date: Wed, 11 Jan 2023 14:00:04 +0200 Subject: [PATCH 1/3] add pythonServer case for eval fix tests --- .../bindings/scripts/ScriptEvaluator.java | 33 +++++++++++++++++-- .../bindings/ArgumentsBindingTest.java | 6 ++-- .../runtime/bindings/InputsBindingTest.java | 6 ++-- .../runtime/bindings/OutputsBindingTest.java | 18 +++++----- .../runtime/bindings/ResultBindingTest.java | 6 ++-- .../bindings/scripts/ScriptEvaluatorTest.java | 6 ++-- .../bindings/scripts/ScriptExecutorTest.java | 7 ++-- .../lang/runtime/steps/ActionStepsTest.java | 6 ++-- .../runtime/steps/ExecutableStepsTest.java | 8 ++--- .../runtime/steps/ParallelLoopStepsTest.java | 13 +++++++- .../runtime/steps/StepExecutionDataTest.java | 6 ++-- 11 files changed, 78 insertions(+), 37 deletions(-) diff --git a/cloudslang-runtime/src/main/java/io/cloudslang/lang/runtime/bindings/scripts/ScriptEvaluator.java b/cloudslang-runtime/src/main/java/io/cloudslang/lang/runtime/bindings/scripts/ScriptEvaluator.java index 1d6f43c288..9d5c130e95 100644 --- a/cloudslang-runtime/src/main/java/io/cloudslang/lang/runtime/bindings/scripts/ScriptEvaluator.java +++ b/cloudslang-runtime/src/main/java/io/cloudslang/lang/runtime/bindings/scripts/ScriptEvaluator.java @@ -59,6 +59,9 @@ public class ScriptEvaluator extends ScriptProcessor { @Resource(name = "jythonRuntimeService") private PythonRuntimeService legacyJythonRuntimeService; + @Resource(name = "externalPythonServerService") + private PythonRuntimeService pythonServerService; + @Autowired private ScriptsService scriptsService; @@ -66,11 +69,14 @@ public Value evalExpr(String expr, Map context, Set functionDependencies) { try { switch (PYTHON_EVALUATOR) { + case PYTHON_EXECUTOR: + return doEvaluateExpressionServerPython(expr, context, systemProperties, functionDependencies); + case PYTHON: + return doEvaluateExpressionExternalPython(expr, context, systemProperties, functionDependencies); case JYTHON: return doEvaluateExpressionJython(expr, context, systemProperties, functionDependencies); - //case PYTHON_EXECUTOR or PYTHON default: - return doEvaluateExpressionExternalPython(expr, context, systemProperties, functionDependencies); + return doEvaluateExpressionServerPython(expr, context, systemProperties, functionDependencies); } } catch (Exception exception) { throw new RuntimeException("Error in evaluating expression: '" + @@ -121,6 +127,29 @@ private Value doEvaluateExpressionExternalPython(String expr, return ValueFactory.create(result.getEvalResult(), getSensitive(pythonContext, accessedResources)); } + private Value doEvaluateExpressionServerPython(String expr, + Map context, + Set systemProperties, + Set functionDependencies) { + Map pythonContext = createExternalPythonContext(context); + boolean systemPropertiesDefined = false; + if (functionDependencies.contains(ScriptFunction.GET_SYSTEM_PROPERTY) || + functionDependencies.contains(ScriptFunction.GET_SP_VAR)) { + systemPropertiesDefined = true; + } + if (systemPropertiesDefined) { + pythonContext.put(SYSTEM_PROPERTIES_MAP, + (Serializable) prepareSystemPropertiesForExternalPython(systemProperties)); + } + + PythonEvaluationResult result = pythonServerService.eval( + buildAddFunctionsScriptForExternalPython(functionDependencies), expr, pythonContext); + + //noinspection unchecked + Set accessedResources = (Set) result.getResultContext().get(ACCESSED_RESOURCES_SET); + return ValueFactory.create(result.getEvalResult(), getSensitive(pythonContext, accessedResources)); + } + public Value testExpr(String expr, Map context, Set systemProperties, Set functionDependencies, long timeoutPeriod) { try { diff --git a/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/bindings/ArgumentsBindingTest.java b/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/bindings/ArgumentsBindingTest.java index 687db3ddbf..4e5716257b 100644 --- a/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/bindings/ArgumentsBindingTest.java +++ b/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/bindings/ArgumentsBindingTest.java @@ -29,7 +29,6 @@ import io.cloudslang.runtime.impl.python.PythonRuntimeServiceImpl; import io.cloudslang.runtime.impl.python.external.ExternalPythonExecutionEngine; import io.cloudslang.runtime.impl.python.external.ExternalPythonRuntimeServiceImpl; -import io.cloudslang.runtime.impl.python.external.ExternalPythonServerService; import io.cloudslang.runtime.impl.python.external.ExternalPythonServerServiceImpl; import io.cloudslang.runtime.impl.python.external.StatefulRestEasyClientsHolder; import io.cloudslang.score.events.EventBus; @@ -461,8 +460,9 @@ public PythonExecutionEngine pythonExecutionEngine() { } @Bean(name = "externalPythonServerService") - public ExternalPythonServerService externalPythonServerService() { - return new ExternalPythonServerServiceImpl(mock(StatefulRestEasyClientsHolder.class)); + public PythonRuntimeService externalPythonServerService() { + return new ExternalPythonServerServiceImpl(mock(StatefulRestEasyClientsHolder.class), + new Semaphore(100), new Semaphore(50)); } @Bean(name = "externalPythonRuntimeService") diff --git a/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/bindings/InputsBindingTest.java b/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/bindings/InputsBindingTest.java index 64961b048f..d932966760 100644 --- a/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/bindings/InputsBindingTest.java +++ b/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/bindings/InputsBindingTest.java @@ -27,7 +27,6 @@ import io.cloudslang.runtime.impl.python.PythonRuntimeServiceImpl; import io.cloudslang.runtime.impl.python.external.ExternalPythonExecutionEngine; import io.cloudslang.runtime.impl.python.external.ExternalPythonRuntimeServiceImpl; -import io.cloudslang.runtime.impl.python.external.ExternalPythonServerService; import io.cloudslang.runtime.impl.python.external.ExternalPythonServerServiceImpl; import io.cloudslang.runtime.impl.python.external.StatefulRestEasyClientsHolder; import io.cloudslang.score.events.EventBus; @@ -560,8 +559,9 @@ public PythonExecutionEngine pythonExecutionEngine() { } @Bean(name = "externalPythonServerService") - public ExternalPythonServerService externalPythonServerService() { - return new ExternalPythonServerServiceImpl(mock(StatefulRestEasyClientsHolder.class)); + public PythonRuntimeService externalPythonServerService() { + return new ExternalPythonServerServiceImpl(mock(StatefulRestEasyClientsHolder.class), + new Semaphore(100), new Semaphore(50)); } @Bean(name = "externalPythonRuntimeService") diff --git a/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/bindings/OutputsBindingTest.java b/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/bindings/OutputsBindingTest.java index 5fca75a018..4d478ed24a 100644 --- a/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/bindings/OutputsBindingTest.java +++ b/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/bindings/OutputsBindingTest.java @@ -26,7 +26,6 @@ import io.cloudslang.runtime.impl.python.PythonRuntimeServiceImpl; import io.cloudslang.runtime.impl.python.external.ExternalPythonExecutionEngine; import io.cloudslang.runtime.impl.python.external.ExternalPythonRuntimeServiceImpl; -import io.cloudslang.runtime.impl.python.external.ExternalPythonServerService; import io.cloudslang.runtime.impl.python.external.ExternalPythonServerServiceImpl; import io.cloudslang.runtime.impl.python.external.StatefulRestEasyClientsHolder; import io.cloudslang.score.events.EventBus; @@ -143,7 +142,7 @@ public void testOperationOutputsExpression() { Map operationContext = prepareOperationContext(); Map actionReturnValues = prepareActionReturnValues(); List outputs = singletonList( - createExpressionOutput("hostFromExpression", "${ 'http://' + hostExpr + ':' + str(port) }")); + createExpressionOutput("hostFromExpression", "${ 'http://' + hostExpr + ':' + str(port) }")); Map result = outputsBinding .bindOutputs(new ReadOnlyContextAccessor(operationContext, actionReturnValues), EMPTY_SET, outputs); @@ -159,9 +158,9 @@ public void testOutputsRetainOrder() { Map operationContext = prepareOperationContext(); Map actionReturnValues = prepareActionReturnValues(); List outputs = Lists.newArrayList( - createExpressionOutput("output1", "1"), - createExpressionOutput("output2", "2"), - createExpressionOutput("output3", "3") + createExpressionOutput("output1", "1"), + createExpressionOutput("output2", "2"), + createExpressionOutput("output3", "3") ); Map result = outputsBinding @@ -190,8 +189,8 @@ public void testOperationOutputsMixed() { Map operationContext = prepareOperationContext(); Map actionReturnValues = prepareActionReturnValues(); List outputs = Arrays.asList( - createNoExpressionOutput("host1"), - createExpressionOutput("hostFromExpression", "${ 'http://' + hostExpr + ':' + str(port) }")); + createNoExpressionOutput("host1"), + createExpressionOutput("hostFromExpression", "${ 'http://' + hostExpr + ':' + str(port) }")); Map result = outputsBinding .bindOutputs(new ReadOnlyContextAccessor(operationContext, actionReturnValues), EMPTY_SET, outputs); @@ -268,8 +267,9 @@ public PythonExecutionEngine pythonExecutionEngine() { } @Bean(name = "externalPythonServerService") - public ExternalPythonServerService externalPythonServerService() { - return new ExternalPythonServerServiceImpl(mock(StatefulRestEasyClientsHolder.class)); + public PythonRuntimeService externalPythonServerService() { + return new ExternalPythonServerServiceImpl(mock(StatefulRestEasyClientsHolder.class), + new Semaphore(100), new Semaphore(50)); } @Bean(name = "externalPythonRuntimeService") diff --git a/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/bindings/ResultBindingTest.java b/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/bindings/ResultBindingTest.java index 060bac926d..7c67e523f3 100644 --- a/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/bindings/ResultBindingTest.java +++ b/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/bindings/ResultBindingTest.java @@ -27,7 +27,6 @@ import io.cloudslang.runtime.impl.python.PythonRuntimeServiceImpl; import io.cloudslang.runtime.impl.python.external.ExternalPythonExecutionEngine; import io.cloudslang.runtime.impl.python.external.ExternalPythonRuntimeServiceImpl; -import io.cloudslang.runtime.impl.python.external.ExternalPythonServerService; import io.cloudslang.runtime.impl.python.external.ExternalPythonServerServiceImpl; import io.cloudslang.runtime.impl.python.external.StatefulRestEasyClientsHolder; import io.cloudslang.score.events.EventBus; @@ -245,8 +244,9 @@ public PythonExecutionEngine pythonExecutionEngine() { } @Bean(name = "externalPythonServerService") - public ExternalPythonServerService externalPythonServerService() { - return new ExternalPythonServerServiceImpl(mock(StatefulRestEasyClientsHolder.class)); + public PythonRuntimeService externalPythonServerService() { + return new ExternalPythonServerServiceImpl(mock(StatefulRestEasyClientsHolder.class), + new Semaphore(100), new Semaphore(50)); } @Bean(name = "externalPythonRuntimeService") diff --git a/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/bindings/scripts/ScriptEvaluatorTest.java b/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/bindings/scripts/ScriptEvaluatorTest.java index 60fb8021cf..e7d70a7cba 100644 --- a/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/bindings/scripts/ScriptEvaluatorTest.java +++ b/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/bindings/scripts/ScriptEvaluatorTest.java @@ -25,7 +25,6 @@ import io.cloudslang.runtime.impl.python.PythonExecutor; import io.cloudslang.runtime.impl.python.external.ExternalPythonExecutionEngine; import io.cloudslang.runtime.impl.python.external.ExternalPythonRuntimeServiceImpl; -import io.cloudslang.runtime.impl.python.external.ExternalPythonServerService; import io.cloudslang.runtime.impl.python.external.ExternalPythonServerServiceImpl; import io.cloudslang.runtime.impl.python.external.StatefulRestEasyClientsHolder; import io.cloudslang.score.events.EventBus; @@ -211,8 +210,9 @@ protected PythonInterpreter initInterpreter(Set dependencies) { } @Bean(name = "externalPythonServerService") - public ExternalPythonServerService externalPythonServerService() { - return new ExternalPythonServerServiceImpl(mock(StatefulRestEasyClientsHolder.class)); + public PythonRuntimeService externalPythonServerService() { + return new ExternalPythonServerServiceImpl(mock(StatefulRestEasyClientsHolder.class), + new Semaphore(100), new Semaphore(50)); } @Bean(name = "externalPythonRuntimeService") diff --git a/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/bindings/scripts/ScriptExecutorTest.java b/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/bindings/scripts/ScriptExecutorTest.java index 5f7b8703ca..a7c0f42afb 100644 --- a/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/bindings/scripts/ScriptExecutorTest.java +++ b/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/bindings/scripts/ScriptExecutorTest.java @@ -24,7 +24,6 @@ import io.cloudslang.runtime.impl.python.PythonRuntimeServiceImpl; import io.cloudslang.runtime.impl.python.external.ExternalPythonExecutionEngine; import io.cloudslang.runtime.impl.python.external.ExternalPythonRuntimeServiceImpl; -import io.cloudslang.runtime.impl.python.external.ExternalPythonServerService; import io.cloudslang.runtime.impl.python.external.ExternalPythonServerServiceImpl; import io.cloudslang.runtime.impl.python.external.StatefulRestEasyClientsHolder; import io.cloudslang.score.events.EventBus; @@ -50,6 +49,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +import java.util.concurrent.Semaphore; import static org.junit.Assert.assertThrows; import static org.mockito.Matchers.any; @@ -200,8 +200,9 @@ protected PythonInterpreter initInterpreter(Set dependencies) { } @Bean(name = "externalPythonServerService") - public ExternalPythonServerService externalPythonServerService() { - return new ExternalPythonServerServiceImpl(mock(StatefulRestEasyClientsHolder.class)); + public PythonRuntimeService externalPythonServerService() { + return new ExternalPythonServerServiceImpl(mock(StatefulRestEasyClientsHolder.class), + new Semaphore(100), new Semaphore(50)); } @Bean(name = "externalPythonRuntimeService") diff --git a/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/steps/ActionStepsTest.java b/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/steps/ActionStepsTest.java index 4ad113f830..23a7054e4a 100644 --- a/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/steps/ActionStepsTest.java +++ b/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/steps/ActionStepsTest.java @@ -36,7 +36,6 @@ import io.cloudslang.runtime.impl.python.PythonRuntimeServiceImpl; import io.cloudslang.runtime.impl.python.external.ExternalPythonExecutionEngine; import io.cloudslang.runtime.impl.python.external.ExternalPythonRuntimeServiceImpl; -import io.cloudslang.runtime.impl.python.external.ExternalPythonServerService; import io.cloudslang.runtime.impl.python.external.ExternalPythonServerServiceImpl; import io.cloudslang.runtime.impl.python.external.StatefulRestEasyClientsHolder; import io.cloudslang.score.api.execution.ExecutionParametersConsts; @@ -1208,8 +1207,9 @@ public PythonExecutionEngine pythonExecutionEngine() { } @Bean(name = "externalPythonServerService") - public ExternalPythonServerService externalPythonServerService() { - return new ExternalPythonServerServiceImpl(mock(StatefulRestEasyClientsHolder.class)); + public PythonRuntimeService externalPythonServerService() { + return new ExternalPythonServerServiceImpl(mock(StatefulRestEasyClientsHolder.class), + new Semaphore(100), new Semaphore(50)); } @Bean(name = "externalPythonRuntimeService") diff --git a/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/steps/ExecutableStepsTest.java b/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/steps/ExecutableStepsTest.java index 64d2fc6468..0736e13a8a 100644 --- a/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/steps/ExecutableStepsTest.java +++ b/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/steps/ExecutableStepsTest.java @@ -46,7 +46,6 @@ import io.cloudslang.runtime.impl.python.PythonRuntimeServiceImpl; import io.cloudslang.runtime.impl.python.external.ExternalPythonExecutionEngine; import io.cloudslang.runtime.impl.python.external.ExternalPythonRuntimeServiceImpl; -import io.cloudslang.runtime.impl.python.external.ExternalPythonServerService; import io.cloudslang.runtime.impl.python.external.ExternalPythonServerServiceImpl; import io.cloudslang.runtime.impl.python.external.StatefulRestEasyClientsHolder; import io.cloudslang.score.api.execution.precondition.ExecutionPreconditionService; @@ -272,7 +271,7 @@ public void testStartExecutableRebindArguments() { public void testStartExecutableRebindWithNoArguments() { List modifiedArguments = new ArrayList<>(); final RunEnvironment runEnv = new RunEnvironment(); - runEnv.getStack().pushContext(new Context(new HashMap<>(),new HashMap<>())); + runEnv.getStack().pushContext(new Context(new HashMap<>(), new HashMap<>())); runEnv.setContextModified(true); runEnv.setModifiedArguments(modifiedArguments); ExecutionRuntimeServices runtimeServices = new ExecutionRuntimeServices(); @@ -512,8 +511,9 @@ public PythonExecutionEngine pythonExecutionEngine() { } @Bean(name = "externalPythonServerService") - public ExternalPythonServerService externalPythonServerService() { - return new ExternalPythonServerServiceImpl(mock(StatefulRestEasyClientsHolder.class)); + public PythonRuntimeService externalPythonServerService() { + return new ExternalPythonServerServiceImpl(mock(StatefulRestEasyClientsHolder.class), + new Semaphore(100), new Semaphore(50)); } @Bean(name = "externalPythonRuntimeService") diff --git a/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/steps/ParallelLoopStepsTest.java b/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/steps/ParallelLoopStepsTest.java index 8733677b92..9104023d5c 100644 --- a/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/steps/ParallelLoopStepsTest.java +++ b/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/steps/ParallelLoopStepsTest.java @@ -35,6 +35,9 @@ import io.cloudslang.runtime.impl.python.PythonExecutionCachedEngine; import io.cloudslang.runtime.impl.python.PythonExecutionEngine; import io.cloudslang.runtime.impl.python.PythonRuntimeServiceImpl; +import io.cloudslang.runtime.impl.python.external.ExternalPythonExecutionEngine; +import io.cloudslang.runtime.impl.python.external.ExternalPythonServerServiceImpl; +import io.cloudslang.runtime.impl.python.external.StatefulRestEasyClientsHolder; import io.cloudslang.score.api.EndBranchDataContainer; import io.cloudslang.score.events.EventBus; import io.cloudslang.score.events.EventBusImpl; @@ -57,6 +60,7 @@ import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.concurrent.Semaphore; import static org.junit.Assert.assertThrows; import static org.junit.Assert.assertTrue; @@ -607,9 +611,16 @@ public PythonRuntimeService externalPythonRuntimeService() { return new PythonRuntimeServiceImpl(); } + @Bean(name = "externalPythonServerService") + public PythonRuntimeService externalPythonServerService() { + return new ExternalPythonServerServiceImpl(mock(StatefulRestEasyClientsHolder.class), + new Semaphore(100), new Semaphore(50)); + } + + @Bean(name = "externalPythonExecutionEngine") public PythonExecutionEngine externalPythonExecutionEngine() { - return new PythonExecutionCachedEngine(); + return new ExternalPythonExecutionEngine(); } @Bean diff --git a/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/steps/StepExecutionDataTest.java b/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/steps/StepExecutionDataTest.java index 6783463330..7e06911ef1 100644 --- a/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/steps/StepExecutionDataTest.java +++ b/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/steps/StepExecutionDataTest.java @@ -43,7 +43,6 @@ import io.cloudslang.runtime.impl.python.PythonRuntimeServiceImpl; import io.cloudslang.runtime.impl.python.external.ExternalPythonExecutionEngine; import io.cloudslang.runtime.impl.python.external.ExternalPythonRuntimeServiceImpl; -import io.cloudslang.runtime.impl.python.external.ExternalPythonServerService; import io.cloudslang.runtime.impl.python.external.ExternalPythonServerServiceImpl; import io.cloudslang.runtime.impl.python.external.StatefulRestEasyClientsHolder; import io.cloudslang.score.events.EventBus; @@ -644,8 +643,9 @@ public PythonExecutionEngine pythonExecutionEngine() { } @Bean(name = "externalPythonServerService") - public ExternalPythonServerService externalPythonServerService() { - return new ExternalPythonServerServiceImpl(mock(StatefulRestEasyClientsHolder.class)); + public PythonRuntimeService externalPythonServerService() { + return new ExternalPythonServerServiceImpl(mock(StatefulRestEasyClientsHolder.class), + new Semaphore(100), new Semaphore(50)); } @Bean(name = "externalPythonRuntimeService") From 3bdcefec620289e4e604c9993be535d7a4be5cc2 Mon Sep 17 00:00:00 2001 From: TVerdesOprea Date: Thu, 12 Jan 2023 11:40:50 +0200 Subject: [PATCH 2/3] change name pythonServer in pythonExecutor --- .../lang/runtime/bindings/scripts/ScriptEvaluator.java | 6 +++--- .../lang/runtime/bindings/ArgumentsBindingTest.java | 8 ++++---- .../lang/runtime/bindings/InputsBindingTest.java | 8 ++++---- .../lang/runtime/bindings/OutputsBindingTest.java | 8 ++++---- .../lang/runtime/bindings/ResultBindingTest.java | 8 ++++---- .../runtime/bindings/scripts/ScriptEvaluatorTest.java | 8 ++++---- .../lang/runtime/bindings/scripts/ScriptExecutorTest.java | 8 ++++---- .../io/cloudslang/lang/runtime/steps/ActionStepsTest.java | 8 ++++---- .../lang/runtime/steps/ExecutableStepsTest.java | 8 ++++---- .../lang/runtime/steps/ParallelLoopStepsTest.java | 8 ++++---- .../lang/runtime/steps/StepExecutionDataTest.java | 8 ++++---- 11 files changed, 43 insertions(+), 43 deletions(-) diff --git a/cloudslang-runtime/src/main/java/io/cloudslang/lang/runtime/bindings/scripts/ScriptEvaluator.java b/cloudslang-runtime/src/main/java/io/cloudslang/lang/runtime/bindings/scripts/ScriptEvaluator.java index 9d5c130e95..9789bc5f1a 100644 --- a/cloudslang-runtime/src/main/java/io/cloudslang/lang/runtime/bindings/scripts/ScriptEvaluator.java +++ b/cloudslang-runtime/src/main/java/io/cloudslang/lang/runtime/bindings/scripts/ScriptEvaluator.java @@ -59,8 +59,8 @@ public class ScriptEvaluator extends ScriptProcessor { @Resource(name = "jythonRuntimeService") private PythonRuntimeService legacyJythonRuntimeService; - @Resource(name = "externalPythonServerService") - private PythonRuntimeService pythonServerService; + @Resource(name = "externalPythonExecutorService") + private PythonRuntimeService pythonExecutorService; @Autowired private ScriptsService scriptsService; @@ -142,7 +142,7 @@ private Value doEvaluateExpressionServerPython(String expr, (Serializable) prepareSystemPropertiesForExternalPython(systemProperties)); } - PythonEvaluationResult result = pythonServerService.eval( + PythonEvaluationResult result = pythonExecutorService.eval( buildAddFunctionsScriptForExternalPython(functionDependencies), expr, pythonContext); //noinspection unchecked diff --git a/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/bindings/ArgumentsBindingTest.java b/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/bindings/ArgumentsBindingTest.java index 4e5716257b..26199b0269 100644 --- a/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/bindings/ArgumentsBindingTest.java +++ b/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/bindings/ArgumentsBindingTest.java @@ -28,8 +28,8 @@ import io.cloudslang.runtime.impl.python.PythonExecutionNotCachedEngine; import io.cloudslang.runtime.impl.python.PythonRuntimeServiceImpl; import io.cloudslang.runtime.impl.python.external.ExternalPythonExecutionEngine; +import io.cloudslang.runtime.impl.python.external.ExternalPythonExecutorServiceImpl; import io.cloudslang.runtime.impl.python.external.ExternalPythonRuntimeServiceImpl; -import io.cloudslang.runtime.impl.python.external.ExternalPythonServerServiceImpl; import io.cloudslang.runtime.impl.python.external.StatefulRestEasyClientsHolder; import io.cloudslang.score.events.EventBus; import io.cloudslang.score.events.EventBusImpl; @@ -459,9 +459,9 @@ public PythonExecutionEngine pythonExecutionEngine() { return new PythonExecutionCachedEngine(); } - @Bean(name = "externalPythonServerService") - public PythonRuntimeService externalPythonServerService() { - return new ExternalPythonServerServiceImpl(mock(StatefulRestEasyClientsHolder.class), + @Bean(name = "externalPythonExecutorService") + public PythonRuntimeService externalPythonExecutorService() { + return new ExternalPythonExecutorServiceImpl(mock(StatefulRestEasyClientsHolder.class), new Semaphore(100), new Semaphore(50)); } diff --git a/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/bindings/InputsBindingTest.java b/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/bindings/InputsBindingTest.java index d932966760..de907b4d75 100644 --- a/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/bindings/InputsBindingTest.java +++ b/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/bindings/InputsBindingTest.java @@ -26,8 +26,8 @@ import io.cloudslang.runtime.impl.python.PythonExecutionEngine; import io.cloudslang.runtime.impl.python.PythonRuntimeServiceImpl; import io.cloudslang.runtime.impl.python.external.ExternalPythonExecutionEngine; +import io.cloudslang.runtime.impl.python.external.ExternalPythonExecutorServiceImpl; import io.cloudslang.runtime.impl.python.external.ExternalPythonRuntimeServiceImpl; -import io.cloudslang.runtime.impl.python.external.ExternalPythonServerServiceImpl; import io.cloudslang.runtime.impl.python.external.StatefulRestEasyClientsHolder; import io.cloudslang.score.events.EventBus; import io.cloudslang.score.events.EventBusImpl; @@ -558,9 +558,9 @@ public PythonExecutionEngine pythonExecutionEngine() { return new PythonExecutionCachedEngine(); } - @Bean(name = "externalPythonServerService") - public PythonRuntimeService externalPythonServerService() { - return new ExternalPythonServerServiceImpl(mock(StatefulRestEasyClientsHolder.class), + @Bean(name = "externalPythonExecutorService") + public PythonRuntimeService externalPythonExecutorService() { + return new ExternalPythonExecutorServiceImpl(mock(StatefulRestEasyClientsHolder.class), new Semaphore(100), new Semaphore(50)); } diff --git a/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/bindings/OutputsBindingTest.java b/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/bindings/OutputsBindingTest.java index 4d478ed24a..f62ed588f1 100644 --- a/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/bindings/OutputsBindingTest.java +++ b/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/bindings/OutputsBindingTest.java @@ -25,8 +25,8 @@ import io.cloudslang.runtime.impl.python.PythonExecutionEngine; import io.cloudslang.runtime.impl.python.PythonRuntimeServiceImpl; import io.cloudslang.runtime.impl.python.external.ExternalPythonExecutionEngine; +import io.cloudslang.runtime.impl.python.external.ExternalPythonExecutorServiceImpl; import io.cloudslang.runtime.impl.python.external.ExternalPythonRuntimeServiceImpl; -import io.cloudslang.runtime.impl.python.external.ExternalPythonServerServiceImpl; import io.cloudslang.runtime.impl.python.external.StatefulRestEasyClientsHolder; import io.cloudslang.score.events.EventBus; import io.cloudslang.score.events.EventBusImpl; @@ -266,9 +266,9 @@ public PythonExecutionEngine pythonExecutionEngine() { return new PythonExecutionCachedEngine(); } - @Bean(name = "externalPythonServerService") - public PythonRuntimeService externalPythonServerService() { - return new ExternalPythonServerServiceImpl(mock(StatefulRestEasyClientsHolder.class), + @Bean(name = "externalPythonExecutorService") + public PythonRuntimeService externalPythonExecutorService() { + return new ExternalPythonExecutorServiceImpl(mock(StatefulRestEasyClientsHolder.class), new Semaphore(100), new Semaphore(50)); } diff --git a/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/bindings/ResultBindingTest.java b/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/bindings/ResultBindingTest.java index 7c67e523f3..6ce5e68e7b 100644 --- a/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/bindings/ResultBindingTest.java +++ b/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/bindings/ResultBindingTest.java @@ -26,8 +26,8 @@ import io.cloudslang.runtime.impl.python.PythonExecutionEngine; import io.cloudslang.runtime.impl.python.PythonRuntimeServiceImpl; import io.cloudslang.runtime.impl.python.external.ExternalPythonExecutionEngine; +import io.cloudslang.runtime.impl.python.external.ExternalPythonExecutorServiceImpl; import io.cloudslang.runtime.impl.python.external.ExternalPythonRuntimeServiceImpl; -import io.cloudslang.runtime.impl.python.external.ExternalPythonServerServiceImpl; import io.cloudslang.runtime.impl.python.external.StatefulRestEasyClientsHolder; import io.cloudslang.score.events.EventBus; import io.cloudslang.score.events.EventBusImpl; @@ -243,9 +243,9 @@ public PythonExecutionEngine pythonExecutionEngine() { return new PythonExecutionCachedEngine(); } - @Bean(name = "externalPythonServerService") - public PythonRuntimeService externalPythonServerService() { - return new ExternalPythonServerServiceImpl(mock(StatefulRestEasyClientsHolder.class), + @Bean(name = "externalPythonExecutorService") + public PythonRuntimeService externalPythonExecutorService() { + return new ExternalPythonExecutorServiceImpl(mock(StatefulRestEasyClientsHolder.class), new Semaphore(100), new Semaphore(50)); } diff --git a/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/bindings/scripts/ScriptEvaluatorTest.java b/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/bindings/scripts/ScriptEvaluatorTest.java index e7d70a7cba..62257fdf0f 100644 --- a/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/bindings/scripts/ScriptEvaluatorTest.java +++ b/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/bindings/scripts/ScriptEvaluatorTest.java @@ -24,8 +24,8 @@ import io.cloudslang.runtime.impl.python.PythonExecutionEngine; import io.cloudslang.runtime.impl.python.PythonExecutor; import io.cloudslang.runtime.impl.python.external.ExternalPythonExecutionEngine; +import io.cloudslang.runtime.impl.python.external.ExternalPythonExecutorServiceImpl; import io.cloudslang.runtime.impl.python.external.ExternalPythonRuntimeServiceImpl; -import io.cloudslang.runtime.impl.python.external.ExternalPythonServerServiceImpl; import io.cloudslang.runtime.impl.python.external.StatefulRestEasyClientsHolder; import io.cloudslang.score.events.EventBus; import io.cloudslang.score.events.EventBusImpl; @@ -209,9 +209,9 @@ protected PythonInterpreter initInterpreter(Set dependencies) { }; } - @Bean(name = "externalPythonServerService") - public PythonRuntimeService externalPythonServerService() { - return new ExternalPythonServerServiceImpl(mock(StatefulRestEasyClientsHolder.class), + @Bean(name = "externalPythonExecutorService") + public PythonRuntimeService externalPythonExecutorService() { + return new ExternalPythonExecutorServiceImpl(mock(StatefulRestEasyClientsHolder.class), new Semaphore(100), new Semaphore(50)); } diff --git a/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/bindings/scripts/ScriptExecutorTest.java b/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/bindings/scripts/ScriptExecutorTest.java index a7c0f42afb..42466bcd25 100644 --- a/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/bindings/scripts/ScriptExecutorTest.java +++ b/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/bindings/scripts/ScriptExecutorTest.java @@ -23,8 +23,8 @@ import io.cloudslang.runtime.impl.python.PythonExecutor; import io.cloudslang.runtime.impl.python.PythonRuntimeServiceImpl; import io.cloudslang.runtime.impl.python.external.ExternalPythonExecutionEngine; +import io.cloudslang.runtime.impl.python.external.ExternalPythonExecutorServiceImpl; import io.cloudslang.runtime.impl.python.external.ExternalPythonRuntimeServiceImpl; -import io.cloudslang.runtime.impl.python.external.ExternalPythonServerServiceImpl; import io.cloudslang.runtime.impl.python.external.StatefulRestEasyClientsHolder; import io.cloudslang.score.events.EventBus; import io.cloudslang.score.events.EventBusImpl; @@ -199,9 +199,9 @@ protected PythonInterpreter initInterpreter(Set dependencies) { }; } - @Bean(name = "externalPythonServerService") - public PythonRuntimeService externalPythonServerService() { - return new ExternalPythonServerServiceImpl(mock(StatefulRestEasyClientsHolder.class), + @Bean(name = "externalPythonExecutorService") + public PythonRuntimeService externalPythonExecutorService() { + return new ExternalPythonExecutorServiceImpl(mock(StatefulRestEasyClientsHolder.class), new Semaphore(100), new Semaphore(50)); } diff --git a/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/steps/ActionStepsTest.java b/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/steps/ActionStepsTest.java index 23a7054e4a..a232ab14a0 100644 --- a/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/steps/ActionStepsTest.java +++ b/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/steps/ActionStepsTest.java @@ -35,8 +35,8 @@ import io.cloudslang.runtime.impl.python.PythonExecutionEngine; import io.cloudslang.runtime.impl.python.PythonRuntimeServiceImpl; import io.cloudslang.runtime.impl.python.external.ExternalPythonExecutionEngine; +import io.cloudslang.runtime.impl.python.external.ExternalPythonExecutorServiceImpl; import io.cloudslang.runtime.impl.python.external.ExternalPythonRuntimeServiceImpl; -import io.cloudslang.runtime.impl.python.external.ExternalPythonServerServiceImpl; import io.cloudslang.runtime.impl.python.external.StatefulRestEasyClientsHolder; import io.cloudslang.score.api.execution.ExecutionParametersConsts; import io.cloudslang.score.events.EventBus; @@ -1206,9 +1206,9 @@ public PythonExecutionEngine pythonExecutionEngine() { return new PythonExecutionCachedEngine(); } - @Bean(name = "externalPythonServerService") - public PythonRuntimeService externalPythonServerService() { - return new ExternalPythonServerServiceImpl(mock(StatefulRestEasyClientsHolder.class), + @Bean(name = "externalPythonExecutorService") + public PythonRuntimeService externalPythonExecutorService() { + return new ExternalPythonExecutorServiceImpl(mock(StatefulRestEasyClientsHolder.class), new Semaphore(100), new Semaphore(50)); } diff --git a/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/steps/ExecutableStepsTest.java b/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/steps/ExecutableStepsTest.java index 0736e13a8a..d85edff130 100644 --- a/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/steps/ExecutableStepsTest.java +++ b/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/steps/ExecutableStepsTest.java @@ -45,8 +45,8 @@ import io.cloudslang.runtime.impl.python.PythonExecutionEngine; import io.cloudslang.runtime.impl.python.PythonRuntimeServiceImpl; import io.cloudslang.runtime.impl.python.external.ExternalPythonExecutionEngine; +import io.cloudslang.runtime.impl.python.external.ExternalPythonExecutorServiceImpl; import io.cloudslang.runtime.impl.python.external.ExternalPythonRuntimeServiceImpl; -import io.cloudslang.runtime.impl.python.external.ExternalPythonServerServiceImpl; import io.cloudslang.runtime.impl.python.external.StatefulRestEasyClientsHolder; import io.cloudslang.score.api.execution.precondition.ExecutionPreconditionService; import io.cloudslang.score.events.EventBus; @@ -510,9 +510,9 @@ public PythonExecutionEngine pythonExecutionEngine() { return new PythonExecutionCachedEngine(); } - @Bean(name = "externalPythonServerService") - public PythonRuntimeService externalPythonServerService() { - return new ExternalPythonServerServiceImpl(mock(StatefulRestEasyClientsHolder.class), + @Bean(name = "externalPythonExecutorService") + public PythonRuntimeService externalPythonExecutorService() { + return new ExternalPythonExecutorServiceImpl(mock(StatefulRestEasyClientsHolder.class), new Semaphore(100), new Semaphore(50)); } diff --git a/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/steps/ParallelLoopStepsTest.java b/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/steps/ParallelLoopStepsTest.java index 9104023d5c..8e0892b73e 100644 --- a/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/steps/ParallelLoopStepsTest.java +++ b/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/steps/ParallelLoopStepsTest.java @@ -36,7 +36,7 @@ import io.cloudslang.runtime.impl.python.PythonExecutionEngine; import io.cloudslang.runtime.impl.python.PythonRuntimeServiceImpl; import io.cloudslang.runtime.impl.python.external.ExternalPythonExecutionEngine; -import io.cloudslang.runtime.impl.python.external.ExternalPythonServerServiceImpl; +import io.cloudslang.runtime.impl.python.external.ExternalPythonExecutorServiceImpl; import io.cloudslang.runtime.impl.python.external.StatefulRestEasyClientsHolder; import io.cloudslang.score.api.EndBranchDataContainer; import io.cloudslang.score.events.EventBus; @@ -611,9 +611,9 @@ public PythonRuntimeService externalPythonRuntimeService() { return new PythonRuntimeServiceImpl(); } - @Bean(name = "externalPythonServerService") - public PythonRuntimeService externalPythonServerService() { - return new ExternalPythonServerServiceImpl(mock(StatefulRestEasyClientsHolder.class), + @Bean(name = "externalPythonExecutorService") + public PythonRuntimeService externalPythonexecutorService() { + return new ExternalPythonExecutorServiceImpl(mock(StatefulRestEasyClientsHolder.class), new Semaphore(100), new Semaphore(50)); } diff --git a/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/steps/StepExecutionDataTest.java b/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/steps/StepExecutionDataTest.java index 7e06911ef1..bef221dfd6 100644 --- a/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/steps/StepExecutionDataTest.java +++ b/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/steps/StepExecutionDataTest.java @@ -42,8 +42,8 @@ import io.cloudslang.runtime.impl.python.PythonExecutionEngine; import io.cloudslang.runtime.impl.python.PythonRuntimeServiceImpl; import io.cloudslang.runtime.impl.python.external.ExternalPythonExecutionEngine; +import io.cloudslang.runtime.impl.python.external.ExternalPythonExecutorServiceImpl; import io.cloudslang.runtime.impl.python.external.ExternalPythonRuntimeServiceImpl; -import io.cloudslang.runtime.impl.python.external.ExternalPythonServerServiceImpl; import io.cloudslang.runtime.impl.python.external.StatefulRestEasyClientsHolder; import io.cloudslang.score.events.EventBus; import io.cloudslang.score.events.EventBusImpl; @@ -642,9 +642,9 @@ public PythonExecutionEngine pythonExecutionEngine() { return new PythonExecutionCachedEngine(); } - @Bean(name = "externalPythonServerService") - public PythonRuntimeService externalPythonServerService() { - return new ExternalPythonServerServiceImpl(mock(StatefulRestEasyClientsHolder.class), + @Bean(name = "externalPythonExecutorService") + public PythonRuntimeService externalPythonExecutorService() { + return new ExternalPythonExecutorServiceImpl(mock(StatefulRestEasyClientsHolder.class), new Semaphore(100), new Semaphore(50)); } From 6df3d06d566ecffbe742247d080b21b364ae0846 Mon Sep 17 00:00:00 2001 From: TVerdesOprea Date: Thu, 12 Jan 2023 11:43:23 +0200 Subject: [PATCH 3/3] rename function --- .../lang/runtime/bindings/scripts/ScriptEvaluator.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cloudslang-runtime/src/main/java/io/cloudslang/lang/runtime/bindings/scripts/ScriptEvaluator.java b/cloudslang-runtime/src/main/java/io/cloudslang/lang/runtime/bindings/scripts/ScriptEvaluator.java index 9789bc5f1a..cedf108700 100644 --- a/cloudslang-runtime/src/main/java/io/cloudslang/lang/runtime/bindings/scripts/ScriptEvaluator.java +++ b/cloudslang-runtime/src/main/java/io/cloudslang/lang/runtime/bindings/scripts/ScriptEvaluator.java @@ -70,13 +70,13 @@ public Value evalExpr(String expr, Map context, Set context, Set systemProperties, Set functionDependencies) {