20
20
21
21
package io .temporal .testserver .functional ;
22
22
23
- import static org .junit .Assume .assumeFalse ;
24
-
25
23
import io .grpc .Status ;
26
24
import io .grpc .StatusRuntimeException ;
27
25
import io .temporal .api .common .v1 .Payloads ;
@@ -548,7 +546,6 @@ public void updateAndPollByWorkflowId() {
548
546
@ Test
549
547
public void getCompletedUpdateOfCompletedWorkflow () {
550
548
// Assert that we can get and poll a completed update from a completed workflow.
551
- assumeFalse ("Skipping as real server has a bug" , SDKTestWorkflowRule .useExternalService );
552
549
553
550
WorkflowOptions options =
554
551
WorkflowOptions .newBuilder ().setTaskQueue (testWorkflowRule .getTaskQueue ()).build ();
@@ -593,7 +590,7 @@ public void getCompletedUpdateOfCompletedWorkflow() {
593
590
594
591
@ Test
595
592
public void getIncompleteUpdateOfCompletedWorkflow () {
596
- // Assert that we can't get an incomplete update of a completed workflow. Expect a NOT_FOUND
593
+ // Assert that the server fails an incomplete update if the workflow is completed.
597
594
WorkflowOptions options =
598
595
WorkflowOptions .newBuilder ().setTaskQueue (testWorkflowRule .getTaskQueue ()).build ();
599
596
@@ -617,48 +614,60 @@ public void getIncompleteUpdateOfCompletedWorkflow() {
617
614
workflowStub .signal ();
618
615
workflowStub .execute ();
619
616
620
- StatusRuntimeException exception =
621
- Assert .assertThrows (
622
- StatusRuntimeException .class ,
623
- () ->
624
- updateWorkflow (
625
- exec ,
626
- "updateId" ,
627
- UpdateWorkflowExecutionLifecycleStage
628
- .UPDATE_WORKFLOW_EXECUTION_LIFECYCLE_STAGE_COMPLETED ,
629
- TestWorkflows .UpdateType .BLOCK ));
630
- Assert .assertEquals (Status .NOT_FOUND .getCode (), exception .getStatus ().getCode ());
631
- exception =
632
- Assert .assertThrows (
633
- StatusRuntimeException .class ,
634
- () ->
635
- updateWorkflow (
636
- exec ,
637
- "updateId" ,
638
- UpdateWorkflowExecutionLifecycleStage
639
- .UPDATE_WORKFLOW_EXECUTION_LIFECYCLE_STAGE_ACCEPTED ,
640
- TestWorkflows .UpdateType .BLOCK ));
641
- Assert .assertEquals (Status .NOT_FOUND .getCode (), exception .getStatus ().getCode ());
642
- exception =
643
- Assert .assertThrows (
644
- StatusRuntimeException .class ,
645
- () ->
646
- pollWorkflowUpdate (
647
- exec ,
648
- "updateId" ,
649
- UpdateWorkflowExecutionLifecycleStage
650
- .UPDATE_WORKFLOW_EXECUTION_LIFECYCLE_STAGE_ACCEPTED ));
651
- Assert .assertEquals (Status .NOT_FOUND .getCode (), exception .getStatus ().getCode ());
652
- exception =
653
- Assert .assertThrows (
654
- StatusRuntimeException .class ,
655
- () ->
656
- pollWorkflowUpdate (
657
- exec ,
658
- "updateId" ,
659
- UpdateWorkflowExecutionLifecycleStage
660
- .UPDATE_WORKFLOW_EXECUTION_LIFECYCLE_STAGE_COMPLETED ));
661
- Assert .assertEquals (Status .NOT_FOUND .getCode (), exception .getStatus ().getCode ());
617
+ response =
618
+ updateWorkflow (
619
+ exec ,
620
+ "updateId" ,
621
+ UpdateWorkflowExecutionLifecycleStage
622
+ .UPDATE_WORKFLOW_EXECUTION_LIFECYCLE_STAGE_COMPLETED ,
623
+ TestWorkflows .UpdateType .BLOCK );
624
+ Assert .assertEquals (
625
+ UpdateWorkflowExecutionLifecycleStage .UPDATE_WORKFLOW_EXECUTION_LIFECYCLE_STAGE_COMPLETED ,
626
+ response .getStage ());
627
+ assertUpdateOutcomeIsAcceptedUpdateCompletedWorkflow (response .getOutcome ());
628
+
629
+ response =
630
+ updateWorkflow (
631
+ exec ,
632
+ "updateId" ,
633
+ UpdateWorkflowExecutionLifecycleStage
634
+ .UPDATE_WORKFLOW_EXECUTION_LIFECYCLE_STAGE_ACCEPTED ,
635
+ TestWorkflows .UpdateType .BLOCK );
636
+ Assert .assertEquals (
637
+ UpdateWorkflowExecutionLifecycleStage .UPDATE_WORKFLOW_EXECUTION_LIFECYCLE_STAGE_COMPLETED ,
638
+ response .getStage ());
639
+ assertUpdateOutcomeIsAcceptedUpdateCompletedWorkflow (response .getOutcome ());
640
+
641
+ PollWorkflowExecutionUpdateResponse pollResponse =
642
+ pollWorkflowUpdate (
643
+ exec ,
644
+ "updateId" ,
645
+ UpdateWorkflowExecutionLifecycleStage
646
+ .UPDATE_WORKFLOW_EXECUTION_LIFECYCLE_STAGE_ACCEPTED );
647
+ Assert .assertEquals (
648
+ UpdateWorkflowExecutionLifecycleStage .UPDATE_WORKFLOW_EXECUTION_LIFECYCLE_STAGE_COMPLETED ,
649
+ pollResponse .getStage ());
650
+ assertUpdateOutcomeIsAcceptedUpdateCompletedWorkflow (pollResponse .getOutcome ());
651
+
652
+ pollResponse =
653
+ pollWorkflowUpdate (
654
+ exec ,
655
+ "updateId" ,
656
+ UpdateWorkflowExecutionLifecycleStage
657
+ .UPDATE_WORKFLOW_EXECUTION_LIFECYCLE_STAGE_ACCEPTED );
658
+ Assert .assertEquals (
659
+ UpdateWorkflowExecutionLifecycleStage .UPDATE_WORKFLOW_EXECUTION_LIFECYCLE_STAGE_COMPLETED ,
660
+ pollResponse .getStage ());
661
+ assertUpdateOutcomeIsAcceptedUpdateCompletedWorkflow (pollResponse .getOutcome ());
662
+ }
663
+
664
+ private void assertUpdateOutcomeIsAcceptedUpdateCompletedWorkflow (Outcome outcome ) {
665
+ Assert .assertEquals (
666
+ "Workflow Update failed because the Workflow completed before the Update completed." ,
667
+ outcome .getFailure ().getMessage ());
668
+ Assert .assertEquals (
669
+ "AcceptedUpdateCompletedWorkflow" ,
670
+ outcome .getFailure ().getApplicationFailureInfo ().getType ());
662
671
}
663
672
664
673
private UpdateWorkflowExecutionResponse updateWorkflow (
0 commit comments