From: Tom Hughes Date: Wed, 19 Feb 2020 22:52:54 +0000 (+0000) Subject: Add test for osqa cookbook X-Git-Url: https://git.openstreetmap.org/chef.git/commitdiff_plain/24c634aea798f7064635cf001cac0430bbc50b33?ds=sidebyside Add test for osqa cookbook --- diff --git a/.kitchen.yml b/.kitchen.yml index be107759a..ec4e81755 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -148,6 +148,9 @@ suites: - name: osmosis run_list: - recipe[osmosis::default] + - name: osqa + run_list: + - recipe[osqa::default] - name: otrs run_list: - recipe[otrs::default] diff --git a/.travis.yml b/.travis.yml index 9a00148e7..e5f5b0b23 100644 --- a/.travis.yml +++ b/.travis.yml @@ -102,6 +102,13 @@ jobs: - name: "Test Kitchen (osmosis)" script: - bundle exec kitchen test osmosis-ubuntu-1804 + - name: "Test Kitchen (osqa)" + script: + - bundle exec kitchen test osqa-ubuntu-1804 + attributes: + osqa: + sites: + - name: help.example.com - name: "Test Kitchen (otrs)" script: - bundle exec kitchen test otrs-ubuntu-1804 diff --git a/cookbooks/osqa/attributes/default.rb b/cookbooks/osqa/attributes/default.rb index 610f68605..cc3243ffc 100644 --- a/cookbooks/osqa/attributes/default.rb +++ b/cookbooks/osqa/attributes/default.rb @@ -4,3 +4,5 @@ default[:osqa][:database_name] = "osqa" default[:osqa][:database_user] = "osqa" default[:osqa][:database_password] = "" default[:osqa][:sites] = [] + +default[:accounts][:users][:osqa][:status] = :role diff --git a/cookbooks/osqa/metadata.rb b/cookbooks/osqa/metadata.rb index 02f870410..932a04697 100644 --- a/cookbooks/osqa/metadata.rb +++ b/cookbooks/osqa/metadata.rb @@ -6,6 +6,7 @@ description "Installs and configures OSQA" version "1.0.0" supports "ubuntu" +depends "accounts" depends "apache" depends "memcached" depends "python" diff --git a/cookbooks/osqa/recipes/default.rb b/cookbooks/osqa/recipes/default.rb index 6e8d00d4a..a1fb95a44 100644 --- a/cookbooks/osqa/recipes/default.rb +++ b/cookbooks/osqa/recipes/default.rb @@ -17,10 +17,11 @@ # limitations under the License. # -include_recipe "tools" +include_recipe "accounts" include_recipe "apache" include_recipe "memcached" include_recipe "python" +include_recipe "tools" package "python-dev" package "libmysqlclient-dev" diff --git a/roles/osqa.rb b/roles/osqa.rb index da7036fe0..45a4cf04c 100644 --- a/roles/osqa.rb +++ b/roles/osqa.rb @@ -2,11 +2,6 @@ name "osqa" description "Role applied to all OSQA servers" default_attributes( - :accounts => { - :users => { - :osqa => { :status => :role } - } - }, :osqa => { :sites => [ { :name => "help.openstreetmap.org", diff --git a/test/data_bags/accounts/osqa.json b/test/data_bags/accounts/osqa.json new file mode 100644 index 000000000..22361d0c6 --- /dev/null +++ b/test/data_bags/accounts/osqa.json @@ -0,0 +1,6 @@ +{ + "id": "osqa", + "uid": "510", + "comment": "osqa.openstreetmap.org", + "home": "/srv/help.openstreetmap.org" +} diff --git a/test/integration/osqa/serverspec/apache_spec.rb b/test/integration/osqa/serverspec/apache_spec.rb new file mode 100644 index 000000000..446d3b915 --- /dev/null +++ b/test/integration/osqa/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