]> git.openstreetmap.org Git - chef.git/commitdiff
Add a test for the community cookbook
authorTom Hughes <tom@compton.nu>
Thu, 14 Jul 2022 13:40:19 +0000 (13:40 +0000)
committerTom Hughes <tom@compton.nu>
Thu, 14 Jul 2022 13:40:19 +0000 (13:40 +0000)
.github/workflows/test-kitchen.yml
.kitchen.yml
cookbooks/community/metadata.rb
cookbooks/community/recipes/default.rb
cookbooks/community/templates/default/web_only.yml.erb
test/data_bags/accounts/community.json [new file with mode: 0644]
test/data_bags/community/passwords.json [new file with mode: 0644]
test/integration/community/serverspec/docker_spec.rb [new file with mode: 0644]
test/integration/community/serverspec/http_spec.rb [new file with mode: 0644]

index cde43686df462b8ff262499b665d5ed49b135000..5072dbe24c7bf64e427c76c34868160c7bc16d30 100644 (file)
@@ -24,6 +24,7 @@ jobs:
           - blogs
           - civicrm
           - clamav
+          - community
           - db-backup
           - db-base
           - db-master
index 933dbdfc07081ffacc1ea0f968abe932136de3b9..6dc0dad227c6a323a2841716223961a127021ea5 100644 (file)
@@ -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]
index c0aba99348057401eeb85087e4999a56b767180c..4d159c4ad600ded182bd7a24074758c09b343cd8 100644 (file)
@@ -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"
index 2297fa76cb52152dd57a3affdf99629a4a79913d..89743de31c0fb7a7de419922633b6bd61b2ed693 100644 (file)
 # 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"
index 42e734e5dd8536cb71b18d4ee7f0b9e787b27cb8..92579138d4275f384bbc33bde4c6629e81f31ba9 100644 (file)
@@ -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 (file)
index 0000000..b4b5fd3
--- /dev/null
@@ -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 (file)
index 0000000..486dded
--- /dev/null
@@ -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 (file)
index 0000000..de7c426
--- /dev/null
@@ -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 (file)
index 0000000..3f445b0
--- /dev/null
@@ -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