Skip to content

Commit f63ed38

Browse files
committed
move versioned workflows to integration tests
1 parent 2ddb5d4 commit f63ed38

File tree

3 files changed

+76
-215
lines changed

3 files changed

+76
-215
lines changed

test/integration_test.go

Lines changed: 57 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ import (
4444
"go.uber.org/cadence/client"
4545
"go.uber.org/cadence/interceptors"
4646
"go.uber.org/cadence/internal"
47-
"go.uber.org/cadence/test/replaytests"
4847
"go.uber.org/cadence/worker"
4948
"go.uber.org/cadence/workflow"
5049
)
@@ -561,15 +560,15 @@ func (ts *IntegrationTestSuite) TestOverrideSpanContext() {
561560
// but not on VersionedWorkflowV4, VersionedWorkflowV5, VersionedWorkflowV6.
562561
func (ts *IntegrationTestSuite) TestVersionedWorkflowV1() {
563562
ts.testVersionedWorkflow(testVersionedWorkflowTestCase{
564-
version: replaytests.VersionWorkflowVersionV1,
565-
compatibleVersions: []replaytests.VersionWorkflowVersion{
566-
replaytests.VersionWorkflowVersionV2,
567-
replaytests.VersionWorkflowVersionV3,
563+
version: VersionedWorkflowVersionV1,
564+
compatibleVersions: []VersionedWorkflowVersion{
565+
VersionedWorkflowVersionV2,
566+
VersionedWorkflowVersionV3,
568567
},
569-
inCompatibleVersions: []replaytests.VersionWorkflowVersion{
570-
replaytests.VersionWorkflowVersionV4,
571-
replaytests.VersionWorkflowVersionV5,
572-
replaytests.VersionWorkflowVersionV6,
568+
inCompatibleVersions: []VersionedWorkflowVersion{
569+
VersionedWorkflowVersionV4,
570+
VersionedWorkflowVersionV5,
571+
VersionedWorkflowVersionV6,
573572
},
574573
})
575574
}
@@ -579,15 +578,15 @@ func (ts *IntegrationTestSuite) TestVersionedWorkflowV1() {
579578
// but not on VersionedWorkflowV4, VersionedWorkflowV5, VersionedWorkflowV6.
580579
func (ts *IntegrationTestSuite) TestVersionedWorkflowV2() {
581580
ts.testVersionedWorkflow(testVersionedWorkflowTestCase{
582-
version: replaytests.VersionWorkflowVersionV2,
583-
compatibleVersions: []replaytests.VersionWorkflowVersion{
584-
replaytests.VersionWorkflowVersionV1,
585-
replaytests.VersionWorkflowVersionV3,
581+
version: VersionedWorkflowVersionV2,
582+
compatibleVersions: []VersionedWorkflowVersion{
583+
VersionedWorkflowVersionV1,
584+
VersionedWorkflowVersionV3,
586585
},
587-
inCompatibleVersions: []replaytests.VersionWorkflowVersion{
588-
replaytests.VersionWorkflowVersionV4,
589-
replaytests.VersionWorkflowVersionV5,
590-
replaytests.VersionWorkflowVersionV6,
586+
inCompatibleVersions: []VersionedWorkflowVersion{
587+
VersionedWorkflowVersionV4,
588+
VersionedWorkflowVersionV5,
589+
VersionedWorkflowVersionV6,
591590
},
592591
})
593592
}
@@ -597,15 +596,15 @@ func (ts *IntegrationTestSuite) TestVersionedWorkflowV2() {
597596
// but not on VersionedWorkflowV1
598597
func (ts *IntegrationTestSuite) TestVersionedWorkflowV3() {
599598
ts.testVersionedWorkflow(testVersionedWorkflowTestCase{
600-
version: replaytests.VersionWorkflowVersionV3,
601-
compatibleVersions: []replaytests.VersionWorkflowVersion{
602-
replaytests.VersionWorkflowVersionV2,
603-
replaytests.VersionWorkflowVersionV4,
604-
replaytests.VersionWorkflowVersionV5,
605-
replaytests.VersionWorkflowVersionV6,
599+
version: VersionedWorkflowVersionV3,
600+
compatibleVersions: []VersionedWorkflowVersion{
601+
VersionedWorkflowVersionV2,
602+
VersionedWorkflowVersionV4,
603+
VersionedWorkflowVersionV5,
604+
VersionedWorkflowVersionV6,
606605
},
607-
inCompatibleVersions: []replaytests.VersionWorkflowVersion{
608-
replaytests.VersionWorkflowVersionV1,
606+
inCompatibleVersions: []VersionedWorkflowVersion{
607+
VersionedWorkflowVersionV1,
609608
},
610609
})
611610
}
@@ -615,15 +614,15 @@ func (ts *IntegrationTestSuite) TestVersionedWorkflowV3() {
615614
// but not on VersionedWorkflowV1
616615
func (ts *IntegrationTestSuite) TestVersionedWorkflowV4() {
617616
ts.testVersionedWorkflow(testVersionedWorkflowTestCase{
618-
version: replaytests.VersionWorkflowVersionV4,
619-
compatibleVersions: []replaytests.VersionWorkflowVersion{
620-
replaytests.VersionWorkflowVersionV2,
621-
replaytests.VersionWorkflowVersionV3,
622-
replaytests.VersionWorkflowVersionV5,
623-
replaytests.VersionWorkflowVersionV6,
617+
version: VersionedWorkflowVersionV4,
618+
compatibleVersions: []VersionedWorkflowVersion{
619+
VersionedWorkflowVersionV2,
620+
VersionedWorkflowVersionV3,
621+
VersionedWorkflowVersionV5,
622+
VersionedWorkflowVersionV6,
624623
},
625-
inCompatibleVersions: []replaytests.VersionWorkflowVersion{
626-
replaytests.VersionWorkflowVersionV1,
624+
inCompatibleVersions: []VersionedWorkflowVersion{
625+
VersionedWorkflowVersionV1,
627626
},
628627
})
629628
}
@@ -633,15 +632,15 @@ func (ts *IntegrationTestSuite) TestVersionedWorkflowV4() {
633632
// but not on VersionedWorkflowV1.
634633
func (ts *IntegrationTestSuite) TestVersionedWorkflowV5() {
635634
ts.testVersionedWorkflow(testVersionedWorkflowTestCase{
636-
version: replaytests.VersionWorkflowVersionV5,
637-
compatibleVersions: []replaytests.VersionWorkflowVersion{
638-
replaytests.VersionWorkflowVersionV2,
639-
replaytests.VersionWorkflowVersionV3,
640-
replaytests.VersionWorkflowVersionV4,
641-
replaytests.VersionWorkflowVersionV6,
635+
version: VersionedWorkflowVersionV5,
636+
compatibleVersions: []VersionedWorkflowVersion{
637+
VersionedWorkflowVersionV2,
638+
VersionedWorkflowVersionV3,
639+
VersionedWorkflowVersionV4,
640+
VersionedWorkflowVersionV6,
642641
},
643-
inCompatibleVersions: []replaytests.VersionWorkflowVersion{
644-
replaytests.VersionWorkflowVersionV1,
642+
inCompatibleVersions: []VersionedWorkflowVersion{
643+
VersionedWorkflowVersionV1,
645644
},
646645
})
647646
}
@@ -651,41 +650,41 @@ func (ts *IntegrationTestSuite) TestVersionedWorkflowV5() {
651650
// but not on VersionedWorkflowV1, VersionedWorkflowV2, VersionedWorkflowV3, VersionedWorkflowV4.
652651
func (ts *IntegrationTestSuite) TestVersionedWorkflowV6() {
653652
ts.testVersionedWorkflow(testVersionedWorkflowTestCase{
654-
version: replaytests.VersionWorkflowVersionV6,
655-
compatibleVersions: []replaytests.VersionWorkflowVersion{
656-
replaytests.VersionWorkflowVersionV5,
653+
version: VersionedWorkflowVersionV6,
654+
compatibleVersions: []VersionedWorkflowVersion{
655+
VersionedWorkflowVersionV5,
657656
},
658-
inCompatibleVersions: []replaytests.VersionWorkflowVersion{
659-
replaytests.VersionWorkflowVersionV1,
660-
replaytests.VersionWorkflowVersionV2,
661-
replaytests.VersionWorkflowVersionV3,
662-
replaytests.VersionWorkflowVersionV4,
657+
inCompatibleVersions: []VersionedWorkflowVersion{
658+
VersionedWorkflowVersionV1,
659+
VersionedWorkflowVersionV2,
660+
VersionedWorkflowVersionV3,
661+
VersionedWorkflowVersionV4,
663662
},
664663
})
665664
}
666665

667666
type testVersionedWorkflowTestCase struct {
668-
version replaytests.VersionWorkflowVersion
669-
compatibleVersions []replaytests.VersionWorkflowVersion
670-
inCompatibleVersions []replaytests.VersionWorkflowVersion
667+
version VersionedWorkflowVersion
668+
compatibleVersions []VersionedWorkflowVersion
669+
inCompatibleVersions []VersionedWorkflowVersion
671670
}
672671

673672
// testVersionedWorkflow tests that a workflow started on the worker with version
674673
// can be replayed on worker with compatibleVersions
675674
// but not on worker with inCompatibleVersions
676675
func (ts *IntegrationTestSuite) testVersionedWorkflow(c testVersionedWorkflowTestCase) {
677-
replaytests.SetupWorkerForVersionedWorkflow(c.version, ts.worker)
676+
SetupWorkerForVersionedWorkflow(c.version, ts.worker)
678677
wfId := fmt.Sprintf("test-versioned-workflow-v%d", c.version)
679-
execution, err := ts.executeWorkflow(wfId, replaytests.VersionedWorkflowName, nil, "arg")
678+
execution, err := ts.executeWorkflow(wfId, VersionedWorkflowName, nil, "arg")
680679
ts.NoError(err)
681680

682681
c.compatibleVersions = append(c.compatibleVersions, c.version)
683682

684-
ts.Require().Equalf(len(c.compatibleVersions)+len(c.inCompatibleVersions), int(replaytests.MaxVersionWorkflowVersion),
683+
ts.Require().Equalf(len(c.compatibleVersions)+len(c.inCompatibleVersions), int(MaxVersionedWorkflowVersion),
685684
"Test case should cover all versions, but got %d compatible (one of them the testing version itself) and %d incompatible versions, that not equal to %d",
686685
len(c.compatibleVersions),
687686
len(c.inCompatibleVersions),
688-
replaytests.MaxVersionWorkflowVersion)
687+
MaxVersionedWorkflowVersion)
689688

690689
for _, replayedVersion := range c.compatibleVersions {
691690
err := ts.replayVersionedWorkflow(replayedVersion, execution)
@@ -698,9 +697,9 @@ func (ts *IntegrationTestSuite) testVersionedWorkflow(c testVersionedWorkflowTes
698697
}
699698
}
700699

701-
func (ts *IntegrationTestSuite) replayVersionedWorkflow(version replaytests.VersionWorkflowVersion, execution *workflow.Execution) error {
700+
func (ts *IntegrationTestSuite) replayVersionedWorkflow(version VersionedWorkflowVersion, execution *workflow.Execution) error {
702701
replayer := worker.NewWorkflowReplayer()
703-
replaytests.SetupWorkerForVersionedWorkflow(version, replayer)
702+
SetupWorkerForVersionedWorkflow(version, replayer)
704703
return replayer.ReplayWorkflowExecution(context.Background(), ts.rpcClient, zaptest.NewLogger(ts.T()), domainName, *execution)
705704
}
706705

test/replaytests/replay_test.go

Lines changed: 0 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -188,141 +188,3 @@ func TestContinueAsNew(t *testing.T) {
188188
err := replayer.ReplayWorkflowHistoryFromJSONFile(zaptest.NewLogger(t), "continue_as_new.json")
189189
assert.ErrorContains(t, err, "missing replay decision for WorkflowExecutionContinuedAsNew")
190190
}
191-
192-
// TestSafeDeploymentVersionedWorkflow verifies that versioned workflows can be executed
193-
// safely across different versions without causing non-deterministic errors.
194-
// There are 2 workflow executions:
195-
//
196-
// * VersionedWorkflowFoo - which is the first version of the workflow which version of change id is DefaultVersion
197-
// - This workflow is supposed to execute FooActivity
198-
//
199-
// * VersionedWorkflowBar - which is the second version of the workflow which version of change id is 1
200-
// - This workflow is supposed to execute BarActivity
201-
//
202-
// There are 6 versions of the workflow:
203-
//
204-
// * VersionedWorkflowV1 - which supports only DefaultVersion and executes FooActivity
205-
// - This workflow is able to replay the history of only of VersionedWorkflowFoo
206-
//
207-
// * VersionedWorkflowV2 - which supports DefaultVersion and Version 1, and can execute FooActivity or BarActivity
208-
// - This workflow is able to replay the history of both of VersionedWorkflowFoo and VersionedWorkflowBar
209-
// - A first execution of this workflow will should execute FooActivity, because of usage workflow.ExecuteWithMinVersion(),
210-
// but the test can't check it due to Replay
211-
//
212-
// * VersionedWorkflowV3 - which supports DefaultVersion and Version 1, and can execute FooActivity or BarActivity
213-
// - This workflow is able to replay the history of both of VersionedWorkflowFoo and VersionedWorkflowBar
214-
// - A first execution of this workflow will should execute BarActivity, but the test can't check it due to Replay
215-
//
216-
// * VersionedWorkflowV4 - which supports Version 1, and can execute BarActivity
217-
// - This workflow is able to replay the history only of VersionedWorkflowBar
218-
//
219-
// * VersionedWorkflowV5 - which supports Version 1 and 2, and can execute BarActivity and BazActivity
220-
// - This workflow is able to replay the history only of VersionedWorkflowBar
221-
// - A first execution of this workflow will should execute BarActivity, because of usage workflow.ExecuteWithMinVersion(),
222-
// but the test can't check it due to Replay
223-
//
224-
// * VersionedWorkflowV6 - which supports Version 1 and 2, and can execute BarActivity and BazActivity
225-
// - This workflow is able to replay the history only of VersionedWorkflowBar
226-
// - A first execution of this workflow will should execute BazActivity, but the test can't check it due to Replay
227-
//
228-
// So the test focusing workflows supports forward and backward compatibility of the workflows
229-
func TestVersionedWorkflows(t *testing.T) {
230-
const (
231-
versionedWorkflowFooHistoryFile = "versioned_workflow_foo.json"
232-
versionedWorkflowBarHistoryFile = "versioned_workflow_bar.json"
233-
)
234-
235-
t.Run("VersionedWorkflowV1", func(t *testing.T) {
236-
replayer := worker.NewWorkflowReplayer()
237-
SetupWorkerForVersionedWorkflowV1(replayer)
238-
239-
t.Run("successfully replayed with VersionedWorkflowFoo", func(t *testing.T) {
240-
err := replayer.ReplayWorkflowHistoryFromJSONFile(zaptest.NewLogger(t), versionedWorkflowFooHistoryFile)
241-
require.NoError(t, err, "Failed to replay VersionedWorkflowFoo history")
242-
})
243-
244-
t.Run("fail to replay with VersionedWorkflowBar", func(t *testing.T) {
245-
err := replayer.ReplayWorkflowHistoryFromJSONFile(zaptest.NewLogger(t), versionedWorkflowBarHistoryFile)
246-
require.Error(t, err, "Expected to fail replaying VersionedWorkflowBar history")
247-
assert.ErrorContains(t, err, "nondeterministic workflow")
248-
})
249-
})
250-
251-
t.Run("VersionedWorkflowV2", func(t *testing.T) {
252-
replayer := worker.NewWorkflowReplayer()
253-
SetupWorkerForVersionedWorkflowV2(replayer)
254-
255-
t.Run("successfully replayed with VersionedWorkflowFoo", func(t *testing.T) {
256-
err := replayer.ReplayWorkflowHistoryFromJSONFile(zaptest.NewLogger(t), versionedWorkflowFooHistoryFile)
257-
require.NoError(t, err, "Failed to replay VersionedWorkflowFoo history")
258-
})
259-
260-
t.Run("successfully replayed with VersionedWorkflowBar", func(t *testing.T) {
261-
err := replayer.ReplayWorkflowHistoryFromJSONFile(zaptest.NewLogger(t), versionedWorkflowBarHistoryFile)
262-
require.NoError(t, err, "Failed to replay VersionedWorkflowBar history")
263-
})
264-
})
265-
266-
t.Run("VersionedWorkflowV3", func(t *testing.T) {
267-
replayer := worker.NewWorkflowReplayer()
268-
SetupWorkerForVersionedWorkflowV3(replayer)
269-
270-
t.Run("successfully replayed with VersionedWorkflowFoo", func(t *testing.T) {
271-
err := replayer.ReplayWorkflowHistoryFromJSONFile(zaptest.NewLogger(t), versionedWorkflowFooHistoryFile)
272-
require.NoError(t, err, "Failed to replay VersionedWorkflowFoo history")
273-
})
274-
275-
t.Run("successfully replayed with VersionedWorkflowBar", func(t *testing.T) {
276-
err := replayer.ReplayWorkflowHistoryFromJSONFile(zaptest.NewLogger(t), versionedWorkflowBarHistoryFile)
277-
require.NoError(t, err, "Failed to replay VersionedWorkflowBar history")
278-
})
279-
})
280-
281-
t.Run("VersionedWorkflowV4", func(t *testing.T) {
282-
replayer := worker.NewWorkflowReplayer()
283-
SetupWorkerForVersionedWorkflowV4(replayer)
284-
285-
t.Run("fail to replay with VersionedWorkflowFoo", func(t *testing.T) {
286-
err := replayer.ReplayWorkflowHistoryFromJSONFile(zaptest.NewLogger(t), versionedWorkflowFooHistoryFile)
287-
require.Error(t, err, "Expected to fail replaying VersionedWorkflowFoo history")
288-
assert.ErrorContains(t, err, "WORKFLOW_WORKER_UNHANDLED_FAILURE")
289-
})
290-
291-
t.Run("successfully replayed with VersionedWorkflowBar", func(t *testing.T) {
292-
err := replayer.ReplayWorkflowHistoryFromJSONFile(zaptest.NewLogger(t), versionedWorkflowBarHistoryFile)
293-
require.NoError(t, err, "Failed to replay VersionedWorkflowBar history")
294-
})
295-
})
296-
297-
t.Run("VersionedWorkflowV5", func(t *testing.T) {
298-
replayer := worker.NewWorkflowReplayer()
299-
SetupWorkerForVersionedWorkflowV5(replayer)
300-
301-
t.Run("fail to replay with VersionedWorkflowFoo", func(t *testing.T) {
302-
err := replayer.ReplayWorkflowHistoryFromJSONFile(zaptest.NewLogger(t), versionedWorkflowFooHistoryFile)
303-
require.Error(t, err, "Expected to fail replaying VersionedWorkflowFoo history")
304-
assert.ErrorContains(t, err, "WORKFLOW_WORKER_UNHANDLED_FAILURE")
305-
})
306-
307-
t.Run("successfully replayed with VersionedWorkflowBar", func(t *testing.T) {
308-
err := replayer.ReplayWorkflowHistoryFromJSONFile(zaptest.NewLogger(t), versionedWorkflowBarHistoryFile)
309-
require.NoError(t, err, "Failed to replay VersionedWorkflowBar history")
310-
})
311-
})
312-
313-
t.Run("VersionedWorkflowV6", func(t *testing.T) {
314-
replayer := worker.NewWorkflowReplayer()
315-
SetupWorkerForVersionedWorkflowV6(replayer)
316-
317-
t.Run("fail to replay with VersionedWorkflowFoo", func(t *testing.T) {
318-
err := replayer.ReplayWorkflowHistoryFromJSONFile(zaptest.NewLogger(t), versionedWorkflowFooHistoryFile)
319-
require.Error(t, err, "Expected to fail replaying VersionedWorkflowFoo history")
320-
assert.ErrorContains(t, err, "WORKFLOW_WORKER_UNHANDLED_FAILURE")
321-
})
322-
323-
t.Run("successfully replayed with VersionedWorkflowBar", func(t *testing.T) {
324-
err := replayer.ReplayWorkflowHistoryFromJSONFile(zaptest.NewLogger(t), versionedWorkflowBarHistoryFile)
325-
require.NoError(t, err, "Failed to replay VersionedWorkflowBar history")
326-
})
327-
})
328-
}

0 commit comments

Comments
 (0)