Skip to content

Commit

Permalink
Update docker-compose-runner
Browse files Browse the repository at this point in the history
  • Loading branch information
rukai committed Nov 30, 2023
1 parent c7b908c commit d0fc266
Show file tree
Hide file tree
Showing 8 changed files with 317 additions and 626 deletions.
793 changes: 247 additions & 546 deletions Cargo.lock

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ resolver = "2"

# https://deterministic.space/high-performance-rust.html
[profile.release]
lto = "fat"
#lto = "fat"
codegen-units = 1

[profile.bench]
lto = "fat"
#lto = "fat"
codegen-units = 1

# used for e.g. generating flamegraphs
Expand Down Expand Up @@ -61,8 +61,8 @@ rand_distr = "0.4.1"
clap = { version = "4.0.4", features = ["cargo", "derive"] }
async-trait = "0.1.30"
typetag = "0.2.5"
aws-throwaway = "0.4.0"
aws-throwaway = "0.5.0"
tokio-bin-process = "0.4.0"
ordered-float = { version = "4.0.0", features = ["serde"] }
hyper = { version = "0.14.14", features = ["server"] }
shell-quote = "0.4.0"
shell-quote = { default-features = false, version = "0.5.0" }
6 changes: 0 additions & 6 deletions ec2-cargo/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,6 @@ sudo /bin/docker1 "$@"
' | sudo dd of=/bin/docker
sudo chmod +x /bin/docker
# hack to work around docker-compose command not being present on this machine
echo '#!/bin/bash
docker compose "$@"
' | sudo dd of=/bin/docker-compose
sudo chmod +x /bin/docker-compose
echo "export RUST_BACKTRACE=1" >> .profile
echo "export CARGO_TERM_COLOR=always" >> .profile
echo 'source "$HOME/.cargo/env"' >> .profile
Expand Down
4 changes: 2 additions & 2 deletions shotover-proxy/benches/windsock/aws/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use std::{
path::{Path, PathBuf},
sync::Arc,
};
use test_helpers::docker_compose::get_image_waiters;
use test_helpers::docker_compose::IMAGE_WAITERS;
use tokio::sync::RwLock;
use tokio_bin_process::bin_path;
use tokio_bin_process::event::{Event, Level};
Expand Down Expand Up @@ -218,7 +218,7 @@ sudo docker system prune -af"#,
.ssh()
.shell_stdout_lines(&format!("sudo docker logs -f {container_id} 2>&1"))
.await;
let image_waiter = get_image_waiters()
let image_waiter = IMAGE_WAITERS
.iter()
.find(|x| x.name == image)
.unwrap_or_else(|| {
Expand Down
2 changes: 1 addition & 1 deletion test-helpers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ tracing-subscriber.workspace = true
serde_yaml.workspace = true
anyhow.workspace = true
rcgen.workspace = true
docker-compose-runner = "0.2.0"
rdkafka = { version = "0.36", features = ["cmake-build"], optional = true }
docker-compose-runner = "0.3.0"
114 changes: 56 additions & 58 deletions test-helpers/src/docker_compose.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use docker_compose_runner::*;
use std::env;
use std::{env, time::Duration};
use tracing_subscriber::fmt::TestWriter;

pub use docker_compose_runner::DockerCompose;
Expand All @@ -14,7 +14,7 @@ fn setup_tracing_subscriber_for_test_logic() {

pub fn docker_compose(file_path: &str) -> DockerCompose {
setup_tracing_subscriber_for_test_logic();
DockerCompose::new(get_image_waiters(), |_| {}, file_path)
DockerCompose::new(&IMAGE_WAITERS, |_| {}, file_path)
}

/// Creates a new DockerCompose running an instance of moto the AWS mocking server
Expand All @@ -27,59 +27,57 @@ pub fn new_moto() -> DockerCompose {
docker_compose("tests/transforms/docker-compose-moto.yaml")
}

pub fn get_image_waiters() -> &'static [Image] {
&[
Image {
name: "motoserver/moto",
log_regex_to_wait_for: r"Press CTRL\+C to quit",
timeout: 120,
},
Image {
name: "library/redis:5.0.9",
log_regex_to_wait_for: r"Ready to accept connections",
timeout: 120,
},
Image {
name: "library/redis:6.2.5",
log_regex_to_wait_for: r"Ready to accept connections",
timeout: 120,
},
Image {
name: "bitnami/redis:6.2.13-debian-11-r73",
log_regex_to_wait_for: r"Ready to accept connections",
timeout: 120,
},
Image {
name: "bitnami/redis-cluster:6.2.12-debian-11-r26",
//`Cluster state changed` is created by the node services
//`Cluster correctly created` is created by the init service
log_regex_to_wait_for: r"Cluster state changed|Cluster correctly created",
timeout: 120,
},
Image {
name: "bitnami/cassandra:4.0.6",
log_regex_to_wait_for: r"Startup complete",
timeout: 120,
},
Image {
name: "shotover/cassandra-test:4.0.6-r1",
log_regex_to_wait_for: r"Startup complete",
timeout: 120,
},
Image {
name: "shotover/cassandra-test:3.11.13-r1",
log_regex_to_wait_for: r"Startup complete",
timeout: 120,
},
Image {
name: "bitnami/kafka:3.4.0-debian-11-r22",
log_regex_to_wait_for: r"Kafka Server started",
timeout: 120,
},
Image {
name: "opensearchproject/opensearch:2.9.0",
log_regex_to_wait_for: r"Node started",
timeout: 120,
},
]
}
pub static IMAGE_WAITERS: [Image; 10] = [
Image {
name: "motoserver/moto",
log_regex_to_wait_for: r"Press CTRL\+C to quit",
timeout: Duration::from_secs(120),
},
Image {
name: "library/redis:5.0.9",
log_regex_to_wait_for: r"Ready to accept connections",
timeout: Duration::from_secs(120),
},
Image {
name: "library/redis:6.2.5",
log_regex_to_wait_for: r"Ready to accept connections",
timeout: Duration::from_secs(120),
},
Image {
name: "bitnami/redis:6.2.13-debian-11-r73",
log_regex_to_wait_for: r"Ready to accept connections",
timeout: Duration::from_secs(120),
},
Image {
name: "bitnami/redis-cluster:6.2.12-debian-11-r26",
//`Cluster state changed` is created by the node services
//`Cluster correctly created` is created by the init service
log_regex_to_wait_for: r"Cluster state changed|Cluster correctly created",
timeout: Duration::from_secs(120),
},
Image {
name: "bitnami/cassandra:4.0.6",
log_regex_to_wait_for: r"Startup complete",
timeout: Duration::from_secs(120),
},
Image {
name: "shotover/cassandra-test:4.0.6-r1",
log_regex_to_wait_for: r"Startup complete",
timeout: Duration::from_secs(120),
},
Image {
name: "shotover/cassandra-test:3.11.13-r1",
log_regex_to_wait_for: r"Startup complete",
timeout: Duration::from_secs(120),
},
Image {
name: "bitnami/kafka:3.4.0-debian-11-r22",
log_regex_to_wait_for: r"Kafka Server started",
timeout: Duration::from_secs(120),
},
Image {
name: "opensearchproject/opensearch:2.9.0",
log_regex_to_wait_for: r"Node started",
timeout: Duration::from_secs(120),
},
];
2 changes: 1 addition & 1 deletion windsock/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ tokio.workspace = true

[dev-dependencies]
scylla = { version = "0.10.0", features = ["ssl"] }
docker-compose-runner = "0.2.0"
docker-compose-runner = "0.3.0"
14 changes: 6 additions & 8 deletions windsock/examples/cassandra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,14 @@ impl BenchTask for BenchTaskCassandra {
}

fn docker_compose(file_path: &str) -> DockerCompose {
DockerCompose::new(get_image_waiters(), |_| {}, file_path)
DockerCompose::new(&IMAGE_WAITERS, |_| {}, file_path)
}

fn get_image_waiters() -> &'static [Image] {
&[Image {
name: "bitnami/cassandra:4.0.6",
log_regex_to_wait_for: r"Startup complete",
timeout: 120,
}]
}
static IMAGE_WAITERS: [Image; 1] = [Image {
name: "bitnami/cassandra:4.0.6",
log_regex_to_wait_for: r"Startup complete",
timeout: Duration::from_secs(120),
}];

fn set_working_dir() {
// tests and benches will set the directory to the directory of the crate, we are acting as a benchmark so we do the same
Expand Down

0 comments on commit d0fc266

Please sign in to comment.