From fca44ca0420b1f3048c2944900cfdef3b34e2509 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Tue, 18 Feb 2020 19:10:10 +0000 Subject: [PATCH] Add test for piwik cookbook --- .kitchen.yml | 6 ++++++ .travis.yml | 3 +++ cookbooks/piwik/recipes/default.rb | 19 ++++++++++------- test/data_bags/piwik/passwords.json | 5 +++++ .../piwik/serverspec/apache_spec.rb | 21 +++++++++++++++++++ 5 files changed, 46 insertions(+), 8 deletions(-) create mode 100644 test/data_bags/piwik/passwords.json create mode 100644 test/integration/piwik/serverspec/apache_spec.rb diff --git a/.kitchen.yml b/.kitchen.yml index b21df580b..1fcc3f7d6 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -148,6 +148,12 @@ suites: - name: passenger run_list: - recipe[passenger::default] + - name: piwik + run_list: + - recipe[piwik::default] + attributes: + apache: + mpm: prefork - name: planet run_list: - recipe[planet::default] diff --git a/.travis.yml b/.travis.yml index 9b55eaa34..8f02cbd48 100644 --- a/.travis.yml +++ b/.travis.yml @@ -99,6 +99,9 @@ jobs: - name: "Test Kitchen (passenger)" script: - bundle exec kitchen test passenger-ubuntu-1804 + - name: "Test Kitchen (piwik)" + script: + - bundle exec kitchen test piwik-ubuntu-1804 - name: "Test Kitchen (planet)" script: - bundle exec kitchen test planet-ubuntu-1804 diff --git a/cookbooks/piwik/recipes/default.rb b/cookbooks/piwik/recipes/default.rb index a6b2bf3a7..5317c3596 100644 --- a/cookbooks/piwik/recipes/default.rb +++ b/cookbooks/piwik/recipes/default.rb @@ -23,14 +23,17 @@ include_recipe "mysql" passwords = data_bag_item("piwik", "passwords") -package "php" -package "php-cli" -package "php-curl" -package "php-mbstring" -package "php-mysql" -package "php-gd" -package "php-xml" -package "php-apcu" +package %w[ + php + php-cli + php-curl + php-mbstring + php-mysql + php-gd + php-xml + php-apcu + unzip +] apache_module "expires" apache_module "php7.2" diff --git a/test/data_bags/piwik/passwords.json b/test/data_bags/piwik/passwords.json new file mode 100644 index 000000000..396b28119 --- /dev/null +++ b/test/data_bags/piwik/passwords.json @@ -0,0 +1,5 @@ +{ + "id": "passwords", + "database": "database-password", + "salt": "salt" +} diff --git a/test/integration/piwik/serverspec/apache_spec.rb b/test/integration/piwik/serverspec/apache_spec.rb new file mode 100644 index 000000000..446d3b915 --- /dev/null +++ b/test/integration/piwik/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 -- 2.43.2