Skip to content

Commit

Permalink
feat(snot-cil): delete with id
Browse files Browse the repository at this point in the history
  • Loading branch information
gluax committed Mar 23, 2024
1 parent 91405a5 commit a0a151a
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 7 deletions.
3 changes: 2 additions & 1 deletion crates/snot-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
23 changes: 17 additions & 6 deletions crates/snot-cli/src/commands/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand All @@ -16,32 +17,42 @@ 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();
use Commands::*;
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(())
}
Expand Down
28 changes: 28 additions & 0 deletions specs/test-1-validators.yaml
Original file line number Diff line number Diff line change
@@ -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: []

0 comments on commit a0a151a

Please sign in to comment.