Fix: CI failing for some CLI tests (#5043)

* Initial commit

Forked at: ad90ab7ec9
Parent branch: origin/master

* Increase killing grace period of CLI tests and display more info

* Use --dev everywhere possible

* Put pruning mode to its own params struct

* Add pruning params to export-blocks command

* Added missing file

* Removed not-dev mode in tests

* Add pruning mode to the revert command

* Decrease killing grace period again

* Move back unsafe_pruning to import_params

* Applied proposed changes
This commit is contained in:
Cecile Tonglet
2020-02-25 15:48:50 +01:00
committed by GitHub
parent 6abed97394
commit 2478046021
10 changed files with 112 additions and 56 deletions
@@ -26,10 +26,10 @@ mod common;
fn check_block_works() {
let base_path = tempdir().expect("could not create a temp dir");
common::run_command_for_a_while(base_path.path(), false);
common::run_dev_node_for_a_while(base_path.path());
let status = Command::new(cargo_bin("substrate"))
.args(&["check-block", "-d"])
.args(&["check-block", "--dev", "--pruning", "archive", "-d"])
.arg(base_path.path())
.arg("1")
.status()
+10 -8
View File
@@ -27,13 +27,18 @@ use nix::unistd::Pid;
///
/// Returns the `Some(exit status)` or `None` if the process did not finish in the given time.
pub fn wait_for(child: &mut Child, secs: usize) -> Option<ExitStatus> {
for _ in 0..secs {
for i in 0..secs {
match child.try_wait().unwrap() {
Some(status) => return Some(status),
Some(status) => {
if i > 5 {
eprintln!("Child process took {} seconds to exit gracefully", i);
}
return Some(status)
},
None => thread::sleep(Duration::from_secs(1)),
}
}
eprintln!("Took to long to exit. Killing...");
eprintln!("Took too long to exit (> {} seconds). Killing...", secs);
let _ = child.kill();
child.wait().unwrap();
@@ -41,14 +46,11 @@ pub fn wait_for(child: &mut Child, secs: usize) -> Option<ExitStatus> {
}
/// Run the node for a while (30 seconds)
pub fn run_command_for_a_while(base_path: &Path, dev: bool) {
pub fn run_dev_node_for_a_while(base_path: &Path) {
let mut cmd = Command::new(cargo_bin("substrate"));
if dev {
cmd.arg("--dev");
}
let mut cmd = cmd
.args(&["--dev"])
.arg("-d")
.arg(base_path)
.spawn()
@@ -27,10 +27,10 @@ fn import_export_and_revert_work() {
let base_path = tempdir().expect("could not create a temp dir");
let exported_blocks = base_path.path().join("exported_blocks");
common::run_command_for_a_while(base_path.path(), false);
common::run_dev_node_for_a_while(base_path.path());
let status = Command::new(cargo_bin("substrate"))
.args(&["export-blocks", "-d"])
.args(&["export-blocks", "--dev", "--pruning", "archive", "-d"])
.arg(base_path.path())
.arg(&exported_blocks)
.status()
@@ -43,7 +43,7 @@ fn import_export_and_revert_work() {
let _ = fs::remove_dir_all(base_path.path().join("db"));
let status = Command::new(cargo_bin("substrate"))
.args(&["import-blocks", "-d"])
.args(&["import-blocks", "--dev", "--pruning", "archive", "-d"])
.arg(base_path.path())
.arg(&exported_blocks)
.status()
@@ -51,7 +51,7 @@ fn import_export_and_revert_work() {
assert!(status.success());
let status = Command::new(cargo_bin("substrate"))
.args(&["revert", "-d"])
.args(&["revert", "--dev", "--pruning", "archive", "-d"])
.arg(base_path.path())
.status()
.unwrap();
@@ -26,10 +26,10 @@ mod common;
fn inspect_works() {
let base_path = tempdir().expect("could not create a temp dir");
common::run_command_for_a_while(base_path.path(), false);
common::run_dev_node_for_a_while(base_path.path());
let status = Command::new(cargo_bin("substrate"))
.args(&["inspect", "-d"])
.args(&["inspect", "--dev", "--pruning", "archive", "-d"])
.arg(base_path.path())
.args(&["block", "1"])
.status()
@@ -25,7 +25,7 @@ mod common;
fn purge_chain_works() {
let base_path = tempdir().expect("could not create a temp dir");
common::run_command_for_a_while(base_path.path(), true);
common::run_dev_node_for_a_while(base_path.path());
let status = Command::new(cargo_bin("substrate"))
.args(&["purge-chain", "--dev", "-d"])