Skip to content

Commit

Permalink
worker group on simple loops fix (#1367)
Browse files Browse the repository at this point in the history
* worker group on simple loops fix

* worker group on simple loops fix
  • Loading branch information
adriana-corui authored Aug 5, 2022
1 parent 4bca0ad commit c98fc80
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -203,14 +203,16 @@ protected static boolean handleEndLoopCondition(RunEnvironment runEnv,
if (langVariables.containsKey(LoopCondition.LOOP_CONDITION_KEY)) {
LoopCondition loopCondition = (LoopCondition) langVariables.get(LoopCondition.LOOP_CONDITION_KEY).get();
if (!shouldBreakLoop(breakOn, executableReturnValues) && loopCondition.hasMore()) {
runEnv.putNextStepPosition(previousStepId);
// setWorkerGroupStep will always precede beginStep in execution plan
final Long workerGroupStepPosition = previousStepId != null ? previousStepId - 1 : null;
runEnv.putNextStepPosition(workerGroupStepPosition);
runEnv.getStack().pushContext(flowContext);
throwEventOutputEnd(
runEnv,
executionRuntimeServices,
nodeName,
publishValues,
previousStepId,
workerGroupStepPosition,
new ReturnValues(publishValues, executableReturnValues.getResult()),
ExecutionParametersConsts.DEFAULT_ROI_VALUE,
contextAccessor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@
import io.cloudslang.score.lang.ExecutionRuntimeServices;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.python.google.common.collect.Lists;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -518,7 +516,7 @@ public void whenLoopConditionIsOfForTypeStartStepWillIncrementIt() {
}

@Test
public void whenLoopConditionHasMoreEndStepSetNextPositionIdToBeginStep() throws Exception {
public void whenLoopConditionHasMoreEndStepSetNextPositionIdToSetWorkerStep() throws Exception {
RunEnvironment runEnv = new RunEnvironment();
runEnv.putReturnValues(new ReturnValues(new HashMap<String, Value>(), "SUCCESS"));
HashMap<String, ResultNavigation> stepNavigationValues = new HashMap<>();
Expand All @@ -529,11 +527,11 @@ public void whenLoopConditionHasMoreEndStepSetNextPositionIdToBeginStep() throws
context.putLanguageVariable(LoopCondition.LOOP_CONDITION_KEY, ValueFactory.create(mockLoopCondition));
when(mockLoopCondition.hasMore()).thenReturn(true);

Long previousStepId = 1L;
Long previousStepId = 2L;
stepExecutionData.endStep(runEnv, new ArrayList<Output>(), stepNavigationValues,
createRuntimeServices(), previousStepId, new ArrayList<String>(), "stepName", false);

assertEquals(previousStepId, runEnv.removeNextStepPosition());
assertEquals(Long.valueOf(previousStepId - 1), runEnv.removeNextStepPosition());
assertEquals(context, runEnv.getStack().popContext());
}

Expand Down

0 comments on commit c98fc80

Please sign in to comment.