Skip to content

Commit

Permalink
Update failover version for namespace promote (#2332)
Browse files Browse the repository at this point in the history
* Update failover version for namespace promote
  • Loading branch information
yiminc authored Dec 29, 2021
1 parent 26278fd commit e9a1cc9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion common/namespace/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ func (d *HandlerImpl) UpdateNamespace(
if configurationChanged {
configVersion++
}
if activeClusterChanged && isGlobalNamespace {
if (needsNamespacePromotion || activeClusterChanged) && isGlobalNamespace {
failoverVersion = d.clusterMetadata.GetNextFailoverVersion(
replicationConfig.ActiveClusterName,
failoverVersion,
Expand Down
28 changes: 28 additions & 0 deletions common/namespace/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,34 @@ func (s *namespaceHandlerCommonSuite) TestUpdateNamespace_InvalidRetentionPeriod
}
}

func (s *namespaceHandlerCommonSuite) TestUpdateNamespace_PromoteLocalNamespace() {
namespace := "local-ns-to-be-promoted"
registerRequest := &workflowservice.RegisterNamespaceRequest{
Namespace: namespace,
Description: namespace,
WorkflowExecutionRetentionPeriod: timestamp.DurationPtr(24 * time.Hour),
IsGlobalNamespace: false,
}
registerResp, err := s.handler.RegisterNamespace(context.Background(), registerRequest)
s.NoError(err)
s.Equal(&workflowservice.RegisterNamespaceResponse{}, registerResp)

updateRequest := &workflowservice.UpdateNamespaceRequest{
Namespace: namespace,
PromoteNamespace: true,
}
s.mockProducer.EXPECT().Publish(gomock.Any())
_, err = s.handler.UpdateNamespace(context.Background(), updateRequest)
s.NoError(err)

descResp, err := s.handler.DescribeNamespace(context.Background(), &workflowservice.DescribeNamespaceRequest{
Namespace: namespace,
})
s.NoError(err)
s.True(descResp.IsGlobalNamespace)
s.Equal(cluster.TestCurrentClusterInitialFailoverVersion, descResp.FailoverVersion)
}

func (s *namespaceHandlerCommonSuite) getRandomNamespace() string {
return "namespace" + uuid.New()
}

0 comments on commit e9a1cc9

Please sign in to comment.