diff --git a/distro/tests/README.md b/distro/tests/README.md index ec9570baa4a7c85df40bcd26ffd5c404bacf5d34..4563c5271214d2cb4ff4bd00fd2a63ba147d158a 100644 --- a/distro/tests/README.md +++ b/distro/tests/README.md @@ -13,18 +13,24 @@ which configures OBS repository, installs the knot-resolver package, starts the kresd@1 service and finally attempts to use it to resolve a domain name. It also tests that DNSSEC validation is turned on. -By default, the *knot-resolver-latest* repo is used. To test the -*knot-resolver-devel* repo, enable in it `knot-resolver-test.yaml`. +By default, the *knot-resolver-devel* repo (for knot-resolver) along +with *knot-resoler-latest* (for knot) is used. To test only the +*knot-resolver-latest* repo, set it in `repos.yaml` (or use the +test-distro.sh script which overwrites this file). If you're running +tests in parallel, they all HAVE TO use the same repo(s). Run the following command for every distro (aka directory with Vagrantfile): -./test-distro.sh debian9 +``` +./test-distro.sh devel debian9 +``` -Caveats -------- +or -This tests the latest `knot-resolver` package that is available. In certain -cases, this may result in unexpected behaviour, because it might be testing a -different package than expected. +``` +./test-distro.sh latest debian9 +``` +At the end of the test, the package version that was tested is +printed out. Make sure you're testing what you intended to. diff --git a/distro/tests/knot-resolver-test.yaml b/distro/tests/knot-resolver-test.yaml index 9f0a4c744ff17a87c139c9696c0a0494f329dbbd..f3b39495e41b0c7637c70c8bbab4c3e535c206d2 100644 --- a/distro/tests/knot-resolver-test.yaml +++ b/distro/tests/knot-resolver-test.yaml @@ -5,9 +5,6 @@ become: true vars: - repos: - - knot-resolver-latest - # - knot-resolver-devel # enable to test development builds ansible_python_interpreter: /usr/bin/python2 dig_package: Debian: dnsutils @@ -31,6 +28,19 @@ wget -nv https://download.opensuse.org/repositories/home:CZ-NIC:{{ item }}/xUbuntu_16.04/Release.key -O Release.key && apt-key add - < Release.key && apt-get update + show_package_version: + Archlinux: + pacman -Qi knot-resolver | grep '^Version' + Fedora: | + rpm -qi knot-resolver | grep '^Version' + CentOS: | + rpm -qi knot-resolver | grep '^Version' + Debian: + dpkg -s knot-resolver | grep '^Version' + Ubuntu: | + dpkg -s knot-resolver | grep '^Version' + vars_files: + - repos.yaml # HACK: Ansible requires Python 2, but it's not installed by default in all distros gather_facts: false @@ -77,6 +87,10 @@ name: knot-resolver state: latest + - name: get installed package version + shell: "{{ show_package_version[ansible_distribution] }}" + register: package_version + - name: install dig package: name: "{{ dig_package[ansible_distribution] }}" @@ -88,25 +102,31 @@ state: latest when: ansible_distribution in ['RedHat', 'Fedora'] - - name: start kresd@1.service - service: - name: kresd@1.service - state: restarted - - - name: resolve nic.cz - shell: dig @127.0.0.1 nic.cz - register: res - failed_when: '"status: NOERROR" not in res.stdout' - - - name: test dnssec is turned on + - name: testing block block: - - name: test dnssec-failed.org +cd returns NOERROR - shell: dig +cd @127.0.0.1 dnssec-failed.org + - name: start kresd@1.service + service: + name: kresd@1.service + state: restarted + + - name: resolve nic.cz + shell: dig @127.0.0.1 nic.cz register: res failed_when: '"status: NOERROR" not in res.stdout' - - name: test dnssec-failed.org returns SERVFAIL - shell: dig @127.0.0.1 dnssec-failed.org - register: res - failed_when: '"status: SERVFAIL" not in res.stdout' + - name: test dnssec is turned on + block: + - name: test dnssec-failed.org +cd returns NOERROR + shell: dig +cd @127.0.0.1 dnssec-failed.org + register: res + failed_when: '"status: NOERROR" not in res.stdout' + + - name: test dnssec-failed.org returns SERVFAIL + shell: dig @127.0.0.1 dnssec-failed.org + register: res + failed_when: '"status: SERVFAIL" not in res.stdout' + always: + - name: show installed version + debug: + var: package_version.stdout diff --git a/distro/tests/repos.yaml b/distro/tests/repos.yaml new file mode 100644 index 0000000000000000000000000000000000000000..9827fe7a101c45c4a30358248989802757592f19 --- /dev/null +++ b/distro/tests/repos.yaml @@ -0,0 +1,3 @@ +repos: + - knot-resolver-latest + - knot-resolver-devel diff --git a/distro/tests/test-distro.sh b/distro/tests/test-distro.sh index 61ac6d716078d76aa24086f887e8b32f60b9c939..78e65db9b4817474d0f810aa946aabdd68235994 100755 --- a/distro/tests/test-distro.sh +++ b/distro/tests/test-distro.sh @@ -1,9 +1,26 @@ #!/bin/bash -x -# Configure which repos to use in knot-resolver-test.yaml (vars - repos) -# Example usage: ./test-distro.sh debian9 +# ./test-distro.sh {devel|latest} {distro} +# Example usage: ./test-distro.sh devel debian9 -cd "$1" +distro=$2 +repo=$1 + +# Select repos +echo -e 'repos:\n - knot-resolver-latest' > repos.yaml # latest is needed for knot +case "$repo" in + devel) + echo -e ' - knot-resolver-devel' >> repos.yaml + ;; + latest) + ;; + *) + echo "Unknown repo, choose devel|latest" + exit 1 + ;; +esac + +cd "$distro" vagrant destroy &>/dev/null vagrant up ret=$?