Change CLI command 'pg stop' to avoid races in tests.

Stop postgres immediately only when destroy option is used. Otherwise, use default shutdown mode (fast).
This commit is contained in:
anastasia
2021-09-07 19:46:50 +03:00
committed by Stas Kelvich
parent d7313bb85c
commit 5488ce8834

View File

@@ -482,13 +482,15 @@ impl PostgresNode {
}
pub fn stop(&self, destroy: bool) -> Result<()> {
self.pg_ctl(&["-m", "immediate", "stop"], &None)?;
if destroy {
self.pg_ctl(&["-m", "immediate", "stop"], &None)?;
println!(
"Destroying postgres data directory '{}'",
self.pgdata().to_str().unwrap()
);
fs::remove_dir_all(&self.pgdata())?;
} else {
self.pg_ctl(&["stop"], &None)?;
}
Ok(())
}