Skip to content

Commit 2ffd4b3

Browse files
committed
Add turmoil test: integrity_check defaults full=false when field omitted
Protects the documented API contract: POST /v1/namespaces/:ns/integrity-check with an empty body {} must default to quick_check. This lets older or simpler clients omit the field entirely. Complements the existing integrity_check_on_healthy_namespace test which only covers explicit full:true/full:false. 5 reset-replication + integrity-check turmoil tests all pass.
1 parent b157328 commit 2ffd4b3

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

  • libsql-server/tests/namespaces

libsql-server/tests/namespaces/mod.rs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,50 @@ fn reset_replication_on_nonexistent_namespace_returns_404() {
303303
sim.run().unwrap();
304304
}
305305

306+
#[test]
307+
fn integrity_check_defaults_to_quick_when_full_omitted() {
308+
// Verifies backward compatibility: if the request body is {} (no
309+
// `full` field), the server defaults to quick_check. This preserves
310+
// the contract for any older/simpler client that doesn't send the
311+
// field, and is also the documented default in the admin API.
312+
let mut sim = Builder::new()
313+
.simulation_duration(Duration::from_secs(1000))
314+
.build();
315+
let tmp = tempdir().unwrap();
316+
make_primary(&mut sim, tmp.path().to_path_buf());
317+
318+
sim.client("client", async {
319+
let client = Client::new();
320+
client
321+
.post("http://primary:9090/v1/namespaces/defchk/create", json!({}))
322+
.await?;
323+
324+
let db = Database::open_remote_with_connector(
325+
"http://defchk.primary:8080",
326+
"",
327+
TurmoilConnector,
328+
)?;
329+
let conn = db.connect()?;
330+
conn.execute("create table t(v text)", ()).await?;
331+
332+
// Empty body: no `full` field at all.
333+
let resp = client
334+
.post(
335+
"http://primary:9090/v1/namespaces/defchk/integrity-check",
336+
json!({}),
337+
)
338+
.await?;
339+
assert_eq!(resp.status(), hyper::http::StatusCode::OK);
340+
let v = resp.json_value().await?;
341+
assert_eq!(v["ok"], json!(true));
342+
assert_eq!(v["check"], json!("quick"));
343+
344+
Ok(())
345+
});
346+
347+
sim.run().unwrap();
348+
}
349+
306350
#[test]
307351
fn reset_replication_is_idempotent() {
308352
// An operator (or the streamer's retry-after-reset path) may call

0 commit comments

Comments
 (0)