Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

worker group on simple loops fix #1367

Merged
merged 2 commits into from
Aug 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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