commit f72d40d3e7d9dccd5d861175b2b4136879078153
parent 3be18b9a0f762098edd05defc9b9156cccfbe337
Author: Asher Morgan <asher@ashermorgan.net>
Date: Wed, 21 Oct 2026 18:47:00 -0700
Add e2e test for client connection failures
Diffstat:
3 files changed, 78 insertions(+), 1 deletion(-)
diff --git a/tests/e2e/playbooks.yml b/tests/e2e/playbooks.yml
@@ -13,3 +13,8 @@ test4.yml:
path: test_become_password_handling.yml
env:
ANSIBLE_PIPELINING: 'true'
+
+test5.yml:
+ path: test_connection_failure.yml
+ env:
+ ANSIBLE_TIMEOUT: '5'
diff --git a/tests/e2e/run.sh b/tests/e2e/run.sh
@@ -11,7 +11,10 @@ log=$(mktemp)
function on_exit() {
echo 'Cleaning up...'
rm -f $log
- if [ $($DOCKER ps --filter name=aoh | wc -l) -gt 1 ]; then
+ if [ $($DOCKER ps --filter name=aoh-test-client | wc -l) -gt 1 ]; then
+ $DOCKER stop aoh-test-client
+ fi
+ if [ $($DOCKER ps --filter name=aoh-test-server | wc -l) -gt 1 ]; then
$DOCKER stop aoh-test-server
fi
}
@@ -52,6 +55,70 @@ for i in {1..4}; do
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 i 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 [ "$i" -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
+
+sleep 1
+$DOCKER stop aoh-test-client
+
+for i 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 [ "$i" -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
+
+$DOCKER stop aoh-test-server
+sleep 1
+
echo ================================
echo All tests passed.
echo ================================
diff --git a/tests/e2e/test_connection_failure.yml b/tests/e2e/test_connection_failure.yml
@@ -0,0 +1,5 @@
+- hosts: aoh
+ gather_facts: no
+ tasks:
+ - name: Long running task
+ command: sleep 300