to fix flaky test about TestTimeSource.callbacks #2111
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I encounter the falky test about TestTimeSource.callbacks some times.
Flaky test failure history:
https://build.ros2.org/job/Rpr__rclcpp__ubuntu_jammy_amd64/602/
https://build.ros2.org/job/Rpr__rclcpp__ubuntu_jammy_amd64/597/
https://build.ros2.org/job/Rpr__rclcpp__ubuntu_jammy_amd64/547/
https://build.ros2.org/job/Rpr__rclcpp__ubuntu_jammy_amd64/530/
Let me explain why the flaky test happened.
If
rclcpp/rclcpp/test/rclcpp/test_time_source.cpp
Line 406 in 432bf21
the
ros_clock
is set with 4.000001000s at this moment,While calling
rclcpp/rclcpp/test/rclcpp/test_time_source.cpp
Line 425 in 432bf21
and if the message published by
clock_pub
inrclcpp/rclcpp/test/rclcpp/test_time_source.cpp
Line 143 in 432bf21
clock_sub
in some situation, theclock->now().nanoseconds() >= end_time.count()
will be always True and return so quick that the new callbackrclcpp/rclcpp/test/rclcpp/test_time_source.cpp
Line 421 in 432bf21