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

Issue #1845: Initial support for Simulation in Tokio #2047

Closed

Conversation

gardnervickers
Copy link
Member

@gardnervickers gardnervickers commented Jan 4, 2020

Opening this draft PR for now to facilitate collaboration in finding a suitable API to expose. Eventually, I think we will want to move the majority of Simulation components outside of the Tokio repository, for now I've included them until we can arrive at a suitable API.

Motivation

More context can be found in #1845

The motivation for this work is to provide support for FoundationDB style simulation testing with Tokio. The goal is to provide users a low friction API for introducing deterministic simulation testing to their existing applications.

Solution

Time

When simulation testing is enabled, the time driver replaces all Park::park_timeout calls to it's inner Park with a Park::park_timeout duration of 0, advancing a mocked clock by the original Park::park_timeout duration. This results in the runtime only advancing time if there are no more tasks which can make progress.

TcpStream and TcpListener

Both the TcpStream and TcpListener have had their internal PollEvented hidden behind an enum which allows for swapping in SimTcpStream and SimTcpListener when under simulation. The calls to construct and register these TCP types have been moved into the I/O driver handle. The I/O driver handle has been made to be based off an enum also, which allows for constructing Simulation types when simulation mode is enabled.

Todo

Aside from settling on an interface for plugging in the Simulation crate, there is quite a bit of work left to cleanup the types, address todo!()'s, fix feature flags, and reintroduce disabled tests. Also, there is no tokio::spawn wrapping yet, and as a result, simulated DNS assumes there is only 1 address, which is localhost.

@LegNeato
Copy link

@gardnervickers did this get merged? If not is a different direction planned?

@LucioFranco
Copy link
Member

@LegNeato yeah, we are still evaluating methods, we have a #simulation channel on discord, feel free to hope in and see where we are at now :)

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.

3 participants