Open
Description
I want to see how an activity times out due to heartbeat timeout while testing. But it doesn't raise the Heartbeat timeout. See the tests in Steps to Reproduce the Problem section
Expected Behavior
I would expect to see the test failing due to HeartbeatTimeout
Actual Behavior
The tests are passing
Steps to Reproduce the Problem
- make a folder with
workflow.go
andworkflow_test.go
below 👇 go test ./...
workflow.go
package hbtimeout
import (
"context"
"time"
"go.temporal.io/sdk/temporal"
"go.temporal.io/sdk/workflow"
)
type In struct {
Sleep int
Heartbeat int
}
func Workflow(ctx workflow.Context, in In) error {
options := workflow.ActivityOptions{
StartToCloseTimeout: time.Second * 10,
HeartbeatTimeout: time.Second * time.Duration(in.Heartbeat),
RetryPolicy: &temporal.RetryPolicy{
MaximumAttempts: 1,
},
}
ctx = workflow.WithActivityOptions(ctx, options)
err := workflow.ExecuteActivity(ctx, Do, in.Sleep).Get(ctx, nil)
if err != nil {
return err
}
return nil
}
func Do(ctx context.Context, sleep int) error {
time.Sleep(time.Second * time.Duration(sleep))
return nil
}
workflow_test.go
package hbtimeout
import (
"testing"
"time"
"github.com/stretchr/testify/suite"
"go.temporal.io/sdk/testsuite"
)
type UnitTestSuite struct {
suite.Suite
testsuite.WorkflowTestSuite
}
func TestUnitTestSuite(t *testing.T) {
suite.Run(t, new(UnitTestSuite))
}
func (s *UnitTestSuite) Test_Workflow() {
env := s.NewTestWorkflowEnvironment()
env.SetTestTimeout(time.Second * 20)
env.RegisterActivity(Do)
env.ExecuteWorkflow(Workflow, In{Sleep: 9, Heartbeat: 1})
s.True(env.IsWorkflowCompleted())
s.NoError(env.GetWorkflowError())
env.AssertExpectations(s.T())
}
Specifications
- Version:
- Platform: testing locally