Files
tasks/tests/ndc/replication_test.go
Roey BermanandGitHub 243effc6e1 Forbid the use of pborman/uuid and remove uses (#8541)
## What

Used the `depguard` linter to prevent importing the package and modified
all uses of it.

Also fixed a bug in the membership code where we were not updating the
next page token:

https://github.com/temporalio/temporal/pull/8541/files#diff-985dd64ffa4c6bfe0248b982dc47439b725862baa3e1f2c559b7ff522bf21969R350


## Why?

From the package README in GitHub:

> This package now leverages the github.com/google/uuid package (which
is based off an earlier version of this package).

Also, there's no point in having two uuid implementations in the
codebase.

## Test

Added the invalid import and confirmed it works:

```
../service/frontend/admin_handler_test.go:13:2: import 'github.com/pborman/uuid' is not allowed from list 'main': Importing github.com/pborman/uuid is disallowed; use github.com/google/uuid instead (depguard)
        _ "github.com/pborman/uuid"

```
2025-11-26 01:33:02 +00:00

95 lines
2.6 KiB
Go

package ndc
import (
"math"
"reflect"
"time"
"github.com/google/uuid"
historypb "go.temporal.io/api/history/v1"
"go.temporal.io/server/common/persistence"
test "go.temporal.io/server/common/testing"
"go.temporal.io/server/service/history/tasks"
"go.temporal.io/server/tests/testcore"
)
func (s *NDCFunctionalTestSuite) TestReplicationMessageDLQ() {
s.T().SkipNow()
var shardID int32 = 1
workflowID := "replication-message-dlq-test" + uuid.NewString()
runID := uuid.NewString()
workflowType := "event-generator-workflow-type"
taskqueue := "event-generator-taskQueue"
var historyBatch []*historypb.History
s.generator = test.InitializeHistoryEventGenerator(s.namespace, s.namespaceID, 1)
events := s.generator.GetNextVertices()
historyEvents := &historypb.History{}
for _, event := range events {
historyEvents.Events = append(historyEvents.Events, event.GetData().(*historypb.HistoryEvent))
}
historyBatch = append(historyBatch, historyEvents)
versionHistory := s.eventBatchesToVersionHistory(nil, historyBatch)
s.NotNil(historyBatch)
historyBatch[0].Events[1].Version = 2
s.applyEventsThroughFetcher(
workflowID,
runID,
workflowType,
taskqueue,
versionHistory,
historyBatch,
)
executionManager := s.cluster.ExecutionManager()
expectedDLQMsgs := map[int64]bool{}
for _, batch := range historyBatch {
firstEventID := batch.Events[0].GetEventId()
expectedDLQMsgs[firstEventID] = true
}
// Applying replication messages through fetcher is Async.
// So we need to retry a couple of times.
Loop:
for i := 0; i < 60; i++ {
time.Sleep(time.Second)
actualDLQMsgs := map[int64]bool{}
request := &persistence.GetReplicationTasksFromDLQRequest{
GetHistoryTasksRequest: persistence.GetHistoryTasksRequest{
ShardID: shardID,
TaskCategory: tasks.CategoryReplication,
InclusiveMinTaskKey: tasks.NewImmediateKey(0),
ExclusiveMaxTaskKey: tasks.NewImmediateKey(math.MaxInt64),
BatchSize: math.MaxInt64,
NextPageToken: nil,
},
SourceClusterName: "standby",
}
var token []byte
for doPaging := true; doPaging; doPaging = len(token) > 0 {
request.NextPageToken = token
response, err := executionManager.GetReplicationTasksFromDLQ(testcore.NewContext(), request)
if err != nil {
continue Loop
}
token = response.NextPageToken
for _, task := range response.Tasks {
firstEventID := task.(*tasks.HistoryReplicationTask).FirstEventID
actualDLQMsgs[firstEventID] = true
}
}
if reflect.DeepEqual(expectedDLQMsgs, actualDLQMsgs) {
return
}
}
s.Fail("Failed to get messages from DLQ")
}