Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 25 additions & 19 deletions tests/activity_api_batch_reset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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(ctx context.Context, s *testcore.TestEnv, 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)
Expand All @@ -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()

Expand All @@ -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(ctx, s, internalWorkflow.WorkflowFunc)
workflowRun2 := createBatchResetWorkflow(ctx, s, internalWorkflow.WorkflowFunc)

// wait for activity to start in both workflows
s.EventuallyWithT(func(t *assert.CollectT) {
Expand Down Expand Up @@ -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()

Expand All @@ -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(ctx, s, internalWorkflow.WorkflowFunc)
workflowRun2 := createBatchResetWorkflow(ctx, s, internalWorkflow.WorkflowFunc)

// wait for activity to start in both workflows
s.EventuallyWithT(func(t *assert.CollectT) {
Expand Down Expand Up @@ -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()

Expand All @@ -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(ctx, s, internalWorkflow.WorkflowFunc)
workflowRun2 := createBatchResetWorkflow(ctx, s, internalWorkflow.WorkflowFunc)

// wait for activity to start in both workflows
s.EventuallyWithT(func(t *assert.CollectT) {
Expand Down Expand Up @@ -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(),
Expand Down
Loading