Files
tasks/service/worker/migration/catchup_workflow_test.go
zigeHandGitHub 0e742bb64e Abstract Catchup Workflow Parameters for Broader Applicability (#7739)
## What changed?
This PR refactors the WaitCatchup workflow by generalizing its input
parameters. The goal is to make the workflow more flexible and reusable
across different use cases where similar catch-up logic is needed. e.g.
catchup process in passive migration.

## Why?
<img width="825" alt="Screenshot 2025-05-08 at 12 39 23 PM"
src="https://github.com/user-attachments/assets/993156ba-3cd1-48b6-9d72-6005229b98ba"
/>
In the previous setup, we ran catchup on passive replica A after T2 to
ensure that cluster C could catch up to replica B’s (the current active)
last AckID on A, guaranteeing that C wouldn't miss any data present on
A. However, this logic was previously hardcoded to use B the active as
catchup target. This PR generalizes the input, allowing the same logic
to be reused during migration scenarios—enabling the source passive
replica to catch up to the new replica’s ack level when the migration
passive is in progress.


## How did you test it?
- [ ] built
- [ ] run locally and tested manually
- [x] covered by existing tests
- [ ] added new unit test(s)
- [ ] added new functional test(s)

## Potential risks
parameter name change. no potential risk
2025-05-12 16:56:17 -07:00

27 lines
614 B
Go

package migration
import (
"testing"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
"go.temporal.io/sdk/testsuite"
)
func TestCatchupWorkflow(t *testing.T) {
testSuite := &testsuite.WorkflowTestSuite{}
env := testSuite.NewTestWorkflowEnvironment()
var a *activities
env.OnActivity(a.WaitCatchup, mock.Anything, mock.Anything).Return(nil)
env.ExecuteWorkflow(CatchupWorkflow, CatchUpParams{
Namespace: "test-ns",
CatchupCluster: "test-remote",
})
require.True(t, env.IsWorkflowCompleted())
require.NoError(t, env.GetWorkflowError())
env.AssertExpectations(t)
}