Commit b8bcca67 authored by Tomas Krizek's avatar Tomas Krizek

packaging: add tests

parent c888c5dc
......@@ -76,3 +76,6 @@ version.h
*.gcno
/coverage.info
/coverage.html
# Vagrant
.vagrant
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-latest* repo is used. To test the
*knot-dns-devel* repo, enable in it `knot-dns-test.yaml`.
Run the following command for every distro (aka directory with
Vagrantfile):
./test-distro.sh debian9
Caveats
-------
This tests the latest `knot` package that is available. In certain cases, this
may result in unexpected behaviour, because it might be testing a different
package than expected.
# -*- 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" do |arch|
arch.vm.provision "ansible" do |ansible|
ansible.playbook = "../knot-dns-test.yaml"
end
end
end
# -*- 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" do |centos7|
centos7.vm.provision "ansible" do |ansible|
ansible.playbook = "../knot-dns-test.yaml"
end
end
end
# -*- 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" do |debian9|
debian9.vm.provision "ansible" do |ansible|
ansible.playbook = "../knot-dns-test.yaml"
end
end
end
# -*- mode: ruby -*-
# vi: set ft=ruby :
#
Vagrant.configure(2) do |config|
config.vm.box = "fedora/27-cloud-base"
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.define "fedora27" do |fedora27|
fedora27.vm.provision "ansible" do |ansible|
ansible.playbook = "../knot-dns-test.yaml"
end
end
end
---
- hosts: all
remote_user: root
become: true
vars:
repos:
- knot-dns-latest
# - knot-dns-devel # enable to test development builds
selinux_on: true
ansible_python_interpreter: /usr/bin/python2
dig_package:
Debian: dnsutils
Ubuntu: dnsutils
Fedora: bind-utils
CentOS: bind-utils
Archlinux: bind-tools
configure_obs_repo:
Fedora: |
dnf config-manager --add-repo https://download.opensuse.org/repositories/home:CZ-NIC:{{ item }}/Fedora_27/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_16.04/ /' > /etc/apt/sources.list.d/{{ item }}.list &&
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
# HACK: Ansible requires Python 2, but it's not installed by default in all distros
gather_facts: false
pre_tasks:
- name: install python and deps for ansible modules
raw: |
yum install -y python2 python2-dnf libselinux-python || \
pacman -Sy python2 --noconfirm || \
apt-get install -y python || \
:
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] }}"
with_items: "{{ repos }}"
when: ansible_distribution != '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
when: ansible_distribution == 'Archlinux'
- name: install knot
package:
name: knot
state: latest
- name: install dig
package:
name: "{{ dig_package[ansible_distribution] }}"
state: present
- name: turn off SELinux
selinux:
policy: targeted
state: permissive
when: not selinux_on and ansible_distribution in ['RedHat', 'Fedora']
- 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'
#!/bin/bash -x
# Configure which repos to use in knot-dns-test.yaml (vars - repos)
# Example usage: ./test-distro.sh debian9
cd "$1"
vagrant destroy &>/dev/null
vagrant up
ret=$?
vagrant destroy &>/dev/null
exit $ret
# -*- 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" do |ubuntu1604|
ubuntu1604.vm.provision "ansible" do |ansible|
ansible.playbook = "../knot-dns-test.yaml"
end
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment