-
Notifications
You must be signed in to change notification settings - Fork 210
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Heartbeat timeout not raised while testing #1282
Comments
as pointed out in the #1167 , activity timeouts are hardcoded to 10min in testWorkflowEnvironmentImpl.executeActivity func (env *testWorkflowEnvironmentImpl) executeActivity(
activityFn interface{},
args ...interface{},
) (converter.EncodedValue, error) {
...
parameters := ExecuteActivityParams{
ExecuteActivityOptions: ExecuteActivityOptions{
ScheduleToCloseTimeout: 600 * time.Second,
StartToCloseTimeout: 600 * time.Second,
},
ActivityType: *activityType,
Input: input,
Header: env.header,
}
...
} heartbeatTimeouts are straight up ignored as a workaround I have been testing for consistent heartbeat strategies with the following, changing the code in func (s *UnitTestSuite) Test_Workflow() {
env := s.NewTestWorkflowEnvironment()
env.SetTestTimeout(time.Second * 1)
env.RegisterActivity(Do)
defer func() {
err := recover()
if r != nil {
s.True(strings.HasPrefix(err.(string), "test timeout"))
}
}()
env.ExecuteWorkflow(Workflow, In{Sleep: 9, Heartbeat: 2})
} when heartbeats are set appropriately, they will keep test workflow alive and it is possible to test for consistent timeout error over longer workload. |
The workflow test environment is meant mostly for just testing workflows though it has some activity support. You should use a |
a // TestActivityEnvironment is the environment that you use to test activity
TestActivityEnvironment struct {
impl *testWorkflowEnvironmentImpl
} which means that when running activities, the same limitations apply, this makes the test environment ignore developer setup and not behave as expected, as we cannot provide or set ExecuteActivityOptions. [Edit]: In my case, I was just trying to validate heartbeat strategies considering different workloads will try |
This worked for my needs (see here). I suppose then it comes to temporal developers wether there is a use case or not for normal configurations to the Activity and Workflow test environments. Personally, I would argue in favour of test environment interface being able to deal with this, as it seems like a lot of work to validate implementation against a simple feature. The heartbeat timeout is still set by the internal implementation, its just set to zero value while other timeouts are hardcoded (/internal/internal_workflow_testsuite.go#L579): parameters := ExecuteActivityParams{
ExecuteActivityOptions: ExecuteActivityOptions{
ScheduleToCloseTimeout: 600 * time.Second,
StartToCloseTimeout: 600 * time.Second,
},
ActivityType: *activityType,
Input: input,
Header: env.header,
}
...
scheduleTaskAttr.HeartbeatTimeout = ¶meters.HeartbeatTimeout
... |
But it's a different level of exposed abstraction. The point is that if you want to test how your workflow reacts to a certain type of activity failure, mock that activity and return that error. If you want to test how your activity works regardless of workflow, use the activity environment. If you must test all behaviors of activity and workflow together based on real-time, it may not make sense to use an activity or time-skipping workflow environment, it may make sense to use a real combined one. Some timeouts we do respect in the workflow environment however, but are on time-skipping basis not based on real time. I will leave this issue open to investigate if real-time heartbeat timeout can/should be respected. |
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
workflow.go
andworkflow_test.go
below 👇go test ./...
workflow.go
workflow_test.go
Specifications
The text was updated successfully, but these errors were encountered: