Test Kitchen
Utilizing test kitchen is optional but valuable. Here are the kitchen settings and example inspec tests.
---
driver:
name: dokken
chef_version: latest
use_sudo: false
privileged: true
run_command: init
build_options: --tag kitchen:<%= File.basename(Dir.pwd) %>
hostname: default-os
transport:
name: dokken
provisioner:
name: dokken
verifier:
name: inspec
platforms:
- name: centos-7
driver:
image: dokken/centos-7
pid_one_command: /usr/lib/systemd/systemd
- name: ubuntu-20.04
driver:
image: dokken/ubuntu-20.04
pid_one_command: /bin/systemd
intermediate_instructions:
- RUN /usr/bin/apt-get update
- name: ubuntu-22.04
driver:
image: dokken/ubuntu-22.04
pid_one_command: /bin/systemd
intermediate_instructions:
- RUN /usr/bin/apt-get update
suites:
- name: default
run_list:
- ::default
attributes:
org_namespace: org1
org1:
test_kitchen: true
...
Inspec tests would be located: [cookbook]/test/integration/default
describe file('/etc/modules-load.d/zram.conf') do
it { should exist }
its('content') { should match /^zram$/ }
end
describe file('/etc/modprobe.d/zram.conf') do
it { should exist }
its('content') { should match /num_devices/ }
end
describe file('/etc/udev/rules.d/99-zram.rules') do
it { should exist }
its('content') { should match /^KERNEL.*ATTR.*systemd/ }
end
describe service('zram') do
it { should be_installed }
it { should be_enabled }
end
describe command('sysctl -a') do
its('stdout') { should match /vm.swappiness = 100/ }
its('stdout') { should match /vm.vfs_cache_pressure = 500/ }
its('stdout') { should match /vm.dirty_background_ratio = 1/ }
its('stdout') { should match /vm.dirty_ratio = 50/ }
end