This is an automated email from the ASF dual-hosted git repository.

heneveld pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brooklyn-server.git


The following commit(s) were added to refs/heads/master by this push:
     new 375c5a6b51 persist workflows on failure
375c5a6b51 is described below

commit 375c5a6b51bcf5b884c9ec31e8bcb17747d29e06
Author: Alex Heneveld <[email protected]>
AuthorDate: Mon Aug 7 12:51:53 2023 +0100

    persist workflows on failure
    
    otherwise they report still running
---
 .../brooklyn/core/workflow/WorkflowExecutionContext.java |  1 +
 .../core/workflow/WorkflowPersistReplayErrorsTest.java   | 16 ++++++++++++++++
 2 files changed, 17 insertions(+)

diff --git 
a/core/src/main/java/org/apache/brooklyn/core/workflow/WorkflowExecutionContext.java
 
b/core/src/main/java/org/apache/brooklyn/core/workflow/WorkflowExecutionContext.java
index f912c5b194..f97666c1bc 100644
--- 
a/core/src/main/java/org/apache/brooklyn/core/workflow/WorkflowExecutionContext.java
+++ 
b/core/src/main/java/org/apache/brooklyn/core/workflow/WorkflowExecutionContext.java
@@ -1394,6 +1394,7 @@ public class WorkflowExecutionContext {
         private Object endWithError(Throwable e, WorkflowStatus 
provisionalStatus) {
             updateStatus(provisionalStatus);
             
WorkflowReplayUtils.updateOnWorkflowError(WorkflowExecutionContext.this, task, 
e);
+            persist();
 
             try {
                 log.debug("Error running workflow " + this + "; will persist 
then rethrow: " + e);
diff --git 
a/core/src/test/java/org/apache/brooklyn/core/workflow/WorkflowPersistReplayErrorsTest.java
 
b/core/src/test/java/org/apache/brooklyn/core/workflow/WorkflowPersistReplayErrorsTest.java
index e85f5af11c..bb94e587f5 100644
--- 
a/core/src/test/java/org/apache/brooklyn/core/workflow/WorkflowPersistReplayErrorsTest.java
+++ 
b/core/src/test/java/org/apache/brooklyn/core/workflow/WorkflowPersistReplayErrorsTest.java
@@ -642,6 +642,22 @@ public class WorkflowPersistReplayErrorsTest extends 
RebindTestFixture<BasicAppl
         }
     }
 
+    @Test
+    public void testSimpleErrorHandlerOnWorkflowFailing() throws IOException {
+        lastInvocation = runSteps(MutableList.of("invoke-effector 
does-not-exist"),
+                null,
+                ConfigBag.newInstance().configure(
+                        WorkflowEffector.ON_ERROR, MutableList.of("set-sensor 
had_error = yes", "fail rethrow message rethrown")) );
+        Asserts.assertFailsWith(() -> lastInvocation.getUnchecked(), e -> {
+            Asserts.expectedFailureContains(e, "rethrown");
+            Asserts.assertThat(Exceptions.getCausalChain(e), ee -> 
ee.stream().filter(e2 -> 
e2.toString().contains("does-not-exist")).findAny().isPresent());
+            return true;
+        });
+        Asserts.assertEquals(app.sensors().get(Sensors.newSensor(Object.class, 
"had_error")), "yes");
+        findSingleLastWorkflow();
+        Asserts.assertEquals(lastWorkflowContext.status, 
WorkflowExecutionContext.WorkflowStatus.ERROR);
+    }
+
     @Test
     public void testErrorHandlerListWithGotoExit() throws IOException {
         try (ClassLogWatcher logWatcher = new 
ClassLogWatcher(getClass().getPackage().getName())) {

Reply via email to