[Git][java-team/css-validator][master] d/testst: robustify restart of server
bastif (@bastif)
gitlab at salsa.debian.org
Tue Mar 3 09:52:56 GMT 2026
bastif pushed to branch master at Debian Java Maintainers / css-validator
Commits:
e3d2e5a7 by Fab Stz at 2026-03-03T10:52:32+01:00
d/testst: robustify restart of server
Wait that the server has stopped before restarting it to prevent slow restarts from
letting the script believe the service is already up after restart although it is
still shutting down. Typically this may happen on slow test systems like riscv64.
Also, move the common code to an external file that will be sourced by each script
- - - - -
3 changed files:
- + debian/tests/webapp_validate_common.sh
- debian/tests/webapp_validate_file.sh
- debian/tests/webapp_validate_url.sh
Changes:
=====================================
debian/tests/webapp_validate_common.sh
=====================================
@@ -0,0 +1,56 @@
+#!/bin/bash
+
+tempfile=$(mktemp)
+
+trap debug_failure ERR
+
+debug_failure()
+{
+ sudo systemctl status "$server" || true
+ sudo journalctl --no-pager -t "$server"
+ cat "$tempfile"
+ rm "$tempfile"
+}
+
+wait_until_not_state()
+{
+ local server state count
+ server="$1"
+ state="$2"
+ count=0
+ while [ "$(systemctl show -P ActiveState "$server")" == "$state" ] ; do
+ if [ $count -gt 60 ]; then
+ break
+ fi
+ count=$((count + 1))
+ sleep 1
+ done
+ if [ ! $count -gt 60 ]; then
+ echo "Startup took $count seconds to leave state '$state' and enter state '$(systemctl show -P ActiveState "$server")'."
+ else
+ echo "$server failed starting up in less than 60 seconds"
+ exit 1
+ fi
+}
+
+wait_until_ready()
+{
+ local server port count
+ server="$1"
+ port="$2"
+ count=0
+ while ! nc -z localhost "${port:-8080}" >/dev/null 2>&1; do
+ if [ $count -gt 60 ]; then
+ break
+ fi
+ count=$((count + 1))
+ sleep 1
+ done
+ if [ ! $count -gt 60 ]; then
+ echo "$server is now up and running at http://localhost:${port:-8080}"
+ echo "Startup took $count seconds."
+ else
+ echo "$server failed starting up in less than 60 seconds"
+ exit 1
+ fi
+}
=====================================
debian/tests/webapp_validate_file.sh
=====================================
@@ -3,38 +3,8 @@
set -e
server="$1"
-tempfile=$(mktemp)
-trap debug_failure ERR
-
-debug_failure()
-{
- sudo systemctl status "$server" || true
- sudo journalctl --no-pager -t "$server"
- cat "$tempfile"
- rm "$tempfile"
-}
-
-wait_until_ready()
-{
- server="$1"
- port="$2"
- count=0
- while ! nc -z localhost "${port:-8080}" >/dev/null 2>&1; do
- if [ $count -gt 60 ]; then
- break
- fi
- count=$((count + 1))
- sleep 1
- done
- if [ ! $count -gt 60 ]; then
- echo "$server is now up and running at http://localhost:${port:-8080}"
- echo "Startup took $count seconds."
- else
- echo "$server failed starting up in less than 60 seconds"
- exit 1
- fi
-}
+source "$(dirname "$0")"/webapp_validate_common.sh
PORT=8080
@@ -48,14 +18,13 @@ if [ -n "$AUTOPKGTEST_TMP" ]; then
;;
esac
- sudo systemctl restart "$server"
+ sudo systemctl stop "$server"
+ wait_until_not_state "$server" "active"
+ sudo systemctl start "$server"
wait_until_ready "$server" "$PORT"
sudo systemctl status "$server"
fi
-
-
-
#echo "current path: $PWD"
curl -v --stderr - \
=====================================
debian/tests/webapp_validate_url.sh
=====================================
@@ -3,17 +3,10 @@
set -e
server="$1"
-tempfile=$(mktemp)
-trap debug_failure ERR
+source "$(dirname "$0")"/webapp_validate_common.sh
-debug_failure()
-{
- sudo systemctl status "$server" || true
- sudo journalctl --no-pager -t "$server"
- cat "$tempfile"
- rm "$tempfile"
-}
+PORT=8080
if [ -n "$AUTOPKGTEST_TMP" ]; then
case "$server" in
@@ -25,8 +18,10 @@ if [ -n "$AUTOPKGTEST_TMP" ]; then
;;
esac
- sudo systemctl restart "$server"
- sleep 5
+ sudo systemctl stop "$server"
+ wait_until_not_state "$server" "active"
+ sudo systemctl start "$server"
+ wait_until_ready "$server" "$PORT"
sudo systemctl status "$server"
fi
@@ -34,7 +29,7 @@ fi
curl -v --stderr - \
-o "$tempfile" \
- "http://localhost:8080/css-validator/validator?uri=http://localhost:8080&profile=css3svg&usermedium=all&warning=2&vextwarning=&lang=en"
+ "http://localhost:${PORT:-8080}/css-validator/validator?uri=http://localhost:${PORT:-8080}&profile=css3svg&usermedium=all&warning=2&vextwarning=&lang=en"
if grep "<h3>Congratulations! No Error Found.</h3>" "$tempfile"; then
echo "Validation of file was successful."
View it on GitLab: https://salsa.debian.org/java-team/css-validator/-/commit/e3d2e5a78fccf5737962ed84607e9cf230596ddd
--
View it on GitLab: https://salsa.debian.org/java-team/css-validator/-/commit/e3d2e5a78fccf5737962ed84607e9cf230596ddd
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20260303/6f740902/attachment.htm>
More information about the pkg-java-commits
mailing list