Skip to content

Commit 36215b8

Browse files
committed
Strengthen GetVersionMultithreadingRemoveTest to verify that setting
`SKIP_YIELD_ON_VERSION` by default corrects for the issue.
1 parent ca8b2af commit 36215b8

1 file changed

Lines changed: 23 additions & 11 deletions

File tree

temporal-sdk/src/test/java/io/temporal/workflow/versionTests/GetVersionMultithreadingRemoveTest.java

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,33 @@
11
package io.temporal.workflow.versionTests;
22

3-
import static org.junit.Assert.*;
4-
import static org.junit.Assume.assumeTrue;
3+
import static org.junit.Assert.assertEquals;
4+
import static org.junit.Assert.assertTrue;
55

66
import io.temporal.internal.Issue;
77
import io.temporal.testing.WorkflowReplayer;
88
import io.temporal.testing.internal.SDKTestOptions;
99
import io.temporal.testing.internal.SDKTestWorkflowRule;
10+
import io.temporal.testing.internal.TracingWorkerInterceptor;
1011
import io.temporal.worker.WorkerOptions;
1112
import io.temporal.workflow.Async;
1213
import io.temporal.workflow.Workflow;
1314
import io.temporal.workflow.shared.TestActivities;
1415
import io.temporal.workflow.shared.TestWorkflows;
1516
import io.temporal.workflow.unsafe.WorkflowUnsafe;
1617
import java.time.Duration;
18+
import org.junit.Before;
1719
import org.junit.Rule;
1820
import org.junit.Test;
1921

2022
@Issue("https://github.com/temporalio/sdk-java/issues/2307")
21-
public class GetVersionMultithreadingRemoveTest extends BaseVersionTest {
23+
public class GetVersionMultithreadingRemoveTest {
2224

2325
private static boolean hasReplayed;
2426

2527
@Rule
2628
public SDKTestWorkflowRule testWorkflowRule =
2729
SDKTestWorkflowRule.newBuilder()
28-
.setWorkflowTypes(
29-
getDefaultWorkflowImplementationOptions(), TestGetVersionWorkflowImpl.class)
30+
.setWorkflowTypes(TestGetVersionWorkflowImpl.class)
3031
.setActivityImplementations(new TestActivities.TestActivitiesImpl())
3132
// Forcing a replay. Full history arrived from a normal queue causing a replay.
3233
.setWorkerOptions(
@@ -35,18 +36,30 @@ public class GetVersionMultithreadingRemoveTest extends BaseVersionTest {
3536
.build())
3637
.build();
3738

38-
public GetVersionMultithreadingRemoveTest(boolean setVersioningFlag, boolean upsertVersioningSA) {
39-
super(setVersioningFlag, upsertVersioningSA);
39+
@Before
40+
public void setUp() {
41+
hasReplayed = false;
4042
}
4143

4244
@Test
4345
public void testGetVersionMultithreadingRemoval() {
44-
assumeTrue("This test only passes if SKIP_YIELD_ON_VERSION is enabled", setVersioningFlag);
4546
TestWorkflows.TestWorkflow1 workflowStub =
4647
testWorkflowRule.newWorkflowStubTimeoutOptions(TestWorkflows.TestWorkflow1.class);
48+
4749
String result = workflowStub.execute(testWorkflowRule.getTaskQueue());
50+
4851
assertTrue(hasReplayed);
4952
assertEquals("activity1", result);
53+
testWorkflowRule
54+
.getInterceptor(TracingWorkerInterceptor.class)
55+
.setExpected(
56+
"interceptExecuteWorkflow " + SDKTestWorkflowRule.UUID_REGEXP,
57+
"newThread workflow-method",
58+
"newThread null",
59+
"getVersion",
60+
"executeActivity customActivity1",
61+
"sleep PT1S",
62+
"activity customActivity1");
5063
}
5164

5265
@Test
@@ -76,9 +89,8 @@ public String execute(String taskQueue) {
7689
} else {
7790
hasReplayed = true;
7891
}
79-
String result =
80-
"activity" + testActivities.activity1(1); // This is executed in non-replay mode.
81-
return result;
92+
93+
return "activity" + testActivities.activity1(1);
8294
}
8395
}
8496
}

0 commit comments

Comments
 (0)