]> git.openstreetmap.org Git - chef.git/commitdiff
vectortile: Run tilekiln prometheus endpoint
authorPaul Norman <penorman@mac.com>
Tue, 3 Dec 2024 08:43:07 +0000 (00:43 -0800)
committerPaul Norman <penorman@mac.com>
Tue, 3 Dec 2024 08:43:07 +0000 (00:43 -0800)
cookbooks/vectortile/recipes/default.rb
test/integration/vectortile/inspec/prometheus_spec.rb [new file with mode: 0644]
test/integration/vectortile/inspec/tilekiln_spec.rb

index 99211975ead7a5d4de1fb7dae9db2a5b90a74b77..1015b38e2b9bd97fe753efb30434dde871352f16 100644 (file)
@@ -99,7 +99,7 @@ end
 python_package "tilekiln" do
   python_virtualenv tilekiln_directory
   python_version "3"
 python_package "tilekiln" do
   python_virtualenv tilekiln_directory
   python_version "3"
-  version "0.6.3"
+  version "0.6.5"
 end
 
 template "/srv/vector.openstreetmap.org/html/index.html" do
 end
 
 template "/srv/vector.openstreetmap.org/html/index.html" do
@@ -189,6 +189,13 @@ end
   end
 end
 
   end
 end
 
+postgresql_table "tile_stats" do
+  cluster node[:vectortile][:database][:cluster]
+  database "tiles"
+  schema "tilekiln"
+  owner "tilekiln"
+end
+
 (0..14).each do |zoom|
   postgresql_table "shortbread_v1_z#{zoom}" do
     cluster node[:vectortile][:database][:cluster]
 (0..14).each do |zoom|
   postgresql_table "shortbread_v1_z#{zoom}" do
     cluster node[:vectortile][:database][:cluster]
@@ -294,3 +301,22 @@ prometheus_exporter "osm2pgsql" do
     "--database-name=spirit"
   ]
 end
     "--database-name=spirit"
   ]
 end
+
+systemd_service "tilekiln-prometheus" do
+  description "Tilekiln vector tile server"
+  user "tilekiln"
+  after "postgresql.service"
+  wants "postgresql.service"
+  sandbox :enable_network => true
+  restrict_address_families "AF_UNIX"
+  exec_start "#{tilekiln_directory}/bin/tilekiln prometheus --bind-host #{node[:prometheus][:address]} --storage-dbname tiles"
+end
+
+service "tilekiln-prometheus" do
+  action [:enable, :start]
+end
+
+node.default[:prometheus][:exporters][10013] = {
+  :name => "tilekiln",
+  :address => "#{node[:prometheus][:address]}:10013",
+}
diff --git a/test/integration/vectortile/inspec/prometheus_spec.rb b/test/integration/vectortile/inspec/prometheus_spec.rb
new file mode 100644 (file)
index 0000000..cb41b1b
--- /dev/null
@@ -0,0 +1,8 @@
+describe service("tilekiln-prometheus") do
+  it { should be_enabled }
+  it { should be_running }
+end
+
+describe port(10013) do
+  it { should be_listening }
+end
index d44562d4c667536558dd0d7878934c3964840c7b..5face190472c2449d94d6ed8a4e01409b130afb4 100644 (file)
@@ -21,14 +21,10 @@ describe http("https://localhost/shortbread_v1/tilejson.json", :ssl_verify => fa
   its("status") { should cmp 200 }
 end
 
   its("status") { should cmp 200 }
 end
 
-describe json(:content => http("https://localhost/shortbread_v1/tilejson.json", :ssl_verify => false)) do
+describe json(:content => http("https://localhost/shortbread_v1/tilejson.json", :ssl_verify => false).body) do
   its(["tiles"]) { should eq(["https://vector.openstreetmap.org/shortbread_v1/{z}/{x}/{y}.mvt"]) }
 end
 
   its(["tiles"]) { should eq(["https://vector.openstreetmap.org/shortbread_v1/{z}/{x}/{y}.mvt"]) }
 end
 
-# There are no tiles so everything should return a 404
-describe http("https://localhost/shortbread_v1/0/0/0.mvt", :ssl_verify => false) do
-  its("status") { should cmp 404 }
-end
 describe http("https://localhost/shortbread_v1/16/0/0.mvt", :ssl_verify => false) do
 describe http("https://localhost/shortbread_v1/16/0/0.mvt", :ssl_verify => false) do
-  its("status") { should cmp 404 }
+  its("status") { should cmp 410 }
 end
 end