Skip to content

Commit

Permalink
Refactor: use namespace.Name and namespace.ID in tests (#7065)
Browse files Browse the repository at this point in the history
## What changed?
<!-- Describe what has changed in this PR -->
Refactor: use `namespace.Name` and `namespace.ID` instead of `string` in
tests.

## Why?
<!-- Tell your future self why have you made these changes -->
Special narrow types should be used where possible.

## How did you test it?
<!-- How have you verified this change? Tested locally? Added a unit
test? Checked in staging env? -->
Run tests.

## Potential risks
<!-- Assuming the worst case, what can be broken when deploying this
change to production? -->
No risks.

## Documentation
<!-- Have you made sure this change doesn't falsify anything currently
stated in `docs/`? If significant
new behavior is added, have you described that in `docs/`? -->
No.

## Is hotfix candidate?
<!-- Is this PR a hotfix candidate or does it require a notification to
be sent to the broader community? (Yes/No) -->
No.
  • Loading branch information
alexshtin authored Jan 11, 2025
1 parent a1a3b3a commit 720505d
Show file tree
Hide file tree
Showing 57 changed files with 1,166 additions and 1,182 deletions.
19 changes: 9 additions & 10 deletions tests/activity_api_pause_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import (
"go.temporal.io/sdk/temporal"
"go.temporal.io/sdk/workflow"
"go.temporal.io/server/common/dynamicconfig"
"go.temporal.io/server/common/namespace"
"go.temporal.io/server/common/testing/testvars"
"go.temporal.io/server/common/util"
"go.temporal.io/server/tests/testcore"
Expand All @@ -56,7 +55,7 @@ type ActivityApiPauseClientTestSuite struct {
func (s *ActivityApiPauseClientTestSuite) SetupSuite() {
s.ClientFunctionalSuite.SetupSuite()
s.OverrideDynamicConfig(dynamicconfig.ActivityAPIsEnabled, true)
s.tv = testvars.New(s.T()).WithTaskQueue(s.TaskQueue()).WithNamespaceName(namespace.Name(s.Namespace()))
s.tv = testvars.New(s.T()).WithTaskQueue(s.TaskQueue()).WithNamespaceName(s.Namespace())
}

func (s *ActivityApiPauseClientTestSuite) SetupTest() {
Expand Down Expand Up @@ -134,7 +133,7 @@ func (s *ActivityApiPauseClientTestSuite) TestActivityPauseApi_WhileRunning() {

// pause activity
pauseRequest := &workflowservice.PauseActivityByIdRequest{
Namespace: s.Namespace(),
Namespace: s.Namespace().String(),
WorkflowId: workflowRun.GetID(),
ActivityId: "activity-id",
}
Expand Down Expand Up @@ -162,7 +161,7 @@ func (s *ActivityApiPauseClientTestSuite) TestActivityPauseApi_WhileRunning() {

// unpause the activity
unpauseRequest := &workflowservice.UnpauseActivityByIdRequest{
Namespace: s.Namespace(),
Namespace: s.Namespace().String(),
WorkflowId: workflowRun.GetID(),
ActivityId: "activity-id",
Operation: &workflowservice.UnpauseActivityByIdRequest_Resume{
Expand Down Expand Up @@ -230,7 +229,7 @@ func (s *ActivityApiPauseClientTestSuite) TestActivityPauseApi_WhileWaiting() {

// pause activity
pauseRequest := &workflowservice.PauseActivityByIdRequest{
Namespace: s.Namespace(),
Namespace: s.Namespace().String(),
WorkflowId: workflowRun.GetID(),
ActivityId: "activity-id",
}
Expand All @@ -250,7 +249,7 @@ func (s *ActivityApiPauseClientTestSuite) TestActivityPauseApi_WhileWaiting() {

// unpause the activity
unpauseRequest := &workflowservice.UnpauseActivityByIdRequest{
Namespace: s.Namespace(),
Namespace: s.Namespace().String(),
WorkflowId: workflowRun.GetID(),
ActivityId: "activity-id",
Operation: &workflowservice.UnpauseActivityByIdRequest_Resume{
Expand Down Expand Up @@ -322,7 +321,7 @@ func (s *ActivityApiPauseClientTestSuite) TestActivityPauseApi_WhileRetryNoWait(

// pause activity
pauseRequest := &workflowservice.PauseActivityByIdRequest{
Namespace: s.Namespace(),
Namespace: s.Namespace().String(),
WorkflowId: workflowRun.GetID(),
ActivityId: "activity-id",
}
Expand All @@ -332,7 +331,7 @@ func (s *ActivityApiPauseClientTestSuite) TestActivityPauseApi_WhileRetryNoWait(

// unpause the activity, and set noWait flag
unpauseRequest := &workflowservice.UnpauseActivityByIdRequest{
Namespace: s.Namespace(),
Namespace: s.Namespace().String(),
WorkflowId: workflowRun.GetID(),
ActivityId: "activity-id",
Operation: &workflowservice.UnpauseActivityByIdRequest_Resume{
Expand Down Expand Up @@ -405,7 +404,7 @@ func (s *ActivityApiPauseClientTestSuite) TestActivityPauseApi_WithReset() {

// pause activity
pauseRequest := &workflowservice.PauseActivityByIdRequest{
Namespace: s.Namespace(),
Namespace: s.Namespace().String(),
WorkflowId: workflowRun.GetID(),
ActivityId: "activity-id",
}
Expand All @@ -427,7 +426,7 @@ func (s *ActivityApiPauseClientTestSuite) TestActivityPauseApi_WithReset() {

// unpause the activity with reset, and set noWait flag
unpauseRequest := &workflowservice.UnpauseActivityByIdRequest{
Namespace: s.Namespace(),
Namespace: s.Namespace().String(),
WorkflowId: workflowRun.GetID(),
ActivityId: "activity-id",
Operation: &workflowservice.UnpauseActivityByIdRequest_Reset_{
Expand Down
9 changes: 4 additions & 5 deletions tests/activity_api_reset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import (
"go.temporal.io/sdk/temporal"
"go.temporal.io/sdk/workflow"
"go.temporal.io/server/common/dynamicconfig"
"go.temporal.io/server/common/namespace"
"go.temporal.io/server/common/testing/testvars"
"go.temporal.io/server/common/util"
"go.temporal.io/server/tests/testcore"
Expand All @@ -58,7 +57,7 @@ type ActivityApiResetClientTestSuite struct {
func (s *ActivityApiResetClientTestSuite) SetupSuite() {
s.ClientFunctionalSuite.SetupSuite()
s.OverrideDynamicConfig(dynamicconfig.ActivityAPIsEnabled, true)
s.tv = testvars.New(s.T()).WithTaskQueue(s.TaskQueue()).WithNamespaceName(namespace.Name(s.Namespace()))
s.tv = testvars.New(s.T()).WithTaskQueue(s.TaskQueue()).WithNamespaceName(s.Namespace())
}

func (s *ActivityApiResetClientTestSuite) SetupTest() {
Expand Down Expand Up @@ -138,7 +137,7 @@ func (s *ActivityApiResetClientTestSuite) TestActivityResetApi_AfterRetry() {
}, 5*time.Second, 200*time.Millisecond)

resetRequest := &workflowservice.ResetActivityByIdRequest{
Namespace: s.Namespace(),
Namespace: s.Namespace().String(),
WorkflowId: workflowRun.GetID(),
ActivityId: "activity-id",
NoWait: true,
Expand Down Expand Up @@ -214,7 +213,7 @@ func (s *ActivityApiResetClientTestSuite) TestActivityResetApi_WithRunningAndNoW

activityAboutToReset.Store(true)
resetRequest := &workflowservice.ResetActivityByIdRequest{
Namespace: s.Namespace(),
Namespace: s.Namespace().String(),
WorkflowId: workflowRun.GetID(),
ActivityId: "activity-id",
NoWait: true,
Expand Down Expand Up @@ -299,7 +298,7 @@ func (s *ActivityApiResetClientTestSuite) TestActivityResetApi_InRetry() {
}, 5*time.Second, 200*time.Millisecond)

resetRequest := &workflowservice.ResetActivityByIdRequest{
Namespace: s.Namespace(),
Namespace: s.Namespace().String(),
WorkflowId: workflowRun.GetID(),
ActivityId: "activity-id",
NoWait: true,
Expand Down
9 changes: 4 additions & 5 deletions tests/activity_api_update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import (
"go.temporal.io/sdk/temporal"
"go.temporal.io/sdk/workflow"
"go.temporal.io/server/common/dynamicconfig"
"go.temporal.io/server/common/namespace"
"go.temporal.io/server/common/testing/testvars"
"go.temporal.io/server/tests/testcore"
"google.golang.org/protobuf/types/known/durationpb"
Expand All @@ -56,7 +55,7 @@ type ActivityApiUpdateClientTestSuite struct {
func (s *ActivityApiUpdateClientTestSuite) SetupSuite() {
s.ClientFunctionalSuite.SetupSuite()
s.OverrideDynamicConfig(dynamicconfig.ActivityAPIsEnabled, true)
s.tv = testvars.New(s.T()).WithTaskQueue(s.TaskQueue()).WithNamespaceName(namespace.Name(s.Namespace()))
s.tv = testvars.New(s.T()).WithTaskQueue(s.TaskQueue()).WithNamespaceName(s.Namespace())
}

func (s *ActivityApiUpdateClientTestSuite) SetupTest() {
Expand Down Expand Up @@ -141,7 +140,7 @@ func (s *ActivityApiUpdateClientTestSuite) TestActivityUpdateApi_ChangeRetryInte
}, 10*time.Second, 500*time.Millisecond)

updateRequest := &workflowservice.UpdateActivityOptionsByIdRequest{
Namespace: s.Namespace(),
Namespace: s.Namespace().String(),
WorkflowId: workflowRun.GetID(),
ActivityId: "activity-id",
ActivityOptions: &activitypb.ActivityOptions{
Expand Down Expand Up @@ -219,7 +218,7 @@ func (s *ActivityApiUpdateClientTestSuite) TestActivityUpdateApi_ChangeScheduleT

// update schedule_to_close_timeout
updateRequest := &workflowservice.UpdateActivityOptionsByIdRequest{
Namespace: s.Namespace(),
Namespace: s.Namespace().String(),
WorkflowId: workflowRun.GetID(),
ActivityId: "activity-id",
ActivityOptions: &activitypb.ActivityOptions{
Expand Down Expand Up @@ -298,7 +297,7 @@ func (s *ActivityApiUpdateClientTestSuite) TestActivityUpdateApi_ChangeScheduleT
// also update retry policy interval, make it shorter
newScheduleToCloseTimeout := 10 * time.Second
updateRequest := &workflowservice.UpdateActivityOptionsByIdRequest{
Namespace: s.Namespace(),
Namespace: s.Namespace().String(),
WorkflowId: workflowRun.GetID(),
ActivityId: "activity-id",
ActivityOptions: &activitypb.ActivityOptions{
Expand Down
Loading

0 comments on commit 720505d

Please sign in to comment.