Skip to content

Commit 156f4f1

Browse files
authored
SDKTestWorkflowRule wasn't calling shutdown (#2243)
* Fixed SDKTestWorkflowRule to call shutdown * Fixed test broken after rule fix
1 parent 52aa9e8 commit 156f4f1

File tree

6 files changed

+25
-11
lines changed

6 files changed

+25
-11
lines changed

temporal-sdk/src/test/java/io/temporal/workflow/SagaTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public void testSaga() {
5757
"activity customActivity1",
5858
"executeChildWorkflow TestNoArgsWorkflowFunc",
5959
"interceptExecuteWorkflow " + SDKTestWorkflowRule.UUID_REGEXP,
60+
"registerUpdateHandlers update",
6061
"newThread workflow-method",
6162
"executeActivity ThrowIO",
6263
"activity ThrowIO",

temporal-sdk/src/test/java/io/temporal/workflow/activityTests/ParallelLocalActivitiesTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ public void testParallelLocalActivities() {
6969
expected.add("newThread workflow-method");
7070
for (int i = 0; i < TestParallelLocalActivitiesWorkflowImpl.COUNT; i++) {
7171
expected.add("executeLocalActivity SleepActivity");
72-
expected.add("currentTimeMillis");
7372
}
7473
for (int i = 0; i < TestParallelLocalActivitiesWorkflowImpl.COUNT; i++) {
7574
expected.add("local activity SleepActivity");

temporal-sdk/src/test/java/io/temporal/workflow/activityTests/TestLocalActivity.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,10 @@ public void testLocalActivity() {
7171
"interceptExecuteWorkflow " + SDKTestWorkflowRule.UUID_REGEXP,
7272
"newThread workflow-method",
7373
"executeLocalActivity ThrowIO",
74-
"currentTimeMillis",
7574
"local activity ThrowIO",
7675
"local activity ThrowIO",
7776
"local activity ThrowIO",
7877
"executeLocalActivity Activity2",
79-
"currentTimeMillis",
8078
"local activity Activity2",
8179
"executeActivity Activity2",
8280
"activity Activity2");
@@ -115,12 +113,10 @@ public void testLocalActivityNoInput() {
115113
"interceptExecuteWorkflow " + SDKTestWorkflowRule.UUID_REGEXP,
116114
"newThread workflow-method",
117115
"executeLocalActivity ThrowIO",
118-
"currentTimeMillis",
119116
"local activity ThrowIO",
120117
"local activity ThrowIO",
121118
"local activity ThrowIO",
122119
"executeLocalActivity Activity2",
123-
"currentTimeMillis",
124120
"local activity Activity2",
125121
"executeActivity Activity2",
126122
"activity Activity2");

temporal-sdk/src/test/java/io/temporal/workflow/searchattributes/UpsertSearchAttributeTest.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,12 @@ public void testUpsertSearchAttributes() {
6969
"interceptExecuteWorkflow " + SDKTestWorkflowRule.UUID_REGEXP,
7070
"newThread workflow-method",
7171
"upsertSearchAttributes",
72-
"executeActivity Activity",
73-
"activity Activity");
72+
"sleep PT0.1S",
73+
"upsertSearchAttributes",
74+
"sleep PT0.1S",
75+
"upsertSearchAttributes",
76+
"upsertSearchAttributes",
77+
"sleep PT0.1S");
7478
testWorkflowRule.assertHistoryEvent(
7579
execution.getWorkflowId(), EventType.EVENT_TYPE_UPSERT_WORKFLOW_SEARCH_ATTRIBUTES);
7680
}

temporal-sdk/src/test/java/io/temporal/workflow/searchattributes/UpsertTypedSearchAttributeTest.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,16 @@ public void testUpsertSearchAttributes() {
7272
.setExpected(
7373
"interceptExecuteWorkflow " + SDKTestWorkflowRule.UUID_REGEXP,
7474
"newThread workflow-method",
75-
"upsertSearchAttributes",
76-
"executeActivity Activity",
77-
"activity Activity");
75+
"upsertTypedSearchAttributes",
76+
"sleep PT0.1S",
77+
"upsertTypedSearchAttributes",
78+
"sleep PT0.1S",
79+
"upsertTypedSearchAttributes",
80+
"upsertTypedSearchAttributes",
81+
"sleep PT0.1S",
82+
"upsertTypedSearchAttributes",
83+
"upsertTypedSearchAttributes",
84+
"upsertTypedSearchAttributes");
7885
testWorkflowRule.assertHistoryEvent(
7986
execution.getWorkflowId(), EventType.EVENT_TYPE_UPSERT_WORKFLOW_SEARCH_ATTRIBUTES);
8087
}

temporal-testing/src/main/java/io/temporal/testing/internal/SDKTestWorkflowRule.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,14 @@ public SDKTestWorkflowRule build() {
232232
}
233233

234234
public Statement apply(@Nonnull Statement base, Description description) {
235-
Statement testWorkflowStatement = base;
235+
Statement testWorkflowStatement =
236+
new Statement() {
237+
@Override
238+
public void evaluate() throws Throwable {
239+
base.evaluate();
240+
shutdown();
241+
}
242+
};
236243

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

0 commit comments

Comments
 (0)