-
-
Notifications
You must be signed in to change notification settings - Fork 119
test: fix flaky chatlist_events test test_update_after_ephemeral_messages #5471
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
Conversation
…ages Previously test did not trigger deletion of ephemeral messages and worked because clear_events() did not remove just emitted events from `send_text_msg`.
|
Generally speaking
This seems to be what happened, |
| chat.set_ephemeral_timer(&alice, crate::ephemeral::Timer::Enabled { duration: 1 }) | ||
| chat.set_ephemeral_timer(&alice, crate::ephemeral::Timer::Enabled { duration: 60 }) | ||
| .await?; | ||
| alice |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this necessary? Maybe not bad to check though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is to ensure we consume all events up to this one, including all chatlist events related to creation of group chat. Otherwise we may these events for events that we expect after deletion of ephemeral message. Better consume as many events as we can reliably expect as possible to have "checkpoints".
Version 7.2.6 does not supported by older Python.
| /// Avoid using this function if you can | ||
| /// by waiting for specific events you expect to receive. | ||
| pub async fn clear_events(&self) { | ||
| while let Ok(_ev) = tokio::time::timeout(Duration::from_secs(1), self.recv()).await {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can it be achieved by emitting a special test event and then waiting for it? Or there may be events that are emitted asynchronously?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is that this task may simply not get resources and move events too slowly:
https://github.com/deltachat/deltachat-core-rust/blob/65822e53e669900d21f2c361458c1aa61851f480/src/test_utils.rs#L367-L376
Better way would be to get rid of this task so event cannot be in the process of being moved from one channel to another by the time we call clear_events(). But I don't know how much refactoring it is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually it is a problem also in cases when test crashes/panics, this may lose events and you don't get them in printout then. Maybe makes sense to file it as a bug. If not for this task, clear_events would work reliably even without 1 second timeout.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously test did not trigger
deletion of ephemeral messages
and worked because clear_events() did not
remove just emitted events from
send_text_msg.Fixes #5470