Skip to content

Commit

Permalink
Merge pull request #112 from myii/feat/add-debian-8_fix-issues_merge-…
Browse files Browse the repository at this point in the history
…test-suites

feat: merge test suites into single `default` suite
  • Loading branch information
myii authored Apr 27, 2020
2 parents 41edff6 + 50262c3 commit a3be59d
Show file tree
Hide file tree
Showing 35 changed files with 2,168 additions and 146 deletions.
5 changes: 4 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ AllCops:
- test/integration/**/serverspec/*

# Any offenses that should be fixed, e.g. collected via. `rubocop --auto-gen-config`
Lint/EmptyWhen:
Exclude:
- test/integration/default/controls/config_spec.rb
Style/FormatStringToken:
Exclude:
- test/integration/tomcat_install/controls/yaml_dump_spec.rb
- test/integration/default/controls/yaml_dump_spec.rb
73 changes: 36 additions & 37 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,43 +58,42 @@ jobs:
## Define the rest of the matrix based on Kitchen testing
# Make sure the instances listed below match up with
# the `platforms` defined in `kitchen.yml`
- env: INSTANCE=tomcat-install-debian-10-master-py3
- env: INSTANCE=tomcat-install-ubuntu-1804-master-py3
# - env: INSTANCE=tomcat-extend-ubuntu-1804-master-py3
# - env: INSTANCE=tomcat-install-centos-8-master-py3
- env: INSTANCE=tomcat-install-fedora-31-master-py3
- env: INSTANCE=tomcat-install-opensuse-leap-151-master-py3
# - env: INSTANCE=tomcat-install-amazonlinux-2-master-py3
# - env: INSTANCE=tomcat-install-arch-base-latest-master-py2
# - env: INSTANCE=tomcat-install-debian-10-3000-1-py3
# - env: INSTANCE=tomcat-install-ubuntu-1804-3000-1-py3
# - env: INSTANCE=tomcat-install-centos-8-3000-1-py3
# - env: INSTANCE=tomcat-install-fedora-31-3000-1-py3
# - env: INSTANCE=tomcat-install-opensuse-leap-151-3000-1-py3
- env: INSTANCE=tomcat-install-amazonlinux-2-3000-1-py3
# - env: INSTANCE=tomcat-install-arch-base-latest-3000-1-py2
# - env: INSTANCE=tomcat-install-debian-10-2019-2-py3
- env: INSTANCE=tomcat-install-debian-9-2019-2-py3
# - env: INSTANCE=tomcat-install-ubuntu-1804-2019-2-py3
# - env: INSTANCE=tomcat-install-ubuntu-1604-2019-2-py3
# - env: INSTANCE=tomcat-install-centos-8-2019-2-py3
- env: INSTANCE=tomcat-install-centos-7-2019-2-py3
# - env: INSTANCE=tomcat-install-fedora-31-2019-2-py3
# - env: INSTANCE=tomcat-install-opensuse-leap-151-2019-2-py3
# - env: INSTANCE=tomcat-install-amazonlinux-2-2019-2-py3
# - env: INSTANCE=tomcat-install-ubuntu-1804-2019-2-py2
# - env: INSTANCE=tomcat-install-amazonlinux-1-2019-2-py2
# - env: INSTANCE=tomcat-install-arch-base-latest-2019-2-py2
# - env: INSTANCE=tomcat-install-centos-7-2018-3-py3
# - env: INSTANCE=tomcat-install-fedora-30-2018-3-py3
# - env: INSTANCE=tomcat-install-debian-9-2018-3-py2
# - env: INSTANCE=tomcat-install-debian-8-2018-3-py2
# - env: INSTANCE=tomcat-install-ubuntu-1804-2018-3-py2
# - env: INSTANCE=tomcat-install-ubuntu-1604-2018-3-py2
# - env: INSTANCE=tomcat-install-centos-6-2018-3-py2
# - env: INSTANCE=tomcat-install-opensuse-leap-151-2018-3-py2
# - env: INSTANCE=tomcat-install-amazonlinux-1-2018-3-py2
# - env: INSTANCE=tomcat-install-arch-base-latest-2018-3-py2
- env: INSTANCE=default-debian-10-master-py3
- env: INSTANCE=default-ubuntu-1804-master-py3
# - env: INSTANCE=default-centos-8-master-py3
- env: INSTANCE=default-fedora-31-master-py3
- env: INSTANCE=default-opensuse-leap-151-master-py3
# - env: INSTANCE=default-amazonlinux-2-master-py3
# - env: INSTANCE=default-arch-base-latest-master-py2
# - env: INSTANCE=default-debian-10-3000-1-py3
# - env: INSTANCE=default-ubuntu-1804-3000-1-py3
# - env: INSTANCE=default-centos-8-3000-1-py3
# - env: INSTANCE=default-fedora-31-3000-1-py3
# - env: INSTANCE=default-opensuse-leap-151-3000-1-py3
- env: INSTANCE=default-amazonlinux-2-3000-1-py3
# - env: INSTANCE=default-arch-base-latest-3000-1-py2
# - env: INSTANCE=default-debian-10-2019-2-py3
- env: INSTANCE=default-debian-9-2019-2-py3
# - env: INSTANCE=default-ubuntu-1804-2019-2-py3
# - env: INSTANCE=default-ubuntu-1604-2019-2-py3
# - env: INSTANCE=default-centos-8-2019-2-py3
- env: INSTANCE=default-centos-7-2019-2-py3
# - env: INSTANCE=default-fedora-31-2019-2-py3
# - env: INSTANCE=default-opensuse-leap-151-2019-2-py3
# - env: INSTANCE=default-amazonlinux-2-2019-2-py3
# - env: INSTANCE=default-ubuntu-1804-2019-2-py2
# - env: INSTANCE=default-amazonlinux-1-2019-2-py2
# - env: INSTANCE=default-arch-base-latest-2019-2-py2
# - env: INSTANCE=default-centos-7-2018-3-py3
# - env: INSTANCE=default-fedora-30-2018-3-py3
# - env: INSTANCE=default-debian-9-2018-3-py2
- env: INSTANCE=default-debian-8-2018-3-py2
# - env: INSTANCE=default-ubuntu-1804-2018-3-py2
# - env: INSTANCE=default-ubuntu-1604-2018-3-py2
# - env: INSTANCE=default-centos-6-2018-3-py2
# - env: INSTANCE=default-opensuse-leap-151-2018-3-py2
# - env: INSTANCE=default-amazonlinux-1-2018-3-py2
# - env: INSTANCE=default-arch-base-latest-2018-3-py2

## Define the release stage that runs `semantic-release`
- stage: 'release'
Expand Down
4 changes: 2 additions & 2 deletions docs/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ Configures Tomcat name-based virtual hosts using data from Pillar.
``tomcat.expires``
^^^^^^^^^^^^^^^^^^

Configures Tomcat simple TCP cluster using data from Pillar.
Enables Tomcats' ExpiresFilter using data from Pillar.

``tomcat.cluster``
^^^^^^^^^^^^^^^^^^

Enables Tomcats' ExpiresFilter using data from Pillar.
Configures Tomcat simple TCP cluster using data from Pillar.

``tomcat.context``
^^^^^^^^^^^^^^^^^^
Expand Down
24 changes: 7 additions & 17 deletions kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -173,28 +173,15 @@ verifier:
- cli

suites:
- name: tomcat_install
- name: default
provisioner:
state_top:
base:
'*':
- tomcat.yaml_dump
- tomcat
pillars:
top.sls:
base:
'*':
- tomcat
pillars_from_files:
tomcat.sls: pillar.example
verifier:
inspec_tests:
- path: test/integration/tomcat_install
- name: tomcat_extend
provisioner:
state_top:
base:
'*':
- tomcat.native
- tomcat.config
- tomcat.manager
- tomcat.vhosts
- tomcat.expires
Expand All @@ -207,6 +194,9 @@ suites:
- tomcat
pillars_from_files:
tomcat.sls: pillar.example
dependencies:
- name: comparison_files
path: ./test/salt
verifier:
inspec_tests:
- path: test/integration/tomcat_extend
- path: test/integration/default
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# InSpec Profile: `tomcat_extend`
# InSpec Profile: `default`

This shows the implementation of the `tomcat_extend` InSpec [profile](https://github.com/inspec/inspec/blob/master/docs/profiles.md).
This shows the implementation of the `default` InSpec [profile](https://github.com/inspec/inspec/blob/master/docs/profiles.md).

## Verify a profile

InSpec ships with built-in features to verify a profile structure.

```bash
$ inspec check tomcat_extend
$ inspec check default
Summary
-------
Location: tomcat_extend
Location: default
Profile: profile
Controls: 4
Timestamp: 2019-06-24T23:09:01+00:00
Expand All @@ -28,7 +28,7 @@ Warnings
To run all **supported** controls on a local machine use `inspec exec /path/to/profile`.

```bash
$ inspec exec tomcat_extend
$ inspec exec default
..

Finished in 0.0025 seconds (files took 0.12449 seconds to load)
Expand All @@ -40,7 +40,7 @@ Finished in 0.0025 seconds (files took 0.12449 seconds to load)
To run one control from the profile use `inspec exec /path/to/profile --controls name`.

```bash
$ inspec exec tomcat_extend --controls package
$ inspec exec default --controls package
.

Finished in 0.0025 seconds (files took 0.12449 seconds to load)
Expand Down
113 changes: 113 additions & 0 deletions test/integration/default/controls/config_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# frozen_string_literal: true

# Prepare platform "finger" and base path to file comparison directory
platform_finger = "#{platform[:name]}-#{platform[:release].split('.')[0]}"
comparison_files_dir = '/tmp/kitchen/srv/salt/comparison_files'

# Default values for `control 'Tomcat main config'`
main_config_file = '/etc/sysconfig/tomcat'
# Default values for `control 'Tomcat Catalina temp dir'`
catalina_tmpdir = '/var/cache/tomcat/temp'
catalina_tmpdir_user_and_group = 'tomcat'
# Default values for `control 'Tomcat `server.xml` config'`
conf_dir = '/etc/tomcat'
server_xml_user_and_group = 'tomcat'

# Override by platform
case platform[:family]
when 'debian'
main_config_file = '/etc/default/tomcat8'
catalina_tmpdir = '/var/cache/tomcat8/temp'
catalina_tmpdir_user_and_group = 'tomcat8'
conf_dir = '/etc/tomcat8'
server_xml_user_and_group = 'tomcat8'
case platform_finger
when 'debian-10'
main_config_file = '/etc/default/tomcat9'
catalina_tmpdir = '/var/cache/tomcat9/temp'
catalina_tmpdir_user_and_group = 'tomcat'
conf_dir = '/etc/tomcat9'
server_xml_user_and_group = 'tomcat'
when 'debian-9'
when 'debian-8'
main_config_file = '/etc/default/tomcat7'
catalina_tmpdir = '/var/cache/tomcat7/temp'
catalina_tmpdir_user_and_group = 'tomcat7'
conf_dir = '/etc/tomcat7'
server_xml_user_and_group = 'tomcat7'
when 'ubuntu-18'
when 'ubuntu-16'
end
when 'redhat'
case platform_finger
when 'centos-8'
when 'centos-7'
when 'centos-6'
when 'amazon-2'
when 'amazon-2018'
end
when 'fedora'
case platform_finger
when 'fedora-31'
when 'fedora-30'
end
when 'suse'
case platform_finger
when 'opensuse-15'
server_xml_user_and_group = 'root'
end
when 'linux'
case platform_finger
when 'arch-5'
end
end

control 'Tomcat main config' do
title 'should contain the lines'

# Prepare comparison file
main_config_path = "#{comparison_files_dir}/main_config/#{platform_finger}"
main_config = file(main_config_path).content

describe file(main_config_file) do
it { should be_file }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
its('mode') { should cmp '0644' }
its('content') { should include main_config }
end
end

control 'Tomcat Catalina temp dir' do
title 'should be prepared with the settings'

describe file(catalina_tmpdir) do
it { should be_directory }
it { should be_owned_by catalina_tmpdir_user_and_group }
it { should be_grouped_into catalina_tmpdir_user_and_group }
its('mode') { should cmp '0755' }
end
end

control 'Tomcat `server.xml` config' do
title 'should contain the lines'

server_xml_file = "#{conf_dir}/server.xml"
server_xml_path = "#{comparison_files_dir}/server_xml/#{platform_finger}.xml"
server_xml = file(server_xml_path).content
# Need the hostname to be used for `tomcat.cluster`
server_xml = server_xml.gsub(
'HOSTNAME_PLACEHOLDER',
file('/etc/hostname').content.chomp
)

describe file(server_xml_file) do
it { should be_file }
it { should be_owned_by server_xml_user_and_group }
it { should be_grouped_into server_xml_user_and_group }
its('mode') { should cmp '0644' }
unless %w[debian-9].include?(platform_finger)
its('content') { should include server_xml }
end
end
end
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
# frozen_string_literal: true

# Prepare platform "finger"
platform_finger = "#{platform[:name]}-#{platform[:release].split('.')[0]}"

control 'Tomcat packages' do
title 'should be installed'

# Overide by platform
packages =
case platform[:family]
when 'debian'
case platform[:release]
when /^10/
case platform_finger
when 'debian-10'
%w[tomcat9 haveged]
else
when 'debian-9', 'ubuntu-18', 'ubuntu-16'
%w[tomcat8 haveged]
when 'debian-8'
%w[tomcat7 haveged]
end
when 'redhat', 'fedora', 'suse'
%w[tomcat]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# frozen_string_literal: true

# Prepare platform "finger"
platform_finger = "#{platform[:name]}-#{platform[:release].split('.')[0]}"

control 'Tomcat services' do
impact 0.5
title 'should be installed, enabled and running'
Expand All @@ -8,11 +11,13 @@
services =
case platform[:family]
when 'debian'
case platform[:release]
when /^10/
case platform_finger
when 'debian-10'
%w[tomcat9 haveged]
else
when 'debian-9', 'ubuntu-18', 'ubuntu-16'
%w[tomcat8 haveged]
when 'debian-8'
%w[tomcat7 haveged]
end
when 'redhat', 'fedora', 'suse'
%w[tomcat]
Expand Down
Loading

0 comments on commit a3be59d

Please sign in to comment.