diff options
author | Jozsef Csongvai <jozsef.csongvai@bell.ca> | 2022-06-13 08:53:19 -0400 |
---|---|---|
committer | Jozsef Csongvai <jozsef.csongvai@bell.ca> | 2022-06-29 17:40:31 -0400 |
commit | 5baa1ed97c1d2b98952a025c3bc76f60587e9670 (patch) | |
tree | baa4fbf040c19c7ade2cb9feb602dff4906bbe9b /bpmn/so-bpmn-tasks | |
parent | 366a173f798422b956625aa83d81fc863e0914a5 (diff) |
Enable long-running processes in ControllerExecutionBB
Instead of blocking a thread while waiting for controller response,
ControllerExecutionBB is now using camunda receive task to support
long running processes without increasing the camunda job timeout.
A new property was added to configure the gRPC client's keep alive
ping mechanism, which will identify connection issues and prevent
the process getting stuck when the controller crashes.
Issue-ID: SO-3953
Signed-off-by: Jozsef Csongvai <jozsef.csongvai@bell.ca>
Change-Id: Iaf6438dba76e715dba846bf45ef47b6a91239c4a
Diffstat (limited to 'bpmn/so-bpmn-tasks')
3 files changed, 52 insertions, 1 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/ControllerExecutionBB.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/ControllerExecutionBB.java index 92be824691..c5536106fe 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/ControllerExecutionBB.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/ControllerExecutionBB.java @@ -26,11 +26,13 @@ import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext; import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerRunnable; import org.onap.so.bpmn.infrastructure.decisionpoint.impl.AbstractControllerExecution; +import org.onap.so.client.cds.PayloadConstants; import org.onap.so.db.catalog.beans.ControllerSelectionReference; import org.onap.so.db.catalog.beans.PnfResourceCustomization; import org.onap.so.db.catalog.beans.VnfResourceCustomization; import org.onap.so.db.catalog.client.CatalogDbClient; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; /** @@ -52,8 +54,11 @@ public class ControllerExecutionBB extends AbstractControllerExecution<BuildingB @Autowired protected CatalogDbClient catalogDbClient; + @Value("${controller-execution.timeout-for-controller-message:P1D}") + private String timeoutForControllerMessage; public void execute(final BuildingBlockExecution execution) { + execution.setVariable(PayloadConstants.TIMEOUT_CONTROLLER_MESSAGE, timeoutForControllerMessage); ControllerContext<BuildingBlockExecution> controllerContext = buildControllerContext(execution); controllerExecute(controllerContext); } @@ -151,4 +156,18 @@ public class ControllerExecutionBB extends AbstractControllerExecution<BuildingB "Unable to find the controller implementation", ONAPComponents.SO); } } + + public void handleFailure(final BuildingBlockExecution execution) { + String errorMessage = execution.getVariable(PayloadConstants.CONTROLLER_ERROR_MESSAGE); + + if (Boolean.TRUE.equals(execution.getVariable(PayloadConstants.CONTROLLER_MSG_TIMEOUT_REACHED))) { + logger.error( + "timeout-for-controller-message was reached. If the controller is still processing, this property should be reconfigured"); + errorMessage = "Controller response was not received within configured timeout"; + } else if (errorMessage == null) { + errorMessage = "Controller call failed. No errormessage was captured."; + } + + exceptionBuilder.buildAndThrowWorkflowException(execution, 9003, errorMessage, ONAPComponents.SO); + } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/ControllerExecutionBBTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/ControllerExecutionBBTest.java index 0f9b4d9012..abc2cc4f76 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/ControllerExecutionBBTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/ControllerExecutionBBTest.java @@ -20,6 +20,10 @@ package org.onap.so.bpmn.infrastructure.decisionpoint.impl.buildingblock; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyInt; +import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import static org.onap.so.bpmn.infrastructure.decisionpoint.impl.buildingblock.MockControllerBB.TEST_ACTION; @@ -27,7 +31,10 @@ import static org.onap.so.bpmn.infrastructure.decisionpoint.impl.buildingblock.M import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.mockito.ArgumentCaptor; +import org.onap.logging.filter.base.ONAPComponents; import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.client.cds.PayloadConstants; import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.db.catalog.beans.ControllerSelectionReference; import org.onap.so.db.catalog.beans.PnfResourceCustomization; @@ -70,6 +77,9 @@ public class ControllerExecutionBBTest { @MockBean private ControllerSelectionReference controllerSelectionReference; + @MockBean + ExceptionBuilder exceptionBuilder; + @Before public void setUp() { when(execution.getVariable(ACTOR_PARAM)).thenReturn(TEST_ACTOR); @@ -157,4 +167,26 @@ public class ControllerExecutionBBTest { expectedVnfControllerActor, controllerActor); } } + + @Test + public void testHandleFailure() { + when(execution.getVariable(PayloadConstants.CONTROLLER_ERROR_MESSAGE)).thenReturn("ERROR MESSAGE"); + + controllerExecutionBB.handleFailure(execution); + + verify(exceptionBuilder).buildAndThrowWorkflowException(execution, 9003, "ERROR MESSAGE", ONAPComponents.SO); + } + + @Test + public void testHandleTimeoutFailure() { + when(execution.getVariable(PayloadConstants.CONTROLLER_MSG_TIMEOUT_REACHED)).thenReturn(true); + + controllerExecutionBB.handleFailure(execution); + + ArgumentCaptor<String> errMsgCaptor = ArgumentCaptor.forClass(String.class); + verify(exceptionBuilder, times(1)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), anyInt(), + errMsgCaptor.capture(), any()); + + assertTrue(errMsgCaptor.getValue().contains("timeout")); + } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/cds/PnfConfigCdsControllerDETest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/cds/PnfConfigCdsControllerDETest.java index d8f607f6d9..3c3dc839c8 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/cds/PnfConfigCdsControllerDETest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/cds/PnfConfigCdsControllerDETest.java @@ -50,7 +50,7 @@ public class PnfConfigCdsControllerDETest { @MockBean private ControllerPreparable<DelegateExecution> preparable; - @Mock + @MockBean private AbstractCDSProcessingBBUtils abstractCDSProcessingBBUtils; @Test |