mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 13:57:58 +00:00
Retire puppet workers (#1449)
Closes #583 After the separation of PVF worker binaries, dedicated puppet workers are not needed for tests anymore. The production workers can be used instead, avoiding some code duplication and decreasing complexity. The changes also make it possible to further refactor the code to isolate workers completely.
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
# PVF host integration tests
|
||||
|
||||
## Testing
|
||||
|
||||
Before running these tests, make sure the worker binaries are built first. This can be done with:
|
||||
|
||||
```sh
|
||||
cargo build --bin polkadot-execute-worker --bin polkadot-prepare-worker
|
||||
```
|
||||
@@ -33,7 +33,6 @@ use tokio::sync::Mutex;
|
||||
mod adder;
|
||||
mod worker_common;
|
||||
|
||||
const PUPPET_EXE: &str = env!("CARGO_BIN_EXE_puppet_worker");
|
||||
const TEST_EXECUTION_TIMEOUT: Duration = Duration::from_secs(3);
|
||||
const TEST_PREPARATION_TIMEOUT: Duration = Duration::from_secs(3);
|
||||
|
||||
@@ -51,10 +50,20 @@ impl TestHost {
|
||||
where
|
||||
F: FnOnce(&mut Config),
|
||||
{
|
||||
let mut workers_path = std::env::current_exe().unwrap();
|
||||
workers_path.pop();
|
||||
workers_path.pop();
|
||||
let mut prepare_worker_path = workers_path.clone();
|
||||
prepare_worker_path.push("polkadot-prepare-worker");
|
||||
let mut execute_worker_path = workers_path.clone();
|
||||
execute_worker_path.push("polkadot-execute-worker");
|
||||
let cache_dir = tempfile::tempdir().unwrap();
|
||||
let program_path = std::path::PathBuf::from(PUPPET_EXE);
|
||||
let mut config =
|
||||
Config::new(cache_dir.path().to_owned(), None, program_path.clone(), program_path);
|
||||
let mut config = Config::new(
|
||||
cache_dir.path().to_owned(),
|
||||
None,
|
||||
prepare_worker_path,
|
||||
execute_worker_path,
|
||||
);
|
||||
f(&mut config);
|
||||
let (host, task) = start(config, Metrics::default());
|
||||
let _ = tokio::task::spawn(task);
|
||||
|
||||
@@ -14,26 +14,41 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use polkadot_node_core_pvf::testing::{spawn_with_program_path, SpawnErr};
|
||||
use std::time::Duration;
|
||||
|
||||
use polkadot_node_core_pvf::testing::{spawn_with_program_path, SpawnErr};
|
||||
|
||||
use crate::PUPPET_EXE;
|
||||
fn worker_path(name: &str) -> std::path::PathBuf {
|
||||
let mut worker_path = std::env::current_exe().unwrap();
|
||||
worker_path.pop();
|
||||
worker_path.pop();
|
||||
worker_path.push(name);
|
||||
worker_path
|
||||
}
|
||||
|
||||
// Test spawning a program that immediately exits with a failure code.
|
||||
#[tokio::test]
|
||||
async fn spawn_immediate_exit() {
|
||||
let result =
|
||||
spawn_with_program_path("integration-test", PUPPET_EXE, &["exit"], Duration::from_secs(2))
|
||||
.await;
|
||||
// There's no explicit `exit` subcommand in the worker; it will panic on an unknown
|
||||
// subcommand anyway
|
||||
let result = spawn_with_program_path(
|
||||
"integration-test",
|
||||
worker_path("polkadot-prepare-worker"),
|
||||
&["exit"],
|
||||
Duration::from_secs(2),
|
||||
)
|
||||
.await;
|
||||
assert!(matches!(result, Err(SpawnErr::AcceptTimeout)));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn spawn_timeout() {
|
||||
let result =
|
||||
spawn_with_program_path("integration-test", PUPPET_EXE, &["sleep"], Duration::from_secs(2))
|
||||
.await;
|
||||
let result = spawn_with_program_path(
|
||||
"integration-test",
|
||||
worker_path("polkadot-execute-worker"),
|
||||
&["test-sleep"],
|
||||
Duration::from_secs(2),
|
||||
)
|
||||
.await;
|
||||
assert!(matches!(result, Err(SpawnErr::AcceptTimeout)));
|
||||
}
|
||||
|
||||
@@ -41,7 +56,7 @@ async fn spawn_timeout() {
|
||||
async fn should_connect() {
|
||||
let _ = spawn_with_program_path(
|
||||
"integration-test",
|
||||
PUPPET_EXE,
|
||||
worker_path("polkadot-prepare-worker"),
|
||||
&["prepare-worker"],
|
||||
Duration::from_secs(2),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user