From: Tom Hughes Date: Sat, 15 Feb 2020 14:52:12 +0000 (+0000) Subject: Add tests for planet cookbook X-Git-Url: https://git.openstreetmap.org/chef.git/commitdiff_plain/d9ce053b71c151916fa8764b44a6058f827d3146?hp=bf4c91815e210ba175f610713fa43cba3aa7d347 Add tests for planet cookbook --- diff --git a/.kitchen.yml b/.kitchen.yml index 792b4198b..63e3503e2 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -142,6 +142,24 @@ suites: - recipe[accounts::default] - recipe[chef::default] - role[otrs] + - name: planet + run_list: + - recipe[planet::default] + - name: planet-dump + run_list: + - recipe[planet::dump] + - name: planet-notes + run_list: + - recipe[planet::notes] + attributes: + web: + readonly_database_host: readonly + - name: planet-replication + run_list: + - recipe[planet::replication] + attributes: + web: + readonly_database_host: readonly - name: python run_list: - recipe[python::default] diff --git a/.travis.yml b/.travis.yml index 26f95c00e..9387d3348 100644 --- a/.travis.yml +++ b/.travis.yml @@ -86,6 +86,18 @@ jobs: - name: "Test Kitchen (otrs)" script: - bundle exec kitchen test otrs-ubuntu-1804 + - name: "Test Kitchen (planet)" + script: + - bundle exec kitchen test planet-ubuntu-1804 + - name: "Test Kitchen (planet::dump)" + script: + - bundle exec kitchen test planet-dump-ubuntu-1804 + - name: "Test Kitchen (planet::notes)" + script: + - bundle exec kitchen test planet-notes-ubuntu-1804 + - name: "Test Kitchen (planet::replication)" + script: + - bundle exec kitchen test planet-replication-ubuntu-1804 - name: "Test Kitchen (python)" script: - bundle exec kitchen test python-ubuntu-1804 diff --git a/cookbooks/bind/recipes/default.rb b/cookbooks/bind/recipes/default.rb index 087ef5802..aaba99781 100644 --- a/cookbooks/bind/recipes/default.rb +++ b/cookbooks/bind/recipes/default.rb @@ -19,15 +19,8 @@ include_recipe "networking" -clients = search(:node, "roles:#{node[:bind][:clients]}") - -ipv4_clients = clients.collect do |client| - client.ipaddresses(:family => :inet) -end.flatten - -ipv6_clients = clients.collect do |client| - client.ipaddresses(:family => :inet6) -end.flatten +ipv4_clients = [] +ipv6_clients = [] package "bind9" diff --git a/cookbooks/planet/attributes/default.rb b/cookbooks/planet/attributes/default.rb index e888b5677..f01d8acc4 100644 --- a/cookbooks/planet/attributes/default.rb +++ b/cookbooks/planet/attributes/default.rb @@ -1,3 +1,5 @@ +default[:accounts][:users][:planet][:status] = :role + default[:planet][:dump][:xml_directory] = "/store/planet/planet" default[:planet][:dump][:xml_history_directory] = "/store/planet/planet/full-history" default[:planet][:dump][:pbf_directory] = "/store/planet/pbf" diff --git a/cookbooks/planet/metadata.rb b/cookbooks/planet/metadata.rb index 97cd99ffb..425fe95f5 100644 --- a/cookbooks/planet/metadata.rb +++ b/cookbooks/planet/metadata.rb @@ -6,8 +6,9 @@ description "Installs and configures a planet server" version "1.0.0" supports "ubuntu" +depends "accounts" depends "apache" depends "git" -depends "osmosis" depends "incron" depends "munin" +depends "osmosis" diff --git a/cookbooks/planet/recipes/default.rb b/cookbooks/planet/recipes/default.rb index ba5bf0023..d8ec3bd3c 100644 --- a/cookbooks/planet/recipes/default.rb +++ b/cookbooks/planet/recipes/default.rb @@ -17,6 +17,7 @@ # limitations under the License. # +include_recipe "accounts" include_recipe "apache" package %w[ diff --git a/cookbooks/planet/recipes/dump.rb b/cookbooks/planet/recipes/dump.rb index a5e9a5fff..aea66204d 100644 --- a/cookbooks/planet/recipes/dump.rb +++ b/cookbooks/planet/recipes/dump.rb @@ -92,6 +92,7 @@ directory "/store/planetdump" do owner "www-data" group "www-data" mode 0o755 + recursive true end %w[planetdump planet-mirror-redirect-update].each do |program| diff --git a/cookbooks/planet/recipes/replication.rb b/cookbooks/planet/recipes/replication.rb index 548ae871b..b23c00f36 100644 --- a/cookbooks/planet/recipes/replication.rb +++ b/cookbooks/planet/recipes/replication.rb @@ -17,6 +17,7 @@ # limitations under the License. # +include_recipe "accounts" include_recipe "osmosis" db_passwords = data_bag_item("db", "passwords") @@ -27,11 +28,11 @@ package "ruby" package "ruby-dev" package "ruby-libxml" -package "libpq-dev" -gem_package "pg" - package "make" package "gcc" +package "libpq-dev" + +gem_package "pg" remote_directory "/opt/flush" do source "flush" diff --git a/roles/planet.rb b/roles/planet.rb index 6c765845b..9055e1efd 100644 --- a/roles/planet.rb +++ b/roles/planet.rb @@ -2,15 +2,6 @@ name "planet" description "Role applied to all planet servers" default_attributes( - :accounts => { - :users => { - :bretth => { :status => :user }, - :planet => { - :status => :administrator, - :members => [:bretth] - } - } - }, :rsyncd => { :modules => { :planet => { diff --git a/test/data_bags/accounts/planet.json b/test/data_bags/accounts/planet.json new file mode 100644 index 000000000..b69305fd8 --- /dev/null +++ b/test/data_bags/accounts/planet.json @@ -0,0 +1,5 @@ +{ + "id": "planet", + "uid": "502", + "comment": "planet.openstreetmap.org" +} diff --git a/test/data_bags/db/passwords.json b/test/data_bags/db/passwords.json new file mode 100644 index 000000000..f509c5ff0 --- /dev/null +++ b/test/data_bags/db/passwords.json @@ -0,0 +1,12 @@ +{ + "id": "passwords", + "openstreetmap": "openstreetmap-password", + "rails": "rails-password", + "cgimap": "cgimap-password", + "planetdump": "planetdump-password", + "planetdiff": "planetdiff-password", + "backup": "backup-password", + "gpximport": "gpximport-password", + "munin": "munin-password", + "replication": "replication-password" +} diff --git a/test/integration/planet-dump/serverspec/planetdump_spec.rb b/test/integration/planet-dump/serverspec/planetdump_spec.rb new file mode 100644 index 000000000..ed082b910 --- /dev/null +++ b/test/integration/planet-dump/serverspec/planetdump_spec.rb @@ -0,0 +1,23 @@ +require "serverspec" + +# Required by serverspec +set :backend, :exec + +describe file("/opt/planet-dump-ng/planet-dump-ng") do + it { should be_file } + it { should be_executable } +end + +describe file("/usr/local/bin/planetdump") do + it { should be_file } + it { should be_executable } +end + +describe file("/usr/local/bin/planet-mirror-redirect-update") do + it { should be_file } + it { should be_executable } +end + +describe file("/etc/cron.d/planet-dump-mirror") do + it { should be_file } +end diff --git a/test/integration/planet-notes/serverspec/planetdump_spec.rb b/test/integration/planet-notes/serverspec/planetdump_spec.rb new file mode 100644 index 000000000..6d35a497b --- /dev/null +++ b/test/integration/planet-notes/serverspec/planetdump_spec.rb @@ -0,0 +1,13 @@ +require "serverspec" + +# Required by serverspec +set :backend, :exec + +describe file("/usr/local/bin/planet-notes-dump") do + it { should be_file } + it { should be_executable } +end + +describe file("/etc/cron.d/planet-notes-dump") do + it { should be_file } +end diff --git a/test/integration/planet/serverspec/apache_spec.rb b/test/integration/planet/serverspec/apache_spec.rb new file mode 100644 index 000000000..446d3b915 --- /dev/null +++ b/test/integration/planet/serverspec/apache_spec.rb @@ -0,0 +1,21 @@ +require "serverspec" + +# Required by serverspec +set :backend, :exec + +describe package("apache2") do + it { should be_installed } +end + +describe service("apache2") do + it { should be_enabled } + it { should be_running } +end + +describe port(80) do + it { should be_listening.with("tcp") } +end + +describe port(443) do + it { should be_listening.with("tcp") } +end