@@ -227,7 +227,6 @@ func (ts *IntegrationTestSuite) SetupTest() {
227227 }
228228
229229 if strings .Contains (ts .T ().Name (), "GracefulActivityCompletion" ) ||
230- strings .Contains (ts .T ().Name (), "GracefulLocalActivityCompletion" ) ||
231230 strings .Contains (ts .T ().Name (), "LocalActivityCompleteWithinGracefulShutdown" ) ||
232231 strings .Contains (ts .T ().Name (), "LocalActivityTaskTimeoutHeartbeat" ) {
233232 options .WorkerStopTimeout = 10 * time .Second
@@ -2409,82 +2408,14 @@ func (ts *IntegrationTestSuite) TestGracefulActivityCompletion() {
24092408 ts .Equal ("stopped" , s )
24102409}
24112410
2412- func (ts * IntegrationTestSuite ) TestGracefulLocalActivityCompletion () {
2413- // FYI, setup of this test allows the worker to wait to stop for 10 seconds
2414- ctx , cancel := context .WithCancel (context .Background ())
2415- defer cancel ()
2416- localActivityFn := func (ctx context.Context ) error {
2417- time .Sleep (100 * time .Millisecond )
2418- return ctx .Err ()
2419- }
2420-
2421- workflowFn := func (ctx workflow.Context ) error {
2422- ctx = workflow .WithLocalActivityOptions (ctx , workflow.LocalActivityOptions {
2423- StartToCloseTimeout : 1 * time .Minute ,
2424- })
2425- localActivity := workflow .ExecuteLocalActivity (ctx , localActivityFn )
2426- err := localActivity .Get (ctx , nil )
2427- if err != nil {
2428- workflow .GetLogger (ctx ).Error ("Activity failed." , "Error" , err )
2429- }
2430-
2431- localActivity = workflow .ExecuteLocalActivity (ctx , localActivityFn )
2432- err = localActivity .Get (ctx , nil )
2433- if err != nil {
2434- workflow .GetLogger (ctx ).Error ("Second activity failed." , "Error" , err )
2435- }
2436-
2437- return nil
2438-
2439- }
2440-
2441- workflowID := "local-activity-stop-" + uuid .NewString ()
2442- ts .worker .RegisterWorkflowWithOptions (workflowFn , workflow.RegisterOptions {Name : "local-activity-stop" })
2443- startOptions := client.StartWorkflowOptions {
2444- ID : workflowID ,
2445- TaskQueue : ts .taskQueueName ,
2446- WorkflowTaskTimeout : 5 * time .Second ,
2447- }
2448-
2449- // Start workflow
2450- run , err := ts .client .ExecuteWorkflow (ctx , startOptions , workflowFn )
2451- ts .NoError (err )
2452-
2453- // Stop the worker
2454- time .Sleep (100 * time .Millisecond )
2455- ts .worker .Stop ()
2456- ts .workerStopped = true
2457- time .Sleep (500 * time .Millisecond )
2458-
2459- // Look for activity completed from the history
2460- var laCompleted int
2461- var wfeCompleted bool
2462- iter := ts .client .GetWorkflowHistory (ctx , run .GetID (), run .GetRunID (),
2463- false , enumspb .HISTORY_EVENT_FILTER_TYPE_ALL_EVENT )
2464- for iter .HasNext () {
2465- event , err := iter .Next ()
2466- ts .NoError (err )
2467- attributes := event .GetMarkerRecordedEventAttributes ()
2468- if event .EventType == enumspb .EVENT_TYPE_MARKER_RECORDED && attributes .MarkerName == "LocalActivity" && attributes .GetFailure () == nil {
2469- laCompleted ++
2470- }
2471- if event .EventType == enumspb .EVENT_TYPE_WORKFLOW_EXECUTION_COMPLETED {
2472- wfeCompleted = true
2473- }
2474- }
2475-
2476- // Confirm local activity and WFE completed
2477- ts .Equal (2 , laCompleted )
2478- ts .True (wfeCompleted )
2479- }
2480-
24812411func (ts * IntegrationTestSuite ) TestLocalActivityTaskTimeoutHeartbeat () {
24822412 // FYI, setup of this test allows the worker to wait to stop for 10 seconds
24832413 ctx , cancel := context .WithCancel (context .Background ())
24842414 defer cancel ()
24852415
24862416 localActivityFn := func (ctx context.Context ) error {
24872417 // wait for worker shutdown to be started and WorkflowTaskTimeout to be hit
2418+ <- activity .GetWorkerStopChannel (ctx )
24882419 time .Sleep (1500 * time .Millisecond ) // 1.5 seconds
24892420 return ctx .Err ()
24902421 }
@@ -7777,13 +7708,11 @@ func (ts *IntegrationTestSuite) TestLocalActivityCancelFromWorkerShutdown() {
77777708}
77787709
77797710func (ts * IntegrationTestSuite ) TestLocalActivityWorkerShutdownNoHeartbeat () {
7780- // FYI, setup of this test allows the worker to wait to stop for 10 seconds
77817711 ctx , cancel := context .WithCancel (context .Background ())
77827712 defer cancel ()
77837713 localActivityFn := func (ctx context.Context ) error {
7784- // TODO: Use GetWorkerStopChannel once https://github.com/temporalio/sdk-go/issues/1963 is fixed
7785- // in this place and other similar tests
7786- time .Sleep (300 * time .Millisecond )
7714+ // Wait for the LA to return context canceled, so we can test failed LA will not heartbeat on worker shutdown
7715+ time .Sleep (100 * time .Millisecond )
77877716 return ctx .Err ()
77887717 }
77897718 workflowFn := func (ctx workflow.Context ) error {
@@ -7852,7 +7781,7 @@ func (ts *IntegrationTestSuite) TestLocalActivityCompleteWithinGracefulShutdown(
78527781 ctx , cancel := context .WithCancel (context .Background ())
78537782 defer cancel ()
78547783 localActivityFn := func (ctx context.Context ) error {
7855- time . Sleep ( 300 * time . Millisecond )
7784+ <- activity . GetWorkerStopChannel ( ctx )
78567785 return ctx .Err ()
78577786 }
78587787 workflowFn := func (ctx workflow.Context ) error {
@@ -7910,7 +7839,8 @@ func (ts *IntegrationTestSuite) TestLocalActivityCompleteWithinGracefulShutdown(
79107839 }
79117840 }
79127841
7913- // Confirm no heartbeats from local activity
7842+ // Confirm no heartbeats from local activity and confirm that LA and workflow have completed successfully within
7843+ // graceful shutdown
79147844 ts .Equal (1 , wftStarted )
79157845 ts .Equal (2 , laCompleted )
79167846 ts .True (wfeCompleted )
0 commit comments