Skip to content
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

Fix flaky CBOR test #718

Merged
merged 1 commit into from
Mar 18, 2025
Merged

Fix flaky CBOR test #718

merged 1 commit into from
Mar 18, 2025

Conversation

graebm
Copy link
Contributor

@graebm graebm commented Mar 18, 2025

Issue:

Rare random failure of "CborTimeStampTest" (see logs)

Diagnosis:

This test does:

  • get timestamp from current `std::chrono::time_pointstd::chrono::system_clock
  • CBOR encode timestamp as seconds-as-64bit-floating-point
  • decode timestamp
  • compare original timestamp with encoded/decoded timestam
    • deal with floating point precision differences by casting to milliseconds-as-integer before comparing

The flow above seems good. There are some differences in floating point precision, but we ultimately compare the values at lower precision (milliseconds-as-integer). So what's up???

Description of changes:

Fix helper function that loses lots of precision, due to too much casting back and forth between floating-point -> integer -> floating-point -> integer

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Comment on lines +187 to +188
outTimePoint = std::chrono::system_clock::time_point(
std::chrono::duration_cast<std::chrono::system_clock::duration>(timestamp));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we were casting from float->int->float here, now it's float->float->float

well ... some of those "float" are weird "std chrono ratio" things, but you know what I mean

@graebm graebm merged commit e43d14b into main Mar 18, 2025
63 checks passed
@graebm graebm deleted the flaky-cbor-test branch March 18, 2025 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants