Skip to content
Merged
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
34 changes: 34 additions & 0 deletions score/kvs/rust_kvs/tests/test_scenarios/cit/persistency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,39 @@ impl Scenario for SetAndFlush {
}
}

/// Flush a one-character string, then a string of "large_value_bytes" characters.
///
/// Log "small_flush_ok", true if the first flush succeeded.
/// Log "large_flush", "ok" if the second flush succeeded, else the name of its error code.
struct FlushStorageLimit;

impl Scenario for FlushStorageLimit {
fn name(&self) -> &str {
"flush_storage_limit"
}

fn run(&self, input: &str) -> Result<(), String> {
let v: Value = serde_json::from_str(input).expect("Failed to parse input string");
let large_value_bytes: usize = serde_json::from_value(v["large_value_bytes"].clone())
.expect("Failed to parse \"large_value_bytes\" field");
let params = KvsParameters::from_value(&v).expect("Failed to parse parameters");
let kvs = kvs_instance(params).expect("Failed to create KVS instance");

kvs.set_value("small", "s").expect("Failed to set small");
info!(small_flush_ok = kvs.flush().is_ok());

kvs.set_value("large", "l".repeat(large_value_bytes))
.expect("Failed to set large");
let large_flush = match kvs.flush() {
Ok(()) => "ok".to_string(),
Err(e) => format!("{e:?}"),
};
info!(large_flush);

Ok(())
}
}

pub fn persistency_group() -> Box<dyn ScenarioGroup> {
Box::new(ScenarioGroupImpl::new(
"persistency",
Expand All @@ -413,6 +446,7 @@ pub fn persistency_group() -> Box<dyn ScenarioGroup> {
Box::new(RecoverFromSnapshot),
Box::new(FailedFlush),
Box::new(SetAndFlush),
Box::new(FlushStorageLimit),
],
vec![],
))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ pub fn kvs_instance(kvs_parameters: KvsParameters) -> Result<Kvs, ErrorCode> {
set_backend = true;
}

// Rust has no storage size limit (#810), so "max_storage_bytes" is not applied.
let _ = kvs_parameters.max_storage_bytes;

// Set backend, if backend parameters were provided.
if set_backend {
builder = builder.backend(Box::new(backend_builder.build()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pub struct KvsParameters {
pub kvs_load: Option<KvsLoad>,
pub dir: Option<PathBuf>,
pub snapshot_max_count: Option<usize>,
pub max_storage_bytes: Option<usize>,
}

impl KvsParameters {
Expand Down
Loading
Loading