From c7422420944e58498665e895a496bdaeb3fdbcb4 Mon Sep 17 00:00:00 2001 From: mmetc <92726601+mmetc@users.noreply.github.com> Date: Fri, 29 Jul 2022 10:34:03 +0200 Subject: [PATCH] Ansible testing (#1691) --- tests/ansible/README.md | 11 ++++---- tests/ansible/provision_dependencies.yml | 21 +++++++++++++--- tests/ansible/requirements.yml | 4 ++- .../roles/bats_requirements/defaults/main.yml | 2 +- .../roles/bats_requirements/tasks/main.yml | 11 ++++---- .../roles/bats_requirements/tasks/netcat.yml | 15 ++++++++--- tests/ansible/roles/common/tasks/main.yml | 14 +++-------- .../tasks/install_from_deb.yml | 25 ++++++++++++++++--- .../tasks/install_from_deb_repo.yml | 4 +-- .../tasks/install_from_rpm.yml | 23 +++++++++++++++-- .../install_crowdsec_package/tasks/main.yml | 18 ++++++------- .../install_crowdsec_package/vars/main.yml | 5 +++- .../install_crowdsec_tests/tasks/main.yml | 9 +++++++ tests/ansible/roles/machine_id/tasks/main.yml | 7 +++++- .../ansible/roles/make_fixture/tasks/main.yml | 4 +-- .../roles/run_func_tests/tasks/main.yml | 6 ++--- tests/ansible/vagrant/alma-9/Vagrantfile | 6 +++++ tests/ansible/vagrant/centos-9/Vagrantfile | 6 +++++ tests/ansible/vagrant/rocky-9/Vagrantfile | 6 +++++ tests/bats/05_config_yaml_local.bats | 13 +++++++--- tests/lib/config/config-global | 17 +++++++------ 21 files changed, 162 insertions(+), 65 deletions(-) create mode 100644 tests/ansible/vagrant/alma-9/Vagrantfile create mode 100644 tests/ansible/vagrant/centos-9/Vagrantfile create mode 100644 tests/ansible/vagrant/rocky-9/Vagrantfile diff --git a/tests/ansible/README.md b/tests/ansible/README.md index c7ab21840..3ae2c2df4 100644 --- a/tests/ansible/README.md +++ b/tests/ansible/README.md @@ -58,16 +58,17 @@ ansible won't be able to see them. variables for Debian and RedHat-based distributions, because stable releases require a package version suffix in the RPM file names. -- `TEST_PACKAGE_FILE`: optional, file pointing to the package under test - (.deb, .rpm, .pkg...). If both `TEST_PACKAGE_VERSION_*` and - `TEST_PACKAGE_FILE` are provided, both are be installed (to test upgrades +- `TEST_PACKAGE_FILE`: optional, file pointing to the package under test (.deb, + .rpm, .pkg...). It can be a glob expression but it must match a single file, + and the pattern works only on the filename. If both `TEST_PACKAGE_VERSION_*` + and `TEST_PACKAGE_FILE` are provided, both are be installed (to test upgrades for example). Requires `PACKAGE_TESTING=true` - `TEST_PACKAGE_DIR`: optional (but conflicts with `TEST_PACKAGE_FILE`), the path to a directory containing packages with the following layout: - For DEB: `{{ package_dir }}/{{ ansible_distribution_release }}_{{ ansible_architecture.replace('x86_64', 'amd64) }}/{{ ansible_distribution_release }}/{{ ansible_architecture.replace('x86_64', 'amd64' }}/crowdsec_*.deb` - For RPM: `{{ package_dir }}/{{ releasever }}/RPMS/{{ ansible_architecture }}/crowdsec-{{ testing_file_version }}*.{{ releasever }}.{{ ansible_architecture }}.rpm` + For DEB: `{{ package_dir }}/{{ ansible_distribution_release }}/{{ ansible_architecture.replace('x86_64', 'amd64' }}/crowdsec_*.deb` + For RPM: `{{ package_dir }}/{{ releasever }}/RPMS/{{ ansible_architecture }}/crowdsec-*.{{ releasever }}.{{ ansible_architecture }}.rpm` - `TEST_SKIP`: optional, comma-separated list of scripts that won't be executed. Example: `TEST_SKIP=02_nolapi.bats,03_noagent.bats` diff --git a/tests/ansible/provision_dependencies.yml b/tests/ansible/provision_dependencies.yml index cdec8afc1..6eb7ed944 100644 --- a/tests/ansible/provision_dependencies.yml +++ b/tests/ansible/provision_dependencies.yml @@ -1,5 +1,5 @@ --- -- name: "install Go (!freebsd)" +- name: "install Go (!bsd)" hosts: all gather_facts: true vars_files: @@ -8,9 +8,9 @@ - ansible.builtin.include_role: name: gantsign.golang when: - - ansible_os_family != "FreeBSD" + - ansible_facts.system == 'Linux' -- name: "install Go (freebsd)" +- name: "install Go (bsd)" hosts: all gather_facts: true become: true @@ -19,7 +19,20 @@ name: go state: present when: - - ansible_os_family == "FreeBSD" + - ansible_facts.system == 'FreeBSD' + +# required for jq and basic tools on centos and rhel +- name: "enable EPEL repository (RedHat)" + hosts: all + become: true + tasks: + - ansible.builtin.include_role: + name: geerlingguy.repo-epel + vars: + epel_repo_disable: false + when: + - ansible_facts.os_family == 'RedHat' + - ansible_facts.distribution != 'Fedora' - name: "apply common configuration to all nodes" hosts: all diff --git a/tests/ansible/requirements.yml b/tests/ansible/requirements.yml index e20812ebf..27295dabd 100644 --- a/tests/ansible/requirements.yml +++ b/tests/ansible/requirements.yml @@ -1,4 +1,6 @@ --- -- src: geerlingguy.postgresql - src: geerlingguy.mysql +- src: geerlingguy.postgresql +- src: geerlingguy.repo-epel - src: gantsign.golang + diff --git a/tests/ansible/roles/bats_requirements/defaults/main.yml b/tests/ansible/roles/bats_requirements/defaults/main.yml index e18ee3032..ad75e642b 100644 --- a/tests/ansible/roles/bats_requirements/defaults/main.yml +++ b/tests/ansible/roles/bats_requirements/defaults/main.yml @@ -1,4 +1,4 @@ --- build_bash: false -build_daemonize: (ansible_distribution == "Ubuntu" and ansible_distribution_version == '16.04') or ansible_distribution == 'Amazon' +build_daemonize: (ansible_facts.distribution == "Ubuntu" and ansible_facts.distribution == '16.04') or ansible_facts.distribution == 'Amazon' diff --git a/tests/ansible/roles/bats_requirements/tasks/main.yml b/tests/ansible/roles/bats_requirements/tasks/main.yml index 0a2c6b9c5..b45b1abf9 100644 --- a/tests/ansible/roles/bats_requirements/tasks/main.yml +++ b/tests/ansible/roles/bats_requirements/tasks/main.yml @@ -5,7 +5,7 @@ - name: "Install daemonize" ansible.builtin.import_tasks: daemonize.yml when: - - ansible_os_family != 'FreeBSD' + - ansible_facts.system == 'Linux' - name: "install netcat" ansible.builtin.import_tasks: netcat.yml @@ -25,15 +25,16 @@ name: - bc when: - - ansible_os_family != 'FreeBSD' + - ansible_facts.system == 'Linux' -- name: "install base64(freebsd)" +# base64 for linux is in coreutils +- name: "install base64 (freebsd)" become: true ansible.builtin.package: name: - base64 when: - - ansible_os_family == 'FreeBSD' + - ansible_facts.system == 'FreeBSD' - name: "install pidof (Amazon)" become: true @@ -41,7 +42,7 @@ name: - procps-ng when: - - ansible_distribution == 'Amazon' + - ansible_facts.distribution == 'Amazon' - name: "install gcc (for go-sqlite, needs cgo)" become: true diff --git a/tests/ansible/roles/bats_requirements/tasks/netcat.yml b/tests/ansible/roles/bats_requirements/tasks/netcat.yml index feb417448..a8bf0853f 100644 --- a/tests/ansible/roles/bats_requirements/tasks/netcat.yml +++ b/tests/ansible/roles/bats_requirements/tasks/netcat.yml @@ -5,7 +5,7 @@ name: - nmap-ncat when: - - ansible_facts['distribution'] in ['Amazon', 'Fedora', 'CentOS', 'OracleLinux'] + - ansible_facts.distribution in ['Amazon', 'Fedora', 'CentOS', 'OracleLinux'] - name: "install netcat (RedHat)" become: true @@ -13,7 +13,7 @@ name: - netcat when: - - ansible_facts['distribution'] == 'RedHat' + - (ansible_facts.distribution == 'RedHat') or (ansible_facts.distribution == 'AlmaLinux') # "netcat" does not exist in some versions (only -traditional or -openbsd) - name: "install netcat (Debian)" @@ -22,4 +22,13 @@ name: - netcat-traditional when: - - ansible_os_family == "Debian" + - ansible_facts.os_family == "Debian" + +# "netcat" does not exist in some versions (only -traditional or -openbsd) +- name: "install netcat (Suse)" + become: true + ansible.builtin.package: + name: + - netcat-openbsd + when: + - ansible_facts.os_family == "Suse" diff --git a/tests/ansible/roles/common/tasks/main.yml b/tests/ansible/roles/common/tasks/main.yml index b7a14a7c2..baa01129c 100644 --- a/tests/ansible/roles/common/tasks/main.yml +++ b/tests/ansible/roles/common/tasks/main.yml @@ -1,19 +1,11 @@ --- -# required for (at least) jq -- name: "enable EPEL" - become: true - ansible.builtin.package: - name: epel-release - when: - - ansible_distribution == 'CentOS' - - name: "update package cache (Debian)" become: true ansible.builtin.apt: upgrade: false update_cache: true when: - - ansible_os_family == "Debian" + - ansible_facts.os_family == "Debian" - name: "install gcc, git" become: true @@ -28,7 +20,7 @@ name: - make when: - - ansible_os_family != "FreeBSD" + - ansible_facts.system == "Linux" - name: "install gmake (FreeBSD)" become: true @@ -36,4 +28,4 @@ name: - gmake when: - - ansible_os_family == "FreeBSD" + - ansible_facts.system == "FreeBSD" diff --git a/tests/ansible/roles/install_crowdsec_package/tasks/install_from_deb.yml b/tests/ansible/roles/install_crowdsec_package/tasks/install_from_deb.yml index a8b341843..afb2b0ba2 100644 --- a/tests/ansible/roles/install_crowdsec_package/tasks/install_from_deb.yml +++ b/tests/ansible/roles/install_crowdsec_package/tasks/install_from_deb.yml @@ -1,19 +1,38 @@ --- - name: "set package_file from package_dir" ansible.builtin.set_fact: - package_file: "{{ package_dir }}/{{ ansible_distribution_release }}_{{ ansible_architecture.replace('x86_64', 'amd64) }}/{{ ansible_distribution_release }}/{{ ansible_architecture.replace('x86_64', 'amd64' }}/crowdsec_*.deb" + package_file: "{{ package_dir }}/{{ ansible_facts.distribution_release }}/{{ ansible_facts.architecture.replace('x86_64', 'amd64') }}/crowdsec_*.deb" when: - (package_dir is defined) and (package_dir | length > 0) +- name: "look for .deb file matching package_file" + ansible.builtin.set_fact: + found_file: "{{ item }}" + with_fileglob: + - "{{ package_file }}" + when: + - (package_file is defined) and (package_file | length > 0) + +- name: "check found_file" + ansible.builtin.fail: + msg: "No file found matching {{ package_file }}" + when: + - found_file is not defined + - (package_file is defined) and (package_file | length > 0) + - name: "copy built file for deb-like" become: false ansible.builtin.copy: - src: "{{ package_file }}" + src: "{{ found_file }}" dest: "{{ ansible_env.HOME }}/crowdsec.deb" mode: 0o644 + when: + - (package_file is defined) and (package_file | length > 0) - name: "install crowdsec on deb-like" become: true ansible.builtin.apt: - name: "{{ ansible_env.HOME }}/crowdsec.deb" + deb: "{{ ansible_env.HOME }}/crowdsec.deb" allow_downgrade: true + when: + - (package_file is defined) and (package_file | length > 0) diff --git a/tests/ansible/roles/install_crowdsec_package/tasks/install_from_deb_repo.yml b/tests/ansible/roles/install_crowdsec_package/tasks/install_from_deb_repo.yml index 624603b3c..4b55fe1ea 100644 --- a/tests/ansible/roles/install_crowdsec_package/tasks/install_from_deb_repo.yml +++ b/tests/ansible/roles/install_crowdsec_package/tasks/install_from_deb_repo.yml @@ -14,7 +14,7 @@ - name: "add crowdsec repo [2/2] (*.deb)" become: true ansible.builtin.apt_repository: - repo: deb https://packagecloud.io/crowdsec/crowdsec/{{ ansible_distribution | lower }}/ {{ ansible_distribution_release }} main + repo: deb https://packagecloud.io/crowdsec/crowdsec/{{ ansible_facts.distribution | lower }}/ {{ ansible_facts.distribution_release }} main - name: "install crowdsec testing repo [1/2] (*.deb)" become: true @@ -24,7 +24,7 @@ - name: "add crowdsec testing repo [1/2] (*.deb)" become: true ansible.builtin.apt_repository: - repo: deb https://packagecloud.io/crowdsec/crowdsec-testing/{{ ansible_distribution | lower }}/ {{ ansible_distribution_release }} main + repo: deb https://packagecloud.io/crowdsec/crowdsec-testing/{{ ansible_facts.distribution | lower }}/ {{ ansible_facts.distribution_release }} main - name: "install crowdsec" become: true diff --git a/tests/ansible/roles/install_crowdsec_package/tasks/install_from_rpm.yml b/tests/ansible/roles/install_crowdsec_package/tasks/install_from_rpm.yml index a96ab8387..bb74c0af6 100644 --- a/tests/ansible/roles/install_crowdsec_package/tasks/install_from_rpm.yml +++ b/tests/ansible/roles/install_crowdsec_package/tasks/install_from_rpm.yml @@ -1,16 +1,33 @@ --- - name: "set package_file from package_dir" ansible.builtin.set_fact: - package_file: "{{ package_dir }}/{{ releasever }}/RPMS/{{ ansible_architecture }}/crowdsec-{{ testing_file_version }}*.{{ releasever }}.{{ ansible_architecture }}.rpm" + package_file: "{{ package_dir }}/{{ releasever }}/RPMS/{{ ansible_facts.architecture }}/crowdsec-*.{{ releasever }}.{{ ansible_facts.architecture }}.rpm" when: - (package_dir is defined) and (package_dir | length > 0) +- name: "look for .rpm file matching package_file" + ansible.builtin.set_fact: + found_file: "{{ item }}" + with_fileglob: + - "{{ package_file }}" + when: + - (package_file is defined) and (package_file | length > 0) + +- name: "check found_file" + ansible.builtin.fail: + msg: "No file found matching {{ package_file }}" + when: + - found_file is not defined + - (package_file is defined) and (package_file | length > 0) + - name: "copy built file for rpm-like" become: false ansible.builtin.copy: - src: "{{ package_file }}" + src: "{{ found_file }}" dest: "{{ ansible_env.HOME }}/crowdsec.rpm" mode: 0o644 + when: + - (package_file is defined) and (package_file | length > 0) - name: "install crowdsec on rpm-like" become: true @@ -18,3 +35,5 @@ name: "{{ ansible_env.HOME }}/crowdsec.rpm" disable_gpg_check: true allow_downgrade: true + when: + - (package_file is defined) and (package_file | length > 0) diff --git a/tests/ansible/roles/install_crowdsec_package/tasks/main.yml b/tests/ansible/roles/install_crowdsec_package/tasks/main.yml index da22a598e..3c2bc1f92 100644 --- a/tests/ansible/roles/install_crowdsec_package/tasks/main.yml +++ b/tests/ansible/roles/install_crowdsec_package/tasks/main.yml @@ -2,32 +2,30 @@ - name: "system details" ansible.builtin.debug: msg: | - Distribution: {{ ansible_distribution }} - Version: {{ ansible_distribution_version }} - Major: {{ ansible_distribution_major_version }} - Release: {{ ansible_distribution_release }} + Distribution: {{ ansible_facts.distribution }} + Version: {{ ansible_facts.distribution_version }} + Major: {{ ansible_facts.distribution_major_version }} + Release: {{ ansible_facts.distribution_release }} Releasever: {{ releasever }} - name: "install from binary repository (RedHat)" ansible.builtin.import_tasks: install_from_rpm_repo.yml when: - (package_version_rpm is defined) and (package_version_rpm|length > 0) - - ansible_os_family == "RedHat" + - ansible_facts.os_family == "RedHat" - name: "install from binary repository (Debian)" ansible.builtin.import_tasks: install_from_deb_repo.yml when: - (package_version_deb is defined) and (package_version_deb|length > 0) - - ansible_os_family == "Debian" + - ansible_facts.os_family == "Debian" - name: "install from *.rpm package file" ansible.builtin.import_tasks: install_from_rpm.yml when: - - (package_file is defined) and (package_file|length > 0) - - ansible_os_family == "RedHat" + - ansible_facts.os_family == "RedHat" - name: "install from *.deb package file" ansible.builtin.import_tasks: install_from_deb.yml when: - - (package_file is defined) and (package_file|length > 0) - - ansible_os_family == "Debian" + - ansible_facts.os_family == "Debian" diff --git a/tests/ansible/roles/install_crowdsec_package/vars/main.yml b/tests/ansible/roles/install_crowdsec_package/vars/main.yml index 90654b74c..1fc3b413f 100644 --- a/tests/ansible/roles/install_crowdsec_package/vars/main.yml +++ b/tests/ansible/roles/install_crowdsec_package/vars/main.yml @@ -7,8 +7,11 @@ release: Ubuntu: ubuntu FreeBSD: freebsd OracleLinux: ol + Rocky: el + AlmaLinux: el + openSUSE Leap: opensuse -releasever: "{{ release[ansible_distribution] + ansible_distribution_major_version }}" +releasever: "{{ release[ansible_facts.distribution] + ansible_facts.distribution_major_version }}" package_version_deb: "{{ lookup('ansible.builtin.env', 'TEST_PACKAGE_VERSION_DEB') }}" package_version_rpm: "{{ lookup('ansible.builtin.env', 'TEST_PACKAGE_VERSION_RPM') }}" diff --git a/tests/ansible/roles/install_crowdsec_tests/tasks/main.yml b/tests/ansible/roles/install_crowdsec_tests/tasks/main.yml index b728a9be5..db6fea05f 100644 --- a/tests/ansible/roles/install_crowdsec_tests/tasks/main.yml +++ b/tests/ansible/roles/install_crowdsec_tests/tasks/main.yml @@ -60,6 +60,15 @@ when: - (suite_zip is not defined) or (suite_zip|length == 0) +- name: set safe.directory on crowdsec dir" + become: false + ansible.builtin.git_config: + scope: global + name: safe.directory + value: "{{ ansible_env.HOME }}/crowdsec" + when: + - (suite_zip is not defined) or (suite_zip|length == 0) + - name: "install tests: create crowdsec tests/local dir" become: false ansible.builtin.file: diff --git a/tests/ansible/roles/machine_id/tasks/main.yml b/tests/ansible/roles/machine_id/tasks/main.yml index 30eee41e5..26756f5a4 100644 --- a/tests/ansible/roles/machine_id/tasks/main.yml +++ b/tests/ansible/roles/machine_id/tasks/main.yml @@ -6,6 +6,11 @@ content: "{{ machine_id }}" mode: 0o444 +- name: "see if /var/lib/dbus exists" + ansible.builtin.stat: + path: "/var/lib/dbus" + register: dbus + # some distributions use var/lib/dbus, # but the directory doesn't exists on fedora - name: "set /var/lib/dbus/machine-id" @@ -15,4 +20,4 @@ content: "{{ machine_id }}" mode: 0o444 when: - - ansible_os_family != 'FreeBSD' and ansible_distribution != "Fedora" + - dbus.stat.exists diff --git a/tests/ansible/roles/make_fixture/tasks/main.yml b/tests/ansible/roles/make_fixture/tasks/main.yml index bbf539215..65a5bd200 100644 --- a/tests/ansible/roles/make_fixture/tasks/main.yml +++ b/tests/ansible/roles/make_fixture/tasks/main.yml @@ -3,13 +3,13 @@ ansible.builtin.set_fact: make_cmd: make when: - - ansible_os_family != 'FreeBSD' + - ansible_facts.system != 'FreeBSD' - name: "set make_cmd = gmake (freebsd)" ansible.builtin.set_fact: make_cmd: gmake when: - - ansible_os_family == 'FreeBSD' + - ansible_facts.system == 'FreeBSD' - name: "build crowdsec from sources, prepare test environment and fixture" become: false diff --git a/tests/ansible/roles/run_func_tests/tasks/main.yml b/tests/ansible/roles/run_func_tests/tasks/main.yml index 9338488f5..86243b07e 100644 --- a/tests/ansible/roles/run_func_tests/tasks/main.yml +++ b/tests/ansible/roles/run_func_tests/tasks/main.yml @@ -9,7 +9,7 @@ state: directory when: - (package_testing is defined) and (package_testing not in ['', 'false', 'False']) - - ansible_os_family in ["RedHat", "Debian"] + - ansible_facts.os_family in ["RedHat", "Debian"] - name: "override StartLimitBurst" become: true @@ -23,7 +23,7 @@ value: 100 when: - (package_testing is defined) and (package_testing not in ['', 'false', 'False']) - - ansible_os_family in ["RedHat", "Debian"] + - ansible_facts.os_family in ["RedHat", "Debian"] - name: "systemctl daemon-reload" become: true @@ -31,7 +31,7 @@ daemon_reload: true when: - (package_testing is defined) and (package_testing not in ['', 'false', 'False']) - - ansible_os_family in ["RedHat", "Debian"] + - ansible_facts.os_family in ["RedHat", "Debian"] - name: "search for test scripts" become: false diff --git a/tests/ansible/vagrant/alma-9/Vagrantfile b/tests/ansible/vagrant/alma-9/Vagrantfile new file mode 100644 index 000000000..0a8a72e67 --- /dev/null +++ b/tests/ansible/vagrant/alma-9/Vagrantfile @@ -0,0 +1,6 @@ +common = '../Vagrantfile.common' +load common if File.exists?(common) + +Vagrant.configure("2") do |config| + config.vm.box = "generic/alma9" +end diff --git a/tests/ansible/vagrant/centos-9/Vagrantfile b/tests/ansible/vagrant/centos-9/Vagrantfile new file mode 100644 index 000000000..4178473df --- /dev/null +++ b/tests/ansible/vagrant/centos-9/Vagrantfile @@ -0,0 +1,6 @@ +common = '../Vagrantfile.common' +load common if File.exists?(common) + +Vagrant.configure("2") do |config| + config.vm.box = "generic/centos9s" +end diff --git a/tests/ansible/vagrant/rocky-9/Vagrantfile b/tests/ansible/vagrant/rocky-9/Vagrantfile new file mode 100644 index 000000000..0021a1ac7 --- /dev/null +++ b/tests/ansible/vagrant/rocky-9/Vagrantfile @@ -0,0 +1,6 @@ +common = '../Vagrantfile.common' +load common if File.exists?(common) + +Vagrant.configure("2") do |config| + config.vm.box = "generic/rocky9" +end diff --git a/tests/bats/05_config_yaml_local.bats b/tests/bats/05_config_yaml_local.bats index 0e43cbff0..6bdf413a9 100644 --- a/tests/bats/05_config_yaml_local.bats +++ b/tests/bats/05_config_yaml_local.bats @@ -129,9 +129,14 @@ teardown() { ./instance-crowdsec start fake_log >>"${tmpfile}" - sleep 2 + + # this could be simplified, but some systems are slow and we don't want to + # wait more than required + for ((idx = 0; idx < 20; idx++)); do + sleep .5 + run -0 --separate-stderr cscli decisions list -o json + run -0 jq --exit-status '.[].decisions[0] | [.value,.type] == ["1.1.1.172","captcha"]' <(output) && break + done rm -f -- "${tmpfile}" - run -0 --separate-stderr cscli decisions list -o json - run -0 jq -c '.[].decisions[0] | [.value,.type]' <(output) - assert_output '["1.1.1.172","captcha"]' + [[ "${status}" -eq 0 ]] || fail "captcha not triggered" } diff --git a/tests/lib/config/config-global b/tests/lib/config/config-global index 2e1774f7a..4a3a270ed 100755 --- a/tests/lib/config/config-global +++ b/tests/lib/config/config-global @@ -58,14 +58,17 @@ make_init_data() { "${TEST_DIR}/instance-crowdsec" start - "${CSCLI}" decisions delete --all - - loop_max=15 - for ((i = 0; i <= loop_max; i++)); do - sleep 2 - [[ $("${CSCLI}" alerts list -o json) != "null" ]] && break + for ((i=0; i<10; i++)); do + sleep .5 + "${CSCLI}" decisions delete --all && break done - [[ $("${CSCLI}" alerts list -a -o json) != "null" ]] || die "could not get community data" + + for ((i=0; i<15; i++)); do + sleep 2 + [[ $("${CSCLI}" alerts list -a -o json) != "null" ]] && break + done + # shellcheck disable=SC2181 + [[ "$?" -ne "0" ]] && die "could not get community data" "${TEST_DIR}/instance-crowdsec" stop