mirror of
https://framagit.org/ppom/reaction
synced 2026-03-14 20:55:47 +01:00
Add new failing tests on start / stop sequences.
They fail because reaction don't correctly order stop commands after
This commit is contained in:
parent
91885e49bd
commit
c824583613
2 changed files with 104 additions and 0 deletions
41
tests/start_stop.jsonnet
Normal file
41
tests/start_stop.jsonnet
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
local echo(message) = ['sh', '-c', 'echo %s >> ./log' % message];
|
||||
{
|
||||
patterns: {
|
||||
num: {
|
||||
regex: '[0-9]+',
|
||||
},
|
||||
},
|
||||
|
||||
start: [
|
||||
echo('start 1'),
|
||||
echo('start 2'),
|
||||
],
|
||||
|
||||
stop: [
|
||||
echo('stop 1'),
|
||||
echo('stop 2'),
|
||||
],
|
||||
|
||||
streams: {
|
||||
s1: {
|
||||
cmd: ['sh', '-c', 'seq 2 | while read i; do echo runtime $i; sleep 0.1; done'],
|
||||
filters: {
|
||||
f1: {
|
||||
regex: [
|
||||
'^runtime <num>$',
|
||||
],
|
||||
actions: {
|
||||
one: {
|
||||
cmd: echo('runtime <num>'),
|
||||
},
|
||||
two: {
|
||||
cmd: echo('after <num>'),
|
||||
after: '1s',
|
||||
onexit: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
63
tests/start_stop.rs
Normal file
63
tests/start_stop.rs
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
use std::{path::Path, time::Duration};
|
||||
|
||||
use assert_cmd::Command;
|
||||
use assert_fs::{prelude::*, TempDir};
|
||||
use predicates::prelude::predicate;
|
||||
|
||||
#[test]
|
||||
#[ignore = "currently failing"] // FIXME
|
||||
fn start_stop() {
|
||||
let tmp_dir = assert_fs::TempDir::new().unwrap();
|
||||
|
||||
run_reaction(&tmp_dir);
|
||||
|
||||
// Expected output
|
||||
let output = [
|
||||
"start 1",
|
||||
"start 2",
|
||||
"runtime 1",
|
||||
"runtime 2",
|
||||
"after 1",
|
||||
"after 2",
|
||||
"stop 1",
|
||||
"stop 2",
|
||||
"",
|
||||
];
|
||||
tmp_dir.child("log").assert(&output.join("\n"));
|
||||
tmp_dir.child("log").write_str("").unwrap();
|
||||
|
||||
// Second run
|
||||
run_reaction(&tmp_dir);
|
||||
|
||||
// Expected output
|
||||
let output = [
|
||||
"start 1",
|
||||
"start 2",
|
||||
"runtime 1",
|
||||
"runtime 2",
|
||||
"runtime 1",
|
||||
"runtime 2",
|
||||
"after 1",
|
||||
"after 2",
|
||||
"after 1",
|
||||
"after 2",
|
||||
"stop 1",
|
||||
"stop 2",
|
||||
"",
|
||||
];
|
||||
tmp_dir.child("log").assert(&output.join("\n"));
|
||||
}
|
||||
|
||||
fn run_reaction(tmp_dir: &TempDir) {
|
||||
tmp_dir
|
||||
.child("config.jsonnet")
|
||||
.write_file(Path::new("tests/start_stop.jsonnet"))
|
||||
.unwrap();
|
||||
|
||||
let mut cmd = Command::cargo_bin("reaction").unwrap();
|
||||
cmd.args(["start", "--socket", "./s", "--config", "./config.jsonnet"]);
|
||||
cmd.current_dir(tmp_dir.path());
|
||||
cmd.timeout(Duration::from_secs(5));
|
||||
// Expected exit 1: all stream exited
|
||||
cmd.assert().code(predicate::eq(1));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue