From d1249949a8084da8c8128efed406e91da92c5a65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20B=C3=A9rtoli?= Date: Sat, 26 May 2018 18:54:26 -0300 Subject: [PATCH] Add basic testing scaffold, with travis support --- .gitignore | 103 ++++++++++++++++++++ .kitchen.yml | 115 +++++++++++++++++++++++ .travis.yml | 11 +++ README.rst | 21 +++++ test/integration/default/pkgs_spec.rb | 27 ++++++ test/integration/default/service_spec.rb | 17 ++++ 6 files changed, 294 insertions(+) create mode 100644 .gitignore create mode 100644 .kitchen.yml create mode 100644 .travis.yml create mode 100644 test/integration/default/pkgs_spec.rb create mode 100644 test/integration/default/service_spec.rb diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..45f46f6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,103 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a packager +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +.hypothesis/ +.kitchen +.kitchen.local.yml + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# dotenv +.env + +# virtualenv +.venv +venv/ +ENV/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ diff --git a/.kitchen.yml b/.kitchen.yml new file mode 100644 index 0000000..ce5459d --- /dev/null +++ b/.kitchen.yml @@ -0,0 +1,115 @@ +--- +driver: + name: docker + +driver_config: + use_sudo: false + privileged: true + provision_command: mkdir -p /run/sshd + run_command: /lib/systemd/systemd + +platforms: + - name: debian-8 + - name: debian-9 + - name: ubuntu-16.04 + - name: ubuntu-18.04 + - name: fedora-27 + - name: centos-7 + +provisioner: + name: salt_solo + log_level: info + require_chef: false + salt_version: latest + formula: bind + salt_copy_filter: + - .kitchen + - .git + pillars: + top.sls: + base: + '*': + - bind + bind.sls: + bind: + configured_acls: + client1: + - 127.0.0.0/8 + - 10.20.0.0/16 + client2: + - 10.30.0.0/8 + configured_zones: + my.zone: + type: master + notify: False + update_policy: + - "grant core_dhcp name dns_entry_allowed_to_update. ANY" + + example.com: + type: master + notify: false + available_zones: + my.zone: + file: my.zone.txt + soa: + class: IN + ns: ns1.example.com + contact: hostmaster.example.com + serial: 2017041001 + retry: 600 + ttl: 8600 + records: + A: + ns1: 1.2.3.4 + mx1: + - 1.2.3.228 + - 1.2.3.229 + NS: + '@': + - ns1 + example.com: + file: example.com.txt + soa: + class: IN + ns: ns1.example.com + contact: hostmaster.example.com + serial: 2017041001 + retry: 600 + ttl: 8600 + records: + A: + mx1: + - 1.2.3.228 + - 1.2.3.229 + - 2.3.4.186 + cat: 2.3.4.188 + rat: 1.2.3.231 + live: 1.2.3.236 + NS: + '@': + - rat + - cat + CNAME: + ftp: cat.example.com. + www: cat.example.com. + mail: mx1.example.com. + smtp: mx1.example.com. + TXT: + '@': + - '"some_value"' + +verifier: + name: inspec + sudo: true + reporter: cli + inspec_tests: + - path: test/integration/default + +suites: + - name: bind + provisioner: + state_top: + base: + '*': + - bind + - bind.config diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..a0e3087 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,11 @@ +sudo: required +cache: bundler +language: ruby + +services: + - docker + +before_install: + - bundle install + +script: bundle exec kitchen verify diff --git a/README.rst b/README.rst index 5e9043e..34b8fde 100644 --- a/README.rst +++ b/README.rst @@ -85,3 +85,24 @@ Notes ===== * When using views all zones must be configured in views! + +Salt Compatibility +================== + +Tested with: + +* 2017.7.x +* 2018.3.x + +OS Compatibility +================ + +Tested with: + +* Archlinux +* CentOS 7 +* Debian-8 +* Debian-9 +* Fedora-27 +* Ubuntu-16.04 +* Ubuntu-18.04 diff --git a/test/integration/default/pkgs_spec.rb b/test/integration/default/pkgs_spec.rb new file mode 100644 index 0000000..1bea319 --- /dev/null +++ b/test/integration/default/pkgs_spec.rb @@ -0,0 +1,27 @@ + +case os[:name] +when 'arch' + os_packages = %w( + bind + bind-tools + dnssec-tools + ) +when 'redhat', 'centos', 'fedora' + os_packages = %w(bind) +when 'debian', 'ubuntu' + os_packages = %w( + bind9 + bind9utils + ) +end + +control 'Bind9 packages' do + title 'should be installed' + + os_packages.each do |p| + describe package(p) do + it { should be_installed } + end + end +end + diff --git a/test/integration/default/service_spec.rb b/test/integration/default/service_spec.rb new file mode 100644 index 0000000..e6e78fb --- /dev/null +++ b/test/integration/default/service_spec.rb @@ -0,0 +1,17 @@ + +case os[:name] +when 'arch','redhat', 'centos', 'fedora' + service = 'named' +when 'debian', 'ubuntu' + service = 'bind9' +end + +control 'Bind9 service' do + title 'should be running' + + describe service(service) do + it { should be_enabled } + it { should be_running } + end +end +