Skip to content

Commit

Permalink
Fix flaky integration test (cadence-workflow#4092)
Browse files Browse the repository at this point in the history
  • Loading branch information
emrahs authored Mar 30, 2021
1 parent 7661a45 commit 471f99b
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions host/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1208,15 +1208,26 @@ func (s *integrationSuite) TestCronWorkflow() {
}
for i := 1; i != 4; i++ {
executionInfo := closedExecutions[i]
// Roundup to compare on the precision of seconds
expectedBackoff := executionInfo.GetExecutionTime()/1000000000 - lastExecution.GetExecutionTime()/1000000000
expectedBackoff := executionInfo.GetExecutionTime() - lastExecution.GetExecutionTime()
// The execution time calculate based on last execution close time
// However, the current execution time is based on the current start time
// This code is to remove the diff between current start time and last execution close time
// TODO: Remove this line once we unify the time source
executionTimeDiff := executionInfo.GetStartTime()/1000000000 - lastExecution.GetCloseTime()/1000000000
executionTimeDiff := executionInfo.GetStartTime() - lastExecution.GetCloseTime()
// The backoff between any two executions should be multiplier of the target backoff duration which is 3 in this test
s.Equal(int64(0), int64(expectedBackoff-executionTimeDiff)%(targetBackoffDuration.Nanoseconds()/1000000000))
backoffSeconds := int(time.Duration(expectedBackoff-executionTimeDiff).Round(time.Second).Seconds())
targetBackoffSeconds := int(targetBackoffDuration.Seconds())
s.Equal(
0,
backoffSeconds % targetBackoffSeconds,
"Still Flaky?: backoffSeconds: %v ((%v-%v) - (%v-%v)), targetBackoffSeconds: %v",
backoffSeconds,
executionInfo.GetExecutionTime(),
lastExecution.GetExecutionTime(),
executionInfo.GetStartTime(),
lastExecution.GetCloseTime(),
targetBackoffSeconds,
)
lastExecution = executionInfo
}
}
Expand Down

0 comments on commit 471f99b

Please sign in to comment.