mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 11:41:02 +00:00
[Fix] flaky node tests (#1534)
* [Fix] flaky node tests * fix tokio ver * fix errors/warnings * fix more errors * some fixe * fix err * fix arg order for the base path to work properly * comments * remove extra dependencies and waiting for blocks * fix errors * bump sleep
This commit is contained in:
@@ -14,41 +14,20 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use assert_cmd::cargo::cargo_bin;
|
||||
use std::{convert::TryInto, fs, process::Command, thread, time::Duration};
|
||||
use tempfile::tempdir;
|
||||
|
||||
mod common;
|
||||
|
||||
#[test]
|
||||
#[tokio::test]
|
||||
#[cfg(unix)]
|
||||
#[ignore]
|
||||
fn interrupt_polkadot_mdns_issue_test() {
|
||||
use nix::{
|
||||
sys::signal::{
|
||||
kill,
|
||||
Signal::{self, SIGINT, SIGTERM},
|
||||
},
|
||||
unistd::Pid,
|
||||
};
|
||||
async fn interrupt_polkadot_mdns_issue_test() {
|
||||
use nix::sys::signal::Signal::{SIGINT, SIGTERM};
|
||||
|
||||
fn run_command_and_kill(signal: Signal) {
|
||||
let _ = fs::remove_dir_all("interrupt_polkadot_mdns_issue_test");
|
||||
let mut cmd = Command::new(cargo_bin("polkadot-parachain"))
|
||||
.args(&["-d", "interrupt_polkadot_mdns_issue_test", "--", "--dev"])
|
||||
.spawn()
|
||||
.unwrap();
|
||||
let base_dir = tempdir().expect("could not create a temp dir");
|
||||
|
||||
thread::sleep(Duration::from_secs(20));
|
||||
assert!(cmd.try_wait().unwrap().is_none(), "the process should still be running");
|
||||
kill(Pid::from_raw(cmd.id().try_into().unwrap()), signal).unwrap();
|
||||
assert_eq!(
|
||||
common::wait_for(&mut cmd, 30).map(|x| x.success()),
|
||||
Some(true),
|
||||
"the process must exit gracefully after signal {}",
|
||||
signal,
|
||||
);
|
||||
}
|
||||
let args = &["--", "--dev"];
|
||||
|
||||
run_command_and_kill(SIGINT);
|
||||
run_command_and_kill(SIGTERM);
|
||||
common::run_node_for_a_while(base_dir.path(), args, SIGINT).await;
|
||||
common::run_node_for_a_while(base_dir.path(), args, SIGTERM).await;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user