From: Tom Hughes Date: Wed, 26 Oct 2016 22:13:10 +0000 (+0100) Subject: Add basic tests for apache cookbook X-Git-Url: https://git.openstreetmap.org/chef.git/commitdiff_plain/36c8de71e95be32e9748b0670b33080866216dad?ds=sidebyside Add basic tests for apache cookbook --- diff --git a/.kitchen.yml b/.kitchen.yml index e2667127e..12ffa4914 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -7,11 +7,18 @@ driver: provisioner: name: chef_zero + data_bags_path: test/data_bags platforms: - name: ubuntu-16.04 suites: + - name: apache + run_list: + - recipe[apache::default] + - name: apache-ssl + run_list: + - recipe[apache::ssl] - name: apt run_list: - recipe[apt::default] diff --git a/cookbooks/apache/metadata.rb b/cookbooks/apache/metadata.rb index 24c69d703..635f9cfca 100644 --- a/cookbooks/apache/metadata.rb +++ b/cookbooks/apache/metadata.rb @@ -5,4 +5,5 @@ license "Apache 2.0" description "Installs and configures apache" long_description IO.read(File.join(File.dirname(__FILE__), "README.md")) version "1.0.0" +depends "munin" depends "ssl" diff --git a/test/data_bags/apache/admins.json b/test/data_bags/apache/admins.json new file mode 100644 index 000000000..20853a929 --- /dev/null +++ b/test/data_bags/apache/admins.json @@ -0,0 +1,6 @@ +{ + "id": "admins", + "hosts": [ + "192.168.1.1" + ] +} diff --git a/test/data_bags/ssl/keys.json b/test/data_bags/ssl/keys.json new file mode 100644 index 000000000..fdc5266d9 --- /dev/null +++ b/test/data_bags/ssl/keys.json @@ -0,0 +1,18 @@ +{ + "id": "keys", + "openstreetmap": [ + "-----BEGIN RSA PRIVATE KEY-----", + "dummy", + "-----END RSA PRIVATE KEY-----" + ], + "tile.openstreetmap": [ + "-----BEGIN RSA PRIVATE KEY-----", + "dummy", + "-----END RSA PRIVATE KEY-----" + ], + "osmfoundation": [ + "-----BEGIN PRIVATE KEY-----", + "dummy", + "-----END PRIVATE KEY-----" + ] +} diff --git a/test/integration/apache-ssl/serverspec/apache_spec.rb b/test/integration/apache-ssl/serverspec/apache_spec.rb new file mode 100644 index 000000000..9d5268271 --- /dev/null +++ b/test/integration/apache-ssl/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 } +end + +describe port(443) do + it { should be_listening } +end diff --git a/test/integration/apache/serverspec/apache_spec.rb b/test/integration/apache/serverspec/apache_spec.rb new file mode 100644 index 000000000..57b0b7d86 --- /dev/null +++ b/test/integration/apache/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 } +end + +describe port(443) do + it { should_not be_listening } +end