aoh

A tool for running Ansible playbooks with `curl <url> | python` commands
git clone https://git.ashermorgan.net/aoh/
Log | Files | Refs | README

commit 89ff70b15158c704dbf44d9b0ee42031659ede99
parent e85ddb9fb7b66f0989e595e45d3bd23476441e33
Author: Asher Morgan <asher@ashermorgan.net>
Date:   Sat, 24 Oct 2026 21:44:41 -0700

Update e2e test script

Simplify playbook failure detection by just checking the client exit code. Also
move special test5.yml logic back into main test loop to make it easier to add
new tests in the future.

Diffstat:
Mtests/e2e/run.sh | 142++++++++++++++++++++++++++++++++++++++-----------------------------------------
1 file changed, 68 insertions(+), 74 deletions(-)

diff --git a/tests/e2e/run.sh b/tests/e2e/run.sh @@ -6,11 +6,8 @@ cd $(dirname $0) DOCKER=${DOCKER:-docker} # Set DOCKER=podman to use podman instead of docker -log=$(mktemp) - function on_exit() { echo 'Cleaning up...' - rm -f $log if [ $($DOCKER ps --filter name=aoh-test-client | wc -l) -gt 1 ]; then $DOCKER stop aoh-test-client fi @@ -26,98 +23,95 @@ if [ $($DOCKER network ls --filter name=aoh-test | wc -l) -eq 1 ]; then $DOCKER network create aoh-test fi -for i in {1..4}; do +for i in {1..5}; do echo ================================ echo Running test$i.yml... echo ================================ - echo > $log + if [ "$i" -eq 5 ]; then + # Test 5 is different: start a long-running playbook, kill the client, + # and then check to make sure that server cleans everything up + $DOCKER run --rm --network aoh-test --detach -h aoh-test-server \ + --name aoh-test-server -v ./:/aoh \ + -e AOH_GC_INTERVAL=1 -e AOH_GC_THRESHOLD=1 aoh-test-server + sleep 1 + $DOCKER run --rm --network aoh-test --detach --name aoh-test-client \ + aoh-test-client bash -c \ + "curl http://aoh-test-server:8000/run | python3 - test$i.yml" + + for j in {1..10}; do + if $DOCKER exec aoh-test-server sh -c \ + 'find /tmp -maxdepth 1 -type d -name "aoh-*" -print -quit | \ + grep -q . && ps -eo comm | grep -qx ansible-playboo' + then + break + elif [ "$j" -eq 10 ]; then + echo Timed out waiting for server to start runner + $DOCKER exec aoh-test-server sh -c \ + 'find /tmp -maxdepth 1 -type d -name "aoh-*" -print -quit; \ + ps -eo comm' + echo ================================ + echo test$i.yml failed. + echo ================================ + exit 1 + else + sleep 1 + fi + done - $DOCKER run --rm --network aoh-test --detach -h aoh-test-server \ - --name aoh-test-server -v ./:/aoh aoh-test-server - sleep 1 - $DOCKER run --rm --network aoh-test --tty aoh-test-client bash -c \ - "curl http://aoh-test-server:8000/run | python3 - test$i.yml" \ - | tee $log - $DOCKER stop aoh-test-server - sleep 1 + sleep 1 + $DOCKER stop aoh-test-client - if grep 'failed=0' < $log; then - echo ================================ - echo test$i.yml passed. - echo ================================ - echo - else - echo ================================ - echo test$i.yml failed. - echo ================================ - exit 1 - fi -done + for j in {1..10}; do + if $DOCKER exec aoh-test-server sh -c \ + '! find /tmp -maxdepth 1 -type d -name "aoh-*" -print -quit | \ + grep -q . && ! ps -eo comm | grep -qx ansible-playboo' + then + echo ================================ + echo test$i.yml passed. + echo ================================ + break + elif [ "$j" -eq 10 ]; then + echo Timed out waiting for server to clean up runner + $DOCKER exec aoh-test-server sh -c \ + 'find /tmp -maxdepth 1 -type d -name "aoh-*" -print -quit; \ + ps -eo comm' + echo ================================ + echo test$i.yml failed. + echo ================================ + exit 1 + else + sleep 1 + fi + done -# Test 5 is different: start a long-running playbook, kill the client, and then -# check to make sure that server cleans everything up -i=5 -echo ================================ -echo Running test$i.yml... -echo ================================ - -$DOCKER run --rm --network aoh-test --detach -h aoh-test-server \ - --name aoh-test-server -v ./:/aoh \ - -e AOH_GC_INTERVAL=1 -e AOH_GC_THRESHOLD=1 aoh-test-server -sleep 1 -$DOCKER run --rm --network aoh-test --detach --name aoh-test-client \ - aoh-test-client bash -c \ - "curl http://aoh-test-server:8000/run | python3 - test$i.yml" - -for j in {1..10}; do - if $DOCKER exec aoh-test-server sh -c \ - 'find /tmp -maxdepth 1 -type d -name "aoh-*" -print -quit | grep -q .\ - && ps -eo comm | grep -qx ansible-playboo' - then - break - elif [ "$j" -eq 10 ]; then - echo Timed out waiting for server to start runner - $DOCKER exec aoh-test-server sh -c \ - 'find /tmp -maxdepth 1 -type d -name "aoh-*" -print -quit; \ - ps -eo comm' - echo ================================ - echo test$i.yml failed. - echo ================================ - exit 1 - else + $DOCKER stop aoh-test-server sleep 1 + + continue fi -done -sleep 1 -$DOCKER stop aoh-test-client + $DOCKER run --rm --network aoh-test --detach -h aoh-test-server \ + --name aoh-test-server -v ./:/aoh aoh-test-server + sleep 1 -for j in {1..10}; do - if $DOCKER exec aoh-test-server sh -c \ - '! find /tmp -maxdepth 1 -type d -name "aoh-*" -print -quit | grep -q .\ - && ! ps -eo comm | grep -qx ansible-playboo' + if $DOCKER run --rm --network aoh-test --tty aoh-test-client bash -c \ + "curl http://aoh-test-server:8000/run | python3 - test$i.yml" then echo ================================ echo test$i.yml passed. echo ================================ - break - elif [ "$j" -eq 10 ]; then - echo Timed out waiting for server to clean up runner - $DOCKER exec aoh-test-server sh -c \ - 'find /tmp -maxdepth 1 -type d -name "aoh-*" -print -quit; \ - ps -eo comm' + echo + else echo ================================ echo test$i.yml failed. echo ================================ exit 1 - else - sleep 1 fi -done -$DOCKER stop aoh-test-server -sleep 1 + $DOCKER stop aoh-test-server + sleep 1 +done echo ================================ echo All tests passed.