@@ -3,6 +3,7 @@ package test_test
33import (
44 "context"
55 "testing"
6+ "time"
67
78 "github.com/stretchr/testify/require"
89 "github.com/stretchr/testify/suite"
@@ -48,7 +49,7 @@ func (ts *WorkerTunerTestSuite) TestFixedSizeWorkerTuner() {
4849 })
4950 ts .NoError (err )
5051
51- ts .runTheWorkflow (worker.Options {Tuner : tuner }, ctx )
52+ ts .runTheWorkflow (worker.Options {Tuner : tuner }, ctx , 0 )
5253}
5354
5455func (ts * WorkerTunerTestSuite ) TestCompositeWorkerTuner () {
@@ -75,7 +76,7 @@ func (ts *WorkerTunerTestSuite) TestCompositeWorkerTuner() {
7576 WorkflowSlotSupplier : wfSS , ActivitySlotSupplier : actSS , LocalActivitySlotSupplier : laCss })
7677 ts .NoError (err )
7778
78- ts .runTheWorkflow (worker.Options {Tuner : tuner }, ctx )
79+ ts .runTheWorkflow (worker.Options {Tuner : tuner }, ctx , 0 )
7980}
8081
8182func (ts * WorkerTunerTestSuite ) TestPollerBehaviorAutoscalingScaler () {
@@ -89,7 +90,7 @@ func (ts *WorkerTunerTestSuite) TestPollerBehaviorAutoscalingScaler() {
8990 ActivityTaskPollerBehavior : worker .NewPollerBehaviorAutoscaling (
9091 worker.PollerBehaviorAutoscalingOptions {},
9192 ),
92- }, ctx )
93+ }, ctx , 0 )
9394}
9495
9596func (ts * WorkerTunerTestSuite ) TestPollerBehaviorSimpleMaximumScaler () {
@@ -103,11 +104,11 @@ func (ts *WorkerTunerTestSuite) TestPollerBehaviorSimpleMaximumScaler() {
103104 ActivityTaskPollerBehavior : worker .NewPollerBehaviorSimpleMaximum (
104105 worker.PollerBehaviorSimpleMaximumOptions {},
105106 ),
106- }, ctx )
107+ }, ctx , 0 )
107108}
108109
109110func (ts * WorkerTunerTestSuite ) TestResourceBasedSmallSlots () {
110- ctx , cancel := context .WithTimeout (context .Background (), ctxTimeout )
111+ ctx , cancel := context .WithTimeout (context .Background (), 5 * time . Minute )
111112 defer cancel ()
112113
113114 wfSS , err := worker .NewFixedSizeSlotSupplier (10 )
@@ -132,19 +133,22 @@ func (ts *WorkerTunerTestSuite) TestResourceBasedSmallSlots() {
132133
133134 // The bug this is verifying was triggered by a race, so run this a bunch to verify it's not hit
134135 for i := 0 ; i < 10 ; i ++ {
135- ts .runTheWorkflow (worker.Options {Tuner : tuner }, ctx )
136+ ts .runTheWorkflow (worker.Options {Tuner : tuner }, ctx , 2 * time . Minute )
136137 }
137138}
138139
139- func (ts * WorkerTunerTestSuite ) runTheWorkflow (workerOptions worker.Options , ctx context.Context ) {
140+ func (ts * WorkerTunerTestSuite ) runTheWorkflow (workerOptions worker.Options , ctx context.Context , wfTimeout time. Duration ) {
140141 myWorker := worker .New (ts .client , ts .taskQueueName , workerOptions )
141142 ts .workflows .register (myWorker )
142143 ts .activities .register (myWorker )
143144 ts .NoError (myWorker .Start ())
144145 defer myWorker .Stop ()
145146
146- handle , err := ts .client .ExecuteWorkflow (ctx ,
147- ts .startWorkflowOptions (ts .T ().Name ()),
147+ opts := ts .startWorkflowOptions (ts .T ().Name ())
148+ if wfTimeout > 0 {
149+ opts .WorkflowExecutionTimeout = wfTimeout
150+ }
151+ handle , err := ts .client .ExecuteWorkflow (ctx , opts ,
148152 ts .workflows .RunsLocalAndNonlocalActsWithRetries , 5 , 2 )
149153 ts .NoError (err )
150154 ts .NoError (handle .Get (ctx , nil ))
0 commit comments