Skip to content

Commit

Permalink
Fix flaky Test_ActivityTimeouts (#2325)
Browse files Browse the repository at this point in the history
  • Loading branch information
yycptt authored Dec 28, 2021
1 parent e1fa8f2 commit 097fa79
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion host/client_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,9 +468,22 @@ func (s *clientIntegrationSuite) Test_ActivityTimeouts() {
info := activity.GetInfo(ctx)
if info.ActivityID == "Heartbeat" {
go func() {
// NOTE: due to client side heartbeat batching, heartbeat may be sent
// later than expected.
// e.g. if activity heartbeat timeout is 2s,
// and we call RecordHeartbeat() at 0s, 0.5s, 1s, 1.5s
// the client by default will send two heartbeats at 0s and 2*0.8=1.6s
// Now if when running the test, this heartbeat goroutine becomes slow,
// and call RecordHeartbeat() after 1.6s, then that heartbeat will be sent
// to server at 3.2s (the next batch).
// Since the entire activity will finish at 5s, there won't be
// any heartbeat timeout error.
// so here, we reduce the duration between two heartbeats, so that they are
// more likey be sent in the heartbeat batch at 1.6s
// (basically increasing the room for delay in heartbeat goroutine from 0.1s to 1s)
for i := 0; i < 4; i++ {
activity.RecordHeartbeat(ctx, i)
time.Sleep(500 * time.Millisecond)
time.Sleep(200 * time.Millisecond)
}
}()
}
Expand Down

0 comments on commit 097fa79

Please sign in to comment.