diff options
Diffstat (limited to 'distro/tests')
-rw-r--r-- | distro/tests/README.md | 41 | ||||
-rw-r--r-- | distro/tests/arch/Vagrantfile | 16 | ||||
-rw-r--r-- | distro/tests/centos7/Vagrantfile | 19 | ||||
-rw-r--r-- | distro/tests/debian9/Vagrantfile | 16 | ||||
-rw-r--r-- | distro/tests/fedora28/Vagrantfile | 19 | ||||
-rw-r--r-- | distro/tests/fedora29/Vagrantfile | 19 | ||||
-rw-r--r-- | distro/tests/knot-dns-test.yaml | 158 | ||||
-rw-r--r-- | distro/tests/leap15/Vagrantfile | 16 | ||||
-rw-r--r-- | distro/tests/repos.yaml | 2 | ||||
-rwxr-xr-x | distro/tests/test-distro.sh | 32 | ||||
-rw-r--r-- | distro/tests/tumbleweed/Vagrantfile | 16 | ||||
-rw-r--r-- | distro/tests/ubuntu1604/Vagrantfile | 19 | ||||
-rw-r--r-- | distro/tests/ubuntu1804/Vagrantfile | 19 | ||||
-rw-r--r-- | distro/tests/ubuntu1810/Vagrantfile | 19 |
14 files changed, 411 insertions, 0 deletions
diff --git a/distro/tests/README.md b/distro/tests/README.md new file mode 100644 index 0000000..d834892 --- /dev/null +++ b/distro/tests/README.md @@ -0,0 +1,41 @@ +Requirements +------------ + +- ansible +- vagrant +- libvirt (+vagrant-libvirt) / virtualbox + +Usage +----- + +`vagrant up` command is configured to trigger ansible provisioning +which configures OBS repository, installs the knot package, creates +a zone and config file, starts the knot.service and attempts to +resolve the entry from created zone file. + +By default, the *knot-dns-devel* repo is used. To test the +*knot-dns-latest* or *knot-dns-testing* 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. + +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..f7fe880 --- /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-dns" do |machine| + machine.vm.provision "ansible" do |ansible| + ansible.playbook = "../knot-dns-test.yaml" + end + end + +end diff --git a/distro/tests/centos7/Vagrantfile b/distro/tests/centos7/Vagrantfile new file mode 100644 index 0000000..dbb61f4 --- /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-dns" do |machine| + machine.vm.provision "ansible" do |ansible| + ansible.playbook = "../knot-dns-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..2450d14 --- /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-dns" do |machine| + machine.vm.provision "ansible" do |ansible| + ansible.playbook = "../knot-dns-test.yaml" + end + end + +end diff --git a/distro/tests/fedora28/Vagrantfile b/distro/tests/fedora28/Vagrantfile new file mode 100644 index 0000000..d64d6af --- /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-dns" do |machine| + machine.vm.provision "ansible" do |ansible| + ansible.playbook = "../knot-dns-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..73ecef2 --- /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-dns" do |machine| + machine.vm.provision "ansible" do |ansible| + ansible.playbook = "../knot-dns-test.yaml" + ansible.extra_vars = { + ansible_python_interpreter: "/usr/bin/python3" + } + end + end + +end diff --git a/distro/tests/knot-dns-test.yaml b/distro/tests/knot-dns-test.yaml new file mode 100644 index 0000000..828f71e --- /dev/null +++ b/distro/tests/knot-dns-test.yaml @@ -0,0 +1,158 @@ +--- +- 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 | grep '^Version' + Fedora: &pkg_version_rpm | + rpm -qi knot | grep '^Version' + CentOS: *pkg_version_rpm + openSUSE Leap: *pkg_version_rpm + openSUSE Tumbleweed: *pkg_version_rpm + Debian: &pkg_version_dpkg | + dpkg -s knot | grep '^Version' + Ubuntu: *pkg_version_dpkg + 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: sync repos (Arch) + shell: pacman -Syu --noconfirm + args: + warn: false + when: ansible_distribution_file_variety == 'Archlinux' + + - name: install knot + package: + name: knot + 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: create example.com zone + copy: + dest: /etc/knot/example.com.zone + content: | + $ORIGIN example.com. + $TTL 3600 + @ SOA dns1.example.com. hostmaster.example.com. ( + 2010111213 ; serial + 6h ; refresh + 1h ; retry + 1w ; expire + 1d ) ; minimum + NS dns1 + dns1 A 192.0.2.1 + + - name: create config + blockinfile: + dest: /etc/knot/knot.conf + block: | + zone: + - domain: example.com + file: "/etc/knot/example.com.zone" + + - name: start knot.service + service: + name: knot.service + state: restarted + + - name: resolve dns1.example.com + shell: dig @127.0.0.1 dns1.example.com A + register: res + failed_when: '"192.0.2.1" not in res.stdout' + + - name: reload knot.service + service: + name: knot.service + state: reloaded + + - name: resolve dns1.example.com + shell: dig @127.0.0.1 dns1.example.com A + register: res + failed_when: '"192.0.2.1" 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..91996f0 --- /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-dns" do |machine| + machine.vm.provision "ansible" do |ansible| + ansible.playbook = "../knot-dns-test.yaml" + end + end + +end diff --git a/distro/tests/repos.yaml b/distro/tests/repos.yaml new file mode 100644 index 0000000..ca4b13b --- /dev/null +++ b/distro/tests/repos.yaml @@ -0,0 +1,2 @@ +repos: + - knot-dns-devel diff --git a/distro/tests/test-distro.sh b/distro/tests/test-distro.sh new file mode 100755 index 0000000..550ff90 --- /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 +case "$repo" in + devel) + echo -e 'repos:\n - knot-dns-devel' > repos.yaml + ;; + testing) + echo -e 'repos:\n - knot-dns-testing' > repos.yaml + ;; + latest) + echo -e 'repos:\n - knot-dns-latest' > repos.yaml + ;; + *) + 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..afdd618 --- /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-dns" do |machine| + machine.vm.provision "ansible" do |ansible| + ansible.playbook = "../knot-dns-test.yaml" + end + end + +end diff --git a/distro/tests/ubuntu1604/Vagrantfile b/distro/tests/ubuntu1604/Vagrantfile new file mode 100644 index 0000000..d5ea370 --- /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-dns" do |machine| + machine.vm.provision "ansible" do |ansible| + ansible.playbook = "../knot-dns-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..317de61 --- /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-dns" do |machine| + machine.vm.provision "ansible" do |ansible| + ansible.playbook = "../knot-dns-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..6302256 --- /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-dns" do |machine| + machine.vm.provision "ansible" do |ansible| + ansible.playbook = "../knot-dns-test.yaml" + ansible.extra_vars = { + ansible_python_interpreter: "/usr/bin/python3" + } + end + end + +end |