-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Running in a distributed mode is great for bigger tests, but sometimes you just want to test something locally. This commit adds a `run` subcommand that can run a wasm scenario directly: crows run foo.wasm
- Loading branch information
Showing
16 changed files
with
608 additions
and
445 deletions.
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
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
mod start; | ||
mod run; | ||
|
||
pub use start::start; | ||
pub use run::run; |
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,28 @@ | ||
use std::path::PathBuf; | ||
|
||
use crows_cli::output::{drive_progress, LocalProgressFetcher}; | ||
use crows_utils::services::RunId; | ||
use crows_wasm::{fetch_config, run_scenario}; | ||
|
||
pub async fn run(path: &PathBuf) -> anyhow::Result<()> { | ||
let scenario = std::fs::read(path).unwrap(); | ||
let (runtime, info_handle) = | ||
crows_wasm::Runtime::new(&scenario).expect("Could not create a runtime"); | ||
let (instance, _, mut store) = runtime | ||
.new_instance() | ||
.await | ||
.expect("Could not create an instance"); | ||
let config = fetch_config(instance, &mut store) | ||
.await | ||
.expect("Config not found in the module"); | ||
|
||
run_scenario(runtime, scenario, config).await; | ||
|
||
let mut client = LocalProgressFetcher::new(info_handle, "worker".to_string()); | ||
|
||
drive_progress(&mut client, &RunId::new(), vec!["worker".to_string()]) | ||
.await | ||
.expect("Error while running the scenario"); | ||
|
||
Ok(()) | ||
} |
Oops, something went wrong.