From 804b6f4c5d1f639a3edc06cbb0404410fa9c4c69 Mon Sep 17 00:00:00 2001 From: mmetc <92726601+mmetc@users.noreply.github.com> Date: Tue, 26 Jul 2022 09:47:56 +0200 Subject: [PATCH] adjust test timing for slow boxes (#1681) --- tests/bats/02_nolapi.bats | 6 ++++-- tests/bats/05_config_yaml_local.bats | 2 +- tests/bats/40_live-ban.bats | 2 +- tests/lib/util/wait-for-port | 3 ++- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/bats/02_nolapi.bats b/tests/bats/02_nolapi.bats index 0a302b7c3..1b85e4806 100644 --- a/tests/bats/02_nolapi.bats +++ b/tests/bats/02_nolapi.bats @@ -31,12 +31,14 @@ declare stderr } @test "crowdsec should not run without LAPI (-no-api flag)" { - run -1 --separate-stderr timeout 2s "${CROWDSEC}" -no-api + # really needs 4 secs on slow boxes + run -1 --separate-stderr timeout 4s "${CROWDSEC}" -no-api } @test "crowdsec should not run without LAPI (no api.server in configuration file)" { config_disable_lapi - run -1 --separate-stderr timeout 2s "${CROWDSEC}" + # really needs 4 secs on slow boxes + run -1 --separate-stderr timeout 4s "${CROWDSEC}" run -0 echo "${stderr}" assert_output --partial "crowdsec local API is disabled" diff --git a/tests/bats/05_config_yaml_local.bats b/tests/bats/05_config_yaml_local.bats index 484ea5695..0e43cbff0 100644 --- a/tests/bats/05_config_yaml_local.bats +++ b/tests/bats/05_config_yaml_local.bats @@ -129,7 +129,7 @@ teardown() { ./instance-crowdsec start fake_log >>"${tmpfile}" - sleep 1 + sleep 2 rm -f -- "${tmpfile}" run -0 --separate-stderr cscli decisions list -o json run -0 jq -c '.[].decisions[0] | [.value,.type]' <(output) diff --git a/tests/bats/40_live-ban.bats b/tests/bats/40_live-ban.bats index 1ef79526d..8551b28ce 100644 --- a/tests/bats/40_live-ban.bats +++ b/tests/bats/40_live-ban.bats @@ -37,7 +37,7 @@ teardown() { ./instance-crowdsec start fake_log >>"${tmpfile}" - sleep 1 + sleep 2 rm -f -- "${tmpfile}" run -0 cscli decisions list -o json run -0 jq -r '.[].decisions[0].value' <(output) diff --git a/tests/lib/util/wait-for-port b/tests/lib/util/wait-for-port index 75397ccc7..4c6c55be7 100755 --- a/tests/lib/util/wait-for-port +++ b/tests/lib/util/wait-for-port @@ -25,9 +25,10 @@ fi port_number=$1 +# 4 seconds may seem long, but the tests must work on embedded, slow arm boxes too for _ in $(seq 40); do nc -z localhost "${port_number}" >/dev/null 2>&1 && exit 0 - sleep .03 + sleep .1 done # send to &3 if open