Fix flaky entity store persistence test #2540
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.
Proposed changes
The tests were failing due to a time precision problem while validating MQTT messages with a
date_from
range and not because there was a duplicate message. Thedate_from
value takes a UNIX timestamp without milli-second precision. But in the failing test case, the following was happening (note the time precision):10:10:35.513002
10:10:36.198326
date_from
for the assertion was generated usingGet Unix Timestamp
API at10:10:36.756000
. But, theGet Unix Timestamp
returns the time:1703067036
without millisecond precision.When that timestamp without precision, which is
10:10:36.000000
is used as thedate_from
in the assertion, it covers the original message as well, and that wrongly detects it as a duplicate message.To make sure that there is a delay of more than 1 second between the point at which the converted message was emitted and the point of assertion, the managed object existence checks were added in between which should add a significant delay.
Types of changes
Paste Link to the issue
Checklist
cargo fmt
as mentioned in CODING_GUIDELINEScargo clippy
as mentioned in CODING_GUIDELINESFurther comments