Skip to content

Commit

Permalink
Fix domain last updated time in updateDomain Operation (cadence-workf…
Browse files Browse the repository at this point in the history
…low#4211)

* Fix domain last updated time in updateDomain Operation
  • Loading branch information
yux0 authored May 21, 2021
1 parent 1f14ebf commit f1b6e63
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ func (m *nosqlDomainManager) UpdateDomain(
PreviousFailoverVersion: request.PreviousFailoverVersion,
FailoverEndTime: request.FailoverEndTime,
NotificationVersion: request.NotificationVersion,
LastUpdatedTime: request.LastUpdatedTime,
}

err = m.db.UpdateDomain(ctx, row)
Expand Down
21 changes: 16 additions & 5 deletions common/persistence/persistence-tests/metadataPersistenceV2Test.go
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,7 @@ func (m *MetadataPersistenceSuiteV2) TestConcurrentUpdateDomain() {
resp2.PreviousFailoverVersion,
nil,
notificationVersion,
0,
)
if err3 == nil {
atomic.AddInt32(&successCount, 1)
Expand Down Expand Up @@ -699,6 +700,7 @@ func (m *MetadataPersistenceSuiteV2) TestUpdateDomain() {
failoverVersion := int64(59)
failoverEndTime := time.Now().UnixNano()
isGlobalDomain := true
lastUpdateTime := int64(100)
clusters := []*p.ClusterReplicationConfig{
{
ClusterName: clusterActive,
Expand Down Expand Up @@ -733,7 +735,7 @@ func (m *MetadataPersistenceSuiteV2) TestUpdateDomain() {
isGlobalDomain,
configVersion,
failoverVersion,
0,
lastUpdateTime,
)
m.NoError(err1)
m.Equal(id, resp1.ID)
Expand All @@ -759,6 +761,7 @@ func (m *MetadataPersistenceSuiteV2) TestUpdateDomain() {

updateClusterActive := "other random active cluster name"
updateClusterStandby := "other random standby cluster name"
lastUpdateTime++
updateConfigVersion := int64(12)
updateFailoverVersion := int64(28)
updatePreviousFailoverVersion := int64(20)
Expand Down Expand Up @@ -810,6 +813,7 @@ func (m *MetadataPersistenceSuiteV2) TestUpdateDomain() {
updatePreviousFailoverVersion,
&failoverEndTime,
notificationVersion,
lastUpdateTime,
)
m.NoError(err3)

Expand Down Expand Up @@ -841,6 +845,7 @@ func (m *MetadataPersistenceSuiteV2) TestUpdateDomain() {
m.Equal(updateFailoverNotificationVersion, resp4.FailoverNotificationVersion)
m.Equal(notificationVersion, resp4.NotificationVersion)
m.Equal(&failoverEndTime, resp4.FailoverEndTime)
m.Equal(lastUpdateTime, resp4.LastUpdatedTime)

resp5, err5 := m.GetDomain(ctx, id, "")
m.NoError(err5)
Expand All @@ -865,12 +870,14 @@ func (m *MetadataPersistenceSuiteV2) TestUpdateDomain() {
}
m.Equal(updateConfigVersion, resp5.ConfigVersion)
m.Equal(updateFailoverVersion, resp5.FailoverVersion)
m.Equal(updatePreviousFailoverVersion, resp4.PreviousFailoverVersion)
m.Equal(updatePreviousFailoverVersion, resp5.PreviousFailoverVersion)
m.Equal(updateFailoverNotificationVersion, resp5.FailoverNotificationVersion)
m.Equal(notificationVersion, resp5.NotificationVersion)
m.Equal(&failoverEndTime, resp4.FailoverEndTime)
m.Equal(&failoverEndTime, resp5.FailoverEndTime)
m.Equal(lastUpdateTime, resp5.LastUpdatedTime)

notificationVersion++
lastUpdateTime++
err6 := m.UpdateDomain(
ctx,
&p.DomainInfo{
Expand Down Expand Up @@ -900,6 +907,7 @@ func (m *MetadataPersistenceSuiteV2) TestUpdateDomain() {
updatePreviousFailoverVersion,
nil,
notificationVersion,
lastUpdateTime,
)
m.NoError(err6)

Expand All @@ -923,14 +931,15 @@ func (m *MetadataPersistenceSuiteV2) TestUpdateDomain() {
m.Equal(updateClusterActive, resp6.ReplicationConfig.ActiveClusterName)
m.Equal(len(updateClusters), len(resp6.ReplicationConfig.Clusters))
for index := range clusters {
m.Equal(updateClusters[index], resp4.ReplicationConfig.Clusters[index])
m.Equal(updateClusters[index], resp6.ReplicationConfig.Clusters[index])
}
m.Equal(updateConfigVersion, resp6.ConfigVersion)
m.Equal(updateFailoverVersion, resp6.FailoverVersion)
m.Equal(updatePreviousFailoverVersion, resp4.PreviousFailoverVersion)
m.Equal(updatePreviousFailoverVersion, resp6.PreviousFailoverVersion)
m.Equal(updateFailoverNotificationVersion, resp6.FailoverNotificationVersion)
m.Equal(notificationVersion, resp6.NotificationVersion)
m.Nil(resp6.FailoverEndTime)
m.Equal(lastUpdateTime, resp6.LastUpdatedTime)
}

// TestDeleteDomain test
Expand Down Expand Up @@ -1241,6 +1250,7 @@ func (m *MetadataPersistenceSuiteV2) UpdateDomain(
PreviousFailoverVersion int64,
failoverEndTime *int64,
notificationVersion int64,
lastUpdateTime int64,
) error {

return m.MetadataManager.UpdateDomain(ctx, &p.UpdateDomainRequest{
Expand All @@ -1253,6 +1263,7 @@ func (m *MetadataPersistenceSuiteV2) UpdateDomain(
FailoverNotificationVersion: failoverNotificationVersion,
PreviousFailoverVersion: PreviousFailoverVersion,
NotificationVersion: notificationVersion,
LastUpdatedTime: lastUpdateTime,
})
}

Expand Down

0 comments on commit f1b6e63

Please sign in to comment.