This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Add a feature to create automatically a random temporary directory for base path & remove Clone
#6221
Merged
Merged
Add a feature to create automatically a random temporary directory for base path & remove Clone
#6221
Changes from 16 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
7fbed1b
Initial commit
cecton aa518e4
Add a feature to create automatically a temporary directory for base …
cecton 5338633
doc fix and todos
cecton baf6ad2
use parking_lot instead
cecton 179dda3
use refcell instead since we stay in the main thread
cecton 2aea88f
remove Clone derives
cecton b6358e8
add test
cecton f81522d
solving dependency issue
cecton 55ed555
clarifying doc
cecton cfc6fa4
conflict argument with base-path
cecton 5a5c546
WIP
cecton bf1da7e
Merge commit f028a509789289a34c468f42b4361c49279893f2 (no conflict)
cecton 68dfe89
revert dep deletion
cecton 898dcd6
fixing test and making base_path optional
cecton d26da87
hold basepath while the service is running
cecton 9c6f71a
fixes
cecton 9e989de
Update client/cli/src/params/shared_params.rs
cecton c811cb6
Update client/service/Cargo.toml
cecton 65cb074
Update client/cli/src/commands/mod.rs
cecton fdb3f20
Update client/service/src/config.rs
cecton 39bc022
WIP
cecton cb140b6
improve doc
cecton ca42803
Merge commit 252b146b43e3877aefae6afd5c9a9e6093c5d7a9 (no conflict)
cecton 468f16a
Merge commit 9ce077465ac46a93ebaced4b47863952b3d63d33 (conflicts)
cecton 49cfe00
Merge commit d68cfd7cd5c64cb0965b49d9868aff02849e077c (no conflict)
cecton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// This file is part of Substrate. | ||
|
||
// Copyright (C) 2020 Parity Technologies (UK) Ltd. | ||
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 | ||
|
||
// This program 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. | ||
|
||
// This program 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 this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
#![cfg(unix)] | ||
|
||
use assert_cmd::cargo::cargo_bin; | ||
use nix::sys::signal::{kill, Signal::SIGINT}; | ||
use nix::unistd::Pid; | ||
use regex::Regex; | ||
use std::convert::TryInto; | ||
use std::io::Read; | ||
use std::path::PathBuf; | ||
use std::process::{Command, Stdio}; | ||
use std::thread; | ||
use std::time::Duration; | ||
|
||
pub mod common; | ||
|
||
#[test] | ||
fn temp_base_path_works() { | ||
let mut cmd = Command::new(cargo_bin("substrate")); | ||
|
||
let mut cmd = cmd | ||
.args(&["--dev", "--tmp"]) | ||
.stdout(Stdio::piped()) | ||
.stderr(Stdio::piped()) | ||
.spawn() | ||
.unwrap(); | ||
|
||
// Let it produce some blocks. | ||
thread::sleep(Duration::from_secs(30)); | ||
assert!( | ||
cmd.try_wait().unwrap().is_none(), | ||
"the process should still be running" | ||
); | ||
|
||
// Stop the process | ||
kill(Pid::from_raw(cmd.id().try_into().unwrap()), SIGINT).unwrap(); | ||
assert!(common::wait_for(&mut cmd, 40) | ||
.map(|x| x.success()) | ||
.unwrap_or_default()); | ||
|
||
// Ensure the database has been deleted | ||
let mut stderr = String::new(); | ||
cmd.stderr.unwrap().read_to_string(&mut stderr).unwrap(); | ||
let re = Regex::new(r"Database: .+ at (\S+)").unwrap(); | ||
let db_path = PathBuf::from( | ||
re.captures(stderr.as_str()) | ||
.unwrap() | ||
.get(1) | ||
.unwrap() | ||
.as_str() | ||
.to_string(), | ||
); | ||
|
||
assert!(!db_path.exists()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I think these are all wrong. sc-cli should probably make a hidden re-export of
sc_service
and the macro should get it from there.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that is right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will make another PR for that for the sake of having isolated commits per change