Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Commit

Permalink
sharding test scenarios
Browse files Browse the repository at this point in the history
  • Loading branch information
senia-psm committed Mar 18, 2024
1 parent 4015507 commit ad71215
Show file tree
Hide file tree
Showing 7 changed files with 391 additions and 84 deletions.
48 changes: 48 additions & 0 deletions scenario.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"workers_count": 4,
"steps": [
"StopAllShards",
{
"InvokeAndAwaitWorkersAsync": "Invoke, RestartShardManager, StartShards"
},
"RestartShardManager",
{
"Sleep": {
"secs": 3,
"nanos": 0
}
},
{
"StartShards": 4
},
"WaitForInvokeAndAwaitResult",
"StopAllShards",
"RestartShardManager",
{
"StartShards": 4
},
"RestartShardManager",
{
"InvokeAndAwaitWorkersAsync": "StartShards, RestartShardManager, Invoke"
},
"WaitForInvokeAndAwaitResult",
"StopAllShards",
"RestartShardManager",
{
"StartShards": 4
},
{
"StopShards": 3
},
{
"Sleep": {
"secs": 3,
"nanos": 0
}
},
{
"InvokeAndAwaitWorkersAsync": "StartShards(4), StopShards(3), Invoke"
},
"WaitForInvokeAndAwaitResult"
]
}
20 changes: 20 additions & 0 deletions scenario1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"workers_count": 4,
"steps": [
"StopAllShards",
{
"InvokeAndAwaitWorkersAsync": "Invoke, RestartShardManager, StartShards"
},
"RestartShardManager",
{
"Sleep": {
"secs": 3,
"nanos": 0
}
},
{
"StartShards": 4
},
"WaitForInvokeAndAwaitResult"
]
}
15 changes: 15 additions & 0 deletions scenario2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"workers_count": 4,
"steps": [
"StopAllShards",
"RestartShardManager",
{
"StartShards": 4
},
"RestartShardManager",
{
"InvokeAndAwaitWorkersAsync": "StartShards, RestartShardManager, Invoke"
},
"WaitForInvokeAndAwaitResult"
]
}
23 changes: 23 additions & 0 deletions scenario3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"workers_count": 4,
"steps": [
"StopAllShards",
"RestartShardManager",
{
"StartShards": 4
},
{
"StopShards": 3
},
{
"Sleep": {
"secs": 3,
"nanos": 0
}
},
{
"InvokeAndAwaitWorkersAsync": "StartShards(4), StopShards(3), Invoke"
},
"WaitForInvokeAndAwaitResult"
]
}
41 changes: 41 additions & 0 deletions scenario4.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"workers_count": 4,
"steps": [
"StopAllShards",
{
"Sleep": {
"secs": 10,
"nanos": 0
}
},
"RestartShardManager",
{
"Sleep": {
"secs": 10,
"nanos": 0
}
},
{
"StartShards": 4
},
{
"Sleep": {
"secs": 10,
"nanos": 0
}
},
{
"StopShards": 3
},
{
"Sleep": {
"secs": 10,
"nanos": 0
}
},
{
"InvokeAndAwaitWorkersAsync": "StartShards(4), StopShards(3), Invoke"
},
"WaitForInvokeAndAwaitResult"
]
}
34 changes: 25 additions & 9 deletions tests/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use std::process::{Child, Command, Stdio};
#[derive(Debug, Clone)]
pub struct CliConfig {
short_args: bool,
quiet: bool,
}

impl CliConfig {
Expand Down Expand Up @@ -44,7 +45,10 @@ pub struct CliLive {
impl CliLive {
pub fn with_short_args(&self) -> Self {
CliLive {
config: CliConfig { short_args: true },
config: CliConfig {
short_args: true,
quiet: self.config.quiet,
},
golem_template_port: self.golem_template_port,
golem_worker_port: self.golem_worker_port,
golem_cli_path: self.golem_cli_path.clone(),
Expand All @@ -53,7 +57,10 @@ impl CliLive {

pub fn with_long_args(&self) -> Self {
CliLive {
config: CliConfig { short_args: false },
config: CliConfig {
short_args: false,
quiet: self.config.quiet,
},
golem_template_port: self.golem_template_port,
golem_worker_port: self.golem_worker_port,
golem_cli_path: self.golem_cli_path.clone(),
Expand All @@ -70,9 +77,14 @@ impl CliLive {
context.golem_worker_service.local_http_port
);

let quiet = std::env::var("QUIET").is_ok();

if golem_cli_path.exists() {
Ok(CliLive {
config: CliConfig { short_args: false },
config: CliConfig {
short_args: false,
quiet,
},
golem_template_port: context.golem_template_service.local_http_port,
golem_worker_port: context.golem_worker_service.local_http_port,
golem_cli_path,
Expand All @@ -95,10 +107,12 @@ impl CliLive {
}

fn run_inner<S: AsRef<OsStr> + Debug>(&self, args: &[S]) -> Result<String, Failed> {
println!(
"Executing Golem CLI command: {} {args:?}",
self.golem_cli_path.to_str().unwrap_or("")
);
if !self.config.quiet {
println!(
"Executing Golem CLI command: {} {args:?}",
self.golem_cli_path.to_str().unwrap_or("")
);
}

let output = Command::new(&self.golem_cli_path)
.env("GOLEM_TEMPLATE_BASE_URL", self.template_base_url())
Expand All @@ -112,8 +126,10 @@ impl CliLive {
let stdout = String::from_utf8_lossy(output.stdout.as_slice()).to_string();
let stderr = String::from_utf8_lossy(output.stderr.as_slice()).to_string();

println!("CLI stdout: {stdout} for command {args:?}");
println!("CLI stderr: {stderr} for command {args:?}");
if !self.config.quiet {
println!("CLI stdout: {stdout} for command {args:?}");
println!("CLI stderr: {stderr} for command {args:?}");
}

if !output.status.success() {
return Err(format!(
Expand Down
Loading

0 comments on commit ad71215

Please sign in to comment.