From 202690082d4ddcecd9f75ef359602d2dafab90c4 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Wed, 19 Feb 2020 22:16:43 +0000 Subject: [PATCH] Add test for gps-tile cookbook --- .kitchen.yml | 3 +++ .travis.yml | 3 +++ cookbooks/gps-tile/attributes/default.rb | 1 + cookbooks/gps-tile/metadata.rb | 3 +++ cookbooks/gps-tile/recipes/default.rb | 5 ++++- roles/gps-tile.rb | 2 -- test/data_bags/accounts/gpstile.json | 6 ++++++ .../gps-tile/serverspec/apache_spec.rb | 21 +++++++++++++++++++ .../gps-tile/serverspec/gpsupdate_spec.rb | 9 ++++++++ 9 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 cookbooks/gps-tile/attributes/default.rb create mode 100644 test/data_bags/accounts/gpstile.json create mode 100644 test/integration/gps-tile/serverspec/apache_spec.rb create mode 100644 test/integration/gps-tile/serverspec/gpsupdate_spec.rb diff --git a/.kitchen.yml b/.kitchen.yml index e383bd272..be107759a 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -99,6 +99,9 @@ suites: - name: geoipupdate run_list: - recipe[geoipupdate::default] + - name: gps-tile + run_list: + - recipe[gps-tile::default] - name: incron run_list: - recipe[incron::default] diff --git a/.travis.yml b/.travis.yml index 25cf63dbf..9a00148e7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -57,6 +57,9 @@ jobs: - name: "Test Kitchen (geoipupdate)" script: - bundle exec kitchen test geoipupdate-ubuntu-1804 + - name: "Test Kitchen (gps-tile)" + script: + - bundle exec kitchen test gps-tile-ubuntu-1804 - name: "Test Kitchen (incron)" script: - bundle exec kitchen test incron-ubuntu-1804 diff --git a/cookbooks/gps-tile/attributes/default.rb b/cookbooks/gps-tile/attributes/default.rb new file mode 100644 index 000000000..61ab02a8b --- /dev/null +++ b/cookbooks/gps-tile/attributes/default.rb @@ -0,0 +1 @@ +default[:accounts][:users][:gpstile][:status] = :role diff --git a/cookbooks/gps-tile/metadata.rb b/cookbooks/gps-tile/metadata.rb index 78acecfa5..c23644f44 100644 --- a/cookbooks/gps-tile/metadata.rb +++ b/cookbooks/gps-tile/metadata.rb @@ -6,5 +6,8 @@ description "Configures a GPS tile server" version "1.0.0" supports "ubuntu" +depends "accounts" depends "apache" +depends "git" +depends "memcached" depends "systemd" diff --git a/cookbooks/gps-tile/recipes/default.rb b/cookbooks/gps-tile/recipes/default.rb index 5de9d5573..42b3f8a28 100644 --- a/cookbooks/gps-tile/recipes/default.rb +++ b/cookbooks/gps-tile/recipes/default.rb @@ -17,7 +17,10 @@ # limitations under the License. # +include_recipe "accounts" include_recipe "apache" +include_recipe "git" +include_recipe "memcached" package %w[ make @@ -48,7 +51,7 @@ end execute "/srv/gps-tile.openstreetmap.org/import/src/Makefile" do action :nothing - command "make" + command "make DB=none LDFLAGS=-lm" cwd "/srv/gps-tile.openstreetmap.org/import/src" user "gpstile" group "gpstile" diff --git a/roles/gps-tile.rb b/roles/gps-tile.rb index 285d461de..e6a0e5ec2 100644 --- a/roles/gps-tile.rb +++ b/roles/gps-tile.rb @@ -6,7 +6,6 @@ default_attributes( :users => { :enf => { :status => :administrator }, :gpstile => { - :status => :role, :members => [:enf, :tomh] } } @@ -25,6 +24,5 @@ default_attributes( ) run_list( - "recipe[memcached]", "recipe[gps-tile]" ) diff --git a/test/data_bags/accounts/gpstile.json b/test/data_bags/accounts/gpstile.json new file mode 100644 index 000000000..3a242c4ed --- /dev/null +++ b/test/data_bags/accounts/gpstile.json @@ -0,0 +1,6 @@ +{ + "id": "gpstile", + "uid": "519", + "comment": "gps-tile.openstreetmap.org", + "home": "/srv/gps-tile.openstreetmap.org" +} diff --git a/test/integration/gps-tile/serverspec/apache_spec.rb b/test/integration/gps-tile/serverspec/apache_spec.rb new file mode 100644 index 000000000..446d3b915 --- /dev/null +++ b/test/integration/gps-tile/serverspec/apache_spec.rb @@ -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/gps-tile/serverspec/gpsupdate_spec.rb b/test/integration/gps-tile/serverspec/gpsupdate_spec.rb new file mode 100644 index 000000000..bf6a3db6b --- /dev/null +++ b/test/integration/gps-tile/serverspec/gpsupdate_spec.rb @@ -0,0 +1,9 @@ +require "serverspec" + +# Required by serverspec +set :backend, :exec + +describe service("gps-update") do + it { should be_enabled } + it { should be_running } +end -- 2.43.2