Skip to content

Commit

Permalink
update RunID test vars #2
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanos committed Nov 5, 2024
1 parent a565451 commit 7a03113
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
5 changes: 5 additions & 0 deletions common/testing/testvars/any.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
package testvars

import (
"github.com/pborman/uuid"
commonpb "go.temporal.io/api/common/v1"
"go.temporal.io/server/common/payload"
"go.temporal.io/server/common/payloads"
Expand Down Expand Up @@ -63,3 +64,7 @@ func (a Any) EventID() int64 {
// This produces EventID in XX0YY format, where XX is unique for every test and YY is a random number.
return int64(randInt(a.testHash, 2, 1, 2))
}

func (a Any) RunID() string {
return uuid.New()
}
31 changes: 17 additions & 14 deletions service/history/api/respondworkflowtaskcompleted/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,36 +42,34 @@ import (
taskqueuepb "go.temporal.io/api/taskqueue/v1"
updatepb "go.temporal.io/api/update/v1"
"go.temporal.io/api/workflowservice/v1"
"google.golang.org/protobuf/types/known/durationpb"

enumsspb "go.temporal.io/server/api/enums/v1"
"go.temporal.io/server/api/historyservice/v1"
tokenspb "go.temporal.io/server/api/token/v1"
"go.temporal.io/server/common/cluster"
"go.temporal.io/server/common/testing/historyrequire"
"go.temporal.io/server/common/testing/protorequire"
"go.temporal.io/server/common/testing/protoutils"
"go.temporal.io/server/common/testing/testvars"
"go.temporal.io/server/common/testing/updateutils"
"go.temporal.io/server/internal/effect"
"go.temporal.io/server/service/history/hsm"
wcache "go.temporal.io/server/service/history/workflow/cache"
"go.temporal.io/server/service/history/workflow/update"

persistencespb "go.temporal.io/server/api/persistence/v1"
tokenspb "go.temporal.io/server/api/token/v1"
"go.temporal.io/server/common"
"go.temporal.io/server/common/clock"
"go.temporal.io/server/common/cluster"
"go.temporal.io/server/common/locks"
"go.temporal.io/server/common/log"
"go.temporal.io/server/common/metrics"
"go.temporal.io/server/common/namespace"
"go.temporal.io/server/common/payloads"
"go.temporal.io/server/common/persistence"
"go.temporal.io/server/common/testing/historyrequire"
"go.temporal.io/server/common/testing/protorequire"
"go.temporal.io/server/common/testing/protoutils"
"go.temporal.io/server/common/testing/testvars"
"go.temporal.io/server/common/testing/updateutils"
"go.temporal.io/server/internal/effect"
"go.temporal.io/server/service/history/api"
"go.temporal.io/server/service/history/events"
"go.temporal.io/server/service/history/hsm"
"go.temporal.io/server/service/history/shard"
"go.temporal.io/server/service/history/tests"
"go.temporal.io/server/service/history/workflow"
wcache "go.temporal.io/server/service/history/workflow/cache"
"go.temporal.io/server/service/history/workflow/update"
"google.golang.org/protobuf/types/known/durationpb"
)

type (
Expand Down Expand Up @@ -184,6 +182,7 @@ func (s *WorkflowTaskCompletedHandlerSuite) TestUpdateWorkflow() {

s.Run("Accept Complete", func() {
tv := testvars.New(s.T())
tv = tv.WithRunID(tv.Any().RunID())
s.mockNamespaceCache.EXPECT().GetNamespaceByID(tv.NamespaceID()).Return(tv.Namespace(), nil).AnyTimes()
wfContext := s.createStartedWorkflow(tv)
writtenHistoryCh := createWrittenHistoryCh(1)
Expand Down Expand Up @@ -217,6 +216,7 @@ func (s *WorkflowTaskCompletedHandlerSuite) TestUpdateWorkflow() {

s.Run("Reject", func() {
tv := testvars.New(s.T())
tv = tv.WithRunID(tv.Any().RunID())
s.mockNamespaceCache.EXPECT().GetNamespaceByID(tv.NamespaceID()).Return(tv.Namespace(), nil).AnyTimes()
wfContext := s.createStartedWorkflow(tv)

Expand All @@ -241,6 +241,7 @@ func (s *WorkflowTaskCompletedHandlerSuite) TestUpdateWorkflow() {

s.Run("Write failed on normal task queue", func() {
tv := testvars.New(s.T())
tv = tv.WithRunID(tv.Any().RunID())
s.mockNamespaceCache.EXPECT().GetNamespaceByID(tv.NamespaceID()).Return(tv.Namespace(), nil).AnyTimes()
wfContext := s.createStartedWorkflow(tv)

Expand All @@ -266,6 +267,7 @@ func (s *WorkflowTaskCompletedHandlerSuite) TestUpdateWorkflow() {

s.Run("Write failed on sticky task queue", func() {
tv := testvars.New(s.T())
tv = tv.WithRunID(tv.Any().RunID())
s.mockNamespaceCache.EXPECT().GetNamespaceByID(tv.NamespaceID()).Return(tv.Namespace(), nil).AnyTimes()
wfContext := s.createStartedWorkflow(tv)

Expand Down Expand Up @@ -298,6 +300,7 @@ func (s *WorkflowTaskCompletedHandlerSuite) TestUpdateWorkflow() {

s.Run("GetHistory failed", func() {
tv := testvars.New(s.T())
tv = tv.WithRunID(tv.Any().RunID())
s.mockNamespaceCache.EXPECT().GetNamespaceByID(tv.NamespaceID()).Return(tv.Namespace(), nil).AnyTimes()
wfContext := s.createStartedWorkflow(tv)
writtenHistoryCh := createWrittenHistoryCh(1)
Expand Down

0 comments on commit 7a03113

Please # to comment.