Skip to content

Commit

Permalink
Feat/process manager (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
l0r1s authored Oct 11, 2023
1 parent 3807ece commit d1354c7
Show file tree
Hide file tree
Showing 19 changed files with 1,730 additions and 563 deletions.
11 changes: 3 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,8 @@ jobs:
- name: Build
run: cargo build

- name: Tests (except provider crate)
run: cargo test --workspace --exclude provider

- name: Tests (provider crate)
# there should be a unique test thread for native provider tests (asserting spawned processes count)
run: cargo test -p provider -- --test-threads 1
- name: Tests
run: cargo test --workspace

coverage:
name: Zombienet SDK - coverage
Expand All @@ -64,8 +60,7 @@ jobs:
uses: taiki-e/install-action@cargo-llvm-cov

- name: Collect coverage data
# there should be a unique test thread for native provider tests (asserting spawned processes count)
run: cargo llvm-cov nextest -j 1 --lcov --output-path lcov.info
run: cargo llvm-cov nextest --lcov --output-path lcov.info

- name: Report code coverage
uses: Nef10/[email protected]
Expand Down
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ multiaddr = "0.18"
url = "2.3"
uuid = "1.4"
nix = "0.27"
procfs = "0.15"
pest = "2.7"
pest_derive = "2.7"
rand = "0.8"
Expand Down
5 changes: 3 additions & 2 deletions crates/examples/examples/simple_network_example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@
use configuration::NetworkConfig;
use orchestrator::Orchestrator;
use provider::NativeProvider;
use support::fs::local::LocalFileSystem;
use support::{fs::local::LocalFileSystem, process::os::OsProcessManager};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let config = NetworkConfig::load_from_toml("./crates/examples/examples/0001-simple.toml")
.expect("errored?");

let fs = LocalFileSystem;
let provider = NativeProvider::new(fs.clone());
let pm = OsProcessManager;
let provider = NativeProvider::new(fs.clone(), pm);
let orchestrator = Orchestrator::new(fs, provider);
orchestrator.spawn(config).await?;
println!("🚀🚀🚀🚀 network deployed");
Expand Down
5 changes: 3 additions & 2 deletions crates/examples/examples/small_network_with_default.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use configuration::NetworkConfigBuilder;
use orchestrator::{AddNodeOpts, Orchestrator};
use provider::NativeProvider;
use support::fs::local::LocalFileSystem;
use support::{fs::local::LocalFileSystem, process::os::OsProcessManager};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
Expand All @@ -21,7 +21,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
.unwrap();

let fs = LocalFileSystem;
let provider = NativeProvider::new(fs.clone());
let pm = OsProcessManager;
let provider = NativeProvider::new(fs.clone(), pm);
let orchestrator = Orchestrator::new(fs, provider);
let mut network = orchestrator.spawn(config).await?;
println!("🚀🚀🚀🚀 network deployed");
Expand Down
5 changes: 3 additions & 2 deletions crates/examples/examples/small_network_with_para.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::time::Duration;
use configuration::{NetworkConfigBuilder, RegistrationStrategy};
use orchestrator::{AddNodeOpts, Orchestrator};
use provider::NativeProvider;
use support::fs::local::LocalFileSystem;
use support::{fs::local::LocalFileSystem, process::os::OsProcessManager};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
Expand All @@ -24,7 +24,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
.unwrap();

let fs = LocalFileSystem;
let provider = NativeProvider::new(fs.clone());
let pm = OsProcessManager;
let provider = NativeProvider::new(fs.clone(), pm);
let orchestrator = Orchestrator::new(fs, provider);
let mut network = orchestrator.spawn(config).await?;
println!("🚀🚀🚀🚀 network deployed");
Expand Down
6 changes: 3 additions & 3 deletions crates/orchestrator/src/spawner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ where
bootnode_addr: ctx.bootnodes_addr.clone(),
};

let (cmd, args) = match ctx.role {
let (program, args) = match ctx.role {
// Collator should be `non-cumulus` one (e.g adder/undying)
ZombieRole::Node | ZombieRole::Collator => {

Expand All @@ -126,11 +126,11 @@ where

println!("\n");
println!("🚀 {}, spawning.... with command:", node.name);
println!("{cmd} {}", args.join(" "));
println!("{program} {}", args.join(" "));

let spawn_ops = SpawnNodeOptions {
name: node.name.clone(),
command: cmd,
program,
args,
env: node
.env
Expand Down
5 changes: 1 addition & 4 deletions crates/provider/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,4 @@ tokio = { workspace = true, features = [
thiserror = { workspace = true }
anyhow = { workspace = true }
uuid = { workspace = true, features = ["v4"] }
nix = { workspace = true, features = ["signal"] }

[dev-dependencies]
procfs = { workspace = true }
nix = { workspace = true, features = ["signal"] }
Loading

0 comments on commit d1354c7

Please sign in to comment.