Skip to content

Commit

Permalink
Override names for anonymous functions used as workflows or activities
Browse files Browse the repository at this point in the history
  • Loading branch information
dnr committed Jan 6, 2022
1 parent ec65088 commit 74b5006
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
10 changes: 6 additions & 4 deletions host/activity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,8 @@ func (s *clientIntegrationSuite) TestActivityHeartbeatDetailsDuringRetry() {
// 5. Test should start polling for heartbeat details once first heartbeat was reported.
// 6. Once workflow completes -- we're done.

workflowType := "integration-test-activity-heartbeat-details-during-retry-wf"
activityType := "integration-test-activity-heartbeat-details-during-retry-activity"
activityTimeout := time.Second

activityExecutedCount := 0
Expand Down Expand Up @@ -915,15 +917,15 @@ func (s *clientIntegrationSuite) TestActivityHeartbeatDetailsDuringRetry() {
StartToCloseTimeout: 2 * time.Second,
RetryPolicy: activityRetryPolicy,
})
f1 := workflow.ExecuteActivity(ctx1, activityFn)
f1 := workflow.ExecuteActivity(ctx1, activityType)

err1 = f1.Get(ctx1, nil)

return nil
}

s.worker.RegisterActivity(activityFn)
s.worker.RegisterWorkflow(workflowFn)
s.worker.RegisterActivityWithOptions(activityFn, activity.RegisterOptions{Name: activityType})
s.worker.RegisterWorkflowWithOptions(workflowFn, workflow.RegisterOptions{Name: workflowType})

wfId := "integration-test-heartbeat-details-during-retry"
workflowOptions := sdkclient.StartWorkflowOptions{
Expand All @@ -933,7 +935,7 @@ func (s *clientIntegrationSuite) TestActivityHeartbeatDetailsDuringRetry() {
}
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
workflowRun, err := s.sdkClient.ExecuteWorkflow(ctx, workflowOptions, workflowFn)
workflowRun, err := s.sdkClient.ExecuteWorkflow(ctx, workflowOptions, workflowType)
if err != nil {
s.Logger.Fatal("Start workflow failed with err", tag.Error(err))
}
Expand Down
26 changes: 16 additions & 10 deletions host/client_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ func (s *clientIntegrationSuite) SetupTest() {
}

// register dummy workflow and activity, otherwise worker won't start.
s.worker.RegisterWorkflow(workflowFn)
s.worker.RegisterActivity(activityFn)
s.worker.RegisterWorkflowWithOptions(workflowFn, workflow.RegisterOptions{Name: "dummy-workflow-type"})
s.worker.RegisterActivityWithOptions(activityFn, activity.RegisterOptions{Name: "dummy-activity-type"})

if err := s.worker.Start(); err != nil {
s.Logger.Fatal("Error when start worker", tag.Error(err))
Expand Down Expand Up @@ -464,6 +464,9 @@ func (s *clientIntegrationSuite) TestClientDataConverter_WithChild() {
}

func (s *clientIntegrationSuite) Test_ActivityTimeouts() {
workflowType := "integration-test-activity-timeouts-wf"
activityType := "integration-test-activity-timeouts-activity"

activityFn := func(ctx context.Context) error {
info := activity.GetInfo(ctx)
if info.ActivityID == "Heartbeat" {
Expand Down Expand Up @@ -528,7 +531,7 @@ func (s *clientIntegrationSuite) Test_ActivityTimeouts() {
HeartbeatTimeout: 2 * time.Second,
RetryPolicy: noRetryPolicy,
})
f4 := workflow.ExecuteActivity(ctx4, activityFn)
f4 := workflow.ExecuteActivity(ctx4, activityType)

err1 = f1.Get(ctx1, nil)
err2 = f2.Get(ctx2, nil)
Expand All @@ -538,8 +541,8 @@ func (s *clientIntegrationSuite) Test_ActivityTimeouts() {
return nil
}

s.worker.RegisterActivity(activityFn)
s.worker.RegisterWorkflow(workflowFn)
s.worker.RegisterActivityWithOptions(activityFn, activity.RegisterOptions{Name: activityType})
s.worker.RegisterWorkflowWithOptions(workflowFn, workflow.RegisterOptions{Name: workflowType})

id := "integration-test-activity-timeouts"
workflowOptions := sdkclient.StartWorkflowOptions{
Expand All @@ -549,7 +552,7 @@ func (s *clientIntegrationSuite) Test_ActivityTimeouts() {
}
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
workflowRun, err := s.sdkClient.ExecuteWorkflow(ctx, workflowOptions, workflowFn)
workflowRun, err := s.sdkClient.ExecuteWorkflow(ctx, workflowOptions, workflowType)
if err != nil {
s.Logger.Fatal("Start workflow failed with err", tag.Error(err))
}
Expand Down Expand Up @@ -611,6 +614,7 @@ func (s *clientIntegrationSuite) Test_UnhandledCommandAndNewTask() {
Server complete workflow as requested.
*/

workflowType := "integration-test-unhandled-command-and-new-task-wf"
sigReadyToSendChan := make(chan struct{}, 1)
sigSendDoneChan := make(chan struct{})
localActivityFn := func(ctx context.Context) error {
Expand Down Expand Up @@ -656,7 +660,7 @@ func (s *clientIntegrationSuite) Test_UnhandledCommandAndNewTask() {
return nil
}

s.worker.RegisterWorkflow(workflowFn)
s.worker.RegisterWorkflowWithOptions(workflowFn, workflow.RegisterOptions{Name: workflowType})

id := "integration-test-unhandled-command-new-task"
workflowOptions := sdkclient.StartWorkflowOptions{
Expand All @@ -669,7 +673,7 @@ func (s *clientIntegrationSuite) Test_UnhandledCommandAndNewTask() {
}
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
workflowRun, err := s.sdkClient.ExecuteWorkflow(ctx, workflowOptions, workflowFn)
workflowRun, err := s.sdkClient.ExecuteWorkflow(ctx, workflowOptions, workflowType)
if err != nil {
s.Logger.Fatal("Start workflow failed with err", tag.Error(err))
}
Expand Down Expand Up @@ -709,6 +713,8 @@ func (s *clientIntegrationSuite) Test_UnhandledCommandAndNewTask() {
}

func (s *clientIntegrationSuite) Test_BufferedQuery() {
workflowType := "integration-test-buffered-query-wf"

localActivityFn := func(ctx context.Context) error {
time.Sleep(5 * time.Second) // use local activity sleep to block workflow task to force query to be buffered
return nil
Expand Down Expand Up @@ -736,7 +742,7 @@ func (s *clientIntegrationSuite) Test_BufferedQuery() {
return err1
}

s.worker.RegisterWorkflow(workflowFn)
s.worker.RegisterWorkflowWithOptions(workflowFn, workflow.RegisterOptions{Name: workflowType})

id := "integration-test-buffered-query"
workflowOptions := sdkclient.StartWorkflowOptions{
Expand All @@ -746,7 +752,7 @@ func (s *clientIntegrationSuite) Test_BufferedQuery() {
}
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
workflowRun, err := s.sdkClient.ExecuteWorkflow(ctx, workflowOptions, workflowFn)
workflowRun, err := s.sdkClient.ExecuteWorkflow(ctx, workflowOptions, workflowType)
if err != nil {
s.Logger.Fatal("Start workflow failed with err", tag.Error(err))
}
Expand Down

0 comments on commit 74b5006

Please sign in to comment.