From 73f71a0aa3f247c5d96ed7bff71dc8a47b730847 Mon Sep 17 00:00:00 2001 From: mmetc <92726601+mmetc@users.noreply.github.com> Date: Tue, 4 Jul 2023 12:26:32 +0200 Subject: [PATCH] tests: vagrant refactoring (#2328) --- Makefile | 20 ++++-- test/ansible/debug_tools.yml | 2 + test/ansible/provision_dependencies.yml | 1 - test/ansible/requirements.yml | 4 +- .../ansible/roles/make_fixture/tasks/main.yml | 12 ++++ test/ansible/vagrant/alma-8/Vagrantfile | 5 +- test/ansible/vagrant/alma-8/bootstrap | 5 -- test/ansible/vagrant/alma-9/Vagrantfile | 5 +- test/ansible/vagrant/alma-9/bootstrap | 5 -- test/ansible/vagrant/centos-7/Vagrantfile | 2 + test/ansible/vagrant/centos-8/Vagrantfile | 5 +- test/ansible/vagrant/centos-8/bootstrap | 6 -- test/ansible/vagrant/centos-9/Vagrantfile | 5 +- test/ansible/vagrant/centos-9/bootstrap | 6 -- test/ansible/vagrant/common | 65 +++++++++++++----- .../vagrant/debian-10-buster/Vagrantfile | 2 + .../vagrant/debian-11-bullseye/Vagrantfile | 2 + .../vagrant/debian-12-bookworm/Vagrantfile | 3 + .../vagrant/debian-9-stretch/Vagrantfile | 3 + .../vagrant/debian-testing/Vagrantfile | 2 + .../experimental/hardenedbsd-13/Vagrantfile | 21 ++---- .../experimental/hardenedbsd-13/bootstrap | 5 -- .../experimental/openbsd-6/Vagrantfile | 14 ++++ .../vagrant/experimental/openbsd-6/skip | 9 +++ .../experimental/openbsd-7/Vagrantfile | 24 +++---- .../vagrant/experimental/openbsd-7/bootstrap | 6 -- test/ansible/vagrant/fedora-33/Vagrantfile | 2 + test/ansible/vagrant/fedora-34/Vagrantfile | 2 + test/ansible/vagrant/fedora-35/Vagrantfile | 2 + test/ansible/vagrant/fedora-36/Vagrantfile | 2 + test/ansible/vagrant/fedora-37/Vagrantfile | 4 +- test/ansible/vagrant/fedora-37/bootstrap | 5 -- test/ansible/vagrant/fedora-38/Vagrantfile | 4 +- test/ansible/vagrant/freebsd-12/Vagrantfile | 4 +- test/ansible/vagrant/freebsd-12/bootstrap | 6 -- test/ansible/vagrant/freebsd-13/Vagrantfile | 4 +- test/ansible/vagrant/freebsd-13/bootstrap | 6 -- test/ansible/vagrant/oracle-7/Vagrantfile | 3 + test/ansible/vagrant/oracle-8/Vagrantfile | 3 + test/ansible/vagrant/oracle-9/Vagrantfile | 3 + test/ansible/vagrant/rocky-8/Vagrantfile | 4 ++ test/ansible/vagrant/rocky-9/Vagrantfile | 4 ++ .../vagrant/ubuntu-16.04-xenial/Vagrantfile | 2 + .../vagrant/ubuntu-18.04-bionic/Vagrantfile | 2 + .../vagrant/ubuntu-20.04-focal/Vagrantfile | 3 + .../vagrant/ubuntu-20.04-focal/bootstrap | 5 -- .../vagrant/ubuntu-22.04-jammy/Vagrantfile | 2 + .../vagrant/ubuntu-22.10-kinetic/Vagrantfile | 10 +++ .../vagrant/ubuntu-23.04-lunar/Vagrantfile | 10 +++ .../vagrant/wizard/centos-8/Vagrantfile | 43 +++--------- .../ansible/vagrant/wizard/centos-8/bootstrap | 5 -- test/ansible/vagrant/wizard/common | 67 +++++++++++++++++++ .../wizard/debian-10-buster/Vagrantfile | 12 ++++ .../wizard/debian-11-bullseye/Vagrantfile | 12 ++++ .../wizard/debian-12-bookworm/Vagrantfile | 12 ++++ .../wizard/debian-bullseye/Vagrantfile | 43 ------------ .../vagrant/wizard/debian-bullseye/bootstrap | 5 -- .../vagrant/wizard/debian-buster/Vagrantfile | 43 ------------ .../vagrant/wizard/debian-buster/bootstrap | 5 -- .../vagrant/wizard/fedora-36/Vagrantfile | 39 ++--------- .../vagrant/wizard/fedora-36/bootstrap | 5 -- .../wizard/ubuntu-22.04-jammy/Vagrantfile | 44 ++---------- .../wizard/ubuntu-22.04-jammy/bootstrap | 5 -- .../wizard/ubuntu-22.10-kinetic/Vagrantfile | 44 ++---------- test/bats-detect/openresty-deb.bats | 7 +- test/bats-detect/openresty-rpm.bats | 8 ++- test/bats/01_cscli.bats | 2 +- 67 files changed, 354 insertions(+), 378 deletions(-) delete mode 100755 test/ansible/vagrant/alma-8/bootstrap delete mode 100755 test/ansible/vagrant/alma-9/bootstrap delete mode 100755 test/ansible/vagrant/centos-8/bootstrap delete mode 100755 test/ansible/vagrant/centos-9/bootstrap delete mode 100755 test/ansible/vagrant/experimental/hardenedbsd-13/bootstrap create mode 100644 test/ansible/vagrant/experimental/openbsd-6/Vagrantfile create mode 100755 test/ansible/vagrant/experimental/openbsd-6/skip delete mode 100755 test/ansible/vagrant/experimental/openbsd-7/bootstrap delete mode 100755 test/ansible/vagrant/fedora-37/bootstrap delete mode 100644 test/ansible/vagrant/freebsd-12/bootstrap delete mode 100644 test/ansible/vagrant/freebsd-13/bootstrap delete mode 100644 test/ansible/vagrant/ubuntu-20.04-focal/bootstrap create mode 100644 test/ansible/vagrant/ubuntu-22.10-kinetic/Vagrantfile create mode 100644 test/ansible/vagrant/ubuntu-23.04-lunar/Vagrantfile delete mode 100755 test/ansible/vagrant/wizard/centos-8/bootstrap create mode 100644 test/ansible/vagrant/wizard/common create mode 100644 test/ansible/vagrant/wizard/debian-10-buster/Vagrantfile create mode 100644 test/ansible/vagrant/wizard/debian-11-bullseye/Vagrantfile create mode 100644 test/ansible/vagrant/wizard/debian-12-bookworm/Vagrantfile delete mode 100644 test/ansible/vagrant/wizard/debian-bullseye/Vagrantfile delete mode 100755 test/ansible/vagrant/wizard/debian-bullseye/bootstrap delete mode 100644 test/ansible/vagrant/wizard/debian-buster/Vagrantfile delete mode 100755 test/ansible/vagrant/wizard/debian-buster/bootstrap delete mode 100755 test/ansible/vagrant/wizard/fedora-36/bootstrap delete mode 100755 test/ansible/vagrant/wizard/ubuntu-22.04-jammy/bootstrap diff --git a/Makefile b/Makefile index 8943c6782..0fb36261f 100644 --- a/Makefile +++ b/Makefile @@ -11,13 +11,13 @@ include mk/gmsl # MacOS: brew install re2 # To build without re2, run "make BUILD_RE2_WASM=1" -# The WASM version works just as well but might have performance issues, XXX: clarify -# so it is not recommended for production use. +# The WASM version is slower and introduces a short delay when starting a process +# (including cscli) so it is not recommended for production use. BUILD_RE2_WASM ?= 0 # To build static binaries, run "make BUILD_STATIC=1". -# On some platforms, this requires -# additional packages (e.g. glibc-static and libstdc++-static on fedora, centos..). +# On some platforms, this requires additional packages +# (e.g. glibc-static and libstdc++-static on fedora, centos.. which are on the powertools/crb repository). # If the static build fails at the link stage, it might be because the static library is not provided # for your distribution (look for libre2.a). See the Dockerfile for an example of how to build it. BUILD_STATIC ?= 0 @@ -77,8 +77,6 @@ LD_OPTS_VARS += -X '$(GO_MODULE_NAME)/pkg/cwversion.System=docker' endif GO_TAGS := netgo,osusergo,sqlite_omit_load_extension -# this will be used by Go in the make target -export PKG_CONFIG_PATH:=/usr/local/lib/pkgconfig:$(PKG_CONFIG_PATH) ifeq ($(call bool,$(BUILD_RE2_WASM)),0) ifeq ($(PKG_CONFIG),) @@ -115,6 +113,7 @@ endif .PHONY: build build: pre-build goversion crowdsec cscli plugins +# Sanity checks and build information .PHONY: pre-build pre-build: $(info Building $(BUILD_VERSION) ($(BUILD_TAG)) $(BUILD_TYPE) for $(GOOS)/$(GOARCH)) @@ -166,6 +165,7 @@ testclean: bats-clean @$(RM) pkg/cwhub/install $(WIN_IGNORE_ERR) @$(RM) pkg/types/example.txt $(WIN_IGNORE_ERR) +# for the tests with localstack export AWS_ENDPOINT_FORCE=http://localhost:4566 export AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE export AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY @@ -173,15 +173,18 @@ export AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY testenv: @echo 'NOTE: You need Docker, docker-compose and run "make localstack" in a separate shell ("make localstack-stop" to terminate it)' +# run the tests with localstack .PHONY: test test: testenv goversion $(GOTEST) $(LD_OPTS) ./... +# run the tests with localstack and coverage .PHONY: go-acc go-acc: testenv goversion go-acc ./... -o coverage.out --ignore database,notifications,protobufs,cwversion,cstest,models -- $(LD_OPTS) | \ sed 's/ *coverage:.*of statements in.*//' +# mock AWS services .PHONY: localstack localstack: docker-compose -f test/localstack/docker-compose.yml up @@ -193,6 +196,7 @@ localstack-stop: # list of plugins that contain go.mod PLUGIN_VENDOR = $(foreach plugin,$(PLUGINS),$(shell if [ -f $(PLUGINS_DIR)/$(plugin)/go.mod ]; then echo $(PLUGINS_DIR)/$(plugin); fi)) +# build vendor.tgz to be distributed with the release .PHONY: vendor vendor: $(foreach plugin_dir,$(PLUGIN_VENDOR), \ @@ -203,6 +207,7 @@ vendor: $(GOCMD) mod vendor tar -czf vendor.tgz vendor $(foreach plugin_dir,$(PLUGIN_VENDOR),$(plugin_dir)/vendor) +# remove vendor directories and vendor.tgz .PHONY: vendor-remove vendor-remove: $(foreach plugin_dir,$(PLUGIN_VENDOR), \ @@ -239,13 +244,16 @@ else @if (Test-Path -Path $(RELDIR)) { echo "$(RELDIR) already exists, abort" ; exit 1 ; } endif +# build a release tarball .PHONY: release release: check_release build package +# build the windows installer .PHONY: windows_installer windows_installer: build @.\make_installer.ps1 -version $(BUILD_VERSION) +# build the chocolatey package .PHONY: chocolatey chocolatey: windows_installer @.\make_chocolatey.ps1 -version $(BUILD_VERSION) diff --git a/test/ansible/debug_tools.yml b/test/ansible/debug_tools.yml index 15baa7cab..769a973fe 100644 --- a/test/ansible/debug_tools.yml +++ b/test/ansible/debug_tools.yml @@ -14,3 +14,5 @@ - zsh-autosuggestions - zsh-syntax-highlighting - zsh-theme-powerlevel9k + when: + - ansible_facts.os_family == "Debian" diff --git a/test/ansible/provision_dependencies.yml b/test/ansible/provision_dependencies.yml index 9c85e29ed..bcfe8fcca 100644 --- a/test/ansible/provision_dependencies.yml +++ b/test/ansible/provision_dependencies.yml @@ -10,7 +10,6 @@ - crowdsecurity.testing.go - crowdsecurity.testing.machine_id - crowdsecurity.testing.epel - - crowdsecurity.testing.powertools - crowdsecurity.testing.git - crowdsecurity.testing.gcc - crowdsecurity.testing.gnu_make diff --git a/test/ansible/requirements.yml b/test/ansible/requirements.yml index adf7c27f8..70f8ca394 100644 --- a/test/ansible/requirements.yml +++ b/test/ansible/requirements.yml @@ -9,12 +9,12 @@ roles: # these should be included as dependencies of crowdsecurity.testing, but sometime are not - src: geerlingguy.repo-epel - src: gantsign.golang - - src: robertdebock.powertools collections: + - name: ansible.posix - name: https://github.com/crowdsecurity/ansible-collection-crowdsecurity.testing.git type: git - version: v0.0.3 + version: v0.0.4 # - name: crowdsecurity.testing # source: ../../../crowdsecurity.testing diff --git a/test/ansible/roles/make_fixture/tasks/main.yml b/test/ansible/roles/make_fixture/tasks/main.yml index bb255a04c..305cec3a6 100644 --- a/test/ansible/roles/make_fixture/tasks/main.yml +++ b/test/ansible/roles/make_fixture/tasks/main.yml @@ -1,6 +1,18 @@ # vim: set ft=yaml.ansible: --- +- name: "Set make_cmd = make (!bsd)" + ansible.builtin.set_fact: + make_cmd: make + when: + - ansible_facts.system not in ['FreeBSD', 'OpenBSD'] + +- name: "Set make_cmd = gmake (bsd)" + ansible.builtin.set_fact: + make_cmd: gmake + when: + - ansible_facts.system in ['FreeBSD', 'OpenBSD'] + - name: "Build crowdsec from sources, prepare test environment and fixture" become: false block: diff --git a/test/ansible/vagrant/alma-8/Vagrantfile b/test/ansible/vagrant/alma-8/Vagrantfile index a1837affb..e246c77ff 100644 --- a/test/ansible/vagrant/alma-8/Vagrantfile +++ b/test/ansible/vagrant/alma-8/Vagrantfile @@ -2,7 +2,10 @@ Vagrant.configure('2') do |config| config.vm.box = 'generic/alma8' - config.vm.provision 'shell', path: 'bootstrap' + config.vm.provision "shell", inline: <<-SHELL + sudo dnf -y install dnf-plugins-core kitty-terminfo + sudo dnf config-manager --set-enabled powertools + SHELL end common = '../common' diff --git a/test/ansible/vagrant/alma-8/bootstrap b/test/ansible/vagrant/alma-8/bootstrap deleted file mode 100755 index f714b2c7c..000000000 --- a/test/ansible/vagrant/alma-8/bootstrap +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -unset IFS -set -euf - -sudo dnf -y install kitty-terminfo diff --git a/test/ansible/vagrant/alma-9/Vagrantfile b/test/ansible/vagrant/alma-9/Vagrantfile index d15917602..9c3d1b67c 100644 --- a/test/ansible/vagrant/alma-9/Vagrantfile +++ b/test/ansible/vagrant/alma-9/Vagrantfile @@ -2,7 +2,10 @@ Vagrant.configure('2') do |config| config.vm.box = 'generic/alma9' - config.vm.provision 'shell', path: 'bootstrap' + config.vm.provision "shell", inline: <<-SHELL + sudo dnf -y install kitty-terminfo + sudo dnf config-manager --set-enabled crb + SHELL end common = '../common' diff --git a/test/ansible/vagrant/alma-9/bootstrap b/test/ansible/vagrant/alma-9/bootstrap deleted file mode 100755 index f714b2c7c..000000000 --- a/test/ansible/vagrant/alma-9/bootstrap +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -unset IFS -set -euf - -sudo dnf -y install kitty-terminfo diff --git a/test/ansible/vagrant/centos-7/Vagrantfile b/test/ansible/vagrant/centos-7/Vagrantfile index d7ac021d2..fd207359f 100644 --- a/test/ansible/vagrant/centos-7/Vagrantfile +++ b/test/ansible/vagrant/centos-7/Vagrantfile @@ -2,6 +2,8 @@ Vagrant.configure('2') do |config| config.vm.box = 'centos/7' + config.vm.provision "shell", inline: <<-SHELL + SHELL end common = '../common' diff --git a/test/ansible/vagrant/centos-8/Vagrantfile b/test/ansible/vagrant/centos-8/Vagrantfile index 5ef3ec721..a88d621c4 100644 --- a/test/ansible/vagrant/centos-8/Vagrantfile +++ b/test/ansible/vagrant/centos-8/Vagrantfile @@ -2,7 +2,10 @@ Vagrant.configure('2') do |config| config.vm.box = 'generic/centos8s' - config.vm.provision 'shell', path: 'bootstrap' + config.vm.provision "shell", inline: <<-SHELL + sudo dnf -y install dnf-plugins-core kitty-terminfo + sudo dnf config-manager --set-enabled powertools + SHELL end common = '../common' diff --git a/test/ansible/vagrant/centos-8/bootstrap b/test/ansible/vagrant/centos-8/bootstrap deleted file mode 100755 index 6e1ce0409..000000000 --- a/test/ansible/vagrant/centos-8/bootstrap +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -unset IFS -set -euf - -sudo dnf -y install dnf-plugins-core -dnf config-manager --set-enabled powertools diff --git a/test/ansible/vagrant/centos-9/Vagrantfile b/test/ansible/vagrant/centos-9/Vagrantfile index a1fe2b5f7..1087225be 100644 --- a/test/ansible/vagrant/centos-9/Vagrantfile +++ b/test/ansible/vagrant/centos-9/Vagrantfile @@ -2,7 +2,10 @@ Vagrant.configure('2') do |config| config.vm.box = 'generic/centos9s' - config.vm.provision 'shell', path: 'bootstrap' + config.vm.provision "shell", inline: <<-SHELL + sudo dnf -y install dnf-plugins-core + sudo dnf config-manager --set-enabled crb + SHELL end common = '../common' diff --git a/test/ansible/vagrant/centos-9/bootstrap b/test/ansible/vagrant/centos-9/bootstrap deleted file mode 100755 index ea7a5fbc6..000000000 --- a/test/ansible/vagrant/centos-9/bootstrap +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -unset IFS -set -euf - -sudo dnf -y install dnf-plugins-core -dnf config-manager --set-enabled crb diff --git a/test/ansible/vagrant/common b/test/ansible/vagrant/common index adafa08c5..4bc237a7e 100644 --- a/test/ansible/vagrant/common +++ b/test/ansible/vagrant/common @@ -1,46 +1,75 @@ # vim: set ft=ruby: # frozen_string_literal: true +def find_ansible_cfg + path = Pathname.new(Dir.pwd) + until path.root? + ansible_cfg = path + 'ansible.cfg' + return path if ansible_cfg.exist? + path = path.parent + end + nil # return nil if not found +end + Vagrant.configure('2') do |config| config.vm.define 'crowdsec' + if ARGV.any? { |arg| arg == 'up' || arg == 'provision' } + unless ENV['DB_BACKEND'] + $stderr.puts "\e[31mThe DB_BACKEND environment variable is not defined. Please set up the environment and try again.\e[0m" + exit 1 + end + end + + config.vm.provision 'shell', path: 'bootstrap' if File.exists?('bootstrap') + config.vm.synced_folder '.', '/vagrant', disabled: true + config.vm.provider :libvirt do |libvirt| libvirt.cpus = 1 libvirt.memory = 1536 end - config.vm.synced_folder '.', '/vagrant', disabled: true + path = find_ansible_cfg + if !path + puts "ansible.cfg not found" + end config.vm.provision 'ansible' do |ansible| # ansible.verbose = 'vvvv' - ansible.config_file = '../../ansible.cfg' - ansible.playbook = '../../run_all.yml' + ansible.config_file = (path + 'ansible.cfg').to_s + ansible.playbook = (path + 'run_all.yml').to_s + ansible.compatibility_mode = "2.0" end # same as above, to run the steps separately - # config.vm.provision 'ansible' do |provdep| - # provdep.config_file = '../../ansible.cfg' - # provdep.playbook = '../../provision_dependencies.yml' + # config.vm.provision 'ansible' do |ansible| + # ansible.config_file = (path + 'ansible.cfg').to_s + # ansible.playbook = (path + 'provision_dependencies.yml').to_s + # ansible.compatibility_mode = "2.0" # end - # config.vm.provision 'ansible' do |provtest| - # provtest.config_file = '../../ansible.cfg' - # provtest.playbook = '../../provision_test_suite.yml' + # config.vm.provision 'ansible' do |ansible| + # ansible.config_file = (path + 'ansible.cfg').to_s + # ansible.playbook = (path + 'provision_test_suite.yml').to_s + # ansible.compatibility_mode = "2.0" # end - # config.vm.provision 'ansible' do |preptest| - # preptest.config_file = '../../ansible.cfg' - # preptest.playbook = '../../install_binary_package.yml' + # config.vm.provision 'ansible' do |ansible| + # ansible.config_file = (path + 'ansible.cfg').to_s + # ansible.playbook = (path + 'install_binary_package.yml').to_s + # ansible.compatibility_mode = "2.0" # end - # config.vm.provision 'ansible' do |preptest| - # preptest.config_file = '../../ansible.cfg' - # preptest.playbook = '../../prepare_tests.yml' + # config.vm.provision 'ansible' do |ansible| + # ansible.config_file = (path + 'ansible.cfg').to_s + # ansible.playbook = (path + 'prepare_tests.yml').to_s + # ansible.compatibility_mode = "2.0" # end - # config.vm.provision 'ansible' do |runtests| - # runtests.config_file = '../../ansible.cfg' - # runtests.playbook = '../../run_tests.yml' + # config.vm.provision 'ansible' do |ansible| + # ansible.config_file = (path + 'ansible.cfg').to_s + # ansible.playbook = (path + 'run_tests.yml').to_s + # ansible.compatibility_mode = "2.0" # end end diff --git a/test/ansible/vagrant/debian-10-buster/Vagrantfile b/test/ansible/vagrant/debian-10-buster/Vagrantfile index 2b1a4e2da..8d0a04eaf 100644 --- a/test/ansible/vagrant/debian-10-buster/Vagrantfile +++ b/test/ansible/vagrant/debian-10-buster/Vagrantfile @@ -2,6 +2,8 @@ Vagrant.configure('2') do |config| config.vm.box = 'debian/buster64' + config.vm.provision "shell", inline: <<-SHELL + SHELL end common = '../common' diff --git a/test/ansible/vagrant/debian-11-bullseye/Vagrantfile b/test/ansible/vagrant/debian-11-bullseye/Vagrantfile index 9166427cb..fbd2ca41e 100644 --- a/test/ansible/vagrant/debian-11-bullseye/Vagrantfile +++ b/test/ansible/vagrant/debian-11-bullseye/Vagrantfile @@ -2,6 +2,8 @@ Vagrant.configure('2') do |config| config.vm.box = 'debian/bullseye64' + config.vm.provision "shell", inline: <<-SHELL + SHELL end common = '../common' diff --git a/test/ansible/vagrant/debian-12-bookworm/Vagrantfile b/test/ansible/vagrant/debian-12-bookworm/Vagrantfile index 999001809..68a33a947 100644 --- a/test/ansible/vagrant/debian-12-bookworm/Vagrantfile +++ b/test/ansible/vagrant/debian-12-bookworm/Vagrantfile @@ -2,6 +2,9 @@ Vagrant.configure('2') do |config| config.vm.box = 'debian/bookworm64' + config.vm.provision "shell", inline: <<-SHELL + # sudo apt install -y kitty-terminfo + SHELL end common = '../common' diff --git a/test/ansible/vagrant/debian-9-stretch/Vagrantfile b/test/ansible/vagrant/debian-9-stretch/Vagrantfile index 4c4e39cf7..d40b1640c 100644 --- a/test/ansible/vagrant/debian-9-stretch/Vagrantfile +++ b/test/ansible/vagrant/debian-9-stretch/Vagrantfile @@ -2,6 +2,9 @@ Vagrant.configure('2') do |config| config.vm.box = 'debian/stretch64' + config.vm.provision "shell", inline: <<-SHELL + sudo sed -i s/httpredir.debian.org/archive.debian.org/g /etc/apt/sources.list + SHELL end common = '../common' diff --git a/test/ansible/vagrant/debian-testing/Vagrantfile b/test/ansible/vagrant/debian-testing/Vagrantfile index 5e3b68e54..6cd2667a9 100644 --- a/test/ansible/vagrant/debian-testing/Vagrantfile +++ b/test/ansible/vagrant/debian-testing/Vagrantfile @@ -2,6 +2,8 @@ Vagrant.configure('2') do |config| config.vm.box = 'debian/testing64' + config.vm.provision "shell", inline: <<-SHELL + SHELL end common = '../common' diff --git a/test/ansible/vagrant/experimental/hardenedbsd-13/Vagrantfile b/test/ansible/vagrant/experimental/hardenedbsd-13/Vagrantfile index 0d34ea126..975d39ea0 100644 --- a/test/ansible/vagrant/experimental/hardenedbsd-13/Vagrantfile +++ b/test/ansible/vagrant/experimental/hardenedbsd-13/Vagrantfile @@ -2,19 +2,10 @@ Vagrant.configure('2') do |config| config.vm.box = 'generic/hardenedbsd13' - config.vm.define 'crowdsec' - - config.vm.provision 'shell', path: 'bootstrap' - - config.vm.provider :libvirt do |libvirt| - libvirt.cpus = 1 - libvirt.memory = 1536 - end - - config.vm.synced_folder '.', '/vagrant', disabled: true - - config.vm.provision 'ansible' do |ansible| - ansible.config_file = '../../../ansible.cfg' - ansible.playbook = '../../../run_all.yml' - end + config.vm.provision "shell", inline: <<-SHELL + sudo pkg install python3 + SHELL end + +common = '../../common' +load common if File.exist?(common) diff --git a/test/ansible/vagrant/experimental/hardenedbsd-13/bootstrap b/test/ansible/vagrant/experimental/hardenedbsd-13/bootstrap deleted file mode 100755 index 370b1b68e..000000000 --- a/test/ansible/vagrant/experimental/hardenedbsd-13/bootstrap +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -unset IFS -set -euf - -sudo pkg install python3 diff --git a/test/ansible/vagrant/experimental/openbsd-6/Vagrantfile b/test/ansible/vagrant/experimental/openbsd-6/Vagrantfile new file mode 100644 index 000000000..1a1fc3421 --- /dev/null +++ b/test/ansible/vagrant/experimental/openbsd-6/Vagrantfile @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +Vagrant.configure('2') do |config| + config.vm.box = 'generic/openbsd6' + # config.vm.box_version = '4.2.16' + config.vm.provision "shell", inline: <<-SHELL + sudo pkg_add python py3-pip gcc openssl-1.0.2up3 gtar-1.34 + # sudo pkg_add -u + # sudo pkg_add kitty + SHELL +end + +common = '../../common' +load common if File.exist?(common) diff --git a/test/ansible/vagrant/experimental/openbsd-6/skip b/test/ansible/vagrant/experimental/openbsd-6/skip new file mode 100755 index 000000000..18d4c60f4 --- /dev/null +++ b/test/ansible/vagrant/experimental/openbsd-6/skip @@ -0,0 +1,9 @@ +#!/bin/sh + +die() { + echo "$@" >&2 + exit 1 +} + +[ "${PACKAGE_TESTING}" = "true" ] && die "no package available for this distribution" +exit 0 diff --git a/test/ansible/vagrant/experimental/openbsd-7/Vagrantfile b/test/ansible/vagrant/experimental/openbsd-7/Vagrantfile index d7f9801e1..1c11a94dc 100644 --- a/test/ansible/vagrant/experimental/openbsd-7/Vagrantfile +++ b/test/ansible/vagrant/experimental/openbsd-7/Vagrantfile @@ -2,19 +2,13 @@ Vagrant.configure('2') do |config| config.vm.box = 'generic/openbsd7' - config.vm.define 'crowdsec' - - config.vm.provision 'shell', path: 'bootstrap' - - config.vm.provider :libvirt do |libvirt| - libvirt.cpus = 1 - libvirt.memory = 1536 - end - - config.vm.synced_folder '.', '/vagrant', disabled: true - - config.vm.provision 'ansible' do |ansible| - ansible.config_file = '../../../ansible.cfg' - ansible.playbook = '../../../run_all.yml' - end + # config.vm.box_version = '4.2.16' + config.vm.provision "shell", inline: <<-SHELL + sudo pkg_add python-3.9.16 py3-pip gcc-11.2.0p3 openssl-3.0.8 gtar-1.34 + # sudo pkg_add -u + # sudo pkg_add kitty + SHELL end + +common = '../../common' +load common if File.exist?(common) diff --git a/test/ansible/vagrant/experimental/openbsd-7/bootstrap b/test/ansible/vagrant/experimental/openbsd-7/bootstrap deleted file mode 100755 index 3b2480d3b..000000000 --- a/test/ansible/vagrant/experimental/openbsd-7/bootstrap +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -unset IFS -set -euf - -sudo pkg_add -u -sudo pkg_add python-3.9.13 py3-pip gcc-11.2.0p2 openssl-3.0.3p0 gtar-1.34 truncate-5.2.1 diff --git a/test/ansible/vagrant/fedora-33/Vagrantfile b/test/ansible/vagrant/fedora-33/Vagrantfile index 49b5ee990..df6f06944 100644 --- a/test/ansible/vagrant/fedora-33/Vagrantfile +++ b/test/ansible/vagrant/fedora-33/Vagrantfile @@ -3,6 +3,8 @@ Vagrant.configure('2') do |config| # config.vm.box = "fedora/33-cloud-base" config.vm.box = 'generic/fedora33' + config.vm.provision "shell", inline: <<-SHELL + SHELL end common = '../common' diff --git a/test/ansible/vagrant/fedora-34/Vagrantfile b/test/ansible/vagrant/fedora-34/Vagrantfile index 1d172c9c7..db2db8d08 100644 --- a/test/ansible/vagrant/fedora-34/Vagrantfile +++ b/test/ansible/vagrant/fedora-34/Vagrantfile @@ -3,6 +3,8 @@ Vagrant.configure('2') do |config| # config.vm.box = "fedora/34-cloud-base" config.vm.box = 'generic/fedora34' + config.vm.provision "shell", inline: <<-SHELL + SHELL end common = '../common' diff --git a/test/ansible/vagrant/fedora-35/Vagrantfile b/test/ansible/vagrant/fedora-35/Vagrantfile index f11730764..c52604340 100644 --- a/test/ansible/vagrant/fedora-35/Vagrantfile +++ b/test/ansible/vagrant/fedora-35/Vagrantfile @@ -3,6 +3,8 @@ Vagrant.configure('2') do |config| # config.vm.box = 'fedora/35-cloud-base' config.vm.box = 'generic/fedora35' + config.vm.provision "shell", inline: <<-SHELL + SHELL end common = '../common' diff --git a/test/ansible/vagrant/fedora-36/Vagrantfile b/test/ansible/vagrant/fedora-36/Vagrantfile index ef80f514c..0cd4fafd0 100644 --- a/test/ansible/vagrant/fedora-36/Vagrantfile +++ b/test/ansible/vagrant/fedora-36/Vagrantfile @@ -3,6 +3,8 @@ Vagrant.configure('2') do |config| # config.vm.box = "fedora/36-cloud-base" config.vm.box = 'generic/fedora36' + config.vm.provision "shell", inline: <<-SHELL + SHELL end common = '../common' diff --git a/test/ansible/vagrant/fedora-37/Vagrantfile b/test/ansible/vagrant/fedora-37/Vagrantfile index 73e9cd4e7..0eb8978e3 100644 --- a/test/ansible/vagrant/fedora-37/Vagrantfile +++ b/test/ansible/vagrant/fedora-37/Vagrantfile @@ -2,7 +2,9 @@ Vagrant.configure('2') do |config| config.vm.box = 'generic/fedora37' - config.vm.provision 'shell', path: 'bootstrap' + config.vm.provision "shell", inline: <<-SHELL + sudo dnf -y install kitty-terminfo + SHELL end common = '../common' diff --git a/test/ansible/vagrant/fedora-37/bootstrap b/test/ansible/vagrant/fedora-37/bootstrap deleted file mode 100755 index f714b2c7c..000000000 --- a/test/ansible/vagrant/fedora-37/bootstrap +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -unset IFS -set -euf - -sudo dnf -y install kitty-terminfo diff --git a/test/ansible/vagrant/fedora-38/Vagrantfile b/test/ansible/vagrant/fedora-38/Vagrantfile index 091185c90..0e5bf79ed 100644 --- a/test/ansible/vagrant/fedora-38/Vagrantfile +++ b/test/ansible/vagrant/fedora-38/Vagrantfile @@ -1,7 +1,9 @@ # frozen_string_literal: true Vagrant.configure('2') do |config| - config.vm.box = "fedora/38-cloud-base" + config.vm.box = "fedora/38-cloud-base" + config.vm.provision "shell", inline: <<-SHELL + SHELL end common = '../common' diff --git a/test/ansible/vagrant/freebsd-12/Vagrantfile b/test/ansible/vagrant/freebsd-12/Vagrantfile index 65aa98aeb..b500a64d9 100644 --- a/test/ansible/vagrant/freebsd-12/Vagrantfile +++ b/test/ansible/vagrant/freebsd-12/Vagrantfile @@ -2,7 +2,9 @@ Vagrant.configure('2') do |config| config.vm.box = 'generic/freebsd12' - config.vm.provision 'shell', path: 'bootstrap' + config.vm.provision "shell", inline: <<-SHELL + pkg install -y gtar + SHELL end common = '../common' diff --git a/test/ansible/vagrant/freebsd-12/bootstrap b/test/ansible/vagrant/freebsd-12/bootstrap deleted file mode 100644 index 1a4adafdb..000000000 --- a/test/ansible/vagrant/freebsd-12/bootstrap +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -set -eu - -pkg install -y gtar - diff --git a/test/ansible/vagrant/freebsd-13/Vagrantfile b/test/ansible/vagrant/freebsd-13/Vagrantfile index d162c86f8..f416ad677 100644 --- a/test/ansible/vagrant/freebsd-13/Vagrantfile +++ b/test/ansible/vagrant/freebsd-13/Vagrantfile @@ -2,7 +2,9 @@ Vagrant.configure('2') do |config| config.vm.box = 'generic/freebsd13' - config.vm.provision 'shell', path: 'bootstrap' + config.vm.provision "shell", inline: <<-SHELL + pkg install -y gtar + SHELL end common = '../common' diff --git a/test/ansible/vagrant/freebsd-13/bootstrap b/test/ansible/vagrant/freebsd-13/bootstrap deleted file mode 100644 index 1a4adafdb..000000000 --- a/test/ansible/vagrant/freebsd-13/bootstrap +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -set -eu - -pkg install -y gtar - diff --git a/test/ansible/vagrant/oracle-7/Vagrantfile b/test/ansible/vagrant/oracle-7/Vagrantfile index 638a6123b..bd435ca54 100644 --- a/test/ansible/vagrant/oracle-7/Vagrantfile +++ b/test/ansible/vagrant/oracle-7/Vagrantfile @@ -2,6 +2,9 @@ Vagrant.configure('2') do |config| config.vm.box = 'generic/oracle7' + config.vm.provision "shell", inline: <<-SHELL + sudo yum-config-manager --enable ol7_optional_latest + SHELL end common = '../common' diff --git a/test/ansible/vagrant/oracle-8/Vagrantfile b/test/ansible/vagrant/oracle-8/Vagrantfile index 425ad5e16..6744ea87d 100644 --- a/test/ansible/vagrant/oracle-8/Vagrantfile +++ b/test/ansible/vagrant/oracle-8/Vagrantfile @@ -2,6 +2,9 @@ Vagrant.configure('2') do |config| config.vm.box = 'generic/oracle8' + config.vm.provision "shell", inline: <<-SHELL + sudo dnf config-manager --set-enabled ol8_codeready_builder + SHELL end common = '../common' diff --git a/test/ansible/vagrant/oracle-9/Vagrantfile b/test/ansible/vagrant/oracle-9/Vagrantfile index d4e3f618f..8dcb4a13b 100644 --- a/test/ansible/vagrant/oracle-9/Vagrantfile +++ b/test/ansible/vagrant/oracle-9/Vagrantfile @@ -2,6 +2,9 @@ Vagrant.configure('2') do |config| config.vm.box = 'generic/oracle9' + config.vm.provision "shell", inline: <<-SHELL + sudo dnf config-manager --set-enabled ol9_codeready_builder + SHELL end common = '../common' diff --git a/test/ansible/vagrant/rocky-8/Vagrantfile b/test/ansible/vagrant/rocky-8/Vagrantfile index c7315cc67..27caf80c7 100644 --- a/test/ansible/vagrant/rocky-8/Vagrantfile +++ b/test/ansible/vagrant/rocky-8/Vagrantfile @@ -2,6 +2,10 @@ Vagrant.configure('2') do |config| config.vm.box = 'generic/rocky8' + config.vm.provision "shell", inline: <<-SHELL + sudo dnf config-manager --set-enabled powertools + sudo dnf -y install kitty-terminfo + SHELL end common = '../common' diff --git a/test/ansible/vagrant/rocky-9/Vagrantfile b/test/ansible/vagrant/rocky-9/Vagrantfile index 0adb3ab51..a4d06e4a9 100644 --- a/test/ansible/vagrant/rocky-9/Vagrantfile +++ b/test/ansible/vagrant/rocky-9/Vagrantfile @@ -2,6 +2,10 @@ Vagrant.configure('2') do |config| config.vm.box = 'generic/rocky9' + config.vm.provision "shell", inline: <<-SHELL + sudo dnf config-manager --set-enabled crb + sudo dnf -y install kitty-terminfo + SHELL end common = '../common' diff --git a/test/ansible/vagrant/ubuntu-16.04-xenial/Vagrantfile b/test/ansible/vagrant/ubuntu-16.04-xenial/Vagrantfile index 86646ee7a..3af880994 100644 --- a/test/ansible/vagrant/ubuntu-16.04-xenial/Vagrantfile +++ b/test/ansible/vagrant/ubuntu-16.04-xenial/Vagrantfile @@ -2,6 +2,8 @@ Vagrant.configure('2') do |config| config.vm.box = 'generic/ubuntu1604' + config.vm.provision "shell", inline: <<-SHELL + SHELL end common = '../common' diff --git a/test/ansible/vagrant/ubuntu-18.04-bionic/Vagrantfile b/test/ansible/vagrant/ubuntu-18.04-bionic/Vagrantfile index 70a77806b..5e25a2ee8 100644 --- a/test/ansible/vagrant/ubuntu-18.04-bionic/Vagrantfile +++ b/test/ansible/vagrant/ubuntu-18.04-bionic/Vagrantfile @@ -3,6 +3,8 @@ Vagrant.configure('2') do |config| # the official boxes only supports virtualbox config.vm.box = 'generic/ubuntu1804' + config.vm.provision "shell", inline: <<-SHELL + SHELL end common = '../common' diff --git a/test/ansible/vagrant/ubuntu-20.04-focal/Vagrantfile b/test/ansible/vagrant/ubuntu-20.04-focal/Vagrantfile index 0006ae926..ea5b33907 100644 --- a/test/ansible/vagrant/ubuntu-20.04-focal/Vagrantfile +++ b/test/ansible/vagrant/ubuntu-20.04-focal/Vagrantfile @@ -2,6 +2,9 @@ Vagrant.configure('2') do |config| config.vm.box = 'generic/ubuntu2004' + config.vm.provision "shell", inline: <<-SHELL + sudo apt install -y kitty-terminfo + SHELL end common = '../common' diff --git a/test/ansible/vagrant/ubuntu-20.04-focal/bootstrap b/test/ansible/vagrant/ubuntu-20.04-focal/bootstrap deleted file mode 100644 index 57f40cc2e..000000000 --- a/test/ansible/vagrant/ubuntu-20.04-focal/bootstrap +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -unset IFS -set -euf - -sudo apt install -y kitty-terminfo diff --git a/test/ansible/vagrant/ubuntu-22.04-jammy/Vagrantfile b/test/ansible/vagrant/ubuntu-22.04-jammy/Vagrantfile index c0ccee54b..9e17f71fb 100644 --- a/test/ansible/vagrant/ubuntu-22.04-jammy/Vagrantfile +++ b/test/ansible/vagrant/ubuntu-22.04-jammy/Vagrantfile @@ -2,6 +2,8 @@ Vagrant.configure('2') do |config| config.vm.box = 'generic/ubuntu2204' + config.vm.provision "shell", inline: <<-SHELL + SHELL end common = '../common' diff --git a/test/ansible/vagrant/ubuntu-22.10-kinetic/Vagrantfile b/test/ansible/vagrant/ubuntu-22.10-kinetic/Vagrantfile new file mode 100644 index 000000000..6c15b0a1e --- /dev/null +++ b/test/ansible/vagrant/ubuntu-22.10-kinetic/Vagrantfile @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +Vagrant.configure('2') do |config| + config.vm.box = 'generic/ubuntu2210' + config.vm.provision "shell", inline: <<-SHELL + SHELL +end + +common = '../common' +load common if File.exist?(common) diff --git a/test/ansible/vagrant/ubuntu-23.04-lunar/Vagrantfile b/test/ansible/vagrant/ubuntu-23.04-lunar/Vagrantfile new file mode 100644 index 000000000..f40fb7bd5 --- /dev/null +++ b/test/ansible/vagrant/ubuntu-23.04-lunar/Vagrantfile @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +Vagrant.configure('2') do |config| + config.vm.box = 'bento/ubuntu-23.04' + config.vm.provision "shell", inline: <<-SHELL + SHELL +end + +common = '../common' +load common if File.exist?(common) diff --git a/test/ansible/vagrant/wizard/centos-8/Vagrantfile b/test/ansible/vagrant/wizard/centos-8/Vagrantfile index 2df31a392..9db09a4ce 100644 --- a/test/ansible/vagrant/wizard/centos-8/Vagrantfile +++ b/test/ansible/vagrant/wizard/centos-8/Vagrantfile @@ -1,38 +1,13 @@ # frozen_string_literal: true Vagrant.configure('2') do |config| - config.vm.box = 'centos/stream8' - config.vm.define 'wizard' - - config.vm.provision 'shell', path: 'bootstrap' - - config.vm.provider :libvirt do |libvirt| - libvirt.cpus = 4 - libvirt.memory = 4096 - end - - config.vm.synced_folder '.', '/vagrant', disabled: true - - # install the dependencies for functional tests - - config.vm.provision 'ansible' do |provdep| - provdep.config_file = '../../../ansible.cfg' - provdep.playbook = '../../../provision_dependencies.yml' - end - - config.vm.provision 'ansible' do |provtest| - provtest.config_file = '../../../ansible.cfg' - provtest.playbook = '../../../provision_test_suite.yml' - end - - config.vm.provision 'ansible' do |preptest| - preptest.config_file = '../../../ansible.cfg' - preptest.playbook = '../../../prepare_tests.yml' - end - - config.vm.provision 'ansible' do |preptest| - preptest.config_file = '../../../ansible.cfg' - preptest.playbook = '../../../run_wizard_tests.yml' - end - + config.vm.box = 'generic/centos8s' + config.vm.provision "shell", inline: <<-SHELL + sudo dnf -y install dnf-plugins-core kitty-terminfo + dnf config-manager --set-enabled powertools + # sudo dnf -y update + SHELL end + +common = '../common' +load common if File.exists?(common) diff --git a/test/ansible/vagrant/wizard/centos-8/bootstrap b/test/ansible/vagrant/wizard/centos-8/bootstrap deleted file mode 100755 index b33ad9c88..000000000 --- a/test/ansible/vagrant/wizard/centos-8/bootstrap +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -unset IFS -set -euf - -sudo dnf -y update diff --git a/test/ansible/vagrant/wizard/common b/test/ansible/vagrant/wizard/common new file mode 100644 index 000000000..be1820914 --- /dev/null +++ b/test/ansible/vagrant/wizard/common @@ -0,0 +1,67 @@ +# vim: set ft=ruby: +# frozen_string_literal: true + +def find_ansible_cfg + path = Pathname.new(Dir.pwd) + until path.root? + ansible_cfg = path + 'ansible.cfg' + return path if ansible_cfg.exist? + path = path.parent + end + nil # return nil if not found +end + +Vagrant.configure('2') do |config| + config.vm.define 'wizard' + + if ARGV.any? { |arg| arg == 'up' || arg == 'provision' } + unless ENV['DB_BACKEND'] + $stderr.puts "\e[31mThe DB_BACKEND environment variable is not defined. Please set up the environment and try again.\e[0m" + exit 1 + end + end + + config.vm.provision 'shell', path: 'bootstrap' if File.exists?('bootstrap') + config.vm.synced_folder '.', '/vagrant', disabled: true + + config.vm.provider :libvirt do |libvirt| + libvirt.cpus = 4 + libvirt.memory = 4096 + end + + path = find_ansible_cfg + if !path + puts "ansible.cfg not found" + end + + config.vm.provision 'ansible' do |ansible| + ansible.config_file = (path + 'ansible.cfg').to_s + ansible.playbook = (path + 'provision_dependencies.yml').to_s + ansible.compatibility_mode = "2.0" + end + + config.vm.provision 'ansible' do |ansible| + ansible.config_file = (path + 'ansible.cfg').to_s + ansible.playbook = (path + 'provision_test_suite.yml').to_s + ansible.compatibility_mode = "2.0" + end + + config.vm.provision 'ansible' do |ansible| + ansible.config_file = (path + 'ansible.cfg').to_s + ansible.playbook = (path + 'prepare_tests.yml').to_s + ansible.compatibility_mode = "2.0" + end + + config.vm.provision 'ansible' do |ansible| + ansible.config_file = (path + 'ansible.cfg').to_s + ansible.playbook = (path + 'debug_tools.yml').to_s + ansible.compatibility_mode = "2.0" + end + + config.vm.provision 'ansible' do |ansible| + ansible.config_file = (path + 'ansible.cfg').to_s + ansible.playbook = (path + 'run_wizard_tests.yml').to_s + ansible.compatibility_mode = "2.0" + end + +end diff --git a/test/ansible/vagrant/wizard/debian-10-buster/Vagrantfile b/test/ansible/vagrant/wizard/debian-10-buster/Vagrantfile new file mode 100644 index 000000000..3b10b312d --- /dev/null +++ b/test/ansible/vagrant/wizard/debian-10-buster/Vagrantfile @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +Vagrant.configure('2') do |config| + config.vm.box = 'debian/buster64' + config.vm.provision "shell", inline: <<-SHELL + sudo apt update + sudo apt install -y aptitude kitty-terminfo + SHELL +end + +common = '../common' +load common if File.exists?(common) diff --git a/test/ansible/vagrant/wizard/debian-11-bullseye/Vagrantfile b/test/ansible/vagrant/wizard/debian-11-bullseye/Vagrantfile new file mode 100644 index 000000000..6dd7bb2fc --- /dev/null +++ b/test/ansible/vagrant/wizard/debian-11-bullseye/Vagrantfile @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +Vagrant.configure('2') do |config| + config.vm.box = 'debian/bullseye64' + config.vm.provision "shell", inline: <<-SHELL + sudo apt update + sudo apt install -y aptitude kitty-terminfo + SHELL +end + +common = '../common' +load common if File.exists?(common) diff --git a/test/ansible/vagrant/wizard/debian-12-bookworm/Vagrantfile b/test/ansible/vagrant/wizard/debian-12-bookworm/Vagrantfile new file mode 100644 index 000000000..5ccf234eb --- /dev/null +++ b/test/ansible/vagrant/wizard/debian-12-bookworm/Vagrantfile @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +Vagrant.configure('2') do |config| + config.vm.box = 'debian/bookworm64' + config.vm.provision "shell", inline: <<-SHELL + sudo apt update + sudo apt install -y aptitude kitty-terminfo + SHELL +end + +common = '../common' +load common if File.exists?(common) diff --git a/test/ansible/vagrant/wizard/debian-bullseye/Vagrantfile b/test/ansible/vagrant/wizard/debian-bullseye/Vagrantfile deleted file mode 100644 index 1d6993a4e..000000000 --- a/test/ansible/vagrant/wizard/debian-bullseye/Vagrantfile +++ /dev/null @@ -1,43 +0,0 @@ -# frozen_string_literal: true - -Vagrant.configure('2') do |config| - config.vm.box = 'debian/bullseye64' - config.vm.define 'wizard' - - config.vm.provision 'shell', path: 'bootstrap' - - config.vm.provider :libvirt do |libvirt| - libvirt.cpus = 4 - libvirt.memory = 4096 - end - - config.vm.synced_folder '.', '/vagrant', disabled: true - - # install the dependencies for functional tests - - config.vm.provision 'ansible' do |provdep| - provdep.config_file = '../../../ansible.cfg' - provdep.playbook = '../../../provision_dependencies.yml' - end - - config.vm.provision 'ansible' do |provtest| - provtest.config_file = '../../../ansible.cfg' - provtest.playbook = '../../../provision_test_suite.yml' - end - - config.vm.provision 'ansible' do |preptest| - preptest.config_file = '../../../ansible.cfg' - preptest.playbook = '../../../prepare_tests.yml' - end - - config.vm.provision 'ansible' do |preptest| - preptest.config_file = '../../../ansible.cfg' - preptest.playbook = '../../../debug_tools.yml' - end - - config.vm.provision 'ansible' do |preptest| - preptest.config_file = '../../../ansible.cfg' - preptest.playbook = '../../../run_wizard_tests.yml' - end - -end diff --git a/test/ansible/vagrant/wizard/debian-bullseye/bootstrap b/test/ansible/vagrant/wizard/debian-bullseye/bootstrap deleted file mode 100755 index 6a5df521a..000000000 --- a/test/ansible/vagrant/wizard/debian-bullseye/bootstrap +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -unset IFS -set -euf - -sudo apt install -y aptitude diff --git a/test/ansible/vagrant/wizard/debian-buster/Vagrantfile b/test/ansible/vagrant/wizard/debian-buster/Vagrantfile deleted file mode 100644 index d4380a945..000000000 --- a/test/ansible/vagrant/wizard/debian-buster/Vagrantfile +++ /dev/null @@ -1,43 +0,0 @@ -# frozen_string_literal: true - -Vagrant.configure('2') do |config| - config.vm.box = 'debian/buster64' - config.vm.define 'wizard' - - config.vm.provision 'shell', path: 'bootstrap' - - config.vm.provider :libvirt do |libvirt| - libvirt.cpus = 4 - libvirt.memory = 4096 - end - - config.vm.synced_folder '.', '/vagrant', disabled: true - - # install the dependencies for functional tests - - config.vm.provision 'ansible' do |provdep| - provdep.config_file = '../../../ansible.cfg' - provdep.playbook = '../../../provision_dependencies.yml' - end - - config.vm.provision 'ansible' do |provtest| - provtest.config_file = '../../../ansible.cfg' - provtest.playbook = '../../../provision_test_suite.yml' - end - - config.vm.provision 'ansible' do |preptest| - preptest.config_file = '../../../ansible.cfg' - preptest.playbook = '../../../prepare_tests.yml' - end - - config.vm.provision 'ansible' do |preptest| - preptest.config_file = '../../../ansible.cfg' - preptest.playbook = '../../../debug_tools.yml' - end - - config.vm.provision 'ansible' do |preptest| - preptest.config_file = '../../../ansible.cfg' - preptest.playbook = '../../../run_wizard_tests.yml' - end - -end diff --git a/test/ansible/vagrant/wizard/debian-buster/bootstrap b/test/ansible/vagrant/wizard/debian-buster/bootstrap deleted file mode 100755 index 6a5df521a..000000000 --- a/test/ansible/vagrant/wizard/debian-buster/bootstrap +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -unset IFS -set -euf - -sudo apt install -y aptitude diff --git a/test/ansible/vagrant/wizard/fedora-36/Vagrantfile b/test/ansible/vagrant/wizard/fedora-36/Vagrantfile index 09ee8a39d..969a8e70c 100644 --- a/test/ansible/vagrant/wizard/fedora-36/Vagrantfile +++ b/test/ansible/vagrant/wizard/fedora-36/Vagrantfile @@ -2,37 +2,10 @@ Vagrant.configure('2') do |config| config.vm.box = 'fedora/36-cloud-base' - config.vm.define 'wizard' - - config.vm.provision 'shell', path: 'bootstrap' - - config.vm.provider :libvirt do |libvirt| - libvirt.cpus = 4 - libvirt.memory = 4096 - end - - config.vm.synced_folder '.', '/vagrant', disabled: true - - # install the dependencies for functional tests - - config.vm.provision 'ansible' do |provdep| - provdep.config_file = '../../../ansible.cfg' - provdep.playbook = '../../../provision_dependencies.yml' - end - - config.vm.provision 'ansible' do |provtest| - provtest.config_file = '../../../ansible.cfg' - provtest.playbook = '../../../provision_test_suite.yml' - end - - config.vm.provision 'ansible' do |preptest| - preptest.config_file = '../../../ansible.cfg' - preptest.playbook = '../../../prepare_tests.yml' - end - - config.vm.provision 'ansible' do |preptest| - preptest.config_file = '../../../ansible.cfg' - preptest.playbook = '../../../run_wizard_tests.yml' - end - + config.vm.provision "shell", inline: <<-SHELL + # sudo dnf -y update + SHELL end + +common = '../common' +load common if File.exists?(common) diff --git a/test/ansible/vagrant/wizard/fedora-36/bootstrap b/test/ansible/vagrant/wizard/fedora-36/bootstrap deleted file mode 100755 index b33ad9c88..000000000 --- a/test/ansible/vagrant/wizard/fedora-36/bootstrap +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -unset IFS -set -euf - -sudo dnf -y update diff --git a/test/ansible/vagrant/wizard/ubuntu-22.04-jammy/Vagrantfile b/test/ansible/vagrant/wizard/ubuntu-22.04-jammy/Vagrantfile index 933dabab5..c13d2f946 100644 --- a/test/ansible/vagrant/wizard/ubuntu-22.04-jammy/Vagrantfile +++ b/test/ansible/vagrant/wizard/ubuntu-22.04-jammy/Vagrantfile @@ -2,42 +2,10 @@ Vagrant.configure('2') do |config| config.vm.box = 'generic/ubuntu2204' - config.vm.define 'wizard' - - config.vm.provision 'shell', path: 'bootstrap' - - config.vm.provider :libvirt do |libvirt| - libvirt.cpus = 4 - libvirt.memory = 4096 - end - - config.vm.synced_folder '.', '/vagrant', disabled: true - - # install the dependencies for functional tests - - config.vm.provision 'ansible' do |provdep| - provdep.config_file = '../../../ansible.cfg' - provdep.playbook = '../../../provision_dependencies.yml' - end - - config.vm.provision 'ansible' do |provtest| - provtest.config_file = '../../../ansible.cfg' - provtest.playbook = '../../../provision_test_suite.yml' - end - - config.vm.provision 'ansible' do |preptest| - preptest.config_file = '../../../ansible.cfg' - preptest.playbook = '../../../prepare_tests.yml' - end - - config.vm.provision 'ansible' do |preptest| - preptest.config_file = '../../../ansible.cfg' - preptest.playbook = '../../../debug_tools.yml' - end - - config.vm.provision 'ansible' do |preptest| - preptest.config_file = '../../../ansible.cfg' - preptest.playbook = '../../../run_wizard_tests.yml' - end - + config.vm.provision "shell", inline: <<-SHELL + sudo apt install -y aptitude kitty-terminfo + SHELL end + +common = '../common' +load common if File.exists?(common) diff --git a/test/ansible/vagrant/wizard/ubuntu-22.04-jammy/bootstrap b/test/ansible/vagrant/wizard/ubuntu-22.04-jammy/bootstrap deleted file mode 100755 index 6a5df521a..000000000 --- a/test/ansible/vagrant/wizard/ubuntu-22.04-jammy/bootstrap +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -unset IFS -set -euf - -sudo apt install -y aptitude diff --git a/test/ansible/vagrant/wizard/ubuntu-22.10-kinetic/Vagrantfile b/test/ansible/vagrant/wizard/ubuntu-22.10-kinetic/Vagrantfile index c3e8759aa..d0e2e3cda 100644 --- a/test/ansible/vagrant/wizard/ubuntu-22.10-kinetic/Vagrantfile +++ b/test/ansible/vagrant/wizard/ubuntu-22.10-kinetic/Vagrantfile @@ -2,42 +2,10 @@ Vagrant.configure('2') do |config| config.vm.box = 'generic/ubuntu2210' - config.vm.define 'wizard' - - config.vm.provision 'shell', path: 'bootstrap' - - config.vm.provider :libvirt do |libvirt| - libvirt.cpus = 4 - libvirt.memory = 4096 - end - - config.vm.synced_folder '.', '/vagrant', disabled: true - - # install the dependencies for functional tests - - config.vm.provision 'ansible' do |provdep| - provdep.config_file = '../../../ansible.cfg' - provdep.playbook = '../../../provision_dependencies.yml' - end - - config.vm.provision 'ansible' do |provtest| - provtest.config_file = '../../../ansible.cfg' - provtest.playbook = '../../../provision_test_suite.yml' - end - - config.vm.provision 'ansible' do |preptest| - preptest.config_file = '../../../ansible.cfg' - preptest.playbook = '../../../prepare_tests.yml' - end - - config.vm.provision 'ansible' do |preptest| - preptest.config_file = '../../../ansible.cfg' - preptest.playbook = '../../../debug_tools.yml' - end - - config.vm.provision 'ansible' do |preptest| - preptest.config_file = '../../../ansible.cfg' - preptest.playbook = '../../../run_wizard_tests.yml' - end - + config.vm.provision "shell", inline: <<-SHELL + sudo apt install -y aptitude kitty-terminfo + SHELL end + +common = '../common' +load common if File.exists?(common) diff --git a/test/bats-detect/openresty-deb.bats b/test/bats-detect/openresty-deb.bats index c1e91949d..0c8bc3c9a 100644 --- a/test/bats-detect/openresty-deb.bats +++ b/test/bats-detect/openresty-deb.bats @@ -37,8 +37,13 @@ setup() { run -0 sudo gpg --yes --dearmor -o /usr/share/keyrings/openresty.gpg < <(output) run -0 sudo tee <<< "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/openresty.gpg] http://openresty.org/package/ubuntu $(lsb_release -sc) main" /etc/apt/sources.list.d/openresty.list else + release="$(lsb_release -sc)" + # Debian 12 package is not available as of 2023-07-3 + if [[ "$release" == "bookworm" ]]; then + release="bullseye" + fi run -0 sudo apt-key add - < <(output) - run -0 sudo tee <<< "deb http://openresty.org/package/debian $(lsb_release -sc) openresty" /etc/apt/sources.list.d/openresty.list + run -0 sudo tee <<< "deb http://openresty.org/package/debian $release openresty" /etc/apt/sources.list.d/openresty.list fi run -0 deb-update run -0 deb-install openresty diff --git a/test/bats-detect/openresty-rpm.bats b/test/bats-detect/openresty-rpm.bats index 6fc0a8a09..d4c3661bc 100644 --- a/test/bats-detect/openresty-rpm.bats +++ b/test/bats-detect/openresty-rpm.bats @@ -34,10 +34,14 @@ setup() { run -0 rpm-install redhat-lsb-core if [[ "$(lsb_release -is)" == "Fedora" ]]; then run -0 sudo curl -1sSLf "https://openresty.org/package/fedora/openresty.repo" -o "/etc/yum.repos.d/openresty.repo" - elif [[ "$(lsb_release -is)" == "CentOS" ]]; then + elif [[ "$(lsb_release -is)" == CentOS* ]]; then # must match CentOSStream run -0 sudo curl -1sSLf "https://openresty.org/package/centos/openresty.repo" -o "/etc/yum.repos.d/openresty.repo" fi - run -0 sudo dnf check-update + run sudo dnf check-update + # 0 = up to date, 100 = updates available + if [[ "$status" -ne 0 ]] && [[ "$status" -ne 100 ]]; then + fail "dnf check-update failed with status $status" + fi run -0 rpm-install openresty run -0 sudo systemctl enable openresty.service } diff --git a/test/bats/01_cscli.bats b/test/bats/01_cscli.bats index 4f6d7b71d..ef825d2a8 100644 --- a/test/bats/01_cscli.bats +++ b/test/bats/01_cscli.bats @@ -182,7 +182,7 @@ teardown() { @test "cscli - empty LAPI credentials file" { LOCAL_API_CREDENTIALS=$(config_get '.api.client.credentials_path') - truncate -s 0 "${LOCAL_API_CREDENTIALS}" + : > "${LOCAL_API_CREDENTIALS}" rune -1 cscli lapi status assert_stderr --partial "no credentials or URL found in api client configuration '${LOCAL_API_CREDENTIALS}'"