From: Tom Hughes Date: Tue, 18 Feb 2020 21:01:21 +0000 (+0000) Subject: Add test for geodns cookbook X-Git-Url: https://git.openstreetmap.org/chef.git/commitdiff_plain/416e7757ab73dc606f49f55fac52ddc2b93edaa0 Add test for geodns cookbook --- diff --git a/.kitchen.yml b/.kitchen.yml index 37f670c79..792949fa9 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -84,6 +84,15 @@ suites: - name: forum run_list: - recipe[forum::default] + - name: geodns + run_list: + - recipe[geodns::default] + attributes: + networking: + interfaces: + test: + role: external + address: 172.18.0.2 - name: geoipupdate run_list: - recipe[geoipupdate::default] diff --git a/.travis.yml b/.travis.yml index 8f02cbd48..e210de27a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -48,6 +48,9 @@ jobs: - name: "Test Kitchen (forum)" script: - bundle exec kitchen test forum-ubuntu-1804 + - name: "Test Kitchen (geodns)" + script: + - bundle exec kitchen test geodns-ubuntu-1804 - name: "Test Kitchen (geoipupdate)" script: - bundle exec kitchen test geoipupdate-ubuntu-1804 diff --git a/cookbooks/geodns/metadata.rb b/cookbooks/geodns/metadata.rb index 4782ac035..b912c7442 100644 --- a/cookbooks/geodns/metadata.rb +++ b/cookbooks/geodns/metadata.rb @@ -7,4 +7,5 @@ description "Installs and configures a geographic DNS server" version "1.0.0" supports "ubuntu" depends "geoipupdate" +depends "networking" depends "systemd" diff --git a/cookbooks/geodns/recipes/default.rb b/cookbooks/geodns/recipes/default.rb index 813ac250c..f017fb124 100644 --- a/cookbooks/geodns/recipes/default.rb +++ b/cookbooks/geodns/recipes/default.rb @@ -29,6 +29,19 @@ directory "/etc/gdnsd/config.d" do mode 0o755 end +%w[tile nominatim].each do |zone| + %w[map resource weighted].each do |type| + template "/etc/gdnsd/config.d/#{zone}.#{type}" do + action :create_if_missing + source "zone.#{type}.erb" + owner "nobody" + group "nogroup" + mode 0o644 + variables :zone => zone + end + end +end + template "/etc/gdnsd/config" do source "config.erb" owner "root" diff --git a/cookbooks/geodns/templates/default/zone.map.erb b/cookbooks/geodns/templates/default/zone.map.erb new file mode 100644 index 000000000..25bf3ad1a --- /dev/null +++ b/cookbooks/geodns/templates/default/zone.map.erb @@ -0,0 +1,3 @@ +<%= @zone %> => { + datacenters => [dummy] +} diff --git a/cookbooks/geodns/templates/default/zone.resource.erb b/cookbooks/geodns/templates/default/zone.resource.erb new file mode 100644 index 000000000..3c1426bb7 --- /dev/null +++ b/cookbooks/geodns/templates/default/zone.resource.erb @@ -0,0 +1,6 @@ +<%= @zone %> => { + map => <%= @zone %> + dcmap => { + dummy => dummy.example.com. + } +} diff --git a/cookbooks/geodns/templates/default/zone.weighted.erb b/cookbooks/geodns/templates/default/zone.weighted.erb new file mode 100644 index 000000000..e69de29bb diff --git a/test/integration/serverinfo/gdsnd_spec.rb b/test/integration/serverinfo/gdsnd_spec.rb new file mode 100644 index 000000000..65adc36e2 --- /dev/null +++ b/test/integration/serverinfo/gdsnd_spec.rb @@ -0,0 +1,18 @@ +require "serverspec" + +# Required by serverspec +set :backend, :exec + +describe package("gdnsd") do + it { should be_installed } +end + +describe service("gdnsd") do + it { should be_enabled } + it { should be_running } +end + +describe port(53) do + it { should be_listening.with("udp") } + it { should be_listening.with("tcp") } +end