diff options
Diffstat (limited to 'test/script')
| -rw-r--r-- | test/script/run.et | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/test/script/run.et b/test/script/run.et index 08df6ce..6c990be 100644 --- a/test/script/run.et +++ b/test/script/run.et @@ -919,3 +919,123 @@ test RunHighestTag: /job-finish $tc:fourth done/ expect /(.*)/ from p capture finish guard (finish == "run-finish") + + +test KillCancelledProcesses: + node n + shell on n as git_init: + git -c init.defaultBranch=master init -q + git -c user.name=test -c user.email=test commit -q --allow-empty -m 'initial commit' + cp "${scripts.path}/forever.yaml" minici.yaml + git add minici.yaml + git -c user.name=test -c user.email=test commit -q -m 'minici.yaml' + git rev-parse HEAD + + touch a + git add a + git -c user.name=test -c user.email=test commit -q -m a + git rev-parse HEAD + git rev-parse HEAD^{tree} + + touch b + git add b + git -c user.name=test -c user.email=test commit -q -m b + git rev-parse HEAD + git rev-parse HEAD^{tree} + + git reset --hard HEAD~2 + git rev-parse HEAD + + expect /([0-9a-f]+)/ from git_init capture c_init + expect /([0-9a-f]+)/ from git_init capture ca + expect /([0-9a-f]+)/ from git_init capture ta + expect /([0-9a-f]+)/ from git_init capture cb + expect /([0-9a-f]+)/ from git_init capture tb + expect /([0-9a-f]+)/ from git_init capture c_end + + guard (c_init == c_end) + + local: + shell on n: + git reset --hard $ca + + spawn on n as p args [ "run", "watch(master)" ] killwith SIGINT + expect from p /watch-branch-started master/ + + expect from p: + /job-enqueue $ta:forever/ + /job-start $ta:forever/ + + spawn on n as log_a args [ "log", "$ta:forever" ] + expect from log_a: + /msg (.*)/ capture a_pid_sh + /msg (.*)/ capture a_pid_sleep + + local: + shell on n as check: + ps -q $a_pid_sh,$a_pid_sleep -o pid=,comm= + + shell on n: + git reset --hard $cb + + expect from p: + /job-finish $ta:forever cancelled/ + /job-enqueue $tb:forever/ + /job-start $tb:forever/ + + spawn on n as log_b args [ "log", "$tb:forever" ] + expect from log_b: + /msg (.*)/ capture b_pid_sh + /msg (.*)/ capture b_pid_sleep + + local: + shell on n: + ! ps -q $a_pid_sh,$a_pid_sleep -o pid=,comm= + ps -q $b_pid_sh,$b_pid_sleep -o pid=,comm= + + local: + spawn on n as log args [ "log", "$tb:forever" ] + expect from log: + /msg (.*)/ capture sh_pid + /msg (.*)/ capture sleep_pid + + shell on n: + ! ps -q $sh_pid,$sleep_pid -o pid=,comm= + + +test KillBackgroundProcesses: + node n + shell on n: + cp "${scripts.path}/background.yaml" minici.yaml + + local: + spawn on n as p args [ "./minici.yaml", "run", "background_success" ] + + expect from p: + /job-enqueue background_success/ + /job-start background_success/ + /job-finish background_success done/ + + spawn on n as log args [ "./minici.yaml", "log", "background_success" ] + expect from log: + /msg (.*)/ capture pid_sh + /msg (.*)/ capture pid_sleep + + shell on n: + ! ps -q $pid_sh,$pid_sleep -o pid=,comm= + + local: + spawn on n as p args [ "./minici.yaml", "run", "background_failure" ] + + expect from p: + /job-enqueue background_failure/ + /job-start background_failure/ + /job-finish background_failure failed/ + + spawn on n as log args [ "./minici.yaml", "log", "background_failure" ] + expect from log: + /msg (.*)/ capture pid_sh + /msg (.*)/ capture pid_sleep + + shell on n: + ! ps -q $pid_sh,$pid_sleep -o pid=,comm= |