Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -235,15 +235,6 @@ check-web-wasm:
- time cargo build --manifest-path=bin/node/cli/Cargo.toml --no-default-features --features "browser" --target=wasm32-unknown-unknown
- sccache -s

node-exits:
stage: test
<<: *docker-env
except:
- /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1
script:
- ./.maintain/check_for_exit.sh


test-full-crypto-feature:
stage: test
<<: *docker-env
Expand Down
16 changes: 0 additions & 16 deletions .maintain/check_for_exit.sh

This file was deleted.

74 changes: 73 additions & 1 deletion Cargo.lock

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

3 changes: 1 addition & 2 deletions bin/node-template/node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ pub fn run(version: VersionInfo) -> error::Result<()>
{
let opt = sc_cli::from_args::<Cli>(&version);

let mut config = sc_service::Configuration::default();
config.impl_name = "node-template";
let config = sc_service::Configuration::new(&version);

match opt.subcommand {
Some(subcommand) => sc_cli::run_subcommand(
Expand Down
2 changes: 2 additions & 0 deletions bin/node/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ sc-consensus-babe = { version = "0.8", features = ["test-helpers"], path = "../.
sc-service-test = { version = "2.0.0", path = "../../../client/service/test" }
futures = "0.3.1"
tempfile = "3.1.0"
assert_cmd = "0.12"
nix = "0.17"

[build-dependencies]
build-script-utils = { version = "2.0.0", package = "substrate-build-script-utils", path = "../../../utils/build-script-utils" }
Expand Down
7 changes: 3 additions & 4 deletions bin/node/cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ where
let args: Vec<_> = args.collect();
let opt = sc_cli::from_iter::<Cli, _>(args.clone(), &version);

let mut config = sc_service::Configuration::default();
config.impl_name = "substrate-node";
let mut config = sc_service::Configuration::new(&version);

match opt.subcommand {
None => sc_cli::run(
Expand All @@ -41,8 +40,8 @@ where
&version,
),
Some(Subcommand::Factory(cli_args)) => {
sc_cli::init(&mut config, load_spec, &cli_args.shared_params, &version)?;

sc_cli::init(&cli_args.shared_params, &version)?;
sc_cli::load_spec(&mut config, &cli_args.shared_params, load_spec)?;
sc_cli::fill_import_params(
&mut config,
&cli_args.import_params,
Expand Down
58 changes: 58 additions & 0 deletions bin/node/cli/tests/running_the_node_and_interrupt.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Copyright 2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.

// Substrate is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// Substrate is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// 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;
use std::process::{Child, Command, ExitStatus};
use std::thread::sleep;
use std::time::Duration;

#[test]
#[cfg(unix)]
fn running_the_node_works_and_can_be_interrupted() {
use nix::sys::signal::{kill, Signal::{self, SIGINT, SIGTERM}};
use nix::unistd::Pid;

fn wait_for(child: &mut Child, secs: usize) -> Option<ExitStatus> {
for _ in 0..secs {
match child.try_wait().unwrap() {
Some(status) => return Some(status),
None => sleep(Duration::from_secs(1)),
}
}
eprintln!("Took to long to exit. Killing...");
let _ = child.kill();
child.wait().unwrap();

None
}

fn run_command_and_kill(signal: Signal) {
let mut cmd = Command::new(cargo_bin("substrate")).spawn().unwrap();
sleep(Duration::from_secs(30));
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!(
wait_for(&mut cmd, 30).map(|x| x.success()),
Some(true),
"the pocess must exit gracefully after signal {}",
signal,
);
}

run_command_and_kill(SIGINT);
run_command_and_kill(SIGTERM);
}
Loading