@@ -32,6 +32,7 @@ import (
32
32
"time"
33
33
34
34
"github.com/pborman/uuid"
35
+ "github.com/stretchr/testify/assert"
35
36
"github.com/stretchr/testify/require"
36
37
"github.com/stretchr/testify/suite"
37
38
commandpb "go.temporal.io/api/command/v1"
@@ -46,8 +47,10 @@ import (
46
47
"go.temporal.io/api/workflowservice/v1"
47
48
"go.temporal.io/server/api/adminservice/v1"
48
49
"go.temporal.io/server/common"
50
+ "go.temporal.io/server/common/dynamicconfig"
49
51
"go.temporal.io/server/common/log"
50
52
"go.temporal.io/server/common/log/tag"
53
+ "go.temporal.io/server/common/namespace"
51
54
"go.temporal.io/server/common/payload"
52
55
"go.temporal.io/server/common/payloads"
53
56
"go.temporal.io/server/common/searchattribute"
@@ -77,6 +80,9 @@ type AdvVisCrossDCTestSuite struct {
77
80
clusterConfigs []* testcore.TestClusterConfig
78
81
isElasticsearchEnabled bool
79
82
83
+ dynamicConfigOverrides map [dynamicconfig.Key ]interface {}
84
+ enableTransitionHistory bool
85
+
80
86
testSearchAttributeKey string
81
87
testSearchAttributeVal string
82
88
@@ -86,7 +92,26 @@ type AdvVisCrossDCTestSuite struct {
86
92
87
93
func TestAdvVisCrossDCTestSuite (t * testing.T ) {
88
94
t .Parallel ()
89
- suite .Run (t , new (AdvVisCrossDCTestSuite ))
95
+ for _ , tc := range []struct {
96
+ name string
97
+ enableTransitionHistory bool
98
+ }{
99
+ {
100
+ name : "EnableTransitionHistory" ,
101
+ enableTransitionHistory : true ,
102
+ },
103
+ {
104
+ name : "DisableTransitionHistory" ,
105
+ enableTransitionHistory : false ,
106
+ },
107
+ } {
108
+ t .Run (tc .name , func (t * testing.T ) {
109
+ s := & AdvVisCrossDCTestSuite {
110
+ enableTransitionHistory : tc .enableTransitionHistory ,
111
+ }
112
+ suite .Run (t , s )
113
+ })
114
+ }
90
115
}
91
116
92
117
var (
@@ -105,6 +130,10 @@ func (s *AdvVisCrossDCTestSuite) SetupSuite() {
105
130
s .logger = log .NewTestLogger ()
106
131
s .testClusterFactory = testcore .NewTestClusterFactory ()
107
132
133
+ s .dynamicConfigOverrides = map [dynamicconfig.Key ]any {
134
+ dynamicconfig .EnableTransitionHistory .Key (): s .enableTransitionHistory ,
135
+ }
136
+
108
137
var fileName string
109
138
if testcore .UsingSQLAdvancedVisibility () {
110
139
// NOTE: can't use xdc_clusters.yaml here because it somehow interferes with the other xDC tests.
@@ -130,6 +159,10 @@ func (s *AdvVisCrossDCTestSuite) SetupSuite() {
130
159
s .Require ().NoError (yaml .Unmarshal (confContent , & clusterConfigs ))
131
160
s .clusterConfigs = clusterConfigs
132
161
162
+ for _ , config := range clusterConfigs {
163
+ config .DynamicConfigOverrides = s .dynamicConfigOverrides
164
+ }
165
+
133
166
c , err := s .testClusterFactory .NewCluster (s .T (), clusterConfigs [0 ], log .With (s .logger , tag .ClusterName (clusterNameAdvVis [0 ])))
134
167
s .Require ().NoError (err )
135
168
s .cluster1 = c
@@ -178,10 +211,10 @@ func (s *AdvVisCrossDCTestSuite) TearDownSuite() {
178
211
}
179
212
180
213
func (s * AdvVisCrossDCTestSuite ) TestSearchAttributes () {
181
- namespace := "test-xdc-search-attr-" + common .GenerateRandomString (5 )
214
+ ns := "test-xdc-search-attr-" + common .GenerateRandomString (5 )
182
215
client1 := s .cluster1 .FrontendClient () // active
183
216
regReq := & workflowservice.RegisterNamespaceRequest {
184
- Namespace : namespace ,
217
+ Namespace : ns ,
185
218
Clusters : clusterReplicationConfigAdvVis ,
186
219
ActiveClusterName : clusterNameAdvVis [0 ],
187
220
IsGlobalNamespace : true ,
@@ -195,7 +228,7 @@ func (s *AdvVisCrossDCTestSuite) TestSearchAttributes() {
195
228
if ! s .isElasticsearchEnabled {
196
229
// When Elasticsearch is enabled, the search attribute aliases are not used.
197
230
_ , err = client1 .UpdateNamespace (testcore .NewContext (), & workflowservice.UpdateNamespaceRequest {
198
- Namespace : namespace ,
231
+ Namespace : ns ,
199
232
Config : & namespacepb.NamespaceConfig {
200
233
CustomSearchAttributeAliases : map [string ]string {
201
234
"Bool01" : "CustomBoolField" ,
@@ -212,8 +245,16 @@ func (s *AdvVisCrossDCTestSuite) TestSearchAttributes() {
212
245
time .Sleep (cacheRefreshInterval ) // nolint:forbidigo
213
246
}
214
247
248
+ s .EventuallyWithT (func (t * assert.CollectT ) {
249
+ // Wait for namespace record to be replicated and loaded into memory.
250
+ for _ , r := range s .cluster2 .Host ().FrontendNamespaceRegistries () {
251
+ _ , err := r .GetNamespace (namespace .Name (ns ))
252
+ assert .NoError (t , err )
253
+ }
254
+ }, 15 * time .Second , 500 * time .Millisecond )
255
+
215
256
descReq := & workflowservice.DescribeNamespaceRequest {
216
- Namespace : namespace ,
257
+ Namespace : ns ,
217
258
}
218
259
resp , err := client1 .DescribeNamespace (testcore .NewContext (), descReq )
219
260
s .NoError (err )
@@ -239,7 +280,7 @@ func (s *AdvVisCrossDCTestSuite) TestSearchAttributes() {
239
280
}
240
281
startReq := & workflowservice.StartWorkflowExecutionRequest {
241
282
RequestId : uuid .New (),
242
- Namespace : namespace ,
283
+ Namespace : ns ,
243
284
WorkflowId : id ,
244
285
WorkflowType : workflowType ,
245
286
TaskQueue : taskQueue ,
@@ -259,7 +300,7 @@ func (s *AdvVisCrossDCTestSuite) TestSearchAttributes() {
259
300
startFilter := & filterpb.StartTimeFilter {}
260
301
startFilter .EarliestTime = timestamppb .New (startTime )
261
302
saListRequest := & workflowservice.ListWorkflowExecutionsRequest {
262
- Namespace : namespace ,
303
+ Namespace : ns ,
263
304
PageSize : 5 ,
264
305
Query : fmt .Sprintf (`WorkflowId = "%s" and %s = "%s"` , id , s .testSearchAttributeKey , s .testSearchAttributeVal ),
265
306
}
@@ -307,7 +348,7 @@ func (s *AdvVisCrossDCTestSuite) TestSearchAttributes() {
307
348
308
349
poller := testcore.TaskPoller {
309
350
Client : client1 ,
310
- Namespace : namespace ,
351
+ Namespace : ns ,
311
352
TaskQueue : taskQueue ,
312
353
Identity : identity ,
313
354
WorkflowTaskHandler : wtHandler ,
@@ -354,7 +395,7 @@ func (s *AdvVisCrossDCTestSuite) TestSearchAttributes() {
354
395
}
355
396
356
397
saListRequest = & workflowservice.ListWorkflowExecutionsRequest {
357
- Namespace : namespace ,
398
+ Namespace : ns ,
358
399
PageSize : int32 (2 ),
359
400
Query : fmt .Sprintf (`WorkflowId = "%s" and %s = "another string"` , id , s .testSearchAttributeKey ),
360
401
}
@@ -365,7 +406,7 @@ func (s *AdvVisCrossDCTestSuite) TestSearchAttributes() {
365
406
testListResult (engine2 , saListRequest )
366
407
367
408
runningListRequest := & workflowservice.ListWorkflowExecutionsRequest {
368
- Namespace : namespace ,
409
+ Namespace : ns ,
369
410
PageSize : int32 (2 ),
370
411
Query : fmt .Sprintf (`WorkflowType = '%s' and ExecutionStatus = 'Running'` , wt ),
371
412
}
@@ -378,7 +419,7 @@ func (s *AdvVisCrossDCTestSuite) TestSearchAttributes() {
378
419
terminateReason := "force terminate to make sure standby process tasks"
379
420
terminateDetails := payloads .EncodeString ("terminate details" )
380
421
_ , err = client1 .TerminateWorkflowExecution (testcore .NewContext (), & workflowservice.TerminateWorkflowExecutionRequest {
381
- Namespace : namespace ,
422
+ Namespace : ns ,
382
423
WorkflowExecution : & commonpb.WorkflowExecution {
383
424
WorkflowId : id ,
384
425
},
@@ -390,7 +431,7 @@ func (s *AdvVisCrossDCTestSuite) TestSearchAttributes() {
390
431
391
432
// check terminate done
392
433
getHistoryReq := & workflowservice.GetWorkflowExecutionHistoryRequest {
393
- Namespace : namespace ,
434
+ Namespace : ns ,
394
435
Execution : & commonpb.WorkflowExecution {
395
436
WorkflowId : id ,
396
437
},
@@ -426,7 +467,7 @@ func (s *AdvVisCrossDCTestSuite) TestSearchAttributes() {
426
467
}, waitTimeInMs * numOfRetry * time .Millisecond , waitTimeInMs * time .Millisecond )
427
468
428
469
terminatedListRequest := & workflowservice.ListWorkflowExecutionsRequest {
429
- Namespace : namespace ,
470
+ Namespace : ns ,
430
471
PageSize : int32 (2 ),
431
472
Query : fmt .Sprintf (`WorkflowType = '%s' and ExecutionStatus = 'Terminated'` , wt ),
432
473
}
0 commit comments