From 75934635be06955f82ddc358728f0e526d468a40 Mon Sep 17 00:00:00 2001 From: Maxim Fateev Date: Fri, 27 Sep 2024 23:33:23 -0400 Subject: [PATCH 1/2] Fixed SDKTestWorkflowRule to call shutdown --- .../temporal/testing/internal/SDKTestWorkflowRule.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/temporal-testing/src/main/java/io/temporal/testing/internal/SDKTestWorkflowRule.java b/temporal-testing/src/main/java/io/temporal/testing/internal/SDKTestWorkflowRule.java index 97907f02b..7d1c18b55 100644 --- a/temporal-testing/src/main/java/io/temporal/testing/internal/SDKTestWorkflowRule.java +++ b/temporal-testing/src/main/java/io/temporal/testing/internal/SDKTestWorkflowRule.java @@ -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; From 6d1d46321399cdb5f68270b1ebca620770f438a4 Mon Sep 17 00:00:00 2001 From: Maxim Fateev Date: Sat, 28 Sep 2024 00:35:42 -0400 Subject: [PATCH 2/2] Fixed test broken after rule fix --- .../test/java/io/temporal/workflow/SagaTest.java | 1 + .../activityTests/ParallelLocalActivitiesTest.java | 1 - .../workflow/activityTests/TestLocalActivity.java | 4 ---- .../searchattributes/UpsertSearchAttributeTest.java | 8 ++++++-- .../UpsertTypedSearchAttributeTest.java | 13 ++++++++++--- 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/temporal-sdk/src/test/java/io/temporal/workflow/SagaTest.java b/temporal-sdk/src/test/java/io/temporal/workflow/SagaTest.java index 78a29a6df..c049337d2 100644 --- a/temporal-sdk/src/test/java/io/temporal/workflow/SagaTest.java +++ b/temporal-sdk/src/test/java/io/temporal/workflow/SagaTest.java @@ -57,6 +57,7 @@ public void testSaga() { "activity customActivity1", "executeChildWorkflow TestNoArgsWorkflowFunc", "interceptExecuteWorkflow " + SDKTestWorkflowRule.UUID_REGEXP, + "registerUpdateHandlers update", "newThread workflow-method", "executeActivity ThrowIO", "activity ThrowIO", diff --git a/temporal-sdk/src/test/java/io/temporal/workflow/activityTests/ParallelLocalActivitiesTest.java b/temporal-sdk/src/test/java/io/temporal/workflow/activityTests/ParallelLocalActivitiesTest.java index 2b27d42f5..17957dbf5 100644 --- a/temporal-sdk/src/test/java/io/temporal/workflow/activityTests/ParallelLocalActivitiesTest.java +++ b/temporal-sdk/src/test/java/io/temporal/workflow/activityTests/ParallelLocalActivitiesTest.java @@ -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"); diff --git a/temporal-sdk/src/test/java/io/temporal/workflow/activityTests/TestLocalActivity.java b/temporal-sdk/src/test/java/io/temporal/workflow/activityTests/TestLocalActivity.java index 841944c0a..f69880fad 100644 --- a/temporal-sdk/src/test/java/io/temporal/workflow/activityTests/TestLocalActivity.java +++ b/temporal-sdk/src/test/java/io/temporal/workflow/activityTests/TestLocalActivity.java @@ -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"); @@ -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"); diff --git a/temporal-sdk/src/test/java/io/temporal/workflow/searchattributes/UpsertSearchAttributeTest.java b/temporal-sdk/src/test/java/io/temporal/workflow/searchattributes/UpsertSearchAttributeTest.java index 286552f70..f00a5a0b5 100644 --- a/temporal-sdk/src/test/java/io/temporal/workflow/searchattributes/UpsertSearchAttributeTest.java +++ b/temporal-sdk/src/test/java/io/temporal/workflow/searchattributes/UpsertSearchAttributeTest.java @@ -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); } diff --git a/temporal-sdk/src/test/java/io/temporal/workflow/searchattributes/UpsertTypedSearchAttributeTest.java b/temporal-sdk/src/test/java/io/temporal/workflow/searchattributes/UpsertTypedSearchAttributeTest.java index 779037e4b..d41422ee7 100644 --- a/temporal-sdk/src/test/java/io/temporal/workflow/searchattributes/UpsertTypedSearchAttributeTest.java +++ b/temporal-sdk/src/test/java/io/temporal/workflow/searchattributes/UpsertTypedSearchAttributeTest.java @@ -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); }