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

test(subscriber): test with custom self_wake() function #525

Merged
merged 2 commits into from
Mar 8, 2024

Conversation

hds
Copy link
Collaborator

@hds hds commented Feb 16, 2024

Part of the testing performed in the console-subscriber integration
tests is detecting self wakes. This relied upon the yield_now() from
Tokio.

However, the behavior of this function was changed in
tokio-rs/tokio#5223 and since Tokio 1.23 the wake doesn't occur in the
task that yield_now() is called from. This breaks the test when using
a newer version of Tokio.

This change replaces the use of yield_now() with a custom
self_wake() function that returns a future which does perform a self
wake (wakes the task from within itself before returning
Poll::Pending).

The same custom self_wake() is also included in the app example so
that it shows self wakes correctly.

Tokio has been updated to 1.28.2 in the lock file (the last with
compatible MSRV) so that this fix is tested.

Ref #512

Part of the testing performed in the `console-subscriber` integration
tests is detecting self wakes. This relied upon the `yield_now()` from
Tokio.

However, the behavior of this function was changed in
tokio-rs/tokio#5223 and since Tokio 1.23 the wake doesn't occur in the
task that `yield_now()` is called from. This breaks the test when using
a newer version of Tokio.

This change replaces the use of `yield_now()` with a custom
`self_wake()` function that returns a future which does perform a self
wake (wakes the task from within itself before returning
`Poll::Pending`).

The same custom `self_wake()` is also included in the `app` example so
that it shows self wakes correctly.

Tokio has been updated to 1.28.2 in the lock file (the last with
compatible MSRV) so that this fix is tested.

Ref #512
@hds hds requested a review from a team as a code owner February 16, 2024 10:57
Copy link
Collaborator

@Rustin170506 Rustin170506 left a comment

Choose a reason for hiding this comment

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

Looks good to me. Thanks! :shipit:

console-subscriber/tests/support/mod.rs Show resolved Hide resolved
console-subscriber/tests/support/mod.rs Show resolved Hide resolved
@hds
Copy link
Collaborator Author

hds commented Feb 20, 2024

@hawkw would you be able to have a look at this one when you get a moment? Thanks!!

@hds hds merged commit b158b05 into main Mar 8, 2024
16 checks passed
@hds hds deleted the hds/tokio-update-self-wakes branch March 8, 2024 10:15
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