From 1eeb41f8cbd0f50b8d4d1e1e83b9e04398d36c9a Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Fri, 14 Feb 2020 14:36:18 +0000 Subject: [PATCH] Add test for dhcpd cookbook --- .kitchen.yml | 18 ++++++++++++++++++ .travis.yml | 3 +++ cookbooks/dhcpd/metadata.rb | 1 + .../integration/dhcpd/serverspec/dhcpd_spec.rb | 17 +++++++++++++++++ 4 files changed, 39 insertions(+) create mode 100644 test/integration/dhcpd/serverspec/dhcpd_spec.rb diff --git a/.kitchen.yml b/.kitchen.yml index b58cbae3c..c2dc660fc 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -48,6 +48,24 @@ suites: - name: devices run_list: - recipe[devices::default] + - name: dhcpd + run_list: + - recipe[dhcpd::default] + attributes: + dhcpd: + first_address: 172.18.100.1 + last_address: 172.18.100.254 + networking: + interfaces: + test: + interface: eth0 + role: internal + address: 172.18.0.2 + prefix: 16 + gateway: 172.18.0.1 + roles: + external: + zone: test - name: exim run_list: - recipe[exim::default] diff --git a/.travis.yml b/.travis.yml index 7bc856208..bff7bff04 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,6 +29,9 @@ jobs: - name: "Test Kitchen (devices)" script: - bundle exec kitchen test devices-ubuntu-1804 + - name: "Test Kitchen (dhcpd)" + script: + - bundle exec kitchen test dhcpd-ubuntu-1804 - name: "Test Kitchen (exim)" script: - bundle exec kitchen test exim-ubuntu-1804 diff --git a/cookbooks/dhcpd/metadata.rb b/cookbooks/dhcpd/metadata.rb index cc693c7df..2e239b157 100644 --- a/cookbooks/dhcpd/metadata.rb +++ b/cookbooks/dhcpd/metadata.rb @@ -7,3 +7,4 @@ description "Configures dhcpd" version "1.0.0" supports "ubuntu" depends "networking" +depends "ntp" diff --git a/test/integration/dhcpd/serverspec/dhcpd_spec.rb b/test/integration/dhcpd/serverspec/dhcpd_spec.rb new file mode 100644 index 000000000..643f083f4 --- /dev/null +++ b/test/integration/dhcpd/serverspec/dhcpd_spec.rb @@ -0,0 +1,17 @@ +require "serverspec" + +# Required by serverspec +set :backend, :exec + +describe package("isc-dhcp-server") do + it { should be_installed } +end + +describe service("isc-dhcp-server") do + it { should be_enabled } + it { should be_running } +end + +describe port(67) do + it { should be_listening.with("udp") } +end -- 2.43.2