]> git.openstreetmap.org Git - chef.git/commitdiff
Add tests for web cookbook
authorTom Hughes <tom@compton.nu>
Sun, 16 Feb 2020 15:37:45 +0000 (15:37 +0000)
committerTom Hughes <tom@compton.nu>
Sun, 16 Feb 2020 15:37:45 +0000 (15:37 +0000)
24 files changed:
.kitchen.yml
.travis.yml
cookbooks/apt/attributes/default.rb
cookbooks/web/attributes/default.rb
cookbooks/web/metadata.rb
cookbooks/web/recipes/base.rb
cookbooks/web/recipes/cgimap.rb
cookbooks/web/recipes/rails.rb
cookbooks/web/resources/rails_port.rb
cookbooks/web/templates/default/apache.frontend.erb
roles/base.rb
roles/web.rb
test/data_bags/accounts/rails.json [new file with mode: 0644]
test/data_bags/geoipupdate/license-keys.json [new file with mode: 0644]
test/data_bags/web/passwords.json [new file with mode: 0644]
test/data_bags/web/piwik.json [new file with mode: 0644]
test/integration/web-backend/serverspec/apache_spec.rb [new file with mode: 0644]
test/integration/web-backend/serverspec/cgimap_spec.rb [new file with mode: 0644]
test/integration/web-backend/serverspec/rails_spec.rb [new file with mode: 0644]
test/integration/web-cgimap/serverspec/cgimap_spec.rb [new file with mode: 0644]
test/integration/web-frontend/serverspec/apache_spec.rb [new file with mode: 0644]
test/integration/web-frontend/serverspec/rails_spec.rb [new file with mode: 0644]
test/integration/web-rails/serverspec/apache_spec.rb [new file with mode: 0644]
test/integration/web-rails/serverspec/rails_spec.rb [new file with mode: 0644]

index 4cff8942bb378e9c52857f32e46b579e7c3bec15..03549801fead7e57876ae64c6e0571cf2054e0f4 100644 (file)
@@ -175,3 +175,15 @@ suites:
   - name: tools
     run_list:
       - recipe[tools::default]
+  - name: web-backend
+    run_list:
+      - recipe[web::backend]
+  - name: web-cgimap
+    run_list:
+      - recipe[web::cgimap]
+  - name: web-frontend
+    run_list:
+      - recipe[web::frontend]
+  - name: web-rails
+    run_list:
+      - recipe[web::rails]
index 5057de2f086a044bc11331dfcea44e6ad31d6f9c..c822da4f03a0d192782b97721c0a466a1e0231af 100644 (file)
@@ -120,3 +120,15 @@ jobs:
     - name: "Test Kitchen (tools)"
       script:
         - bundle exec kitchen test tools-ubuntu-1804
+    - name: "Test Kitchen (web::backend)"
+      script:
+        - bundle exec kitchen test web-backend-ubuntu-1804
+    - name: "Test Kitchen (web::cgimap)"
+      script:
+        - bundle exec kitchen test web-cgimap-ubuntu-1804
+    - name: "Test Kitchen (web::frontend)"
+      script:
+        - bundle exec kitchen test web-frontend-ubuntu-1804
+    - name: "Test Kitchen (web::rails)"
+      script:
+        - bundle exec kitchen test web-rails-ubuntu-1804
index f75ed9e34abe5f4a77f1591ceea00011136f4b61..a949a1c0251300c0cac336057158cb5fffb76814 100644 (file)
@@ -1,4 +1,3 @@
-default_unless[:apt][:sources] = []
-
+default[:apt][:sources] = [ "openstreetmap" ]
 default[:apt][:unattended_upgrades][:enable] = true
 default[:apt][:unattended_upgrades][:remove_unused_dependencies] = true
index 79890cbdb18361c460376b9d5f95c726bfe1c5e2..7c995d9d818b65c54deb345986ce2a46cc8742a7 100644 (file)
@@ -1,4 +1,6 @@
 default[:web][:base_directory] = "/srv/www.openstreetmap.org"
-default[:web][:pid_directory] = "/var/run/web"
+default[:web][:pid_directory] = "/run/web"
 default[:web][:log_directory] = "/var/log/web"
 default[:web][:primary_cluster] = false
