]> git.openstreetmap.org Git - chef.git/commitdiff
Add test for tile cookbook
authorTom Hughes <tom@compton.nu>
Thu, 20 Feb 2020 21:47:45 +0000 (21:47 +0000)
committerTom Hughes <tom@compton.nu>
Thu, 20 Feb 2020 21:47:45 +0000 (21:47 +0000)
17 files changed:
.kitchen.yml
.travis.yml
cookbooks/tile/attributes/default.rb
cookbooks/tile/metadata.rb
cookbooks/tile/recipes/default.rb
cookbooks/tile/templates/default/apache.erb
cookbooks/tile/templates/default/replicate.erb
roles/bowser.rb
roles/odin.rb
roles/pyrene.rb
roles/rhaegal.rb
roles/scorch.rb
roles/tile.rb
roles/ysera.rb
test/data_bags/accounts/tile.json [new file with mode: 0644]
test/data_bags/tile/blocks.json [new file with mode: 0644]
test/integration/tile/serverspec/apache_spec.rb [new file with mode: 0644]

index e91b64040a30edbd3882ffe552a5f65b725b967c..a1a674889c4dde5ce3981d6720c917175a5cc434 100644 (file)
@@ -225,6 +225,9 @@ suites:
       taginfo:
         sites:
           - name: taginfo.example.com
+  - name: tile
+    run_list:
+      - recipe[tile::default]
   - name: tilecache
     run_list:
       - recipe[tilecache::default]
index d699655dd074984fb7b7cc293116c60e83dc26b6..eac9850a51fb41489c191821261b528a3f0fd501 100644 (file)
@@ -169,6 +169,9 @@ jobs:
     - name: "Test Kitchen (taginfo)"
       script:
         - bundle exec kitchen test taginfo-ubuntu-1804
+    - name: "Test Kitchen (tile)"
+      script:
+        - bundle exec kitchen test tile-ubuntu-1804
     - name: "Test Kitchen (tilecache)"
       script:
         - bundle exec kitchen test tilecache-ubuntu-1804
index 7ef34a9580b7f808f6059c2901e8ed15870923c1..ae89aa8d6b735ecdd53b503f1493be07c88a02b0 100644 (file)
@@ -1,2 +1,14 @@
+default[:tile][:database][:cluster] = "10/main"
+default[:tile][:database][:postgis] = "2.4"
+default[:tile][:database][:node_file] = "/store/database/nodes"
+default[:tile][:database][:multi_geometry] = true
+default[:tile][:database][:hstore] = true
+default[:tile][:database][:style_file] = nil
+default[:tile][:database][:tag_transform_script] = nil
+
 default[:tile][:data] = {}
 default[:tile][:styles] = {}
+
+default[:postgresql][:versions] |= ["10"]
+
+default[:accounts][:users][:tile][:status] = :role
index 716401065af07dee530f2e34f73fb70185b3b447..0c44f9c6ca11f29025e74b959bcf6c5514d5efdc 100644 (file)
@@ -6,6 +6,7 @@ description       "Installs and configures tile servers"
 
 version           "1.0.0"
 supports          "ubuntu"
+depends           "accounts"
 depends           "apache"
 depends           "git"
 depends           "munin"
index c1327d811bbd47adbd68818e70166002206ed03e..9aa99b9344c6f4bab8bc9e7e08982a5e634942cb 100644 (file)
@@ -17,6 +17,7 @@
 # limitations under the License.
 #
 
+include_recipe "accounts"
 include_recipe "apache"
 include_recipe "git"
 include_recipe "munin"
@@ -394,6 +395,7 @@ end
 postgresql_extension "hstore" do
   cluster node[:tile][:database][:cluster]
   database "gis"
+  only_if { node[:tile][:database][:hstore] }
 end
 
 %w[geography_columns planet_osm_nodes planet_osm_rels planet_osm_ways raster_columns raster_overviews spatial_ref_sys].each do |table|
@@ -419,7 +421,14 @@ postgresql_munin "gis" do
   database "gis"
 end
 
-file node[:tile][:node_file] do
+directory File.dirname(node[:tile][:database][:node_file]) do
+  owner "root"
+  group "root"
+  mode 0o755
+  recursive true
+end
+
+file node[:tile][:database][:node_file] do
   owner "tile"
   group "www-data"
   mode 0o660
index e5d7f17192bbca6ebb7b2987e40da32a038a254e..182b590e516d7c7883ad0c24306747f4ce2917c5 100644 (file)
@@ -12,8 +12,8 @@
   #
   SSLEngine on
   SSLProxyEngine on
-  SSLCertificateFile /etc/ssl/certs/<%= node.name %>.pem
-  SSLCertificateKeyFile /etc/ssl/private/<%= node.name %>.key
+  SSLCertificateFile /etc/ssl/certs/<%= node[:fqdn] %>.pem
+  SSLCertificateKeyFile /etc/ssl/private/<%= node[:fqdn] %>.key
 
   # Configure location of static files and CGI scripts
   DocumentRoot /srv/tile.openstreetmap.org/html
index 81fc66419e153fa5e4e7970bae7b816ff02c3553..83fec6fb7d123ff94965c7d0fec93b939bd4f2a9 100644 (file)
@@ -47,13 +47,20 @@ do
 
         # Apply the changes to the database
         osm2pgsql --database gis --slim --append --number-processes=1 \
