summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Andres Klode <julian.klode@canonical.com>2021-07-29 11:46:47 +0200
committerJulian Andres Klode <julian.klode@canonical.com>2021-07-29 11:49:59 +0200
commit70ee96670bbc09e724aeeb6263ee6a3bdde8afdc (patch)
tree0a44506d529541dbabc2eeb7da0c5822b76a160e
parent4001af8920389e2bb2672b673b181c4e92515872 (diff)
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.
-rwxr-xr-xtest/integration/test-bug-869859-retry-downloads18
1 files changed, 17 insertions, 1 deletions
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