+
+default[:accounts][:users][:rails][:status] = :role
index 81096e2f19dd33360836748704e4c9fee558661b..89feed9a8996a4063cdb1129cab5593b761f39a2 100644 (file)
@@ -9,6 +9,7 @@ supports          "ubuntu"
 depends           "accounts"
 depends           "apache"
 depends           "apt"
+depends           "chef"
 depends           "geoipupdate"
 depends           "git"
 depends           "memcached"
index 00f77af6cae7525a4d5fa283ab2f07b22652f33a..450b35138a75b7cd77935b06efc4b26df7367ecd 100644 (file)
@@ -22,6 +22,7 @@ node.default[:nfs]["/store/rails"] = {
   :path => "/store/rails"
 }
 
+include_recipe "accounts"
 include_recipe "nfs"
 
 directory node[:web][:base_directory] do
index 22d6d02f0f21fb8af090311b85d6204c4861d8cb..ba9799c4c7685e91c6d253fd5da73f992d0c0409 100644 (file)
@@ -17,6 +17,7 @@
 # limitations under the License.
 #
 
+include_recipe "apt"
 include_recipe "tools"
 include_recipe "web::base"
 
index c007d8e5dea41fa3ebb16bf4c6ccf495a97224d1..79debaa69d1100fdb8c8a773f7dd74e30ef07859 100644 (file)
 # limitations under the License.
 #
 
-include_recipe "tools"
-include_recipe "web::base"
-
 include_recipe "apache"
-include_recipe "passenger"
-include_recipe "geoipupdate"
+include_recipe "apt"
 include_recipe "git"
+include_recipe "geoipupdate"
 include_recipe "munin"
 include_recipe "nodejs"
+include_recipe "passenger"
+include_recipe "tools"
+include_recipe "web::base"
 
 web_passwords = data_bag_item("web", "passwords")
 db_passwords = data_bag_item("db", "passwords")
index 200f3951463d9e1ba1c3c03ee13bb9bfd88c4385..3c8d9ae1e917798deea9cf8fa8ff25b06cdbc474 100644 (file)
@@ -79,6 +79,7 @@ action :create do
     imagemagick
     nodejs
     geoip-database
+    tzdata
   ]
 
   package %w[
index 4c283299b2f8cedc2b866834fa227b0aac595ffe..d77ca4159a6f5dc17ed7bf713186e0af50cfa312 100644 (file)
   #
   <Proxy balancer://backend>
     ProxySet lbmethod=bybusyness
-<% node[:web][:backends].each do |backend| -%>
+<% Array(node[:web][:backends]).each do |backend| -%>
     BalancerMember https://<%= backend %> disablereuse=on
 <% end -%>
   </Proxy>
index 771901def23c713d669054371a00453d296d5b22..f7a5332510478fd3a2625ebbbec22f801e3dc1cd 100644 (file)
@@ -10,9 +10,6 @@ default_attributes(
       :jburgess => { :status => :administrator }
     }
   },
