@@ -16,13 +16,15 @@ import (
1616 "go.temporal.io/api/workflowservice/v1"
1717 sdkclient "go.temporal.io/sdk/client"
1818 "go.temporal.io/server/api/adminservice/v1"
19+ deploymentspb "go.temporal.io/server/api/deployment/v1"
1920 enumsspb "go.temporal.io/server/api/enums/v1"
2021 "go.temporal.io/server/api/matchingservice/v1"
2122 persistencespb "go.temporal.io/server/api/persistence/v1"
2223 "go.temporal.io/server/common"
2324 "go.temporal.io/server/common/clock/hybrid_logical_clock"
2425 "go.temporal.io/server/common/dynamicconfig"
2526 "go.temporal.io/server/common/primitives"
27+ "go.temporal.io/server/common/primitives/timestamp"
2628 "go.temporal.io/server/common/worker_versioning"
2729 "go.temporal.io/server/service/worker/migration"
2830 "go.temporal.io/server/service/worker/scanner/build_ids"
@@ -250,6 +252,97 @@ func (s *UserDataReplicationTestSuite) TestUserDataIsReplicatedFromActiveToPassi
250252 }, replicationWaitTime , replicationCheckInterval )
251253}
252254
255+ func (s * UserDataReplicationTestSuite ) TestUserDataIsReplicatedFromActiveToPassiveV3 () {
256+ namespace := s .T ().Name () + "-" + common .GenerateRandomString (5 )
257+ taskQueue := "versioned"
258+ ctx := testcore .NewContext ()
259+ activeFrontendClient := s .clusters [0 ].FrontendClient ()
260+ activeMatchingClient := s .clusters [0 ].MatchingClient ()
261+ standbyMatchingClient := s .clusters [1 ].MatchingClient ()
262+ regReq := & workflowservice.RegisterNamespaceRequest {
263+ Namespace : namespace ,
264+ IsGlobalNamespace : true ,
265+ Clusters : s .clusterReplicationConfig (),
266+ ActiveClusterName : s .clusters [0 ].ClusterName (),
267+ WorkflowExecutionRetentionPeriod : durationpb .New (7 * time .Hour * 24 ),
268+ }
269+ _ , err := activeFrontendClient .RegisterNamespace (ctx , regReq )
270+ s .NoError (err )
271+
272+ description , err := activeFrontendClient .DescribeNamespace (ctx , & workflowservice.DescribeNamespaceRequest {Namespace : namespace })
273+ s .Require ().NoError (err )
274+
275+ expectedVersionData := & deploymentspb.DeploymentVersionData {
276+ Version : & deploymentspb.WorkerDeploymentVersion {
277+ BuildId : "v1" ,
278+ DeploymentName : "d1" ,
279+ },
280+ RampingSinceTime : timestamp .TimePtr (time .Now ()),
281+ RampPercentage : 10 ,
282+ }
283+
284+ _ , err = activeMatchingClient .SyncDeploymentUserData (ctx , & matchingservice.SyncDeploymentUserDataRequest {
285+ NamespaceId : description .GetNamespaceInfo ().GetId (),
286+ TaskQueue : taskQueue ,
287+ TaskQueueTypes : []enumspb.TaskQueueType {enumspb .TASK_QUEUE_TYPE_WORKFLOW , enumspb .TASK_QUEUE_TYPE_ACTIVITY , enumspb .TASK_QUEUE_TYPE_NEXUS },
288+ Operation : & matchingservice.SyncDeploymentUserDataRequest_UpdateVersionData {
289+ UpdateVersionData : expectedVersionData ,
290+ },
291+ })
292+ s .NoError (err )
293+
294+ s .EventuallyWithT (func (t * assert.CollectT ) {
295+ // Call matching directly in case frontend is configured to redirect API calls to the active cluster
296+ response , err := standbyMatchingClient .GetTaskQueueUserData (ctx , & matchingservice.GetTaskQueueUserDataRequest {
297+ NamespaceId : description .GetNamespaceInfo ().Id ,
298+ TaskQueue : taskQueue ,
299+ TaskQueueType : enumspb .TASK_QUEUE_TYPE_WORKFLOW ,
300+ })
301+ a := assert .New (t )
302+ a .NoError (err )
303+ if perType := response .GetUserData ().GetData ().GetPerType (); a .NotNil (perType ) {
304+ for tqType := 1 ; tqType <= 3 ; tqType ++ {
305+ data := perType [int32 (tqType )].GetDeploymentData ()
306+ if a .Equal (1 , len (data .GetVersions ())) {
307+ a .True (data .GetVersions ()[0 ].Equal (expectedVersionData ))
308+ }
309+ }
310+ }
311+ }, replicationWaitTime , replicationCheckInterval )
312+
313+ // make another change to test that merging works
314+
315+ expectedVersionData .RampPercentage = 20
316+ _ , err = activeMatchingClient .SyncDeploymentUserData (ctx , & matchingservice.SyncDeploymentUserDataRequest {
317+ NamespaceId : description .GetNamespaceInfo ().GetId (),
318+ TaskQueue : taskQueue ,
319+ TaskQueueTypes : []enumspb.TaskQueueType {enumspb .TASK_QUEUE_TYPE_WORKFLOW , enumspb .TASK_QUEUE_TYPE_ACTIVITY , enumspb .TASK_QUEUE_TYPE_NEXUS },
320+ Operation : & matchingservice.SyncDeploymentUserDataRequest_UpdateVersionData {
321+ UpdateVersionData : expectedVersionData ,
322+ },
323+ })
324+ s .NoError (err )
325+
326+ s .EventuallyWithT (func (t * assert.CollectT ) {
327+ // Call matching directly in case frontend is configured to redirect API calls to the active cluster
328+ response , err := standbyMatchingClient .GetTaskQueueUserData (ctx , & matchingservice.GetTaskQueueUserDataRequest {
329+ NamespaceId : description .GetNamespaceInfo ().Id ,
330+ TaskQueue : taskQueue ,
331+ TaskQueueType : enumspb .TASK_QUEUE_TYPE_WORKFLOW ,
332+ })
333+ a := assert .New (t )
334+ a .NoError (err )
335+ if perType := response .GetUserData ().GetData ().GetPerType (); a .NotNil (perType ) {
336+ for tqType := 1 ; tqType <= 3 ; tqType ++ {
337+ data := perType [int32 (tqType )].GetDeploymentData ()
338+ if a .Equal (1 , len (data .GetVersions ())) {
339+ a .True (data .GetVersions ()[0 ].Equal (expectedVersionData ))
340+ }
341+ }
342+ }
343+ }, replicationWaitTime , replicationCheckInterval )
344+ }
345+
253346func (s * UserDataReplicationTestSuite ) TestUserDataIsReplicatedFromPassiveToActive () {
254347 namespace := s .createGlobalNamespace ()
255348 taskQueue := "versioned"
0 commit comments