-<% if node[:tile][:node_file] -%>
-                  --flat-nodes=<%= node[:tile][:node_file] %> \
+<% if node[:tile][:database][:node_file] -%>
+                  --flat-nodes=<%= node[:tile][:database][:node_file] %> \
 <% end -%>
-<% if node[:tile][:styles][:default][:revision] >= "v4.0.0" -%>
-                  --multi-geometry --hstore \
-                  --style=/srv/tile.openstreetmap.org/styles/default/openstreetmap-carto.style \
-                  --tag-transform-script=/srv/tile.openstreetmap.org/styles/default/openstreetmap-carto.lua \
+<% if node[:tile][:database][:multi_geometry] -%>
+                  --multi-geometry \
+<% end -%>
+<% if node[:tile][:database][:hstore] -%>
+                  --hstore \
+<% end -%>
+<% if node[:tile][:database][:style_file] -%>
+                  --style=<%= node[:tile][:database][:style_file] %> \
+<% end -%>
+<% if node[:tile][:database][:tag_transform_script] -%>
+                  --tag-transform-script=<%= node[:tile][:database][:tag_transform_script] %> \
 <% end -%>
                   ${file}
 
index c7cda250a24ef5c4d96d9879e119878a95bf7925..7334805ff997523e417590519b9752f0e5d17c6b 100644 (file)
@@ -41,7 +41,6 @@ default_attributes(
       :cluster => "10/main",
       :postgis => "2.4"
     },
-    :node_file => "/store/database/nodes",
     :styles => {
       :default => {
         :tile_directories => [
index 9b7975aafeb7d22da9decbf4f9981e8b732f5f2f..de22a363ce872af7f8bd001f33c5ffaa3e524be4 100644 (file)
@@ -51,7 +51,6 @@ default_attributes(
       :cluster => "10/main",
       :postgis => "2.4"
     },
-    :node_file => "/store/database/nodes",
     :styles => {
       :default => {
         :tile_directories => [
index 9164524f084f586f2e9c6b01efc20bcab4748585..f320526a89256b21aaf95ab7bcb069111c7f6d68 100644 (file)
@@ -50,7 +50,6 @@ default_attributes(
       :cluster => "10/main",
       :postgis => "2.4"
     },
-    :node_file => "/store/database/nodes",
     :styles => {
       :default => {
         :tile_directories => [
index ed44c294407c9b1d9cc62ee5055be220a89b01e5..6ff245d85a6e24b199177643e8c3356ff4caa935 100644 (file)
@@ -67,7 +67,6 @@ default_attributes(
       :cluster => "10/main",
       :postgis => "2.4"
     },
-    :node_file => "/store/database/nodes",
     :styles => {
       :default => {
         :tile_directories => [
index 82c6eb5732e174b1051de02bd81b60fdb0d543ea..a5c557474cd691a45e5e0b983643815b473d7d09 100644 (file)
@@ -64,7 +64,6 @@ default_attributes(
       :cluster => "10/main",
       :postgis => "2.4"
     },
-    :node_file => "/store/database/nodes",
     :styles => {
       :default => {
         :tile_directories => [
index 9061e2bce33067d0745c9a07520dd985d80566e6..8de66fff5b311501dbb06a1b8b57eb83758e7ee7 100644 (file)
@@ -5,7 +5,6 @@ default_attributes(
   :accounts => {
     :users => {
       :tile => {
-        :status => :role,
         :members => [:jburgess, :tomh]
       }
     }
@@ -67,6 +66,10 @@ default_attributes(
     }
   },
   :tile => {
+    :database => {
+      :style_file => "/srv/tile.openstreetmap.org/styles/default/openstreetmap-carto.style",
+      :tag_transform_script => "/srv/tile.openstreetmap.org/styles/default/openstreetmap-carto.lua"
+    },
     :data => {
       :simplified_land_polygons => {
         :url => "https://osmdata.openstreetmap.de/download/simplified-land-polygons-complete-3857.zip",
index 8bc9d14c0b427e6b059d7a447c2b275d29b64557..3e537b264b039f1685e8fd1a80ba3c85e3932a21 100644 (file)
@@ -42,7 +42,6 @@ default_attributes(
       :cluster => "10/main",
       :postgis => "2.4"
     },
-    :node_file => "/store/database/nodes",
     :styles => {
       :default => {
         :tile_directories => [
diff --git a/test/data_bags/accounts/tile.json b/test/data_bags/accounts/tile.json
new file mode 100644 (file)
index 0000000..435cb15
--- /dev/null
@@ -0,0 +1,6 @@
+{
+  "id": "tile",
+  "uid": "515",
+  "comment": "tile.openstreetmap.org",
+  "home": "/srv/tile.openstreetmap.org"
+}
diff --git a/test/data_bags/tile/blocks.json b/test/data_bags/tile/blocks.json
new file mode 100644 (file)
index 0000000..7088976
--- /dev/null
@@ -0,0 +1,9 @@
+{
+  "id": "blocks",
+  "user_agents": [
+    "dummy"
+  ],
+  "referers": [
+    "https://www.example.com/"
+  ]
+}
diff --git a/test/integration/tile/serverspec/apache_spec.rb b/test/integration/tile/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