From a0a151a98f2d9b5402ecdbda45fb759e25dbc239 Mon Sep 17 00:00:00 2001 From: gluax <16431709+gluax@users.noreply.github.com> Date: Sat, 23 Mar 2024 16:51:48 -0700 Subject: [PATCH] feat(snot-cil): delete with id --- crates/snot-cli/Cargo.toml | 3 ++- crates/snot-cli/src/commands/test.rs | 23 +++++++++++++++++------ specs/test-1-validators.yaml | 28 ++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 7 deletions(-) create mode 100644 specs/test-1-validators.yaml diff --git a/crates/snot-cli/Cargo.toml b/crates/snot-cli/Cargo.toml index a4c1fc95..d58190da 100644 --- a/crates/snot-cli/Cargo.toml +++ b/crates/snot-cli/Cargo.toml @@ -9,5 +9,6 @@ edition = "2021" anyhow.workspace = true clap.workspace = true -reqwest = { workspace = true, features = ["blocking"] } +reqwest = { workspace = true, features = ["blocking", "json"] } +serde_json = { workspace = true } url.workspace = true diff --git a/crates/snot-cli/src/commands/test.rs b/crates/snot-cli/src/commands/test.rs index 451e4956..51a94e5d 100644 --- a/crates/snot-cli/src/commands/test.rs +++ b/crates/snot-cli/src/commands/test.rs @@ -2,6 +2,7 @@ use std::path::PathBuf; use anyhow::Result; use clap::Parser; +use serde_json::Value; /// For interacting with snot tests. #[derive(Debug, Parser)] @@ -16,16 +17,24 @@ pub struct Test { /// Test commands #[derive(Debug, Parser)] enum Commands { + /// Start a test. Start { /// The test spec file. spec: PathBuf, }, - Stop, + /// Stop a test(s). + Stop { + /// Stop all tests. + // #[clap(short, long)] + // all: bool, + /// Stop a specific test. + id: usize, + }, } impl Test { const START_ENDPOINT: &'static str = "api/v1/test/prepare"; - const STOP_ENDPOINT: &'static str = "api/v1/test"; + const STOP_ENDPOINT: &'static str = "api/v1/test/"; pub fn run(self) -> Result<()> { let client = reqwest::blocking::Client::new(); @@ -33,15 +42,17 @@ impl Test { match self.command { Start { spec } => { let file: String = std::fs::read_to_string(spec)?; - client + let id: Value = client .post(&format!("{}{}", self.url, Self::START_ENDPOINT)) .body(file) - .send()?; + .send()? + .json()?; + println!("{}", serde_json::to_string(&id)?); Ok(()) } - Stop => { + Stop { id } => { client - .delete(&format!("{}{}", self.url, Self::STOP_ENDPOINT)) + .delete(&format!("{}{}{id}", self.url, Self::STOP_ENDPOINT)) .send()?; Ok(()) } diff --git a/specs/test-1-validators.yaml b/specs/test-1-validators.yaml new file mode 100644 index 00000000..417d6125 --- /dev/null +++ b/specs/test-1-validators.yaml @@ -0,0 +1,28 @@ +--- +version: storage.snarkos.testing.monadic.us/v1 + +# ADDITIONAL storage information to be run for this test +# this will run a second test with the same topology but different ledger +id: base +name: base-ledger + +generate: + path: ./tests/base + +--- +version: nodes.snarkos.testing.monadic.us/v1 + +name: 4-validators + +nodes: + # validator/test: + # replicas: 4 + # key: committee.$ + # height: 0 + # validators: [validator/*] + # peers: [] + validator/0: + key: APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH + height: 0 + validators: [validator/*] + peers: []