Skip to content

Commit

Permalink
Add a retry to dump-restore tests (#1444)
Browse files Browse the repository at this point in the history
  • Loading branch information
aljazerzen authored Jan 24, 2025
1 parent d5ab75b commit 1bc086e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 24 deletions.
18 changes: 9 additions & 9 deletions flake.lock

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

38 changes: 23 additions & 15 deletions tests/func/dump_restore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,43 +67,52 @@ fn dump_all_without_a_format() {

#[test]
fn dump_restore_all() {
println!("before");
SERVER
.admin_cmd()
.arg("database")
.arg("create")
.arg("dump_02")
.assert()
.success();
println!("dbcreated");
SERVER
.database_cmd("dump_02")
.arg("query")
.arg("CREATE TYPE Hello { CREATE REQUIRED PROPERTY name -> str; }")
.arg("INSERT Hello { name := 'world' }")
.assert()
.success();
println!("Created");
SERVER
.admin_cmd()
.arg("dump")
.arg("--all")
.arg("--format=dir")
.arg("./tmp/dump_02")
.assert()
.success();
println!("dumped");

// dump all databases

// This might fail if a database gets deleted during the dump
// so we retry 5 times.
// We could instead spawn a new edgedb server to increase isolation,
// but that would slow tests down and they are slow enough already.
let mut retry = 0;
let res = loop {
let r = SERVER
.admin_cmd()
.arg("dump")
.arg("--all")
.arg("--format=dir")
.arg("./tmp/dump_02")
.ok();
if r.is_err() && retry < 5 {
retry += 1;
continue;
}
break r;
};
res.unwrap();

let new_instance = ServerGuard(ServerInstance::start());
println!("new instance started");
new_instance
.admin_cmd()
.arg("restore")
.arg("--all")
.arg("./tmp/dump_02")
.assert()
.success();
println!("restored");

new_instance
.database_cmd("dump_02")
Expand All @@ -113,5 +122,4 @@ fn dump_restore_all() {
.success()
.stdout("\"world\"\n");
new_instance.0.stop();
println!("query");
}

0 comments on commit 1bc086e

Please sign in to comment.