Skip to content

Commit 2ec91f2

Browse files
authored
refactor(active-active): Update simulation tests to set ActiveClusterSelectionPolicy in the input (#7303)
<!-- Describe what has changed in this PR --> **What changed?** Update simulation tests to set ActiveClusterSelectionPolicy in the input <!-- Tell your future self why have you made these changes --> **Why?** Refactor the implementation of active-active domains <!-- How have you verified this change? Tested locally? Added a unit test? Checked in staging env? --> **How did you test it?** simulation tests <!-- Assuming the worst case, what can be broken when deploying this change to production? --> **Potential risks** <!-- Is it notable for release? e.g. schema updates, configuration or data migration required? If so, please mention it, and also update CHANGELOG.md --> **Release notes** <!-- Is there any documentation updates should be made for config, https://cadenceworkflow.io/docs/operation-guide/setup/ ? If so, please open an PR in https://github.com/cadence-workflow/cadence-docs --> **Documentation Changes**
1 parent 986dab9 commit 2ec91f2

11 files changed

+100
-13
lines changed

common/types/shared.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2551,8 +2551,8 @@ func (v *ActiveClusters) DeepCopy() *ActiveClusters {
25512551
}
25522552

25532553
type ClusterAttribute struct {
2554-
Scope string `json:"scope,omitempty"`
2555-
Name string `json:"name,omitempty"`
2554+
Scope string `json:"scope,omitempty" yaml:"scope,omitempty"`
2555+
Name string `json:"name,omitempty" yaml:"name,omitempty"`
25562556
}
25572557

25582558
func (c *ClusterAttribute) Equals(other *ClusterAttribute) bool {
@@ -2581,7 +2581,7 @@ type ActiveClusterSelectionPolicy struct {
25812581
ExternalEntityKey string `json:"externalEntityKey,omitempty"`
25822582

25832583
// TODO(active-active): Remove the fields above
2584-
ClusterAttribute *ClusterAttribute `json:"clusterAttribute,omitempty"`
2584+
ClusterAttribute *ClusterAttribute `json:"clusterAttribute,omitempty" yaml:"clusterAttribute,omitempty"`
25852585
}
25862586

25872587
func (p *ActiveClusterSelectionPolicy) Equals(other *ActiveClusterSelectionPolicy) bool {

simulation/replication/replication_simulation_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ func startWorkflow(
155155
WorkflowIDReusePolicy: types.WorkflowIDReusePolicyAllowDuplicate.Ptr(),
156156
DelayStartSeconds: common.Int32Ptr(op.DelayStartSeconds),
157157
CronSchedule: op.CronSchedule,
158+
ActiveClusterSelectionPolicy: op.ActiveClusterSelectionPolicy,
158159
})
159160

160161
if err != nil {
@@ -404,6 +405,7 @@ func signalWithStartWorkflow(
404405
ExecutionStartToCloseTimeoutSeconds: common.Int32Ptr(int32((op.WorkflowExecutionStartToCloseTimeout).Seconds())),
405406
TaskStartToCloseTimeoutSeconds: common.Int32Ptr(5),
406407
Input: mustJSON(t, &simTypes.WorkflowInput{Duration: op.WorkflowDuration, ActivityCount: op.ActivityCount}),
408+
ActiveClusterSelectionPolicy: op.ActiveClusterSelectionPolicy,
407409
})
408410
if err != nil {
409411
return err

simulation/replication/testdata/replication_simulation_activeactive.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ operations:
2929
domain: test-domain-aa
3030
workflowExecutionStartToCloseTimeout: 65s
3131
workflowDuration: 35s
32+
activeClusterSelectionPolicy:
33+
clusterAttribute:
34+
scope: region
35+
name: region0
3236

3337
# start workflow in cluster1
3438
- op: start_workflow
@@ -39,6 +43,10 @@ operations:
3943
domain: test-domain-aa
4044
workflowExecutionStartToCloseTimeout: 65s
4145
workflowDuration: 35s
46+
activeClusterSelectionPolicy:
47+
clusterAttribute:
48+
scope: region
49+
name: region1
4250

4351
# validate that wf1 is started in cluster0 and completed in cluster1
4452
- op: validate

simulation/replication/testdata/replication_simulation_activeactive_cron.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ operations:
3030
workflowExecutionStartToCloseTimeout: 55s
3131
workflowDuration: 35s
3232
cronSchedule: "*/1 * * * *"
33+
activeClusterSelectionPolicy:
34+
clusterAttribute:
35+
scope: region
36+
name: region0
3337

3438
# start a cron workflow that runs every minute in cluster1
3539
- op: start_workflow
@@ -41,6 +45,10 @@ operations:
4145
workflowExecutionStartToCloseTimeout: 55s
4246
workflowDuration: 35s
4347
cronSchedule: "*/1 * * * *"
48+
activeClusterSelectionPolicy:
49+
clusterAttribute:
50+
scope: region
51+
name: region1
4452

4553

4654
# Failover from cluster0 to cluster1

simulation/replication/testdata/replication_simulation_activeactive_regional_failover.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ operations:
2929
domain: test-domain-aa
3030
workflowExecutionStartToCloseTimeout: 45s
3131
workflowDuration: 35s
32+
activeClusterSelectionPolicy:
33+
clusterAttribute:
34+
scope: region
35+
name: region0
3236
- op: validate
3337
at: 60s
3438
workflowID: wf1
@@ -56,6 +60,10 @@ operations:
5660
domain: test-domain-aa
5761
workflowExecutionStartToCloseTimeout: 45s
5862
workflowDuration: 35s
63+
activeClusterSelectionPolicy:
64+
clusterAttribute:
65+
scope: region
66+
name: region0
5967
- op: validate
6068
at: 70s
6169
workflowID: wf2
@@ -77,6 +85,10 @@ operations:
7785
workflowExecutionStartToCloseTimeout: 45s
7886
workflowDuration: 35s
7987
delayStartSeconds: 10
88+
activeClusterSelectionPolicy:
89+
clusterAttribute:
90+
scope: region
91+
name: region0
8092
- op: validate
8193
at: 70s
8294
workflowID: wf3
@@ -95,6 +107,10 @@ operations:
95107
workflowExecutionStartToCloseTimeout: 45s
96108
workflowDuration: 35s
97109
delayStartSeconds: 10
110+
activeClusterSelectionPolicy:
111+
clusterAttribute:
112+
scope: region
113+
name: region0
98114
- op: validate
99115
at: 71s
100116
workflowID: wf4
@@ -113,6 +129,10 @@ operations:
113129
workflowExecutionStartToCloseTimeout: 45s
114130
workflowDuration: 35s
115131
delayStartSeconds: 10
132+
activeClusterSelectionPolicy:
133+
clusterAttribute:
134+
scope: region
135+
name: region0
116136
- op: validate
117137
at: 72s
118138
workflowID: wf5
@@ -131,6 +151,10 @@ operations:
131151
workflowExecutionStartToCloseTimeout: 45s
132152
workflowDuration: 35s
133153
delayStartSeconds: 10
154+
activeClusterSelectionPolicy:
155+
clusterAttribute:
156+
scope: region
157+
name: region0
134158
- op: validate
135159
at: 73s
136160
workflowID: wf6
@@ -150,6 +174,10 @@ operations:
150174
domain: test-domain-aa
151175
workflowExecutionStartToCloseTimeout: 45s
152176
workflowDuration: 35s
177+
activeClusterSelectionPolicy:
178+
clusterAttribute:
179+
scope: region
180+
name: region0
153181
- op: validate
154182
at: 75s
155183
workflowID: wf7

simulation/replication/testdata/replication_simulation_activeactive_regional_failover_start_same_wfid.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ operations:
3232
domain: test-domain-aa
3333
workflowExecutionStartToCloseTimeout: 70s
3434
workflowDuration: 60s
35+
activeClusterSelectionPolicy:
36+
clusterAttribute:
37+
scope: region
38+
name: region1
3539

3640

3741
# Failover from cluster1 to cluster0
@@ -50,6 +54,10 @@ operations:
5054
domain: test-domain-aa
5155
workflowExecutionStartToCloseTimeout: 70s
5256
workflowDuration: 60s
57+
activeClusterSelectionPolicy:
58+
clusterAttribute:
59+
scope: region
60+
name: region1
5361
want:
5462
error: "Workflow execution is already running"
5563

simulation/replication/testdata/replication_simulation_activeactive_regional_failover_start_same_wfid_2.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ operations:
3131
domain: test-domain-aa
3232
workflowExecutionStartToCloseTimeout: 70s
3333
workflowDuration: 60s
34+
activeClusterSelectionPolicy:
35+
clusterAttribute:
36+
scope: region
37+
name: region1
3438

3539

3640
# Failover from cluster1 to cluster0
@@ -49,6 +53,10 @@ operations:
4953
domain: test-domain-aa
5054
workflowExecutionStartToCloseTimeout: 70s
5155
workflowDuration: 60s
56+
activeClusterSelectionPolicy:
57+
clusterAttribute:
58+
scope: region
59+
name: region0
5260
want:
5361
error: "Workflow execution is already running"
5462

simulation/replication/testdata/replication_simulation_activeactive_same_wfid.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ operations:
3030
workflowExecutionStartToCloseTimeout: 65s
3131
workflowDuration: 35s
3232
runIDKey: cluster0
33+
activeClusterSelectionPolicy:
34+
clusterAttribute:
35+
scope: region
36+
name: region0
3337

3438
# start workflow in cluster1
3539
- op: start_workflow
@@ -41,6 +45,10 @@ operations:
4145
workflowExecutionStartToCloseTimeout: 65s
4246
workflowDuration: 35s
4347
runIDKey: cluster1
48+
activeClusterSelectionPolicy:
49+
clusterAttribute:
50+
scope: region
51+
name: region1
4452

4553
# validate that wf1 is started in cluster0 and terminated
4654
- op: validate

simulation/replication/testdata/replication_simulation_activeactive_same_wfid_signalwithstart.yaml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Dynamic config overrides can be set via config/dynamicconfig/replication_simulation_activeactive_same_wfid_signalwithstart.yml
55
# When a domain is configured as active-active
66
# And the same workflow ID is used to SignalWithStart in multiple clusters
7-
# Then the 'earlier' workflow should be terminated
7+
# Then the 'earlier' workflow should be terminated
88
# And the 'later' workflow should complete
99

1010
clusters:
@@ -34,6 +34,10 @@ operations:
3434
workflowExecutionStartToCloseTimeout: 65s
3535
workflowDuration: 35s
3636
runIDKey: cluster0-run
37+
activeClusterSelectionPolicy:
38+
clusterAttribute:
39+
scope: region
40+
name: region0
3741

3842
- op: signal_with_start_workflow
3943
at: 0s
@@ -46,6 +50,10 @@ operations:
4650
workflowExecutionStartToCloseTimeout: 65s
4751
workflowDuration: 35s
4852
runIDKey: cluster1-run
53+
activeClusterSelectionPolicy:
54+
clusterAttribute:
55+
scope: region
56+
name: region1
4957

5058
# Query the cluster0 run to validate it was started with the correct signal
5159
# Note that if this query is delayed it will eventually see the signal from the 'later' workflow, as conflict resolution will have occurred
@@ -69,7 +77,7 @@ operations:
6977
runIDKey: cluster1-run
7078
want:
7179
queryResult: ["cluster1-signal-data"]
72-
80+
7381
- op: validate
7482
at: 30s
7583
workflowID: conflict-wf

simulation/replication/testdata/replication_simulation_activeactive_same_wfid_signalwithstart_delayed.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ operations:
3232
signalInput: "cluster0-signal-data"
3333
workflowExecutionStartToCloseTimeout: 90s
3434
workflowDuration: 60s
35+
activeClusterSelectionPolicy:
36+
clusterAttribute:
37+
scope: region
38+
name: region0
3539

3640
- op: signal_with_start_workflow
3741
at: 20s
@@ -43,6 +47,10 @@ operations:
4347
signalInput: "cluster1-signal-data"
4448
workflowExecutionStartToCloseTimeout: 90s
4549
workflowDuration: 60s
50+
activeClusterSelectionPolicy:
51+
clusterAttribute:
52+
scope: region
53+
name: region1
4654

4755
# Query after the second signal to validate both signals are in the same workflow
4856
- op: query_workflow
@@ -72,4 +80,4 @@ operations:
7280
want:
7381
status: completed
7482
startedByWorkersInCluster: cluster0
75-
completedByWorkersInCluster: cluster0
83+
completedByWorkersInCluster: cluster0

0 commit comments

Comments
 (0)