test: pause the retire timer during source image test

The periodic `dokku-retire` timer could run `ps:retire` between the test's final deploy and its own `ps:retire` call, processing the retire list first and leaving the test with no output to assert on.
This commit is contained in:
Jose Diaz-Gonzalez
2026-10-23 20:21:28 -04:00
parent 2dd77d61e4
commit 3bd74e4eb5

View File

@@ -9,6 +9,7 @@ setup() {
teardown() {
global_teardown
docker image rm "dokku-test/$TEST_APP:shared" &>/dev/null || true
start_retire_timer
}
@test "(scheduler-docker-local:report) --global raw and computed keys" {
@@ -487,6 +488,7 @@ teardown() {
@test "(scheduler-docker-local) ps:retire keeps an image that is another app's source image" {
local SECOND_APP="$TEST_APP-2" TMP_IMAGE_DIR
stop_retire_timer
TMP_IMAGE_DIR="$(mktemp -d "/tmp/${DOKKU_DOMAIN}.XXXXX")"
cp -r "${BATS_TEST_DIRNAME}/../../tests/apps/python/." "$TMP_IMAGE_DIR"
run /bin/bash -c "docker image build -t dokku-test/$TEST_APP:shared -f $TMP_IMAGE_DIR/alt.Dockerfile $TMP_IMAGE_DIR"
@@ -631,3 +633,18 @@ operator_procfile_callback() {
web: python3 -u web.py && echo done
PROCFILE
}
stop_retire_timer() {
declare desc="stops the dokku-retire timer so only the test runs ps:retire"
if systemctl is-active --quiet dokku-retire.timer 2>/dev/null; then
systemctl stop dokku-retire.timer
RETIRE_TIMER_STOPPED=true
fi
}
start_retire_timer() {
declare desc="starts the dokku-retire timer if stop_retire_timer stopped it"
if [[ "$RETIRE_TIMER_STOPPED" == "true" ]]; then
systemctl start dokku-retire.timer
fi
}