From 70ee96670bbc09e724aeeb6263ee6a3bdde8afdc Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Thu, 29 Jul 2021 11:46:47 +0200 Subject: Enhance test to check time spent This is subject to clock skew, unfortunately, as we cannot read monotonic time in shell. We check for >=5s out of the 7s it should take to reduce the risk of skew a bit. --- test/integration/test-bug-869859-retry-downloads | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/test/integration/test-bug-869859-retry-downloads b/test/integration/test-bug-869859-retry-downloads index 66e158a9d..12ca40c77 100755 --- a/test/integration/test-bug-869859-retry-downloads +++ b/test/integration/test-bug-869859-retry-downloads @@ -4,6 +4,22 @@ set -e TESTDIR="$(readlink -f "$(dirname "$0")")" . "$TESTDIR/framework" +testsecondsgreaterequal() { + seconds="$1" + shift + before=$(date +%s) + "$@" + after=$(date +%s) + msggroup 'testsecondsgreaterequal' + msgtest "Checking that previous test took more than $secondss" + if [ $((after - before)) -lt $seconds ]; then + msgfail "Took $((after - before)) second" + else + msgpass + fi + msggroup +} + setupenvironment configarchitecture 'amd64' @@ -21,7 +37,7 @@ rm -f testpkg_1_all.deb msgmsg 'Fail after too many retries' webserverconfig 'aptwebserver::failrequest' '429' webserverconfig 'aptwebserver::failrequest::pool/testpkg_1_all.deb' '99' -testfailureequal "Delaying http://localhost:${APTHTTPPORT} stable/main all testpkg all 1 by 1 seconds +testsecondsgreaterequal 5 testfailureequal "Delaying http://localhost:${APTHTTPPORT} stable/main all testpkg all 1 by 1 seconds Ign:1 http://localhost:${APTHTTPPORT} stable/main all testpkg all 1 429 Unknown HTTP code Delaying http://localhost:${APTHTTPPORT} stable/main all testpkg all 1 by 2 seconds -- cgit v1.2.3-70-g09d2