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

Add simulation testing via turmoil #113

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
165 changes: 146 additions & 19 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ name = "mini-redis-server"
path = "src/bin/server.rs"

[dependencies]
async-trait = "0.1"
async-stream = "0.3.0"
atoi = "0.3.2"
bytes = "1"
Expand All @@ -39,10 +40,14 @@ tracing-opentelemetry = { version = "0.17.2", optional = true }
opentelemetry-aws = { version = "0.5.0", optional = true }
# Allows you to send data to the OTel collector
opentelemetry-otlp = { version = "0.10.0", optional = true }
# Optional depedency used for simulation testing
turmoil = { version = "0.4", optional = true }

[dev-dependencies]
# Enable test-utilities in dev mode only. This is mostly for tests.
tokio = { version = "1", features = ["test-util"] }

[features]
otel = ["dep:opentelemetry", "dep:tracing-opentelemetry", "dep:opentelemetry-aws", "dep:opentelemetry-otlp"]
sim = ["dep:turmoil"]

6 changes: 3 additions & 3 deletions src/blocking_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

use bytes::Bytes;
use std::time::Duration;
use tokio::net::ToSocketAddrs;
use tokio::runtime::Runtime;
use tokio::{net::ToSocketAddrs, runtime::Runtime};

use crate::client;
pub use crate::client::Message;

/// Established connection with a Redis server.
Expand Down Expand Up @@ -74,7 +74,7 @@ pub fn connect<T: ToSocketAddrs>(addr: T) -> crate::Result<BlockingClient> {
.enable_all()
.build()?;

let inner = rt.block_on(crate::client::connect(addr))?;
let inner = rt.block_on(client::connect(addr))?;

Ok(BlockingClient { inner, rt })
}
Expand Down
Loading