private static final String COMPLETED = "completed";
private static final String HANDLINGCODE = "handlingCode";
private static final String ROLLBACKTOCREATED = "RollbackToCreated";
+ private static final String REPLACEINSTANCE = "replaceInstance";
+ private static final String VFMODULE = "VfModule";
protected String maxRetries = "mso.rainyDay.maxRetries";
private static final Logger logger = LoggerFactory.getLogger(WorkflowActionBBTasks.class);
* working on.
*/
public void rollbackExecutionPath(DelegateExecution execution) {
+ final String action = (String) execution.getVariable(G_ACTION);
+ final String resourceName = (String) execution.getVariable("resourceName");
if (!(boolean) execution.getVariable("isRollback")) {
List<ExecuteBuildingBlock> flowsToExecute =
(List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+
+ List<ExecuteBuildingBlock> flowsToExecuteChangeBBs = new ArrayList();
+ for (int i = 0; i < flowsToExecute.size(); i++) {
+ if (flowsToExecute.get(i).getBuildingBlock().getBpmnFlowName().startsWith("Change")) {
+ flowsToExecuteChangeBBs.add(flowsToExecute.get(i));
+ }
+ }
+
List<ExecuteBuildingBlock> rollbackFlows = new ArrayList();
int currentSequence = (int) execution.getVariable(G_CURRENT_SEQUENCE);
int listSize = flowsToExecute.size();
+
for (int i = listSize - 1; i >= 0; i--) {
if (i > currentSequence - 1) {
flowsToExecute.remove(i);
}
}
+ List<ExecuteBuildingBlock> rollbackFlowsFilteredNonChangeBBs = new ArrayList();
+ if (action.equals(REPLACEINSTANCE) && resourceName.equals(VFMODULE)) {
+ for (int i = 0; i < rollbackFlowsFiltered.size(); i++) {
+ if (!rollbackFlowsFiltered.get(i).getBuildingBlock().getBpmnFlowName().startsWith("Change")) {
+ rollbackFlowsFilteredNonChangeBBs.add(rollbackFlowsFiltered.get(i));
+ }
+ }
+ rollbackFlowsFiltered.clear();
+ rollbackFlowsFiltered.addAll(flowsToExecuteChangeBBs);
+ rollbackFlowsFiltered.addAll(rollbackFlowsFilteredNonChangeBBs);
+ }
+
workflowActionBBFailure.updateRequestErrorStatusMessage(execution);
if (rollbackFlows.isEmpty())
execution.setVariable("isRollbackNeeded", false);
private static final String SAMPLE_MSO_REQUEST_ID = "00f704ca-c5e5-4f95-a72c-6889db7b0688";
private static final String SAMPLE_REQUEST_ACTION = "Delete-Network-Collection";
private static final int SAMPLE_SEQUENCE = 0;
+ private static final String EMPTY_STRING = "";
@Mock
protected WorkflowAction workflowAction;
public void rollbackExecutionPathTest() {
execution.setVariable("handlingCode", "Rollback");
execution.setVariable("isRollback", false);
+ execution.setVariable("requestAction", EMPTY_STRING);
+ execution.setVariable("resourceName", EMPTY_STRING);
List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignVfModuleBB");
ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1);
public void rollbackExecutionPathUnfinishedFlowTest() {
execution.setVariable("handlingCode", "Rollback");
execution.setVariable("isRollback", false);
+ execution.setVariable("requestAction", EMPTY_STRING);
+ execution.setVariable("resourceName", EMPTY_STRING);
List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignVfModuleBB");
ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1);
public void rollbackExecutionTest() {
execution.setVariable("handlingCode", "Rollback");
execution.setVariable("isRollback", false);
+ execution.setVariable("requestAction", EMPTY_STRING);
+ execution.setVariable("resourceName", EMPTY_STRING);
List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignServiceInstanceBB");
ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1);
public void rollbackExecutionRollbackToAssignedTest() {
execution.setVariable("isRollback", false);
execution.setVariable("handlingCode", "RollbackToAssigned");
+ execution.setVariable("requestAction", EMPTY_STRING);
+ execution.setVariable("resourceName", EMPTY_STRING);
List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignVfModuleBB");
assertEquals(1, ebbs.size());
}
+ @Test
+ public void rollbackExecutionPathChangeBBForReplaceVFModuleTest() {
+ execution.setVariable("handlingCode", "Rollback");
+ execution.setVariable("isRollback", false);
+ execution.setVariable("requestAction", "replaceInstance");
+ execution.setVariable("resourceName", "VfModule");
+ List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
+ BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignVfModuleBB");
+ ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1);
+ flowsToExecute.add(ebb1);
+
+ BuildingBlock buildingBlock2 = new BuildingBlock().setBpmnFlowName("CreateVfModuleBB");
+ ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock2);
+ flowsToExecute.add(ebb2);
+
+ BuildingBlock buildingBlock3 = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB");
+ ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock3);
+ flowsToExecute.add(ebb3);
+
+
+ BuildingBlock buildingBlock4 = new BuildingBlock().setBpmnFlowName("ChangeModelVnfBB");
+ ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock4);
+ flowsToExecute.add(ebb4);
+
+ BuildingBlock buildingBlock5 = new BuildingBlock().setBpmnFlowName("ChangeModelServiceInstanceBB");
+ ExecuteBuildingBlock ebb5 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock5);
+ flowsToExecute.add(ebb5);
+
+ execution.setVariable("flowsToExecute", flowsToExecute);
+ execution.setVariable("gCurrentSequence", 5);
+ doNothing().when(workflowActionBBFailure).updateRequestErrorStatusMessage(isA(DelegateExecution.class));
+
+ workflowActionBBTasks.rollbackExecutionPath(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ assertEquals(ebbs.get(0).getBuildingBlock().getBpmnFlowName(), "ChangeModelVnfBB");
+ assertEquals(ebbs.get(1).getBuildingBlock().getBpmnFlowName(), "ChangeModelServiceInstanceBB");
+ assertEquals(0, execution.getVariable("gCurrentSequence"));
+ }
+
@Test
public void rollbackExecutionRollbackToAssignedWithFabricTest() {
execution.setVariable("isRollback", false);
execution.setVariable("handlingCode", "RollbackToAssigned");
+ execution.setVariable("requestAction", EMPTY_STRING);
+ execution.setVariable("resourceName", EMPTY_STRING);
List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignVfModuleBB");
public void rollbackExecutionRollbackToCreatedTest() {
execution.setVariable("isRollback", false);
execution.setVariable("handlingCode", "RollbackToCreated");
+ execution.setVariable("requestAction", EMPTY_STRING);
+ execution.setVariable("resourceName", EMPTY_STRING);
List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignVfModuleBB");
ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1);
public void rollbackExecutionRollbackInPlaceSoftwareUpdateTest() {
execution.setVariable("isRollback", false);
execution.setVariable("handlingCode", "Rollback");
+ execution.setVariable("requestAction", EMPTY_STRING);
+ execution.setVariable("resourceName", EMPTY_STRING);
List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("VNFCheckPserversLockedFlagActivity");
ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1);
public void rollbackExecutionRollbackConfigModifyTest() {
execution.setVariable("isRollback", false);
execution.setVariable("handlingCode", "Rollback");
+ execution.setVariable("requestAction", EMPTY_STRING);
+ execution.setVariable("resourceName", EMPTY_STRING);
List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("VNFCheckPserversLockedFlagActivity");
ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1);