|
36 | 36 | import io.temporal.api.history.v1.History;
|
37 | 37 | import io.temporal.api.history.v1.HistoryEvent;
|
38 | 38 | import io.temporal.api.taskqueue.v1.StickyExecutionAttributes;
|
39 |
| -import io.temporal.api.workflowservice.v1.GetSystemInfoResponse; |
40 |
| -import io.temporal.api.workflowservice.v1.GetWorkflowExecutionHistoryResponse; |
41 |
| -import io.temporal.api.workflowservice.v1.PollWorkflowTaskQueueResponse; |
42 |
| -import io.temporal.api.workflowservice.v1.WorkflowServiceGrpc; |
| 39 | +import io.temporal.api.workflowservice.v1.*; |
43 | 40 | import io.temporal.internal.common.InternalUtils;
|
| 41 | +import io.temporal.internal.statemachines.ExecuteLocalActivityParameters; |
44 | 42 | import io.temporal.internal.worker.SingleWorkerOptions;
|
45 | 43 | import io.temporal.internal.worker.WorkflowExecutorCache;
|
46 | 44 | import io.temporal.internal.worker.WorkflowRunLockManager;
|
@@ -79,7 +77,6 @@ public void ifStickyExecutionAttributesAreNotSetThenWorkflowsAreNotCached() thro
|
79 | 77 | // Act
|
80 | 78 | WorkflowTaskHandler.Result result =
|
81 | 79 | taskHandler.handleWorkflowTask(HistoryUtils.generateWorkflowTaskWithInitialHistory());
|
82 |
| - |
83 | 80 | // Assert
|
84 | 81 | assertEquals(0, cache.size());
|
85 | 82 | assertNotNull(result.getTaskCompleted());
|
@@ -142,6 +139,41 @@ public void workflowTaskFailOnIncompleteHistory() throws Throwable {
|
142 | 139 | result.getTaskFailed().getFailure().getMessage());
|
143 | 140 | }
|
144 | 141 |
|
| 142 | + @Test |
| 143 | + public void localActivityMeteringHelper() { |
| 144 | + ReplayWorkflowRunTaskHandler.LocalActivityMeteringHelper laMeteringHelper = |
| 145 | + new ReplayWorkflowRunTaskHandler.LocalActivityMeteringHelper(); |
| 146 | + ExecuteLocalActivityParameters executeLA = |
| 147 | + new ExecuteLocalActivityParameters( |
| 148 | + PollActivityTaskQueueResponse.newBuilder().setActivityId("1"), |
| 149 | + null, |
| 150 | + 0, |
| 151 | + null, |
| 152 | + false, |
| 153 | + null); |
| 154 | + laMeteringHelper.addNewLocalActivity(executeLA); |
| 155 | + laMeteringHelper.addNewLocalActivity( |
| 156 | + new ExecuteLocalActivityParameters( |
| 157 | + PollActivityTaskQueueResponse.newBuilder().setActivityId("2"), |
| 158 | + null, |
| 159 | + 0, |
| 160 | + null, |
| 161 | + false, |
| 162 | + null)); |
| 163 | + for (int i = 0; i < 5; i++) { |
| 164 | + executeLA.getOnNewAttemptCallback().apply(); |
| 165 | + } |
| 166 | + // Verify retries are not counted for the first task |
| 167 | + assertEquals(0, laMeteringHelper.getNonfirstAttempts()); |
| 168 | + laMeteringHelper.newWFTStarting(); |
| 169 | + assertEquals(0, laMeteringHelper.getNonfirstAttempts()); |
| 170 | + // Verify retries are counted for the non first task |
| 171 | + for (int i = 0; i < 5; i++) { |
| 172 | + executeLA.getOnNewAttemptCallback().apply(); |
| 173 | + } |
| 174 | + assertEquals(5, laMeteringHelper.getNonfirstAttempts()); |
| 175 | + } |
| 176 | + |
145 | 177 | @Test
|
146 | 178 | public void ifStickyExecutionAttributesAreSetThenWorkflowsAreCached() throws Throwable {
|
147 | 179 | assumeFalse("skipping for docker tests", SDKTestWorkflowRule.useExternalService);
|
|
0 commit comments