Browse Source

cli: Kill test validator if it starts too slowly. (#809)

Alan O'Donnell 4 years ago
parent
commit
5ba8252ccc
1 changed files with 4 additions and 3 deletions
  1. 4 3
      cli/src/lib.rs

+ 4 - 3
cli/src/lib.rs

@@ -1585,7 +1585,7 @@ fn start_test_validator(cfg: &Config, flags: Option<Vec<String>>) -> Result<Chil
     // Start a validator for testing.
     // Start a validator for testing.
     let test_validator_stdout = File::create(test_ledger_log_filename)?;
     let test_validator_stdout = File::create(test_ledger_log_filename)?;
     let test_validator_stderr = test_validator_stdout.try_clone()?;
     let test_validator_stderr = test_validator_stdout.try_clone()?;
-    let validator_handle = std::process::Command::new("solana-test-validator")
+    let mut validator_handle = std::process::Command::new("solana-test-validator")
         .arg("--ledger")
         .arg("--ledger")
         .arg(test_ledger_filename)
         .arg(test_ledger_filename)
         .arg("--mint")
         .arg("--mint")
@@ -1608,8 +1608,9 @@ fn start_test_validator(cfg: &Config, flags: Option<Vec<String>>) -> Result<Chil
         std::thread::sleep(std::time::Duration::from_millis(1));
         std::thread::sleep(std::time::Duration::from_millis(1));
         count += 1;
         count += 1;
     }
     }
-    if count == 5000 {
-        println!("Unable to start test validator.");
+    if count == ms_wait {
+        eprintln!("Unable to start test validator.");
+        validator_handle.kill();
         std::process::exit(1);
         std::process::exit(1);
     }
     }