Skip to content

Commit f417e7c

Browse files
authored
feat(stresstest): TTL after 1h and make cleanup configurable (#223)
Stresstests are frequently canceled or crash as we test objectstore's limits. This leaves objects in the backends permanently. To fix this, we now configure a default 1h TTL for all objects created by the stresstest. Since we can usually rely on that TTL, we no longer have to run the cleanup. This saves significant time, as the deletions usually take longer than the test itself. To make configuration and usage a bit easier, the stresstest is now converted to the command pattern.
1 parent e840bb8 commit f417e7c

File tree

6 files changed

+239
-136
lines changed

6 files changed

+239
-136
lines changed

objectstore-server/tests/stresstest.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ use std::time::Duration;
33

44
use nix::sys::signal::{self, Signal};
55
use nix::unistd::Pid;
6-
use stresstest::Workload;
76
use stresstest::http::HttpRemote;
7+
use stresstest::{Stresstest, Workload};
88

99
const OBJECTSTORE_EXE: &str = env!("CARGO_BIN_EXE_objectstore");
1010

@@ -60,7 +60,11 @@ async fn test_basic() {
6060
.action_weights(8, 1, 1)
6161
.build();
6262

63-
stresstest::run(remote, vec![workload], Duration::from_secs(2))
63+
Stresstest::new(remote)
64+
.duration(Duration::from_secs(2))
65+
.workload(workload)
66+
.cleanup(true)
67+
.run()
6468
.await
6569
.expect("Failed to run stress test");
6670

stresstest/src/config.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ pub struct Config {
1212
pub duration: Duration,
1313

1414
pub workloads: Vec<Workload>,
15+
16+
#[serde(default)]
17+
pub cleanup: bool,
1518
}
1619

1720
#[derive(Debug, Deserialize)]

stresstest/src/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,16 @@
1212
//!
1313
//! *Read* or *delete* actions are using a *zipfian* distribution, meaning that
1414
//! more recently written blobs are the ones that will be read/deleted.
15+
//!
16+
//! To run a stresstest, instantiate the [`Stresstest`] struct with a remote backend
17+
//! implementation, such as the [`HttpRemote`](http::HttpRemote) and configure it with
18+
//! the desired duration and workload.
1519
#![warn(missing_docs)]
1620
#![warn(missing_debug_implementations)]
1721

1822
pub mod http;
1923
pub mod stresstest;
2024
pub mod workload;
2125

22-
pub use crate::stresstest::run;
26+
pub use crate::stresstest::Stresstest;
2327
pub use crate::workload::Workload;

stresstest/src/main.rs

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use anyhow::Context;
2121
use argh::FromArgs;
2222
use stresstest::Workload;
2323
use stresstest::http::HttpRemote;
24+
use stresstest::stresstest::Stresstest;
2425

2526
use crate::config::Config;
2627

@@ -46,22 +47,23 @@ async fn main() -> anyhow::Result<()> {
4647
serde_yaml::from_reader(config_file).context("failed to parse config YAML")?;
4748

4849
let remote = HttpRemote::new(&config.remote);
50+
let mut stresstest = Stresstest::new(remote)
51+
.duration(config.duration)
52+
.cleanup(config.cleanup);
4953

50-
let workloads = config
51-
.workloads
52-
.into_iter()
53-
.map(|w| {
54-
Workload::builder(w.name)
55-
.concurrency(w.concurrency)
56-
.organizations(w.organizations)
57-
.mode(w.mode)
58-
.size_distribution(w.file_sizes.p50.0, w.file_sizes.p99.0)
59-
.action_weights(w.actions.writes, w.actions.reads, w.actions.deletes)
60-
.build()
61-
})
62-
.collect();
54+
for w in config.workloads {
55+
let workload = Workload::builder(w.name)
56+
.concurrency(w.concurrency)
57+
.organizations(w.organizations)
58+
.mode(w.mode)
59+
.size_distribution(w.file_sizes.p50.0, w.file_sizes.p99.0)
60+
.action_weights(w.actions.writes, w.actions.reads, w.actions.deletes)
61+
.build();
6362

64-
stresstest::run(remote, workloads, config.duration).await?;
63+
stresstest = stresstest.workload(workload);
64+
}
65+
66+
stresstest.run().await?;
6567

6668
Ok(())
6769
}

0 commit comments

Comments
 (0)