Add test for dhcpd cookbook
authorTom Hughes <tom@compton.nu>
Fri, 14 Feb 2020 14:36:18 +0000 (14:36 +0000)
committerTom Hughes <tom@compton.nu>
Fri, 14 Feb 2020 14:36:18 +0000 (14:36 +0000)
.kitchen.yml
.travis.yml
cookbooks/dhcpd/metadata.rb
test/integration/dhcpd/serverspec/dhcpd_spec.rb [new file with mode: 0644]

index b58cbae3c625c6a637749812d4619992fc3bf798..c2dc660fc9323e9502ed25ebfc83d816420ea6cc 100644 (file)
@@ -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]
index 7bc856208343e61fb0652eee517a114ad2e92ca2..bff7bff049444dc47d1fecc94472e1c4c163b72f 100644 (file)
@@ -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
index cc693c7df23b3e6e9498319a95bc9b0a5f5a8049..2e239b15745d5a275aa2ecb83885ee8069e1c055 100644 (file)
@@ -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 (file)
index 0000000..643f083
--- /dev/null
@@ -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