@@ -4458,6 +4458,56 @@ func (ts *IntegrationTestSuite) testNonDeterminismFailureCause(historyMismatch b
4458
4458
ts .True (taskFailedMetric >= 1 )
4459
4459
}
4460
4460
4461
+ func (ts * IntegrationTestSuite ) TestNonDeterminismFailureCauseReplay () {
4462
+ ctx , cancel := context .WithTimeout (context .Background (), 30 * time .Second )
4463
+ defer cancel ()
4464
+
4465
+ fetchMetrics := func () (localMetric int64 ) {
4466
+ for _ , counter := range ts .metricsHandler .Counters () {
4467
+ counter := counter
4468
+ if counter .Name == "temporal_workflow_task_execution_failed" && counter .Tags ["failure_reason" ] == "NonDeterminismError" {
4469
+ localMetric = counter .Value ()
4470
+ }
4471
+ }
4472
+ return
4473
+ }
4474
+
4475
+ // Confirm no metrics to start
4476
+ taskFailedMetric := fetchMetrics ()
4477
+ ts .Zero (taskFailedMetric )
4478
+
4479
+ // Start workflow
4480
+ forcedNonDeterminismCounter = 0
4481
+ run , err := ts .client .ExecuteWorkflow (
4482
+ ctx ,
4483
+ ts .startWorkflowOptions ("test-non-determinism-failure-cause-replay-" + uuid .New ()),
4484
+ ts .workflows .NonDeterminismReplay ,
4485
+ )
4486
+
4487
+ ts .NoError (err )
4488
+ defer func () { _ = ts .client .TerminateWorkflow (ctx , run .GetID (), run .GetRunID (), "" , nil ) }()
4489
+ ts .NoError (run .Get (ctx , nil ))
4490
+
4491
+ // Now, stop the worker and start a new one
4492
+ ts .worker .Stop ()
4493
+ ts .workerStopped = true
4494
+ nextWorker := worker .New (ts .client , ts .taskQueueName , worker.Options {})
4495
+ ts .registerWorkflowsAndActivities (nextWorker )
4496
+ ts .NoError (nextWorker .Start ())
4497
+ defer nextWorker .Stop ()
4498
+
4499
+ // Increase the determinism counter and send a tick to trigger replay
4500
+ // non-determinism
4501
+ forcedNonDeterminismCounter ++
4502
+ fmt .Println ("Querying workflow" )
4503
+ _ , err = ts .client .QueryWorkflow (ctx , run .GetID (), run .GetRunID (), client .QueryTypeStackTrace , nil )
4504
+ ts .Error (err )
4505
+ ts .Equal ("context deadline exceeded" , err .Error ())
4506
+
4507
+ taskFailedMetric = fetchMetrics ()
4508
+ ts .True (taskFailedMetric >= 1 )
4509
+ }
4510
+
4461
4511
func (ts * IntegrationTestSuite ) TestDeterminismUpsertSearchAttributesConditional () {
4462
4512
ctx , cancel := context .WithTimeout (context .Background (), 30 * time .Second )
4463
4513
defer cancel ()
0 commit comments