From: Tom Hughes Date: Thu, 14 Jul 2022 13:40:19 +0000 (+0000) Subject: Add a test for the community cookbook X-Git-Url: https://git.openstreetmap.org/chef.git/commitdiff_plain/69f0fad6138dc422bb01c60a2433c4f5687afe15 Add a test for the community cookbook --- diff --git a/.github/workflows/test-kitchen.yml b/.github/workflows/test-kitchen.yml index cde43686d..5072dbe24 100644 --- a/.github/workflows/test-kitchen.yml +++ b/.github/workflows/test-kitchen.yml @@ -24,6 +24,7 @@ jobs: - blogs - civicrm - clamav + - community - db-backup - db-base - db-master diff --git a/.kitchen.yml b/.kitchen.yml index 933dbdfc0..6dc0dad22 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -59,6 +59,9 @@ suites: - name: clamav run_list: - recipe[clamav::default] + - name: community + run_list: + - recipe[community::default] - name: db-backup run_list: - recipe[db::backup] diff --git a/cookbooks/community/metadata.rb b/cookbooks/community/metadata.rb index c0aba9934..4d159c4ad 100644 --- a/cookbooks/community/metadata.rb +++ b/cookbooks/community/metadata.rb @@ -6,7 +6,8 @@ description "Installs and configures community site" version "1.0.0" supports "ubuntu" +depends "accounts" depends "docker" +depends "geoipupdate" depends "git" depends "ssl" -depends "geoipupdate" diff --git a/cookbooks/community/recipes/default.rb b/cookbooks/community/recipes/default.rb index 2297fa76c..89743de31 100644 --- a/cookbooks/community/recipes/default.rb +++ b/cookbooks/community/recipes/default.rb @@ -17,13 +17,14 @@ # limitations under the License. # +include_recipe "accounts" include_recipe "docker" +include_recipe "geoipupdate" include_recipe "git" include_recipe "ssl" -include_recipe "geoipupdate" passwords = data_bag_item("community", "passwords") -license_keys = data_bag_item("geoipupdate", "license-keys") +license_keys = data_bag_item("geoipupdate", "license-keys") unless kitchen? directory "/srv/community.openstreetmap.org" do owner "root" diff --git a/cookbooks/community/templates/default/web_only.yml.erb b/cookbooks/community/templates/default/web_only.yml.erb index 42e734e5d..92579138d 100644 --- a/cookbooks/community/templates/default/web_only.yml.erb +++ b/cookbooks/community/templates/default/web_only.yml.erb @@ -65,7 +65,9 @@ env: ## The maxmind geolocation IP address key for IP address lookup ## see https://meta.discourse.org/t/-/137387/23 for details +<% if @license_keys -%> DISCOURSE_MAXMIND_LICENSE_KEY: '<%= @license_keys[node[:geoipupdate][:account]] %>' +<% end -%> volumes: - volume: diff --git a/test/data_bags/accounts/community.json b/test/data_bags/accounts/community.json new file mode 100644 index 000000000..b4b5fd3eb --- /dev/null +++ b/test/data_bags/accounts/community.json @@ -0,0 +1,5 @@ +{ + "id": "community", + "uid": "527", + "comment": "Community" +} diff --git a/test/data_bags/community/passwords.json b/test/data_bags/community/passwords.json new file mode 100644 index 000000000..486dded9e --- /dev/null +++ b/test/data_bags/community/passwords.json @@ -0,0 +1,7 @@ +{ + "id": "passwords", + "database": "database", + "oauth2_client_id": "oauth2_client_id", + "oauth2_secret": "oauth2_secret", + "mail_receiver_api_key": "mail_receiver_api_key" +} diff --git a/test/integration/community/serverspec/docker_spec.rb b/test/integration/community/serverspec/docker_spec.rb new file mode 100644 index 000000000..de7c426d2 --- /dev/null +++ b/test/integration/community/serverspec/docker_spec.rb @@ -0,0 +1,13 @@ +require "serverspec" + +# Required by serverspec +set :backend, :exec + +describe package("docker-ce") do + it { should be_installed } +end + +describe service("docker") do + it { should be_enabled } + it { should be_running } +end diff --git a/test/integration/community/serverspec/http_spec.rb b/test/integration/community/serverspec/http_spec.rb new file mode 100644 index 000000000..3f445b0ab --- /dev/null +++ b/test/integration/community/serverspec/http_spec.rb @@ -0,0 +1,12 @@ +require "serverspec" + +# Required by serverspec +set :backend, :exec + +describe port(80) do + it { should be_listening.with("tcp") } +end + +describe port(443) do + it { should be_listening.with("tcp") } +end