Files
tasks/tests/ndc/replication_test.go
Anton RomanovichandGitHub 794754b4d6 Capitalize test suite names (#5192)
## What changed?
Names of all test suites were capitalized.

## Why?
Following up on https://github.com/temporalio/temporal/pull/5118 and
making another step towards exportable functional test suites.

If this PR gets merged, the next (and the final one) PR will move the
test suite implementations from `*_test.go` to `.go` files.

## How did you test it?
Ran tests.

## Potential risks
Merge conflicts in other PRs.

## Is hotfix candidate?
No.
2023-12-05 12:50:10 -06:00

122 lines
3.8 KiB
Go

// The MIT License
//
// Copyright (c) 2020 Temporal Technologies Inc. All rights reserved.
//
// Copyright (c) 2020 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
package ndc
import (
"math"
"reflect"
"time"
"github.com/pborman/uuid"
historypb "go.temporal.io/api/history/v1"
"go.temporal.io/server/common"
"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"
)
func (s *NDCFunctionalTestSuite) TestReplicationMessageDLQ() {
s.T().SkipNow()
var shardID int32 = 1
workflowID := "replication-message-dlq-test" + uuid.New()
runID := uuid.New()
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.GetExecutionManager()
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,
ReaderID: common.DefaultQueueReaderID,
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(tests.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")
}