22
22
23
23
import static org .junit .Assert .*;
24
24
25
+ import com .google .common .collect .ImmutableMap ;
26
+ import com .uber .m3 .tally .RootScopeBuilder ;
27
+ import com .uber .m3 .tally .Scope ;
25
28
import io .temporal .api .enums .v1 .EventType ;
26
29
import io .temporal .api .enums .v1 .WorkflowTaskFailedCause ;
27
30
import io .temporal .api .history .v1 .HistoryEvent ;
28
31
import io .temporal .api .history .v1 .WorkflowTaskFailedEventAttributes ;
29
32
import io .temporal .client .WorkflowFailedException ;
30
33
import io .temporal .client .WorkflowOptions ;
31
34
import io .temporal .client .WorkflowStub ;
35
+ import io .temporal .common .reporter .TestStatsReporter ;
32
36
import io .temporal .failure .TimeoutFailure ;
33
37
import io .temporal .internal .sync .WorkflowMethodThreadNameStrategy ;
34
38
import io .temporal .testing .internal .SDKTestWorkflowRule ;
39
+ import io .temporal .worker .MetricsType ;
35
40
import io .temporal .worker .NonDeterministicException ;
36
41
import io .temporal .worker .WorkerOptions ;
37
42
import io .temporal .workflow .shared .TestActivities .TestActivitiesImpl ;
43
48
import org .junit .Test ;
44
49
45
50
public class NonDeterministicWorkflowPolicyBlockWorkflowTest {
51
+ private final TestStatsReporter reporter = new TestStatsReporter ();
52
+ Scope metricsScope =
53
+ new RootScopeBuilder ().reporter (reporter ).reportEvery (com .uber .m3 .util .Duration .ofMillis (1 ));
46
54
47
55
@ Rule
48
56
public SDKTestWorkflowRule testWorkflowRule =
@@ -54,6 +62,7 @@ public class NonDeterministicWorkflowPolicyBlockWorkflowTest {
54
62
WorkerOptions .newBuilder ()
55
63
.setStickyQueueScheduleToStartTimeout (Duration .ZERO )
56
64
.build ())
65
+ .setMetricsScope (metricsScope )
57
66
.build ();
58
67
59
68
@ Test
@@ -89,6 +98,22 @@ public void testNonDeterministicWorkflowPolicyBlockWorkflow() {
89
98
assertEquals (
90
99
NonDeterministicException .class .getName (),
91
100
failedWFTEventAttributes .getFailure ().getApplicationFailureInfo ().getType ());
101
+ // Verify that the non-deterministic workflow task failure is reported for all the workflow
102
+ // tasks
103
+ reporter .assertCounter (
104
+ MetricsType .WORKFLOW_TASK_EXECUTION_FAILURE_COUNTER ,
105
+ ImmutableMap .of (
106
+ "task_queue" ,
107
+ testWorkflowRule .getTaskQueue (),
108
+ "namespace" ,
109
+ "UnitTest" ,
110
+ "workflow_type" ,
111
+ "TestWorkflowStringArg" ,
112
+ "worker_type" ,
113
+ "WorkflowWorker" ,
114
+ "failure_reason" ,
115
+ "NonDeterminismError" ),
116
+ (i ) -> i >= 2 );
92
117
}
93
118
94
119
@ Test
0 commit comments