Skip to content

Commit ba691a2

Browse files
authored
Testworkflowrule Interceptor Fix (#421)
* Fixed a bug where TestWorkflowRule was merging workerInterceptors from two sources incorrectly * Added Unit tests to prevent this in the future
1 parent 5a33a8b commit ba691a2

26 files changed

+214
-113
lines changed

temporal-sdk/src/main/java/io/temporal/worker/WorkflowImplementationOptions.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@
2323

2424
public final class WorkflowImplementationOptions {
2525

26+
private static final WorkflowImplementationOptions DEFAULT_INSTANCE;
27+
28+
static {
29+
DEFAULT_INSTANCE = WorkflowImplementationOptions.newBuilder().build();
30+
}
31+
32+
public static WorkflowImplementationOptions getDefaultInstance() {
33+
return DEFAULT_INSTANCE;
34+
}
35+
2636
public static Builder newBuilder() {
2737
return new Builder();
2838
}

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,7 @@ public class ContinueAsNewNoArgsTest {
2929

3030
@Rule
3131
public SDKTestWorkflowRule testWorkflowRule =
32-
SDKTestWorkflowRule.newBuilder()
33-
.setWorkflowTypes(TestContinueAsNewNoArgsImpl.class)
34-
.setWorkerInterceptors(
35-
new TracingWorkerInterceptor(new TracingWorkerInterceptor.FilteredTrace()))
36-
.build();
32+
SDKTestWorkflowRule.newBuilder().setWorkflowTypes(TestContinueAsNewNoArgsImpl.class).build();
3733

3834
@Test
3935
public void testContinueAsNewNoArgs() {

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,7 @@ public class ContinueAsNewTest {
3333

3434
@Rule
3535
public SDKTestWorkflowRule testWorkflowRule =
36-
SDKTestWorkflowRule.newBuilder()
37-
.setWorkflowTypes(TestContinueAsNewImpl.class)
38-
.setWorkerInterceptors(
39-
new TracingWorkerInterceptor(new TracingWorkerInterceptor.FilteredTrace()))
40-
.build();
36+
SDKTestWorkflowRule.newBuilder().setWorkflowTypes(TestContinueAsNewImpl.class).build();
4137

4238
@Test
4339
public void testContinueAsNew() {

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ public class SagaTest {
3939
TestCompensationWorkflowImpl.class,
4040
TestMultiargsWorkflowsFuncImpl.class)
4141
.setActivityImplementations(new TestActivities.TestActivitiesImpl())
42-
.setWorkerInterceptors(
43-
new TracingWorkerInterceptor(new TracingWorkerInterceptor.FilteredTrace()))
4442
.build();
4543

4644
@Test

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ public class SideEffectTest {
3838
SDKTestWorkflowRule.newBuilder()
3939
.setWorkflowTypes(TestSideEffectWorkflowImpl.class)
4040
.setActivityImplementations(new TestActivities.TestActivitiesImpl())
41-
.setWorkerInterceptors(
42-
new TracingWorkerInterceptor(new TracingWorkerInterceptor.FilteredTrace()))
4341
.build();
4442

4543
@Test

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ public class SyncTest {
4747
SDKTestWorkflowRule.newBuilder()
4848
.setWorkflowTypes(TestSyncWorkflowImpl.class)
4949
.setActivityImplementations(activitiesImpl)
50-
.setWorkerInterceptors(
51-
new TracingWorkerInterceptor(new TracingWorkerInterceptor.FilteredTrace()))
5250
.build();
5351

5452
@Test

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,7 @@ public class TimerTest {
3636

3737
@Rule
3838
public SDKTestWorkflowRule testWorkflowRule =
39-
SDKTestWorkflowRule.newBuilder()
40-
.setWorkflowTypes(TestTimerWorkflowImpl.class)
41-
.setWorkerInterceptors(
42-
new TracingWorkerInterceptor(new TracingWorkerInterceptor.FilteredTrace()))
43-
.build();
39+
SDKTestWorkflowRule.newBuilder().setWorkflowTypes(TestTimerWorkflowImpl.class).build();
4440

4541
@Test
4642
public void testTimer() {

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ public class UUIDAndRandomTest {
3838
SDKTestWorkflowRule.newBuilder()
3939
.setWorkflowTypes(TestUUIDAndRandom.class)
4040
.setActivityImplementations(new TestActivities.TestActivitiesImpl())
41-
.setWorkerInterceptors(
42-
new TracingWorkerInterceptor(new TracingWorkerInterceptor.FilteredTrace()))
4341
.build();
4442

4543
@Test

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ public class UpsertSearchAttributesTest {
4646
SDKTestWorkflowRule.newBuilder()
4747
.setWorkflowTypes(TestUpsertSearchAttributesImpl.class)
4848
.setActivityImplementations(new TestActivities.TestActivitiesImpl())
49-
.setWorkerInterceptors(
50-
new TracingWorkerInterceptor(new TracingWorkerInterceptor.FilteredTrace()))
5149
.build();
5250

5351
@Test

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ public class ActivityRetryWithMaxAttemptsTest {
4545
public SDKTestWorkflowRule testWorkflowRule =
4646
SDKTestWorkflowRule.newBuilder()
4747
.setWorkflowTypes(TestActivityRetryWithMaxAttempts.class)
48-
.setWorkerInterceptors(
49-
new TracingWorkerInterceptor(new TracingWorkerInterceptor.FilteredTrace()))
5048
.setActivityImplementations(activitiesImpl)
5149
.build();
5250

0 commit comments

Comments
 (0)