diff --git a/tests/README.md b/tests/README.md index 3b7e3a1e8..2d1af960f 100644 --- a/tests/README.md +++ b/tests/README.md @@ -59,7 +59,14 @@ repositories). - `git submodule init; git submodule update` - `daemonize (linux) or daemon (freebsd), bash, python3, openbsd-netcat` - - `yq` from https://github.com/mikefarah/yq + - `go install github.com/cloudflare/cfssl/cmd/cfssl@latest` + - `go install github.com/cloudflare/cfssl/cmd/cfssljson@latest` + - `go install github.com/mikefarah/yq/v4@latest` + - `base64` + - `curl` + - `jq` + - `nc` + - `python3` ## Running all tests diff --git a/tests/check-requirements b/tests/check-requirements index a46cffab7..fd858f81c 100755 --- a/tests/check-requirements +++ b/tests/check-requirements @@ -19,6 +19,12 @@ check_bats_core() { fi } +check_curl() { + if ! command -v curl >/dev/null; then + die "missing required program 'curl'" + fi +} + check_python3() { if ! command -v python3 >/dev/null; then die "missing required program 'python3'" @@ -97,6 +103,7 @@ check_gocovmerge() { } check_bats_core +check_curl check_daemonizer check_cfssl check_cfssljson diff --git a/tests/lib/config/config-global b/tests/lib/config/config-global index 0825c8a73..6593542a7 100755 --- a/tests/lib/config/config-global +++ b/tests/lib/config/config-global @@ -57,8 +57,16 @@ make_init_data() { [[ "${DB_BACKEND}" == "sqlite" ]] || ${CSCLI} machines add --auto "${TEST_DIR}/instance-crowdsec" start - "${CSCLI}" lapi status - [[ -z "${PACKAGE_TESTING}" ]] && "${CSCLI}" decisions delete --all + + "${CSCLI}" decisions delete --all + + loop_max=15 + for ((i = 0; i <= loop_max; i++)); do + sleep 2 + [[ $("${CSCLI}" alerts list -o json) != "null" ]] && break + done + [[ $("${CSCLI}" alerts list -o json) != "null" ]] || die "could not get community data" + "${TEST_DIR}/instance-crowdsec" stop mkdir -p "${LOCAL_INIT_DIR}" @@ -75,7 +83,6 @@ make_init_data() { --file "${LOCAL_INIT_DIR}/init-config-data.tar" "${REL_CONFIG_DIR}" "${REL_DATA_DIR}" ./instance-db setup - remove_init_data } load_init_data() {