|
62 | 62 | import com.uber.cadence.converter.JsonDataConverter; |
63 | 63 | import com.uber.cadence.internal.common.WorkflowExecutionUtils; |
64 | 64 | import com.uber.cadence.internal.sync.DeterministicRunnerTest; |
| 65 | +import com.uber.cadence.internal.sync.SyncWorkflowDefinition; |
65 | 66 | import com.uber.cadence.internal.sync.TestWorkflowEnvironmentInternal; |
66 | 67 | import com.uber.cadence.internal.worker.PollerOptions; |
| 68 | +import com.uber.cadence.internal.worker.WorkflowExecutionException; |
67 | 69 | import com.uber.cadence.serviceclient.ClientOptions; |
68 | 70 | import com.uber.cadence.serviceclient.IWorkflowService; |
69 | 71 | import com.uber.cadence.serviceclient.WorkflowServiceTChannel; |
@@ -503,6 +505,7 @@ public void testSync() { |
503 | 505 | String result = workflowStub.execute(taskList); |
504 | 506 | assertEquals("activity10", result); |
505 | 507 | tracer.setExpected( |
| 508 | + "executeWorkflow: TestWorkflow1::execute", |
506 | 509 | "sleep PT2S", |
507 | 510 | "executeActivity TestActivities::activityWithDelay", |
508 | 511 | "executeActivity TestActivities::activity2"); |
@@ -1276,7 +1279,16 @@ public void testContinueAsNew() { |
1276 | 1279 | TestContinueAsNew.class, newWorkflowOptionsBuilder(this.taskList).build()); |
1277 | 1280 | int result = client.execute(4, continuedTaskList); |
1278 | 1281 | assertEquals(111, result); |
1279 | | - tracer.setExpected("continueAsNew", "continueAsNew", "continueAsNew", "continueAsNew"); |
| 1282 | + tracer.setExpected( |
| 1283 | + "executeWorkflow: TestContinueAsNew::execute", |
| 1284 | + "continueAsNew", |
| 1285 | + "executeWorkflow: TestContinueAsNew::execute", |
| 1286 | + "continueAsNew", |
| 1287 | + "executeWorkflow: TestContinueAsNew::execute", |
| 1288 | + "continueAsNew", |
| 1289 | + "executeWorkflow: TestContinueAsNew::execute", |
| 1290 | + "continueAsNew", |
| 1291 | + "executeWorkflow: TestContinueAsNew::execute"); |
1280 | 1292 | } |
1281 | 1293 |
|
1282 | 1294 | public static class TestAsyncActivityWorkflowImpl implements TestWorkflow1 { |
@@ -2156,10 +2168,18 @@ public void testTimer() { |
2156 | 2168 | assertEquals("testTimer", result); |
2157 | 2169 | if (useExternalService) { |
2158 | 2170 | tracer.setExpected( |
2159 | | - "registerQuery getTrace", "newTimer PT0.7S", "newTimer PT1.3S", "newTimer PT10S"); |
| 2171 | + "executeWorkflow: testActivity", |
| 2172 | + "registerQuery getTrace", |
| 2173 | + "newTimer PT0.7S", |
| 2174 | + "newTimer PT1.3S", |
| 2175 | + "newTimer PT10S"); |
2160 | 2176 | } else { |
2161 | 2177 | tracer.setExpected( |
2162 | | - "registerQuery getTrace", "newTimer PT11M40S", "newTimer PT21M40S", "newTimer PT10H"); |
| 2178 | + "executeWorkflow: testActivity", |
| 2179 | + "registerQuery getTrace", |
| 2180 | + "newTimer PT11M40S", |
| 2181 | + "newTimer PT21M40S", |
| 2182 | + "newTimer PT10H"); |
2163 | 2183 | } |
2164 | 2184 | } |
2165 | 2185 |
|
@@ -3325,7 +3345,9 @@ public void testSignalExternalWorkflow() { |
3325 | 3345 | workflowClient.newWorkflowStub(TestWorkflowSignaled.class, options.build()); |
3326 | 3346 | assertEquals("Hello World!", client.execute()); |
3327 | 3347 | tracer.setExpected( |
| 3348 | + "executeWorkflow: TestWorkflowSignaled::execute", |
3328 | 3349 | "executeChildWorkflow SignalingChild::execute", |
| 3350 | + "executeWorkflow: SignalingChild::execute", |
3329 | 3351 | "signalExternalWorkflow " + UUID_REGEXP + " testSignal"); |
3330 | 3352 | } |
3331 | 3353 |
|
@@ -4499,7 +4521,11 @@ public void testSideEffect() { |
4499 | 4521 | TestWorkflow1.class, newWorkflowOptionsBuilder(taskList).build()); |
4500 | 4522 | String result = workflowStub.execute(taskList); |
4501 | 4523 | assertEquals("activity1", result); |
4502 | | - tracer.setExpected("sideEffect", "sleep PT1S", "executeActivity customActivity1"); |
| 4524 | + tracer.setExpected( |
| 4525 | + "executeWorkflow: TestWorkflow1::execute", |
| 4526 | + "sideEffect", |
| 4527 | + "sleep PT1S", |
| 4528 | + "executeActivity customActivity1"); |
4503 | 4529 | } |
4504 | 4530 |
|
4505 | 4531 | private static final Map<String, Queue<Long>> mutableSideEffectValue = |
@@ -4595,6 +4621,7 @@ public void testGetVersion() { |
4595 | 4621 | String result = workflowStub.execute(taskList); |
4596 | 4622 | assertEquals("activity22activity1activity1activity1", result); |
4597 | 4623 | tracer.setExpected( |
| 4624 | + "executeWorkflow: TestWorkflow1::execute", |
4598 | 4625 | "getVersion", |
4599 | 4626 | "executeActivity TestActivities::activity2", |
4600 | 4627 | "getVersion", |
@@ -4765,6 +4792,7 @@ public void testGetVersionRemovedInReplay() { |
4765 | 4792 | String result = workflowStub.execute(taskList); |
4766 | 4793 | assertEquals("activity22activity", result); |
4767 | 4794 | tracer.setExpected( |
| 4795 | + "executeWorkflow: TestWorkflowQuery::execute", |
4768 | 4796 | "registerQuery TestWorkflowQuery::query", |
4769 | 4797 | "getVersion", |
4770 | 4798 | "executeActivity TestActivities::activity2", |
@@ -4809,6 +4837,7 @@ public void testGetVersionRemovedInReplay2() { |
4809 | 4837 | String result = workflowStub.execute(taskList); |
4810 | 4838 | assertEquals("activity", result); |
4811 | 4839 | tracer.setExpected( |
| 4840 | + "executeWorkflow: TestWorkflowQuery::execute", |
4812 | 4841 | "registerQuery TestWorkflowQuery::query", |
4813 | 4842 | "getVersion", |
4814 | 4843 | "getVersion", |
@@ -4844,7 +4873,8 @@ public void testGetVersionRemovedInReplay3() { |
4844 | 4873 | TestWorkflow1.class, newWorkflowOptionsBuilder(taskList).build()); |
4845 | 4874 | String result = workflowStub.execute(taskList); |
4846 | 4875 | assertEquals("done", result); |
4847 | | - tracer.setExpected("getVersion", "upsertSearchAttributes"); |
| 4876 | + tracer.setExpected( |
| 4877 | + "executeWorkflow: TestWorkflow1::execute", "getVersion", "upsertSearchAttributes"); |
4848 | 4878 | } |
4849 | 4879 |
|
4850 | 4880 | public static class TestVersionNotSupportedWorkflowImpl implements TestWorkflow1 { |
@@ -5113,7 +5143,11 @@ public void testUUIDAndRandom() { |
5113 | 5143 | TestWorkflow1.class, newWorkflowOptionsBuilder(taskList).build()); |
5114 | 5144 | String result = workflowStub.execute(taskList); |
5115 | 5145 | assertEquals("foo10", result); |
5116 | | - tracer.setExpected("sideEffect", "sideEffect", "executeActivity TestActivities::activity2"); |
| 5146 | + tracer.setExpected( |
| 5147 | + "executeWorkflow: TestWorkflow1::execute", |
| 5148 | + "sideEffect", |
| 5149 | + "sideEffect", |
| 5150 | + "executeActivity TestActivities::activity2"); |
5117 | 5151 | } |
5118 | 5152 |
|
5119 | 5153 | public interface GenericParametersActivity { |
@@ -5941,10 +5975,13 @@ public void testSaga() { |
5941 | 5975 | TestSagaWorkflow.class, newWorkflowOptionsBuilder(taskList).build()); |
5942 | 5976 | sagaWorkflow.execute(taskList, false); |
5943 | 5977 | tracer.setExpected( |
| 5978 | + "executeWorkflow: TestSagaWorkflow::execute", |
5944 | 5979 | "executeActivity customActivity1", |
5945 | 5980 | "executeChildWorkflow TestMultiargsWorkflowsFunc::func", |
| 5981 | + "executeWorkflow: TestMultiargsWorkflowsFunc::func", |
5946 | 5982 | "executeActivity TestActivities::throwIO", |
5947 | 5983 | "executeChildWorkflow TestCompensationWorkflow::compensate", |
| 5984 | + "executeWorkflow: TestCompensationWorkflow::compensate", |
5948 | 5985 | "executeActivity TestActivities::activity2"); |
5949 | 5986 | } |
5950 | 5987 |
|
@@ -6062,7 +6099,10 @@ public void testUpsertSearchAttributes() { |
6062 | 6099 | TestUpsertSearchAttributes.class, newWorkflowOptionsBuilder(taskList).build()); |
6063 | 6100 | String result = testWorkflow.execute(taskList, "testKey"); |
6064 | 6101 | assertEquals("done", result); |
6065 | | - tracer.setExpected("upsertSearchAttributes", "executeActivity TestActivities::activity"); |
| 6102 | + tracer.setExpected( |
| 6103 | + "executeWorkflow: TestUpsertSearchAttributes::execute", |
| 6104 | + "upsertSearchAttributes", |
| 6105 | + "executeActivity TestActivities::activity"); |
6066 | 6106 | } |
6067 | 6107 |
|
6068 | 6108 | public static class TestMultiargsWorkflowsFuncChild implements TestMultiargsWorkflowsFunc2 { |
@@ -6118,6 +6158,14 @@ private TracingWorkflowInterceptor(FilteredTrace trace, WorkflowInterceptor next |
6118 | 6158 | this.next = Objects.requireNonNull(next); |
6119 | 6159 | } |
6120 | 6160 |
|
| 6161 | + @Override |
| 6162 | + public byte[] executeWorkflow( |
| 6163 | + SyncWorkflowDefinition workflowDefinition, WorkflowExecuteInput input) |
| 6164 | + throws CancellationException, WorkflowExecutionException { |
| 6165 | + trace.add("executeWorkflow: " + input.getWorkflowType().getName()); |
| 6166 | + return next.executeWorkflow(workflowDefinition, input); |
| 6167 | + } |
| 6168 | + |
6121 | 6169 | @Override |
6122 | 6170 | public <R> Promise<R> executeActivity( |
6123 | 6171 | String activityName, |
|
0 commit comments