-  :apt => {
-    :sources => ["openstreetmap"]
-  },
   :munin => {
     :plugins => {
       :chrony => {
index 3276e43e4dc8bd7fdfbec542a1057c0dc61eadd3..85e4e9821e2bbefb0804df91c17c0785bb1556ba 100644 (file)
@@ -5,7 +5,6 @@ default_attributes(
   :accounts => {
     :users => {
       :rails => {
-        :status => :role,
         :members => [:tomh, :grant]
       }
     }
diff --git a/test/data_bags/accounts/rails.json b/test/data_bags/accounts/rails.json
new file mode 100644 (file)
index 0000000..564acef
--- /dev/null
@@ -0,0 +1,6 @@
+{
+  "id": "rails",
+  "uid": "500",
+  "comment": "Rails",
+  "manage_home": false
+}
diff --git a/test/data_bags/geoipupdate/license-keys.json b/test/data_bags/geoipupdate/license-keys.json
new file mode 100644 (file)
index 0000000..a53c128
--- /dev/null
@@ -0,0 +1,4 @@
+{
+  "id": "license-keys",
+  "149244": "key"
+}
diff --git a/test/data_bags/web/passwords.json b/test/data_bags/web/passwords.json
new file mode 100644 (file)
index 0000000..ad20fa1
--- /dev/null
@@ -0,0 +1,17 @@
+{
+  "id": "passwords",
+  "secret_key_base": "base",
+  "potlatch2_key": "potlatch2",
+  "id_key": "id",
+  "oauth_key": "oauth",
+  "google_auth_secret": "google",
+  "facebook_auth_secret": "facebook",
+  "windowslive_auth_secret": "windowslive",
+  "github_auth_secret": "github",
+  "wikipedia_auth_secret": "wikipedia",
+  "mapquest_key": "mapquest",
+  "mapzen_valhalla_key": "mapzen-valhalla",
+  "thunderforest_key": "thunderforest",
+  "totp_key": "totp",
+  "aws_key": "aws"
+}
diff --git a/test/data_bags/web/piwik.json b/test/data_bags/web/piwik.json
new file mode 100644 (file)
index 0000000..f9b7374
--- /dev/null
@@ -0,0 +1,12 @@
+{
+  "id": "piwik",
+  "location": "piwik",
+  "site": 100,
+  "goals": {
+    "signup": 1001,
+    "mapnik": 1002,
+    "cyclemap": 1003,
+    "transportmap": 1004,
+    "mapquest": 1005
+  }
+}
diff --git a/test/integration/web-backend/serverspec/apache_spec.rb b/test/integration/web-backend/serverspec/apache_spec.rb
new file mode 100644 (file)
index 0000000..446d3b9
--- /dev/null
@@ -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
diff --git a/test/integration/web-backend/serverspec/cgimap_spec.rb b/test/integration/web-backend/serverspec/cgimap_spec.rb
new file mode 100644 (file)
index 0000000..d91e145
--- /dev/null
@@ -0,0 +1,13 @@
+require "serverspec"
+
+# Required by serverspec
+set :backend, :exec
+
+describe service("cgimap") do
+  it { should be_enabled }
+  it { should be_running }
+end
+
+describe port(8000) do
+  it { should be_listening.with("tcp") }
+end
diff --git a/test/integration/web-backend/serverspec/rails_spec.rb b/test/integration/web-backend/serverspec/rails_spec.rb
new file mode 100644 (file)
index 0000000..478549a
--- /dev/null
@@ -0,0 +1,14 @@
+require "serverspec"
+
+# Required by serverspec
+set :backend, :exec
+
+describe service("api-statistics") do
+  it { should be_enabled }
+  it { should be_running }
+end
+
+describe service("rails-jobs@storage") do
+  it { should be_enabled }
+  it { should be_running }
+end
diff --git a/test/integration/web-cgimap/serverspec/cgimap_spec.rb b/test/integration/web-cgimap/serverspec/cgimap_spec.rb
new file mode 100644 (file)
index 0000000..d91e145
--- /dev/null
@@ -0,0 +1,13 @@
+require "serverspec"
+
+# Required by serverspec
+set :backend, :exec
+
+describe service("cgimap") do
+  it { should be_enabled }
+  it { should be_running }
+end
+
+describe port(8000) do
+  it { should be_listening.with("tcp") }
+end
diff --git a/test/integration/web-frontend/serverspec/apache_spec.rb b/test/integration/web-frontend/serverspec/apache_spec.rb
new file mode 100644 (file)
index 0000000..446d3b9
--- /dev/null
@@ -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
diff --git a/test/integration/web-frontend/serverspec/rails_spec.rb b/test/integration/web-frontend/serverspec/rails_spec.rb
new file mode 100644 (file)
index 0000000..3c4c194
--- /dev/null
@@ -0,0 +1,14 @@
+require "serverspec"
+
+# Required by serverspec
+set :backend, :exec
+
+describe service("api-statistics") do
+  it { should be_enabled }
+  it { should be_running }
+end
+
+describe service("rails-jobs@mailers") do
+  it { should be_enabled }
+  it { should be_running }
+end
diff --git a/test/integration/web-rails/serverspec/apache_spec.rb b/test/integration/web-rails/serverspec/apache_spec.rb
new file mode 100644 (file)
index 0000000..446d3b9
--- /dev/null
@@ -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
diff --git a/test/integration/web-rails/serverspec/rails_spec.rb b/test/integration/web-rails/serverspec/rails_spec.rb
new file mode 100644 (file)
index 0000000..d02a658
--- /dev/null
@@ -0,0 +1,9 @@
+require "serverspec"
+
+# Required by serverspec
+set :backend, :exec
+
+describe service("api-statistics") do
+  it { should be_enabled }
+  it { should be_running }
+end