From 129a61b81920ad2b4dcf20667d012af3cc82cece Mon Sep 17 00:00:00 2001 From: "alex.stanfield" <13949480+chaptersix@users.noreply.github.com> Date: Wed, 25 Mar 2026 19:30:51 -0500 Subject: [PATCH 1/2] refactor: migrate activity_api_batch_reset_test to testcore.NewEnv pattern Replace suite-based test structure with t.Run subtests using testcore.NewEnv, consistent with the ongoing test migration effort. --- tests/activity_api_batch_reset_test.go | 44 +++++++++++++++----------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/tests/activity_api_batch_reset_test.go b/tests/activity_api_batch_reset_test.go index 767f855196..27d94235c7 100644 --- a/tests/activity_api_batch_reset_test.go +++ b/tests/activity_api_batch_reset_test.go @@ -9,7 +9,6 @@ import ( "github.com/google/uuid" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/stretchr/testify/suite" "github.com/temporalio/sqlparser" batchpb "go.temporal.io/api/batch/v1" commonpb "go.temporal.io/api/common/v1" @@ -21,19 +20,18 @@ import ( "google.golang.org/grpc/codes" ) -type ActivityApiBatchResetClientTestSuite struct { - testcore.FunctionalTestBase -} - func TestActivityApiBatchResetClientTestSuite(t *testing.T) { - s := new(ActivityApiBatchResetClientTestSuite) - suite.Run(t, s) + t.Parallel() + t.Run("TestActivityBatchReset_Success", testActivityBatchResetSuccess) + t.Run("TestActivityBatchReset_Success_Protobuf", testActivityBatchResetSuccessProtobuf) + t.Run("TestActivityBatchReset_DontResetAttempts", testActivityBatchResetDontResetAttempts) + t.Run("TestActivityBatchReset_Failed", testActivityBatchResetFailed) } -func (s *ActivityApiBatchResetClientTestSuite) createWorkflow(ctx context.Context, workflowFn WorkflowFunction) sdkclient.WorkflowRun { +func createBatchResetWorkflow(s *testcore.TestEnv, ctx context.Context, workflowFn WorkflowFunction) sdkclient.WorkflowRun { workflowOptions := sdkclient.StartWorkflowOptions{ ID: testcore.RandomizeStr("wf_id-" + s.T().Name()), - TaskQueue: s.TaskQueue(), + TaskQueue: s.WorkerTaskQueue(), } workflowRun, err := s.SdkClient().ExecuteWorkflow(ctx, workflowOptions, workflowFn) s.NoError(err) @@ -42,7 +40,9 @@ func (s *ActivityApiBatchResetClientTestSuite) createWorkflow(ctx context.Contex return workflowRun } -func (s *ActivityApiBatchResetClientTestSuite) TestActivityBatchReset_Success() { +func testActivityBatchResetSuccess(t *testing.T) { + s := testcore.NewEnv(t, testcore.WithSdkWorker()) + ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) defer cancel() @@ -51,8 +51,8 @@ func (s *ActivityApiBatchResetClientTestSuite) TestActivityBatchReset_Success() s.SdkWorker().RegisterWorkflow(internalWorkflow.WorkflowFunc) s.SdkWorker().RegisterActivity(internalWorkflow.ActivityFunc) - workflowRun1 := s.createWorkflow(ctx, internalWorkflow.WorkflowFunc) - workflowRun2 := s.createWorkflow(ctx, internalWorkflow.WorkflowFunc) + workflowRun1 := createBatchResetWorkflow(s, ctx, internalWorkflow.WorkflowFunc) + workflowRun2 := createBatchResetWorkflow(s, ctx, internalWorkflow.WorkflowFunc) // wait for activity to start in both workflows s.EventuallyWithT(func(t *assert.CollectT) { @@ -170,7 +170,9 @@ func (s *ActivityApiBatchResetClientTestSuite) TestActivityBatchReset_Success() s.NoError(err) } -func (s *ActivityApiBatchResetClientTestSuite) TestActivityBatchReset_Success_Protobuf() { +func testActivityBatchResetSuccessProtobuf(t *testing.T) { + s := testcore.NewEnv(t, testcore.WithSdkWorker()) + ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) defer cancel() @@ -179,8 +181,8 @@ func (s *ActivityApiBatchResetClientTestSuite) TestActivityBatchReset_Success_Pr s.SdkWorker().RegisterWorkflow(internalWorkflow.WorkflowFunc) s.SdkWorker().RegisterActivity(internalWorkflow.ActivityFunc) - workflowRun1 := s.createWorkflow(ctx, internalWorkflow.WorkflowFunc) - workflowRun2 := s.createWorkflow(ctx, internalWorkflow.WorkflowFunc) + workflowRun1 := createBatchResetWorkflow(s, ctx, internalWorkflow.WorkflowFunc) + workflowRun2 := createBatchResetWorkflow(s, ctx, internalWorkflow.WorkflowFunc) // wait for activity to start in both workflows s.EventuallyWithT(func(t *assert.CollectT) { @@ -298,7 +300,9 @@ func (s *ActivityApiBatchResetClientTestSuite) TestActivityBatchReset_Success_Pr s.NoError(err) } -func (s *ActivityApiBatchResetClientTestSuite) TestActivityBatchReset_DontResetAttempts() { +func testActivityBatchResetDontResetAttempts(t *testing.T) { + s := testcore.NewEnv(t, testcore.WithSdkWorker()) + ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) defer cancel() @@ -307,8 +311,8 @@ func (s *ActivityApiBatchResetClientTestSuite) TestActivityBatchReset_DontResetA s.SdkWorker().RegisterWorkflow(internalWorkflow.WorkflowFunc) s.SdkWorker().RegisterActivity(internalWorkflow.ActivityFunc) - workflowRun1 := s.createWorkflow(ctx, internalWorkflow.WorkflowFunc) - workflowRun2 := s.createWorkflow(ctx, internalWorkflow.WorkflowFunc) + workflowRun1 := createBatchResetWorkflow(s, ctx, internalWorkflow.WorkflowFunc) + workflowRun2 := createBatchResetWorkflow(s, ctx, internalWorkflow.WorkflowFunc) // wait for activity to start in both workflows s.EventuallyWithT(func(t *assert.CollectT) { @@ -425,7 +429,9 @@ func (s *ActivityApiBatchResetClientTestSuite) TestActivityBatchReset_DontResetA s.NoError(err) } -func (s *ActivityApiBatchResetClientTestSuite) TestActivityBatchReset_Failed() { +func testActivityBatchResetFailed(t *testing.T) { + s := testcore.NewEnv(t, testcore.WithSdkWorker()) + // neither activity type not "match all" is provided _, err := s.SdkClient().WorkflowService().StartBatchOperation(context.Background(), &workflowservice.StartBatchOperationRequest{ Namespace: s.Namespace().String(), From 8b51cbbd2931757ad8544593e4bc33bad64d630f Mon Sep 17 00:00:00 2001 From: "alex.stanfield" <13949480+chaptersix@users.noreply.github.com> Date: Thu, 26 Mar 2026 08:23:11 -0500 Subject: [PATCH 2/2] fix: put context.Context as first parameter in createBatchResetWorkflow --- tests/activity_api_batch_reset_test.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/activity_api_batch_reset_test.go b/tests/activity_api_batch_reset_test.go index 27d94235c7..10a909e5c1 100644 --- a/tests/activity_api_batch_reset_test.go +++ b/tests/activity_api_batch_reset_test.go @@ -28,7 +28,7 @@ func TestActivityApiBatchResetClientTestSuite(t *testing.T) { t.Run("TestActivityBatchReset_Failed", testActivityBatchResetFailed) } -func createBatchResetWorkflow(s *testcore.TestEnv, ctx context.Context, workflowFn WorkflowFunction) sdkclient.WorkflowRun { +func createBatchResetWorkflow(ctx context.Context, s *testcore.TestEnv, workflowFn WorkflowFunction) sdkclient.WorkflowRun { workflowOptions := sdkclient.StartWorkflowOptions{ ID: testcore.RandomizeStr("wf_id-" + s.T().Name()), TaskQueue: s.WorkerTaskQueue(), @@ -51,8 +51,8 @@ func testActivityBatchResetSuccess(t *testing.T) { s.SdkWorker().RegisterWorkflow(internalWorkflow.WorkflowFunc) s.SdkWorker().RegisterActivity(internalWorkflow.ActivityFunc) - workflowRun1 := createBatchResetWorkflow(s, ctx, internalWorkflow.WorkflowFunc) - workflowRun2 := createBatchResetWorkflow(s, ctx, internalWorkflow.WorkflowFunc) + workflowRun1 := createBatchResetWorkflow(ctx, s, internalWorkflow.WorkflowFunc) + workflowRun2 := createBatchResetWorkflow(ctx, s, internalWorkflow.WorkflowFunc) // wait for activity to start in both workflows s.EventuallyWithT(func(t *assert.CollectT) { @@ -181,8 +181,8 @@ func testActivityBatchResetSuccessProtobuf(t *testing.T) { s.SdkWorker().RegisterWorkflow(internalWorkflow.WorkflowFunc) s.SdkWorker().RegisterActivity(internalWorkflow.ActivityFunc) - workflowRun1 := createBatchResetWorkflow(s, ctx, internalWorkflow.WorkflowFunc) - workflowRun2 := createBatchResetWorkflow(s, ctx, internalWorkflow.WorkflowFunc) + workflowRun1 := createBatchResetWorkflow(ctx, s, internalWorkflow.WorkflowFunc) + workflowRun2 := createBatchResetWorkflow(ctx, s, internalWorkflow.WorkflowFunc) // wait for activity to start in both workflows s.EventuallyWithT(func(t *assert.CollectT) { @@ -311,8 +311,8 @@ func testActivityBatchResetDontResetAttempts(t *testing.T) { s.SdkWorker().RegisterWorkflow(internalWorkflow.WorkflowFunc) s.SdkWorker().RegisterActivity(internalWorkflow.ActivityFunc) - workflowRun1 := createBatchResetWorkflow(s, ctx, internalWorkflow.WorkflowFunc) - workflowRun2 := createBatchResetWorkflow(s, ctx, internalWorkflow.WorkflowFunc) + workflowRun1 := createBatchResetWorkflow(ctx, s, internalWorkflow.WorkflowFunc) + workflowRun2 := createBatchResetWorkflow(ctx, s, internalWorkflow.WorkflowFunc) // wait for activity to start in both workflows s.EventuallyWithT(func(t *assert.CollectT) {