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

Use single thread Tokio runtime for tests #2916

Merged
merged 2 commits into from
Oct 21, 2021

Conversation

jvff
Copy link
Contributor

@jvff jvff commented Oct 20, 2021

Motivation

This is part of the update to use Tokio version 1 (#2200), but can be merged separately.

Newer versions of Tokio panic if tokio::time::pause() is called from a multi-thread executor, so tests should be updated so that doesn't happen.

Solution

Since #[tokio::test] defaults to a single thread runtime, it makes sense to always use a single thread runtime in all tests unless there's a need for a multi-thread executor.

Review

Anyone from the team can review this.

Reviewer Checklist

  • Code implements Specs and Designs
  • Tests for Expected Behaviour
  • Tests for Errors

Follow Up Work

Newer versions of Tokio panic if `tokio::time::pause()` is called from a
multi-thread executor, and `#[tokio::test]` defaults to a single thread
runtime, so it makes sense to always use a single thread runtime in all
tests.
@jvff jvff requested a review from a team October 20, 2021 19:21
@zfnd-bot zfnd-bot bot assigned jvff Oct 20, 2021
Copy link
Contributor

@dconnolly dconnolly left a comment

Choose a reason for hiding this comment

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

lgtm!

@dconnolly dconnolly added the A-rust Area: Updates to Rust code label Oct 20, 2021
@dconnolly dconnolly added this to the 2021 Sprint 21 milestone Oct 20, 2021
Copy link
Contributor

@teor2345 teor2345 left a comment

Choose a reason for hiding this comment

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

I think you might have skipped a few multi-threaded runtimes that don't panic:
https://github.com/ZcashFoundation/zebra/search?q=Runtime

I think that's a good idea to reduce the risk of unexpected test bugs.
But can you open a follow-up ticket to get rid of all instances of Runtime::new and similar?

@jvff
Copy link
Contributor Author

jvff commented Oct 21, 2021

I opened #2927 to track updating all tests.

@jvff jvff enabled auto-merge (squash) October 21, 2021 15:40
@jvff jvff merged commit 39ed7d7 into ZcashFoundation:main Oct 21, 2021
@jvff jvff deleted the use-current-thread-runtime-in-tests branch October 21, 2021 16:22
@mpguerra mpguerra removed this from the 2021 Sprint 21 milestone Oct 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rust Area: Updates to Rust code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants