From 649af9d4f7118780c7f1cadb8540a78f07a5b6c6 Mon Sep 17 00:00:00 2001 From: "alex.stanfield" <13949480+chaptersix@users.noreply.github.com> Date: Wed, 25 Mar 2026 19:22:31 -0500 Subject: [PATCH] refactor: migrate tests/admin_test.go to testcore.NewEnv pattern Replace suite-based AdminTestSuite with t.Run subtests using testcore.NewEnv() for better parallelization and simpler test infrastructure. --- tests/admin_test.go | 49 ++++++++++++++++----------------------------- 1 file changed, 17 insertions(+), 32 deletions(-) diff --git a/tests/admin_test.go b/tests/admin_test.go index a045aa2203..4638f4f805 100644 --- a/tests/admin_test.go +++ b/tests/admin_test.go @@ -6,7 +6,6 @@ import ( "time" "github.com/google/uuid" - "github.com/stretchr/testify/suite" commonpb "go.temporal.io/api/common/v1" sdkclient "go.temporal.io/sdk/client" "go.temporal.io/sdk/workflow" @@ -19,39 +18,25 @@ import ( "go.temporal.io/server/tests/testcore" ) -type AdminTestSuite struct { - testcore.FunctionalTestBase - testContext context.Context -} - func TestAdminTestSuite(t *testing.T) { t.Parallel() - suite.Run(t, new(AdminTestSuite)) -} - -func (s *AdminTestSuite) SetupSuite() { - // Call parent setup to initialize the test cluster - s.FunctionalTestBase.SetupSuite() - s.testContext = context.Background() -} - -func (s *AdminTestSuite) TestAdminRebuildMutableState_ChasmDisabled() { - rebuildMutableStateWorkflowHelper(s, false) -} - -func (s *AdminTestSuite) TestAdminRebuildMutableState_ChasmEnabled() { - cleanup := s.OverrideDynamicConfig(dynamicconfig.EnableChasm, true) - defer cleanup() - - configValues := s.GetTestCluster().Host().DcClient().GetValue(dynamicconfig.EnableChasm.Key()) - s.NotEmpty(configValues, "EnableChasm config should be set") - configValue, _ := configValues[0].Value.(bool) - s.True(configValue, "EnableChasm config should be true") - rebuildMutableStateWorkflowHelper(s, true) + t.Run("TestAdminRebuildMutableState_ChasmDisabled", func(t *testing.T) { + s := testcore.NewEnv(t, testcore.WithSdkWorker()) + rebuildMutableStateWorkflowHelper(s, false) + }) + t.Run("TestAdminRebuildMutableState_ChasmEnabled", func(t *testing.T) { + s := testcore.NewEnv(t, testcore.WithSdkWorker(), testcore.WithDynamicConfig(dynamicconfig.EnableChasm, true)) + + configValues := s.GetTestCluster().Host().DcClient().GetValue(dynamicconfig.EnableChasm.Key()) + s.NotEmpty(configValues, "EnableChasm config should be set") + configValue, _ := configValues[0].Value.(bool) + s.True(configValue, "EnableChasm config should be true") + rebuildMutableStateWorkflowHelper(s, true) + }) } // common test helper -func rebuildMutableStateWorkflowHelper(s *AdminTestSuite, testWithChasm bool) { +func rebuildMutableStateWorkflowHelper(s *testcore.TestEnv, testWithChasm bool) { tv := testvars.New(s.T()) workflowFn := func(ctx workflow.Context) error { var randomUUID string @@ -70,13 +55,13 @@ func rebuildMutableStateWorkflowHelper(s *AdminTestSuite, testWithChasm bool) { workflowID := tv.Any().String() workflowOptions := sdkclient.StartWorkflowOptions{ ID: workflowID, - TaskQueue: s.TaskQueue(), + TaskQueue: s.WorkerTaskQueue(), WorkflowRunTimeout: 20 * time.Second, } - ctx, cancel := context.WithTimeout(s.testContext, 30*time.Second) + ctx, cancel := context.WithTimeout(s.Context(), 30*time.Second) defer cancel() - workflowRun, err := s.SdkClient().ExecuteWorkflow(s.testContext, workflowOptions, workflowFn) + workflowRun, err := s.SdkClient().ExecuteWorkflow(s.Context(), workflowOptions, workflowFn) s.NoError(err) runID := workflowRun.GetRunID()