summaryrefslogtreecommitdiffstats
path: root/distro/tests
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--distro/tests/README.md42
-rw-r--r--distro/tests/arch/Vagrantfile16
-rw-r--r--distro/tests/centos7/Vagrantfile19
-rw-r--r--distro/tests/debian9/Vagrantfile16
-rw-r--r--distro/tests/fedora28/Vagrantfile19
-rw-r--r--distro/tests/fedora29/Vagrantfile19
-rw-r--r--distro/tests/knot-resolver-test.yaml148
-rw-r--r--distro/tests/leap15/Vagrantfile16
-rw-r--r--distro/tests/repos.yaml3
-rwxr-xr-xdistro/tests/test-distro.sh32
-rw-r--r--distro/tests/tumbleweed/Vagrantfile16
-rw-r--r--distro/tests/ubuntu1604/Vagrantfile19
-rw-r--r--distro/tests/ubuntu1804/Vagrantfile19
-rw-r--r--distro/tests/ubuntu1810/Vagrantfile19
14 files changed, 403 insertions, 0 deletions
diff --git a/distro/tests/README.md b/distro/tests/README.md
new file mode 100644
index 0000000..f528348
--- /dev/null
+++ b/distro/tests/README.md
@@ -0,0 +1,42 @@
+Requirements
+------------
+
+- ansible
+- vagrant
+- libvirt (+vagrant-libvirt) / virtualbox
+
+Usage
+-----
+
+`vagrant up` command is configured to trigger ansible provisioning
+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-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 devel debian9
+```
+
+or
+
+```
+./test-distro.sh testing debian9
+```
+
+or
+
+```
+./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/arch/Vagrantfile b/distro/tests/arch/Vagrantfile
new file mode 100644
index 0000000..8e3677e
--- /dev/null
+++ b/distro/tests/arch/Vagrantfile
@@ -0,0 +1,16 @@
+# -*- mode: ruby -*-
+# vi: set ft=ruby :
+#
+
+Vagrant.configure(2) do |config|
+
+ config.vm.box = "archlinux/archlinux"
+ config.vm.synced_folder ".", "/vagrant", disabled: true
+
+ config.vm.define "arch_knot-resolver" do |machine|
+ machine.vm.provision "ansible" do |ansible|
+ ansible.playbook = "../knot-resolver-test.yaml"
+ end
+ end
+
+end
diff --git a/distro/tests/centos7/Vagrantfile b/distro/tests/centos7/Vagrantfile
new file mode 100644
index 0000000..a03e599
--- /dev/null
+++ b/distro/tests/centos7/Vagrantfile
@@ -0,0 +1,19 @@
+# -*- mode: ruby -*-
+# vi: set ft=ruby :
+#
+
+Vagrant.configure(2) do |config|
+
+ config.vm.box = "centos/7"
+ config.vm.synced_folder ".", "/vagrant", disabled: true
+
+ config.vm.define "centos7_knot-resolver" do |machine|
+ machine.vm.provision "ansible" do |ansible|
+ ansible.playbook = "../knot-resolver-test.yaml"
+ ansible.extra_vars = {
+ ansible_python_interpreter: "/usr/bin/python2"
+ }
+ end
+ end
+
+end
diff --git a/distro/tests/debian9/Vagrantfile b/distro/tests/debian9/Vagrantfile
new file mode 100644
index 0000000..3b7891b
--- /dev/null
+++ b/distro/tests/debian9/Vagrantfile
@@ -0,0 +1,16 @@
+# -*- mode: ruby -*-
+# vi: set ft=ruby :
+#
+
+Vagrant.configure(2) do |config|
+
+ config.vm.box = "debian/stretch64"
+ config.vm.synced_folder ".", "/vagrant", disabled: true
+
+ config.vm.define "debian9_knot-resolver" do |machine|
+ machine.vm.provision "ansible" do |ansible|
+ ansible.playbook = "../knot-resolver-test.yaml"
+ end
+ end
+
+end
diff --git a/distro/tests/fedora28/Vagrantfile b/distro/tests/fedora28/Vagrantfile
new file mode 100644
index 0000000..0171b4f
--- /dev/null
+++ b/distro/tests/fedora28/Vagrantfile
@@ -0,0 +1,19 @@
+# -*- mode: ruby -*-
+# vi: set ft=ruby :
+#
+
+Vagrant.configure(2) do |config|
+
+ config.vm.box = "generic/fedora28"
+ config.vm.synced_folder ".", "/vagrant", disabled: true
+
+ config.vm.define "fedora28_knot-resolver" do |machine|
+ machine.vm.provision "ansible" do |ansible|
+ ansible.playbook = "../knot-resolver-test.yaml"
+ ansible.extra_vars = {
+ ansible_python_interpreter: "/usr/bin/python3"
+ }
+ end
+ end
+
+end
diff --git a/distro/tests/fedora29/Vagrantfile b/distro/tests/fedora29/Vagrantfile
new file mode 100644
index 0000000..67407e8
--- /dev/null
+++ b/distro/tests/fedora29/Vagrantfile
@@ -0,0 +1,19 @@
+# -*- mode: ruby -*-
+# vi: set ft=ruby :
+#
+
+Vagrant.configure(2) do |config|
+
+ config.vm.box = "generic/fedora29"
+ config.vm.synced_folder ".", "/vagrant", disabled: true
+
+ config.vm.define "fedora29_knot-resolver" do |machine|
+ machine.vm.provision "ansible" do |ansible|
+ ansible.playbook = "../knot-resolver-test.yaml"
+ ansible.extra_vars = {
+ ansible_python_interpreter: "/usr/bin/python3"
+ }
+ end
+ end
+
+end
diff --git a/distro/tests/knot-resolver-test.yaml b/distro/tests/knot-resolver-test.yaml
new file mode 100644
index 0000000..33d07aa
--- /dev/null
+++ b/distro/tests/knot-resolver-test.yaml
@@ -0,0 +1,148 @@
+---
+- hosts: all
+
+ remote_user: root
+ become: true
+
+ vars:
+ dig_package:
+ Debian: dnsutils
+ Ubuntu: dnsutils
+ Fedora: bind-utils
+ CentOS: bind-utils
+ openSUSE Leap: bind-utils
+ openSUSE Tumbleweed: bind-utils
+ Archlinux: bind-tools
+ configure_obs_repo:
+ Fedora: |
+ dnf config-manager --add-repo https://download.opensuse.org/repositories/home:CZ-NIC:{{ item }}/Fedora_{{ ansible_distribution_major_version }}/home:CZ-NIC:{{ item }}.repo
+ CentOS: |
+ yum install -y wget &&
+ wget -i wget https://download.opensuse.org/repositories/home:CZ-NIC:{{ item }}/CentOS_7_EPEL/home:CZ-NIC:{{ item }}.repo -O /etc/yum.repos.d/home:CZ-NIC:{{ item }}.repo
+ Debian: |
+ echo 'deb http://download.opensuse.org/repositories/home:/CZ-NIC:/{{ item }}/Debian_9.0/ /' > /etc/apt/sources.list.d/{{ item }}.list &&
+ wget -nv https://download.opensuse.org/repositories/home:CZ-NIC:{{ item }}/Debian_9.0/Release.key -O Release.key &&
+ apt-key add - < Release.key &&
+ apt-get update
+ Ubuntu: |
+ echo 'deb http://download.opensuse.org/repositories/home:/CZ-NIC:/{{ item }}/xUbuntu_{{ ansible_distribution_version }}/ /' > /etc/apt/sources.list.d/{{ item }}.list &&
+ wget -nv https://download.opensuse.org/repositories/home:CZ-NIC:{{ item }}/xUbuntu_{{ ansible_distribution_version }}/Release.key -O Release.key &&
+ apt-key add - < Release.key &&
+ apt-get update
+ openSUSE Tumbleweed: |
+ zypper addrepo https://download.opensuse.org/repositories/home:CZ-NIC:{{ item }}/openSUSE_Tumbleweed/home:CZ-NIC:{{ item }}.repo &&
+ zypper --gpg-auto-import-keys refresh
+ openSUSE Leap: |
+ zypper addrepo https://download.opensuse.org/repositories/home:CZ-NIC:{{ item }}/openSUSE_Leap_15.0/home:CZ-NIC:{{ item }}.repo &&
+ zypper --gpg-auto-import-keys refresh
+ show_package_version:
+ Archlinux:
+ pacman -Qi knot-resolver | grep '^Version'
+ Fedora: &pkg_version_rpm |
+ rpm -qi knot-resolver | grep '^Version'
+ CentOS: *pkg_version_rpm
+ openSUSE Leap: *pkg_version_rpm
+ openSUSE Tumbleweed: *pkg_version_rpm
+ Debian:
+ dpkg -s knot-resolver | grep '^Version'
+ Ubuntu: |
+ dpkg -s knot-resolver | grep '^Version'
+ vars_files:
+ - repos.yaml
+
+ gather_facts: false
+ pre_tasks:
+ - name: install python3 (Arch)
+ raw: |
+ (pacman-key --init && pacman-key --populate archlinux && \
+ pacman -Sy python3 --noconfirm) || :
+ ignore_errors: true
+ - name: gather facts
+ setup:
+
+ tasks:
+ - name: install epel
+ package:
+ name: epel-release
+ state: present
+ when: ansible_distribution == 'CentOS'
+
+ - name: configure OBS repository
+ shell: "{{ configure_obs_repo[ansible_distribution] }}"
+ args:
+ warn: false
+ with_items: "{{ repos }}"
+ when: ansible_distribution_file_variety != 'Archlinux'
+
+ - block:
+ - name: configure OBS repository (Arch)
+ blockinfile:
+ block: |
+ [home_CZ-NIC_{{ item }}_Arch]
+ SigLevel = Never
+ Server = https://download.opensuse.org/repositories/home:/CZ-NIC:/{{ item }}/Arch/$arch
+ insertbefore: '^\[core\]'
+ path: /etc/pacman.conf
+ state: present
+ with_items: "{{ repos }}"
+ - name: set up package mirrors
+ copy:
+ content: |
+ ## Arch Linux repository mirrorlist
+ ## Generated on 2018-12-10
+ ## Czechia
+ Server = http://mirrors.nic.cz/archlinux/$repo/os/$arch
+ Server = http://ftp.fi.muni.cz/pub/linux/arch/$repo/os/$arch
+ Server = http://ftp.sh.cvut.cz/arch/$repo/os/$arch
+ Server = http://gluttony.sin.cvut.cz/arch/$repo/os/$arch
+ dest: /etc/pacman.d/mirrorlist
+ - name: sync repos (Arch)
+ shell: pacman -Syu --noconfirm
+ args:
+ warn: false
+ when: ansible_distribution_file_variety == 'Archlinux'
+
+ - name: install knot-resolver
+ package:
+ name: knot-resolver
+ state: latest
+
+ - name: get installed package version
+ shell: "{{ show_package_version[ansible_distribution] }}"
+ args:
+ warn: false
+ register: package_version
+
+ - name: install dig
+ package:
+ name: "{{ dig_package[ansible_distribution] }}"
+ state: present
+
+ - name: testing block
+ block:
+ - 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
+ 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/leap15/Vagrantfile b/distro/tests/leap15/Vagrantfile
new file mode 100644
index 0000000..14bae76
--- /dev/null
+++ b/distro/tests/leap15/Vagrantfile
@@ -0,0 +1,16 @@
+# -*- mode: ruby -*-
+# vi: set ft=ruby :
+#
+
+Vagrant.configure(2) do |config|
+
+ config.vm.box = "opensuse/openSUSE-15.0-x86_64"
+ config.vm.synced_folder ".", "/vagrant", disabled: true
+
+ config.vm.define "leap15_knot-resolver" do |machine|
+ machine.vm.provision "ansible" do |ansible|
+ ansible.playbook = "../knot-resolver-test.yaml"
+ end
+ end
+
+end
diff --git a/distro/tests/repos.yaml b/distro/tests/repos.yaml
new file mode 100644
index 0000000..9827fe7
--- /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
new file mode 100755
index 0000000..0ae8662
--- /dev/null
+++ b/distro/tests/test-distro.sh
@@ -0,0 +1,32 @@
+#!/bin/bash -x
+
+# ./test-distro.sh {devel|latest} {distro}
+# Example usage: ./test-distro.sh devel debian9
+
+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
+ ;;
+ testing)
+ echo -e 'repos:\n - knot-resolver-testing' > repos.yaml
+ ;;
+ latest)
+ ;;
+ *)
+ echo "Unknown repo, choose devel|latest|testing"
+ exit 1
+ ;;
+esac
+
+cd "$distro"
+vagrant destroy -f &>/dev/null
+vagrant up
+ret=$?
+vagrant destroy -f &>/dev/null
+exit $ret
+
diff --git a/distro/tests/tumbleweed/Vagrantfile b/distro/tests/tumbleweed/Vagrantfile
new file mode 100644
index 0000000..ba0dada
--- /dev/null
+++ b/distro/tests/tumbleweed/Vagrantfile
@@ -0,0 +1,16 @@
+# -*- mode: ruby -*-
+# vi: set ft=ruby :
+#
+
+Vagrant.configure(2) do |config|
+
+ config.vm.box = "opensuse/openSUSE-Tumbleweed-x86_64"
+ config.vm.synced_folder ".", "/vagrant", disabled: true
+
+ config.vm.define "tumbleweed_knot-resolver" do |machine|
+ machine.vm.provision "ansible" do |ansible|
+ ansible.playbook = "../knot-resolver-test.yaml"
+ end
+ end
+
+end
diff --git a/distro/tests/ubuntu1604/Vagrantfile b/distro/tests/ubuntu1604/Vagrantfile
new file mode 100644
index 0000000..40e0492
--- /dev/null
+++ b/distro/tests/ubuntu1604/Vagrantfile
@@ -0,0 +1,19 @@
+# -*- mode: ruby -*-
+# vi: set ft=ruby :
+#
+
+Vagrant.configure(2) do |config|
+
+ config.vm.box = "generic/ubuntu1604"
+ config.vm.synced_folder ".", "/vagrant", disabled: true
+
+ config.vm.define "ubuntu1604_knot-resolver" do |machine|
+ machine.vm.provision "ansible" do |ansible|
+ ansible.playbook = "../knot-resolver-test.yaml"
+ ansible.extra_vars = {
+ ansible_python_interpreter: "/usr/bin/python3"
+ }
+ end
+ end
+
+end
diff --git a/distro/tests/ubuntu1804/Vagrantfile b/distro/tests/ubuntu1804/Vagrantfile
new file mode 100644
index 0000000..57e210d
--- /dev/null
+++ b/distro/tests/ubuntu1804/Vagrantfile
@@ -0,0 +1,19 @@
+# -*- mode: ruby -*-
+# vi: set ft=ruby :
+#
+
+Vagrant.configure(2) do |config|
+
+ config.vm.box = "generic/ubuntu1804"
+ config.vm.synced_folder ".", "/vagrant", disabled: true
+
+ config.vm.define "ubuntu1804_knot-resolver" do |machine|
+ machine.vm.provision "ansible" do |ansible|
+ ansible.playbook = "../knot-resolver-test.yaml"
+ ansible.extra_vars = {
+ ansible_python_interpreter: "/usr/bin/python3"
+ }
+ end
+ end
+
+end
diff --git a/distro/tests/ubuntu1810/Vagrantfile b/distro/tests/ubuntu1810/Vagrantfile
new file mode 100644
index 0000000..c560be1
--- /dev/null
+++ b/distro/tests/ubuntu1810/Vagrantfile
@@ -0,0 +1,19 @@
+# -*- mode: ruby -*-
+# vi: set ft=ruby :
+#
+
+Vagrant.configure(2) do |config|
+
+ config.vm.box = "generic/ubuntu1810"
+ config.vm.synced_folder ".", "/vagrant", disabled: true
+
+ config.vm.define "ubuntu1810_knot-resolver" do |machine|
+ machine.vm.provision "ansible" do |ansible|
+ ansible.playbook = "../knot-resolver-test.yaml"
+ ansible.extra_vars = {
+ ansible_python_interpreter: "/usr/bin/python3"
+ }
+ end
+ end
+
+end