feat: use kitchen for tests
This commit is contained in:
parent
9cfcbc9287
commit
73701e913c
11 changed files with 114 additions and 66 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
.kitchen/*
|
||||
|
36
.kitchen.yml
Normal file
36
.kitchen.yml
Normal file
|
@ -0,0 +1,36 @@
|
|||
driver:
|
||||
name: docker_cli
|
||||
|
||||
transport:
|
||||
name: docker_cli
|
||||
|
||||
provisioner:
|
||||
name: ansible_playbook
|
||||
hosts: localhost
|
||||
# roles_path: .
|
||||
require_ansible_repo: false
|
||||
require_ansible_omnibus: true
|
||||
require_chef_for_busser: true
|
||||
ansible_verbose: false
|
||||
ansible_version: latest
|
||||
ansible_inventory: ./test/integration/inventory
|
||||
|
||||
platforms:
|
||||
- name: debian-9
|
||||
driver_config:
|
||||
image: nishiki/ansible:stretch
|
||||
command: /bin/systemd
|
||||
volume:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
security_opt: seccomp=unconfined
|
||||
|
||||
#verifier:
|
||||
# name: serverspec
|
||||
# bundler_path: '/usr/local/bin'
|
||||
# rspec_path: '/usr/local/bin'
|
||||
#
|
||||
suites:
|
||||
- name: bind
|
||||
# verifier:
|
||||
# patterns:
|
||||
# - tests/spec/*.rb
|
|
@ -5,10 +5,12 @@ services:
|
|||
- docker
|
||||
|
||||
before_install:
|
||||
- docker pull nishiki/ansible:stretch
|
||||
- bundle install
|
||||
|
||||
script:
|
||||
- rake
|
||||
- kitchen conv
|
||||
- kitchen conv | grep changed=0
|
||||
- kitchen verify
|
||||
|
||||
notifications:
|
||||
webhooks: https://galaxy.ansible.com/api/v1/notifications/
|
||||
|
|
5
Gemfile
5
Gemfile
|
@ -1,7 +1,8 @@
|
|||
source 'https://rubygems.org'
|
||||
|
||||
group :development do
|
||||
gem 'rake'
|
||||
gem 'kitchen-ansible'
|
||||
gem 'kitchen-docker_cli'
|
||||
gem 'rubocop', '0.50.0'
|
||||
gem 'serverspec'
|
||||
gem 'test-kitchen'
|
||||
end
|
||||
|
|
94
Gemfile.lock
94
Gemfile.lock
|
@ -2,12 +2,36 @@ GEM
|
|||
remote: https://rubygems.org/
|
||||
specs:
|
||||
ast (2.3.0)
|
||||
diff-lcs (1.3)
|
||||
builder (3.2.3)
|
||||
erubis (2.7.0)
|
||||
ffi (1.9.18)
|
||||
gssapi (1.2.0)
|
||||
ffi (>= 1.0.1)
|
||||
gyoku (1.3.1)
|
||||
builder (>= 2.1.2)
|
||||
httpclient (2.8.3)
|
||||
kitchen-ansible (0.47.5)
|
||||
net-ssh (>= 3)
|
||||
test-kitchen (~> 1.4)
|
||||
kitchen-docker_cli (0.18.0)
|
||||
test-kitchen (>= 1.3)
|
||||
little-plugger (1.1.4)
|
||||
logging (2.2.2)
|
||||
little-plugger (~> 1.1)
|
||||
multi_json (~> 1.10)
|
||||
mixlib-install (3.6.0)
|
||||
mixlib-shellout
|
||||
mixlib-versioning
|
||||
thor
|
||||
mixlib-shellout (2.3.2)
|
||||
mixlib-versioning (1.2.2)
|
||||
multi_json (1.12.2)
|
||||
net-scp (1.2.1)
|
||||
net-ssh (>= 2.6.5)
|
||||
net-ssh (4.2.0)
|
||||
net-telnet (0.1.1)
|
||||
net-ssh-gateway (1.3.0)
|
||||
net-ssh (>= 2.6.5)
|
||||
nori (2.6.0)
|
||||
parallel (1.12.0)
|
||||
parser (2.4.0.0)
|
||||
ast (~> 2.2)
|
||||
|
@ -15,22 +39,6 @@ GEM
|
|||
rainbow (2.2.2)
|
||||
rake
|
||||
rake (12.1.0)
|
||||
rspec (3.6.0)
|
||||
rspec-core (~> 3.6.0)
|
||||
rspec-expectations (~> 3.6.0)
|
||||
rspec-mocks (~> 3.6.0)
|
||||
rspec-core (3.6.0)
|
||||
rspec-support (~> 3.6.0)
|
||||
rspec-expectations (3.6.0)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.6.0)
|
||||
rspec-its (1.2.0)
|
||||
rspec-core (>= 3.0.0)
|
||||
rspec-expectations (>= 3.0.0)
|
||||
rspec-mocks (3.6.0)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.6.0)
|
||||
rspec-support (3.6.0)
|
||||
rubocop (0.50.0)
|
||||
parallel (~> 1.10)
|
||||
parser (>= 2.3.3.1, < 3.0)
|
||||
|
@ -39,26 +47,48 @@ GEM
|
|||
ruby-progressbar (~> 1.7)
|
||||
unicode-display_width (~> 1.0, >= 1.0.1)
|
||||
ruby-progressbar (1.9.0)
|
||||
serverspec (2.41.0)
|
||||
multi_json
|
||||
rspec (~> 3.0)
|
||||
rspec-its
|
||||
specinfra (~> 2.72)
|
||||
sfl (2.3)
|
||||
specinfra (2.72.0)
|
||||
net-scp
|
||||
net-ssh (>= 2.7, < 5.0)
|
||||
net-telnet
|
||||
sfl
|
||||
rubyntlm (0.6.2)
|
||||
rubyzip (1.2.1)
|
||||
safe_yaml (1.0.4)
|
||||
test-kitchen (1.18.0)
|
||||
mixlib-install (~> 3.6)
|
||||
mixlib-shellout (>= 1.2, < 3.0)
|
||||
net-scp (~> 1.1)
|
||||
net-ssh (>= 2.9, < 5.0)
|
||||
net-ssh-gateway (~> 1.2)
|
||||
safe_yaml (~> 1.0)
|
||||
thor (~> 0.19, < 0.19.2)
|
||||
winrm (~> 2.0)
|
||||
winrm-elevated (~> 1.0)
|
||||
winrm-fs (~> 1.0.2)
|
||||
thor (0.19.1)
|
||||
unicode-display_width (1.3.0)
|
||||
winrm (2.2.3)
|
||||
builder (>= 2.1.2)
|
||||
erubis (~> 2.7)
|
||||
gssapi (~> 1.2)
|
||||
gyoku (~> 1.0)
|
||||
httpclient (~> 2.2, >= 2.2.0.2)
|
||||
logging (>= 1.6.1, < 3.0)
|
||||
nori (~> 2.0)
|
||||
rubyntlm (~> 0.6.0, >= 0.6.1)
|
||||
winrm-elevated (1.1.0)
|
||||
winrm (~> 2.0)
|
||||
winrm-fs (~> 1.0)
|
||||
winrm-fs (1.0.2)
|
||||
erubis (~> 2.7)
|
||||
logging (>= 1.6.1, < 3.0)
|
||||
rubyzip (~> 1.1)
|
||||
winrm (~> 2.0)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
rake
|
||||
kitchen-ansible
|
||||
kitchen-docker_cli
|
||||
rubocop (= 0.50.0)
|
||||
serverspec
|
||||
test-kitchen
|
||||
|
||||
BUNDLED WITH
|
||||
1.13.6
|
||||
1.14.6
|
||||
|
|
|
@ -67,7 +67,7 @@ bind_zones:
|
|||
* install ruby
|
||||
* install bundler `gem install bundler`
|
||||
* install dependencies `bundle install`
|
||||
* run the tests `rake`
|
||||
* run the tests `kitchen test`
|
||||
|
||||
## License
|
||||
|
||||
|
|
26
Rakefile
26
Rakefile
|
@ -1,26 +0,0 @@
|
|||
require 'English'
|
||||
|
||||
ansible_role = 'bind'
|
||||
|
||||
def exec_cmd(cmd)
|
||||
puts cmd
|
||||
puts %x(#{cmd})
|
||||
raise unless $CHILD_STATUS.success?
|
||||
end
|
||||
|
||||
task :default do
|
||||
exec_cmd(
|
||||
"docker run -v $(pwd):/#{ansible_role}:ro -it nishiki/ansible:stretch bash -c " \
|
||||
"'cd /#{ansible_role} && rake verify'"
|
||||
)
|
||||
end
|
||||
|
||||
task verify: %w[
|
||||
install
|
||||
]
|
||||
|
||||
task :install do
|
||||
exec_cmd("ansible-playbook -i tests/inventory tests/#{ansible_role}.yml")
|
||||
exec_cmd("ansible-playbook -i tests/inventory tests/#{ansible_role}.yml | grep changed=0")
|
||||
exec_cmd("cd tests/spec && rspec #{ansible_role}.rb")
|
||||
end
|
|
@ -32,5 +32,4 @@
|
|||
- { name: hello, type: a, value: 4.3.2.1 }
|
||||
|
||||
roles:
|
||||
- bind
|
||||
|
||||
- ansible-role-bind
|
|
@ -41,6 +41,11 @@ describe file('/etc/bind/named.conf.options') do
|
|||
it { should contain 'listen-on-v6 { none; };' }
|
||||
end
|
||||
|
||||
describe service('bind9') do
|
||||
it { should be_enabled }
|
||||
it { should be_running.under('systemd') }
|
||||
end
|
||||
|
||||
describe port(53) do
|
||||
it { should be_listening.with('tcp') }
|
||||
it { should be_listening.with('udp') }
|
|
@ -1 +0,0 @@
|
|||
..
|
Loading…
Reference in a new issue