From 39d41872c33e09a0acb72f8653554801d7094409 Mon Sep 17 00:00:00 2001 From: "alex.stanfield" <13949480+chaptersix@users.noreply.github.com> Date: Wed, 25 Mar 2026 18:52:49 -0500 Subject: [PATCH 1/2] refactor: migrate workflow_memo_test.go to TestEnv Replace legacy FunctionalTestBase + testify suite pattern with testcore.NewEnv(t) following the established migration pattern. - Remove WorkflowMemoTestSuite struct and suite.Run - Convert test methods to standalone functions with t.Run subtests - Replace old TaskPoller struct with s.TaskPoller().PollAndHandleWorkflowTask - Update handler signature to return RespondWorkflowTaskCompletedRequest - Remove debug Logger.Info calls and unused imports --- tests/workflow_memo_test.go | 62 ++++++++++++++----------------------- 1 file changed, 24 insertions(+), 38 deletions(-) diff --git a/tests/workflow_memo_test.go b/tests/workflow_memo_test.go index f4bcd111ea..01c54c113c 100644 --- a/tests/workflow_memo_test.go +++ b/tests/workflow_memo_test.go @@ -5,7 +5,6 @@ import ( "time" "github.com/google/uuid" - "github.com/stretchr/testify/suite" commandpb "go.temporal.io/api/command/v1" commonpb "go.temporal.io/api/common/v1" enumspb "go.temporal.io/api/enums/v1" @@ -13,7 +12,6 @@ import ( taskqueuepb "go.temporal.io/api/taskqueue/v1" workflowpb "go.temporal.io/api/workflow/v1" "go.temporal.io/api/workflowservice/v1" - "go.temporal.io/server/common/log/tag" "go.temporal.io/server/common/payload" "go.temporal.io/server/common/payloads" "go.temporal.io/server/tests/testcore" @@ -21,21 +19,20 @@ import ( "google.golang.org/protobuf/types/known/timestamppb" ) -type WorkflowMemoTestSuite struct { - testcore.FunctionalTestBase +type RunIdGetter interface { + GetRunId() string } +type startFunc func() (RunIdGetter, error) func TestWorkflowMemoTestSuite(t *testing.T) { t.Parallel() - suite.Run(t, new(WorkflowMemoTestSuite)) + t.Run("TestStartWithMemo", testStartWithMemo) + t.Run("TestSignalWithStartWithMemo", testSignalWithStartWithMemo) } -type RunIdGetter interface { - GetRunId() string -} -type startFunc func() (RunIdGetter, error) +func testStartWithMemo(t *testing.T) { + s := testcore.NewEnv(t) -func (s *WorkflowMemoTestSuite) TestStartWithMemo() { id := "functional-start-with-memo-test" wt := "functional-start-with-memo-test-type" tl := "functional-start-with-memo-test-taskqueue" @@ -63,7 +60,7 @@ func (s *WorkflowMemoTestSuite) TestStartWithMemo() { fn := func() (RunIdGetter, error) { return s.FrontendClient().StartWorkflowExecution(testcore.NewContext(), request) } - s.startWithMemoHelper(fn, id, &taskqueuepb.TaskQueue{Name: tl, Kind: enumspb.TASK_QUEUE_KIND_NORMAL}, memo, ` + startWithMemoHelper(s, fn, id, &taskqueuepb.TaskQueue{Name: tl, Kind: enumspb.TASK_QUEUE_KIND_NORMAL}, memo, ` 1 WorkflowExecutionStarted {"Memo":{"Fields":{"Info":{"Data":"\"memo-value\""}}}} 2 WorkflowTaskScheduled 3 WorkflowTaskStarted @@ -71,7 +68,9 @@ func (s *WorkflowMemoTestSuite) TestStartWithMemo() { 5 WorkflowExecutionCompleted`) } -func (s *WorkflowMemoTestSuite) TestSignalWithStartWithMemo() { +func testSignalWithStartWithMemo(t *testing.T) { + s := testcore.NewEnv(t) + id := "functional-signal-with-start-with-memo-test" wt := "functional-signal-with-start-with-memo-test-type" tl := "functional-signal-with-start-with-memo-test-taskqueue" @@ -103,7 +102,7 @@ func (s *WorkflowMemoTestSuite) TestSignalWithStartWithMemo() { fn := func() (RunIdGetter, error) { return s.FrontendClient().SignalWithStartWorkflowExecution(testcore.NewContext(), request) } - s.startWithMemoHelper(fn, id, &taskqueuepb.TaskQueue{Name: tl, Kind: enumspb.TASK_QUEUE_KIND_NORMAL}, memo, ` + startWithMemoHelper(s, fn, id, &taskqueuepb.TaskQueue{Name: tl, Kind: enumspb.TASK_QUEUE_KIND_NORMAL}, memo, ` 1 WorkflowExecutionStarted {"Memo":{"Fields":{"Info":{"Data":"\"memo-value\""}}}} 2 WorkflowExecutionSignaled 3 WorkflowTaskScheduled @@ -112,33 +111,23 @@ func (s *WorkflowMemoTestSuite) TestSignalWithStartWithMemo() { 6 WorkflowExecutionCompleted`) } -// helper function for TestStartWithMemo and TestSignalWithStartWithMemo to reduce duplicate code -func (s *WorkflowMemoTestSuite) startWithMemoHelper(startFn startFunc, id string, taskQueue *taskqueuepb.TaskQueue, memo *commonpb.Memo, expectedHistory string) { - identity := "worker1" - +// helper function for testStartWithMemo and testSignalWithStartWithMemo to reduce duplicate code +func startWithMemoHelper(s *testcore.TestEnv, startFn startFunc, id string, taskQueue *taskqueuepb.TaskQueue, memo *commonpb.Memo, expectedHistory string) { we, err0 := startFn() s.NoError(err0) - s.Logger.Info("StartWorkflowExecution: response", tag.WorkflowRunID(we.GetRunId())) - - wtHandler := func(task *workflowservice.PollWorkflowTaskQueueResponse) ([]*commandpb.Command, error) { - return []*commandpb.Command{{ - CommandType: enumspb.COMMAND_TYPE_COMPLETE_WORKFLOW_EXECUTION, - Attributes: &commandpb.Command_CompleteWorkflowExecutionCommandAttributes{CompleteWorkflowExecutionCommandAttributes: &commandpb.CompleteWorkflowExecutionCommandAttributes{ - Result: payloads.EncodeString("Done"), + wtHandler := func(task *workflowservice.PollWorkflowTaskQueueResponse) (*workflowservice.RespondWorkflowTaskCompletedRequest, error) { + return &workflowservice.RespondWorkflowTaskCompletedRequest{ + Commands: []*commandpb.Command{{ + CommandType: enumspb.COMMAND_TYPE_COMPLETE_WORKFLOW_EXECUTION, + Attributes: &commandpb.Command_CompleteWorkflowExecutionCommandAttributes{CompleteWorkflowExecutionCommandAttributes: &commandpb.CompleteWorkflowExecutionCommandAttributes{ + Result: payloads.EncodeString("Done"), + }}, }}, - }}, nil + }, nil } - poller := &testcore.TaskPoller{ - Client: s.FrontendClient(), - Namespace: s.Namespace().String(), - TaskQueue: taskQueue, - Identity: identity, - WorkflowTaskHandler: wtHandler, - Logger: s.Logger, - T: s.T(), - } + tv := s.Tv().WithTaskQueue(taskQueue.Name) // verify open visibility var openExecutionInfo *workflowpb.WorkflowExecutionInfo @@ -160,7 +149,6 @@ func (s *WorkflowMemoTestSuite) startWithMemoHelper(startFn startFunc, id string openExecutionInfo = resp.Executions[0] return true } - s.Logger.Info("Open WorkflowExecution is not yet visible") return false }, testcore.WaitForESToSettle, @@ -184,8 +172,7 @@ func (s *WorkflowMemoTestSuite) startWithMemoHelper(startFn startFunc, id string s.ProtoEqual(memo, descResp.WorkflowExecutionInfo.Memo) // make progress of workflow - _, err = poller.PollAndProcessWorkflowTask() - s.Logger.Info("PollAndProcessWorkflowTask", tag.Error(err)) + _, err = s.TaskPoller().PollAndHandleWorkflowTask(tv, wtHandler) s.NoError(err) // verify history @@ -217,7 +204,6 @@ func (s *WorkflowMemoTestSuite) startWithMemoHelper(startFn startFunc, id string closedExecutionInfo = resp.Executions[0] return true } - s.Logger.Info("Closed WorkflowExecution is not yet visible") return false }, testcore.WaitForESToSettle, From d20ba1f60d2593b7025d867b98475b8c3c6b8b52 Mon Sep 17 00:00:00 2001 From: "alex.stanfield" <13949480+chaptersix@users.noreply.github.com> Date: Wed, 25 Mar 2026 18:59:58 -0500 Subject: [PATCH 2/2] fix: rename RunIdGetter to RunIDGetter per Go naming conventions --- tests/workflow_memo_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/workflow_memo_test.go b/tests/workflow_memo_test.go index 01c54c113c..3498bd7fe2 100644 --- a/tests/workflow_memo_test.go +++ b/tests/workflow_memo_test.go @@ -19,10 +19,10 @@ import ( "google.golang.org/protobuf/types/known/timestamppb" ) -type RunIdGetter interface { +type RunIDGetter interface { GetRunId() string } -type startFunc func() (RunIdGetter, error) +type startFunc func() (RunIDGetter, error) func TestWorkflowMemoTestSuite(t *testing.T) { t.Parallel() @@ -57,7 +57,7 @@ func testStartWithMemo(t *testing.T) { Memo: memo, } - fn := func() (RunIdGetter, error) { + fn := func() (RunIDGetter, error) { return s.FrontendClient().StartWorkflowExecution(testcore.NewContext(), request) } startWithMemoHelper(s, fn, id, &taskqueuepb.TaskQueue{Name: tl, Kind: enumspb.TASK_QUEUE_KIND_NORMAL}, memo, ` @@ -99,7 +99,7 @@ func testSignalWithStartWithMemo(t *testing.T) { Memo: memo, } - fn := func() (RunIdGetter, error) { + fn := func() (RunIDGetter, error) { return s.FrontendClient().SignalWithStartWorkflowExecution(testcore.NewContext(), request) } startWithMemoHelper(s, fn, id, &taskqueuepb.TaskQueue{Name: tl, Kind: enumspb.TASK_QUEUE_KIND_NORMAL}, memo, `