Skip to content

Commit

Permalink
SDKTestWorkflowRule wasn't calling shutdown (temporalio#2243)
Browse files Browse the repository at this point in the history
* Fixed SDKTestWorkflowRule to call shutdown

* Fixed test broken after rule fix
  • Loading branch information
mfateev authored Oct 1, 2024
1 parent 52aa9e8 commit 156f4f1
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public void testSaga() {
"activity customActivity1",
"executeChildWorkflow TestNoArgsWorkflowFunc",
"interceptExecuteWorkflow " + SDKTestWorkflowRule.UUID_REGEXP,
"registerUpdateHandlers update",
"newThread workflow-method",
"executeActivity ThrowIO",
"activity ThrowIO",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ public void testParallelLocalActivities() {
expected.add("newThread workflow-method");
for (int i = 0; i < TestParallelLocalActivitiesWorkflowImpl.COUNT; i++) {
expected.add("executeLocalActivity SleepActivity");
expected.add("currentTimeMillis");
}
for (int i = 0; i < TestParallelLocalActivitiesWorkflowImpl.COUNT; i++) {
expected.add("local activity SleepActivity");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,10 @@ public void testLocalActivity() {
"interceptExecuteWorkflow " + SDKTestWorkflowRule.UUID_REGEXP,
"newThread workflow-method",
"executeLocalActivity ThrowIO",
"currentTimeMillis",
"local activity ThrowIO",
"local activity ThrowIO",
"local activity ThrowIO",
"executeLocalActivity Activity2",
"currentTimeMillis",
"local activity Activity2",
"executeActivity Activity2",
"activity Activity2");
Expand Down Expand Up @@ -115,12 +113,10 @@ public void testLocalActivityNoInput() {
"interceptExecuteWorkflow " + SDKTestWorkflowRule.UUID_REGEXP,
"newThread workflow-method",
"executeLocalActivity ThrowIO",
"currentTimeMillis",
"local activity ThrowIO",
"local activity ThrowIO",
"local activity ThrowIO",
"executeLocalActivity Activity2",
"currentTimeMillis",
"local activity Activity2",
"executeActivity Activity2",
"activity Activity2");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,12 @@ public void testUpsertSearchAttributes() {
"interceptExecuteWorkflow " + SDKTestWorkflowRule.UUID_REGEXP,
"newThread workflow-method",
"upsertSearchAttributes",
"executeActivity Activity",
"activity Activity");
"sleep PT0.1S",
"upsertSearchAttributes",
"sleep PT0.1S",
"upsertSearchAttributes",
"upsertSearchAttributes",
"sleep PT0.1S");
testWorkflowRule.assertHistoryEvent(
execution.getWorkflowId(), EventType.EVENT_TYPE_UPSERT_WORKFLOW_SEARCH_ATTRIBUTES);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,16 @@ public void testUpsertSearchAttributes() {
.setExpected(
"interceptExecuteWorkflow " + SDKTestWorkflowRule.UUID_REGEXP,
"newThread workflow-method",
"upsertSearchAttributes",
"executeActivity Activity",
"activity Activity");
"upsertTypedSearchAttributes",
"sleep PT0.1S",
"upsertTypedSearchAttributes",
"sleep PT0.1S",
"upsertTypedSearchAttributes",
"upsertTypedSearchAttributes",
"sleep PT0.1S",
"upsertTypedSearchAttributes",
"upsertTypedSearchAttributes",
"upsertTypedSearchAttributes");
testWorkflowRule.assertHistoryEvent(
execution.getWorkflowId(), EventType.EVENT_TYPE_UPSERT_WORKFLOW_SEARCH_ATTRIBUTES);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,14 @@ public SDKTestWorkflowRule build() {
}

public Statement apply(@Nonnull Statement base, Description description) {
Statement testWorkflowStatement = base;
Statement testWorkflowStatement =
new Statement() {
@Override
public void evaluate() throws Throwable {
base.evaluate();
shutdown();
}
};

Test annotation = description.getAnnotation(Test.class);
boolean timeoutIsOverriddenOnTestAnnotation = annotation != null && annotation.timeout() > 0;
Expand Down

0 comments on commit 156f4f1

Please sign in to comment.