Skip to content

Commit

Permalink
Drop pointer for cluster name fields (#3927)
Browse files Browse the repository at this point in the history
  • Loading branch information
vytautas-karpavicius authored Jan 28, 2021
1 parent 6fa4cb5 commit 79b8acf
Show file tree
Hide file tree
Showing 23 changed files with 153 additions and 154 deletions.
2 changes: 1 addition & 1 deletion common/domain/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ func (d *handlerImpl) createResponse(
clusters := []*types.ClusterReplicationConfiguration{}
for _, cluster := range replicationConfig.Clusters {
clusters = append(clusters, &types.ClusterReplicationConfiguration{
ClusterName: common.StringPtr(cluster.ClusterName),
ClusterName: cluster.ClusterName,
})
}

Expand Down
24 changes: 12 additions & 12 deletions common/domain/handler_GlobalDomainDisabled_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ func (s *domainHandlerGlobalDomainDisabledSuite) TestRegisterGetDomain_InvalidGl
emitMetric := true
activeClusterName := cluster.TestCurrentClusterName
clusters := []*types.ClusterReplicationConfiguration{
&types.ClusterReplicationConfiguration{
ClusterName: common.StringPtr(activeClusterName),
{
ClusterName: activeClusterName,
},
}
data := map[string]string{"some random key": "some random value"}
Expand Down Expand Up @@ -158,8 +158,8 @@ func (s *domainHandlerGlobalDomainDisabledSuite) TestRegisterGetDomain_InvalidCl
emitMetric := true
activeClusterName := cluster.TestAlternativeClusterName
clusters := []*types.ClusterReplicationConfiguration{
&types.ClusterReplicationConfiguration{
ClusterName: common.StringPtr(activeClusterName),
{
ClusterName: activeClusterName,
},
}
data := map[string]string{"some random key": "some random value"}
Expand All @@ -184,7 +184,7 @@ func (s *domainHandlerGlobalDomainDisabledSuite) TestRegisterGetDomain_AllDefaul
var clusters []*types.ClusterReplicationConfiguration
for _, replicationConfig := range persistence.GetOrUseDefaultClusters(s.ClusterMetadata.GetCurrentClusterName(), nil) {
clusters = append(clusters, &types.ClusterReplicationConfiguration{
ClusterName: common.StringPtr(replicationConfig.ClusterName),
ClusterName: replicationConfig.ClusterName,
})
}

Expand Down Expand Up @@ -235,8 +235,8 @@ func (s *domainHandlerGlobalDomainDisabledSuite) TestRegisterGetDomain_NoDefault
emitMetric := true
activeClusterName := cluster.TestCurrentClusterName
clusters := []*types.ClusterReplicationConfiguration{
&types.ClusterReplicationConfiguration{
ClusterName: common.StringPtr(activeClusterName),
{
ClusterName: activeClusterName,
},
}
data := map[string]string{"some random key": "some random value"}
Expand All @@ -245,7 +245,7 @@ func (s *domainHandlerGlobalDomainDisabledSuite) TestRegisterGetDomain_NoDefault
var expectedClusters []*types.ClusterReplicationConfiguration
for _, replicationConfig := range persistence.GetOrUseDefaultClusters(s.ClusterMetadata.GetCurrentClusterName(), nil) {
expectedClusters = append(expectedClusters, &types.ClusterReplicationConfiguration{
ClusterName: common.StringPtr(replicationConfig.ClusterName),
ClusterName: replicationConfig.ClusterName,
})
}

Expand Down Expand Up @@ -304,7 +304,7 @@ func (s *domainHandlerGlobalDomainDisabledSuite) TestUpdateGetDomain_NoAttrSet()
var clusters []*types.ClusterReplicationConfiguration
for _, replicationConfig := range persistence.GetOrUseDefaultClusters(s.ClusterMetadata.GetCurrentClusterName(), nil) {
clusters = append(clusters, &types.ClusterReplicationConfiguration{
ClusterName: common.StringPtr(replicationConfig.ClusterName),
ClusterName: replicationConfig.ClusterName,
})
}

Expand Down Expand Up @@ -388,16 +388,16 @@ func (s *domainHandlerGlobalDomainDisabledSuite) TestUpdateGetDomain_AllAttrSet(
emitMetric := true
activeClusterName := cluster.TestCurrentClusterName
clusters := []*types.ClusterReplicationConfiguration{
&types.ClusterReplicationConfiguration{
ClusterName: common.StringPtr(activeClusterName),
{
ClusterName: activeClusterName,
},
}
data := map[string]string{"some random key": "some random value"}

var expectedClusters []*types.ClusterReplicationConfiguration
for _, replicationConfig := range persistence.GetOrUseDefaultClusters(s.ClusterMetadata.GetCurrentClusterName(), nil) {
expectedClusters = append(expectedClusters, &types.ClusterReplicationConfiguration{
ClusterName: common.StringPtr(replicationConfig.ClusterName),
ClusterName: replicationConfig.ClusterName,
})
}

Expand Down
28 changes: 14 additions & 14 deletions common/domain/handler_GlobalDomainEnabled_MasterCluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ func (s *domainHandlerGlobalDomainEnabledMasterClusterSuite) TestRegisterGetDoma
emitMetric := true
activeClusterName := cluster.TestAlternativeClusterName
clusters := []*types.ClusterReplicationConfiguration{
&types.ClusterReplicationConfiguration{
ClusterName: common.StringPtr(activeClusterName),
{
ClusterName: activeClusterName,
},
}
data := map[string]string{"some random key": "some random value"}
Expand All @@ -156,7 +156,7 @@ func (s *domainHandlerGlobalDomainEnabledMasterClusterSuite) TestRegisterGetDoma
var clusters []*types.ClusterReplicationConfiguration
for _, replicationConfig := range persistence.GetOrUseDefaultClusters(s.ClusterMetadata.GetCurrentClusterName(), nil) {
clusters = append(clusters, &types.ClusterReplicationConfiguration{
ClusterName: common.StringPtr(replicationConfig.ClusterName),
ClusterName: replicationConfig.ClusterName,
})
}

Expand Down Expand Up @@ -208,8 +208,8 @@ func (s *domainHandlerGlobalDomainEnabledMasterClusterSuite) TestRegisterGetDoma
emitMetric := true
activeClusterName := cluster.TestCurrentClusterName
clusters := []*types.ClusterReplicationConfiguration{
&types.ClusterReplicationConfiguration{
ClusterName: common.StringPtr(activeClusterName),
{
ClusterName: activeClusterName,
},
}
data := map[string]string{"some random key": "some random value"}
Expand All @@ -218,7 +218,7 @@ func (s *domainHandlerGlobalDomainEnabledMasterClusterSuite) TestRegisterGetDoma
var expectedClusters []*types.ClusterReplicationConfiguration
for _, replicationConfig := range persistence.GetOrUseDefaultClusters(s.ClusterMetadata.GetCurrentClusterName(), nil) {
expectedClusters = append(expectedClusters, &types.ClusterReplicationConfiguration{
ClusterName: common.StringPtr(replicationConfig.ClusterName),
ClusterName: replicationConfig.ClusterName,
})
}

Expand Down Expand Up @@ -277,7 +277,7 @@ func (s *domainHandlerGlobalDomainEnabledMasterClusterSuite) TestUpdateGetDomain
var clusters []*types.ClusterReplicationConfiguration
for _, replicationConfig := range persistence.GetOrUseDefaultClusters(s.ClusterMetadata.GetCurrentClusterName(), nil) {
clusters = append(clusters, &types.ClusterReplicationConfiguration{
ClusterName: common.StringPtr(replicationConfig.ClusterName),
ClusterName: replicationConfig.ClusterName,
})
}
isGlobalDomain := false
Expand Down Expand Up @@ -367,7 +367,7 @@ func (s *domainHandlerGlobalDomainEnabledMasterClusterSuite) TestUpdateGetDomain
var clusters []*types.ClusterReplicationConfiguration
for _, replicationConfig := range persistence.GetOrUseDefaultClusters(s.ClusterMetadata.GetCurrentClusterName(), nil) {
clusters = append(clusters, &types.ClusterReplicationConfiguration{
ClusterName: common.StringPtr(replicationConfig.ClusterName),
ClusterName: replicationConfig.ClusterName,
})
}

Expand Down Expand Up @@ -449,7 +449,7 @@ func (s *domainHandlerGlobalDomainEnabledMasterClusterSuite) TestRegisterGetDoma
var clusters []*types.ClusterReplicationConfiguration
for _, replicationConfig := range persistence.GetOrUseDefaultClusters(s.ClusterMetadata.GetCurrentClusterName(), nil) {
clusters = append(clusters, &types.ClusterReplicationConfiguration{
ClusterName: common.StringPtr(replicationConfig.ClusterName),
ClusterName: replicationConfig.ClusterName,
})
}

Expand Down Expand Up @@ -508,7 +508,7 @@ func (s *domainHandlerGlobalDomainEnabledMasterClusterSuite) TestRegisterGetDoma
activeClusterName = clusterName
}
clusters = append(clusters, &types.ClusterReplicationConfiguration{
ClusterName: common.StringPtr(clusterName),
ClusterName: clusterName,
})
}
s.True(len(activeClusterName) > 0)
Expand Down Expand Up @@ -577,7 +577,7 @@ func (s *domainHandlerGlobalDomainEnabledMasterClusterSuite) TestUpdateGetDomain
activeClusterName = clusterName
}
clusters = append(clusters, &types.ClusterReplicationConfiguration{
ClusterName: common.StringPtr(clusterName),
ClusterName: clusterName,
})
}
s.True(len(activeClusterName) > 0)
Expand Down Expand Up @@ -662,7 +662,7 @@ func (s *domainHandlerGlobalDomainEnabledMasterClusterSuite) TestUpdateGetDomain
activeClusterName = clusterName
}
clusters = append(clusters, &types.ClusterReplicationConfiguration{
ClusterName: common.StringPtr(clusterName),
ClusterName: clusterName,
})
}
s.True(len(activeClusterName) > 0)
Expand Down Expand Up @@ -773,7 +773,7 @@ func (s *domainHandlerGlobalDomainEnabledMasterClusterSuite) TestUpdateGetDomain
prevActiveClusterName = clusterName
}
clusters = append(clusters, &types.ClusterReplicationConfiguration{
ClusterName: common.StringPtr(clusterName),
ClusterName: clusterName,
})
}
s.True(len(prevActiveClusterName) > 0)
Expand Down Expand Up @@ -877,7 +877,7 @@ func (s *domainHandlerGlobalDomainEnabledMasterClusterSuite) TestUpdateDomain_Co
var clusters []*types.ClusterReplicationConfiguration
for _, replicationConfig := range persistence.GetOrUseDefaultClusters(s.ClusterMetadata.GetCurrentClusterName(), nil) {
clusters = append(clusters, &types.ClusterReplicationConfiguration{
ClusterName: common.StringPtr(replicationConfig.ClusterName),
ClusterName: replicationConfig.ClusterName,
})
}

Expand Down
20 changes: 10 additions & 10 deletions common/domain/handler_GlobalDomainEnabled_NotMasterCluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func (s *domainHandlerGlobalDomainEnabledNotMasterClusterSuite) TestRegisterGetD
var clusters []*types.ClusterReplicationConfiguration
for _, replicationConfig := range persistence.GetOrUseDefaultClusters(s.ClusterMetadata.GetCurrentClusterName(), nil) {
clusters = append(clusters, &types.ClusterReplicationConfiguration{
ClusterName: common.StringPtr(replicationConfig.ClusterName),
ClusterName: replicationConfig.ClusterName,
})
}

Expand Down Expand Up @@ -179,8 +179,8 @@ func (s *domainHandlerGlobalDomainEnabledNotMasterClusterSuite) TestRegisterGetD
emitMetric := true
activeClusterName := cluster.TestCurrentClusterName
clusters := []*types.ClusterReplicationConfiguration{
&types.ClusterReplicationConfiguration{
ClusterName: common.StringPtr(activeClusterName),
{
ClusterName: activeClusterName,
},
}
data := map[string]string{"some random key": "some random value"}
Expand All @@ -189,7 +189,7 @@ func (s *domainHandlerGlobalDomainEnabledNotMasterClusterSuite) TestRegisterGetD
var expectedClusters []*types.ClusterReplicationConfiguration
for _, replicationConfig := range persistence.GetOrUseDefaultClusters(s.ClusterMetadata.GetCurrentClusterName(), nil) {
expectedClusters = append(expectedClusters, &types.ClusterReplicationConfiguration{
ClusterName: common.StringPtr(replicationConfig.ClusterName),
ClusterName: replicationConfig.ClusterName,
})
}

Expand Down Expand Up @@ -248,7 +248,7 @@ func (s *domainHandlerGlobalDomainEnabledNotMasterClusterSuite) TestUpdateGetDom
var clusters []*types.ClusterReplicationConfiguration
for _, replicationConfig := range persistence.GetOrUseDefaultClusters(s.ClusterMetadata.GetCurrentClusterName(), nil) {
clusters = append(clusters, &types.ClusterReplicationConfiguration{
ClusterName: common.StringPtr(replicationConfig.ClusterName),
ClusterName: replicationConfig.ClusterName,
})
}
isGlobalDomain := false
Expand Down Expand Up @@ -338,7 +338,7 @@ func (s *domainHandlerGlobalDomainEnabledNotMasterClusterSuite) TestUpdateGetDom
var clusters []*types.ClusterReplicationConfiguration
for _, replicationConfig := range persistence.GetOrUseDefaultClusters(s.ClusterMetadata.GetCurrentClusterName(), nil) {
clusters = append(clusters, &types.ClusterReplicationConfiguration{
ClusterName: common.StringPtr(replicationConfig.ClusterName),
ClusterName: replicationConfig.ClusterName,
})
}

Expand Down Expand Up @@ -420,7 +420,7 @@ func (s *domainHandlerGlobalDomainEnabledNotMasterClusterSuite) TestRegisterGetD
var clusters []*types.ClusterReplicationConfiguration
for _, replicationConfig := range persistence.GetOrUseDefaultClusters(s.ClusterMetadata.GetCurrentClusterName(), nil) {
clusters = append(clusters, &types.ClusterReplicationConfiguration{
ClusterName: common.StringPtr(replicationConfig.ClusterName),
ClusterName: replicationConfig.ClusterName,
})
}
s.Equal(1, len(clusters))
Expand Down Expand Up @@ -451,7 +451,7 @@ func (s *domainHandlerGlobalDomainEnabledNotMasterClusterSuite) TestRegisterGetD
activeClusterName = clusterName
}
clusters = append(clusters, &types.ClusterReplicationConfiguration{
ClusterName: common.StringPtr(clusterName),
ClusterName: clusterName,
})
}
s.True(len(activeClusterName) > 0)
Expand Down Expand Up @@ -548,7 +548,7 @@ func (s *domainHandlerGlobalDomainEnabledNotMasterClusterSuite) TestUpdateGetDom
activeClusterName = clusterName
}
clusters = append(clusters, &types.ClusterReplicationConfiguration{
ClusterName: common.StringPtr(clusterName),
ClusterName: clusterName,
})
clustersDB = append(clustersDB, &persistence.ClusterReplicationConfig{
ClusterName: clusterName,
Expand Down Expand Up @@ -627,7 +627,7 @@ func (s *domainHandlerGlobalDomainEnabledNotMasterClusterSuite) TestUpdateGetDom
prevActiveClusterName = clusterName
}
clusters = append(clusters, &types.ClusterReplicationConfiguration{
ClusterName: common.StringPtr(clusterName),
ClusterName: clusterName,
})
clustersDB = append(clustersDB, &persistence.ClusterReplicationConfig{
ClusterName: clusterName,
Expand Down
28 changes: 14 additions & 14 deletions common/domain/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ func (s *domainHandlerCommonSuite) TestListDomain() {
var cluster1 []*types.ClusterReplicationConfiguration
for _, replicationConfig := range persistence.GetOrUseDefaultClusters(s.ClusterMetadata.GetCurrentClusterName(), nil) {
cluster1 = append(cluster1, &types.ClusterReplicationConfiguration{
ClusterName: common.StringPtr(replicationConfig.ClusterName),
ClusterName: replicationConfig.ClusterName,
})
}
err := s.handler.RegisterDomain(context.Background(), &types.RegisterDomainRequest{
Expand Down Expand Up @@ -300,7 +300,7 @@ func (s *domainHandlerCommonSuite) TestListDomain() {
activeClusterName2 = clusterName
}
cluster2 = append(cluster2, &types.ClusterReplicationConfiguration{
ClusterName: common.StringPtr(clusterName),
ClusterName: clusterName,
})
}
s.mockProducer.On("Publish", mock.Anything, mock.Anything).Return(nil).Once()
Expand Down Expand Up @@ -432,10 +432,10 @@ func (s *domainHandlerCommonSuite) TestUpdateDomain_GracefulFailover_Success() {
ActiveClusterName: common.StringPtr("standby"),
Clusters: []*types.ClusterReplicationConfiguration{
{
common.StringPtr(s.ClusterMetadata.GetCurrentClusterName()),
s.ClusterMetadata.GetCurrentClusterName(),
},
{
common.StringPtr("standby"),
"standby",
},
},
}
Expand Down Expand Up @@ -476,10 +476,10 @@ func (s *domainHandlerCommonSuite) TestUpdateDomain_GracefulFailover_NotCurrentA
ActiveClusterName: common.StringPtr("active"),
Clusters: []*types.ClusterReplicationConfiguration{
{
common.StringPtr("active"),
"active",
},
{
common.StringPtr("standby"),
"standby",
},
},
}
Expand Down Expand Up @@ -508,10 +508,10 @@ func (s *domainHandlerCommonSuite) TestUpdateDomain_GracefulFailover_OngoingFail
ActiveClusterName: common.StringPtr("standby"),
Clusters: []*types.ClusterReplicationConfiguration{
{
common.StringPtr(s.ClusterMetadata.GetCurrentClusterName()),
s.ClusterMetadata.GetCurrentClusterName(),
},
{
common.StringPtr("standby"),
"standby",
},
},
}
Expand Down Expand Up @@ -542,10 +542,10 @@ func (s *domainHandlerCommonSuite) TestUpdateDomain_GracefulFailover_NoUpdateAct
ActiveClusterName: common.StringPtr("standby"),
Clusters: []*types.ClusterReplicationConfiguration{
{
common.StringPtr(s.ClusterMetadata.GetCurrentClusterName()),
s.ClusterMetadata.GetCurrentClusterName(),
},
{
common.StringPtr("standby"),
"standby",
},
},
}
Expand Down Expand Up @@ -574,10 +574,10 @@ func (s *domainHandlerCommonSuite) TestUpdateDomain_GracefulFailover_After_Force
ActiveClusterName: common.StringPtr("standby"),
Clusters: []*types.ClusterReplicationConfiguration{
{
common.StringPtr(s.ClusterMetadata.GetCurrentClusterName()),
s.ClusterMetadata.GetCurrentClusterName(),
},
{
common.StringPtr("standby"),
"standby",
},
},
}
Expand Down Expand Up @@ -622,10 +622,10 @@ func (s *domainHandlerCommonSuite) TestUpdateDomain_ForceFailover_SameActiveClus
ActiveClusterName: common.StringPtr("standby"),
Clusters: []*types.ClusterReplicationConfiguration{
{
common.StringPtr(s.ClusterMetadata.GetCurrentClusterName()),
s.ClusterMetadata.GetCurrentClusterName(),
},
{
common.StringPtr("standby"),
"standby",
},
},
}
Expand Down
Loading

0 comments on commit 79b8acf

Please sign in to comment.