Skip to content

Commit

Permalink
Merge pull request #195 from jjm/bug/jjm/expand-testing
Browse files Browse the repository at this point in the history
Expand and correct suite failures so all supported OSes are covered + split suites between Vagrant and Dokken
  • Loading branch information
haidangwa authored Oct 30, 2020
2 parents 21e4fa3 + 1cbbfdb commit 6866e53
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 34 deletions.
58 changes: 42 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
name: ci

on:
Expand Down Expand Up @@ -26,28 +25,21 @@ jobs:
- name: Run yaml Lint
uses: actionshub/yamllint@master

# Vagrant tests are very slow and often time out, so only check those suites that
# don't run as root across latest centos, debian and ubuntu.
vagrant:
needs: [yamllint, delivery]
runs-on: macos-latest
strategy:
matrix:
os:
- 'debian-10'
- 'centos-8'
- 'debian-10'
- 'ubuntu-2004'
suite:
- 'client'
- 'uninstall-forwarder'
- 'client-inputs-outputs'
- 'client-runas-splunk'
- 'server-runas-splunk'
# Run the server in Vagrant too, as it splunk often does not keep running in Dokken.
- 'server-runas-root'
- 'server-cluster-master'
- 'server-shdeployer'
- 'server-shcluster-member'
- 'disabled'
- 'upgrade-server'
- 'upgrade-client'
- 'server-resources'
- 'client-resources'
fail-fast: false

steps:
Expand All @@ -64,9 +56,43 @@ jobs:
suite: ${{ matrix.suite }}
os: ${{ matrix.os }}

final:
needs: [vagrant]
# Run most tests in dokken as it's quicker than Vagrant
dokken:
runs-on: ubuntu-latest
strategy:
matrix:
os:
- 'centos-7'
- 'centos-8'
- 'debian-10'
- 'debian-9'
- 'ubuntu-1604'
- 'ubuntu-1804'
- 'ubuntu-2004'
suite:
- 'client'
- 'client-inputs-outputs'
- 'client-resources'
- 'disabled'
- 'server-cluster-master'
- 'server-resources'
- 'server-shcluster-member'
- 'server-shdeployer'
- 'uninstall-forwarder'
- 'upgrade-client'
- 'upgrade-server'
fail-fast: false

steps:
- name: Check out code
uses: actions/checkout@master
- name: Install Chef
uses: actionshub/chef-install@master
- name: Test Kitchen
uses: actionshub/test-kitchen@master
env:
CHEF_LICENSE: accept-no-persist
KITCHEN_LOCAL_YAML: test/kitchen/kitchen.dokken.yml
with:
suite: ${{ matrix.suite }}
os: ${{ matrix.os }}
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

This file is used to list changes made in each version of the splunk cookbook.

## 7.0.1 (unreleased)
- Moves most tests back to dokken and only run suites that change splunk user from root in vagrant.

## 7.0.0 (2020-10-22)
**BREAKING CHANGE**
- sets umask when executing the `execute[splunk enable boot-start]` resource
Expand Down
13 changes: 9 additions & 4 deletions kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ suites:
inspec_tests:
- path: test/integration/inspec/client_test.rb

- name: uninstall_forwarder
- name: uninstall-forwarder
run_list:
- recipe[test::uninstall_forwarder]
attributes:
Expand Down Expand Up @@ -84,6 +84,9 @@ suites:
source: tcp:123123

- name: server-runas-root
lifecycle:
post_converge:
- local: sleep 120
run_list:
- recipe[test::file_locking_check]
- recipe[chef-splunk::default]
Expand All @@ -97,6 +100,9 @@ suites:
- path: test/integration/inspec/server_test.rb

- name: server-runas-splunk
lifecycle:
post_converge:
- local: sleep 120
run_list:
- recipe[chef-splunk::default]
attributes:
Expand Down Expand Up @@ -161,7 +167,6 @@ suites:
- recipe[test::file_locking_check]
- recipe[chef-splunk::default]
- recipe[chef-splunk::disabled]
attributes:
attributes:
splunk:
is_server: true
Expand All @@ -172,7 +177,7 @@ suites:
inspec_tests:
- path: test/integration/inspec/disabled_test.rb

- name: upgrade_server
- name: upgrade-server
run_list:
- recipe[test::file_locking_check]
- recipe[test::upgrade]
Expand All @@ -187,7 +192,7 @@ suites:
inspec_tests:
- path: test/integration/inspec/upgrade_test.rb

- name: upgrade_client
- name: upgrade-client
run_list:
- recipe[test::file_locking_check]
- recipe[test::upgrade]
Expand Down
2 changes: 1 addition & 1 deletion metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
maintainer_email '[email protected]'
license 'Apache-2.0'
description 'Manage Splunk Enterprise or Splunk Universal Forwarder'
version '7.0.0'
version '7.0.1'

supports 'debian', '>= 8.9'
supports 'ubuntu', '>= 16.04'
Expand Down
21 changes: 15 additions & 6 deletions test/integration/inspec/server_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@
end

describe.one do
describe processes(/splunkd.*-p 8089 _internal_launch_under_systemd/) do
describe processes(Regexp.new('splunkd.*-p 8089 _internal_launch_under_systemd')) do
its('users') { should include 'splunk' }
its('users') { should_not include 'root' }
it { should exist }
end
describe processes(/splunkd.*-p 8089 _internal_launch_under_systemd/) do
describe processes(Regexp.new('splunkd.*-p 8089 _internal_launch_under_systemd')) do
its('users') { should include 'root' }
it { should exist }
end
Expand Down Expand Up @@ -79,9 +79,18 @@
it { should exist }
end

# the password used for validation here is from the test/fixture/data_bags/vault/splunk__default.rb
describe command("#{SPLUNK_HOME}/bin/splunk login -auth admin:notarealpassword") do
its('stderr') { should be_empty }
its('exit_status') { should eq 0 }
describe.one do
# the password used for validation here is from the test/fixture/data_bags/vault/splunk__default.rb
describe command("#{SPLUNK_HOME}/bin/splunk login -auth admin:notarealpassword") do
its('stderr') { should be_empty }
its('exit_status') { should eq 0 }
end

# When running as a service user, need to check logging into splunk as the service user or
# you get a permission denied when writing the token to ~/.splunk/.
describe command("sudo -u splunk #{SPLUNK_HOME}/bin/splunk login -auth admin:notarealpassword") do
its('stderr') { should be_empty }
its('exit_status') { should eq 0 }
end
end
end
32 changes: 25 additions & 7 deletions test/kitchen/kitchen.dokken.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,18 @@ provisioner:
transport:
name: dokken

# splunkd takes a little time to be fully ready for Inspec
# so we force a wait after converging the node
lifecycle:
post_converge:
- local: sleep 300

platforms:
- name: debian-10
driver:
image: dokken/debian-10
pid_one_command: /sbin/init
pid_one_command: /bin/systemd
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro # required by systemd

- name: debian-9
driver:
image: dokken/debian-9
pid_one_command: /bin/systemd
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro # required by systemd

Expand All @@ -34,7 +35,24 @@ platforms:
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro # required by systemd

- name: centos-7
driver:
image: dokken/centos-7
pid_one_command: /usr/lib/systemd/systemd
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro # required by systemd

- name: ubuntu-20.04
driver:
image: dokken/ubuntu-20.04
pid_one_command: /bin/systemd

- name: ubuntu-18.04
driver:
image: dokken/ubuntu-18.04
pid_one_command: /bin/systemd

- name: ubuntu-16.04
driver:
image: dokken/ubuntu-16.04
pid_one_command: /bin/systemd
20 changes: 20 additions & 0 deletions test/kitchen/kitchen.vagrant.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,32 @@ platforms:
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro # required by systemd

- name: debian-9
driver:
pid_one_command: /sbin/init
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro # required by systemd

- name: centos-8
driver:
pid_one_command: /usr/lib/systemd/systemd
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro # required by systemd

- name: centos-7
driver:
pid_one_command: /usr/lib/systemd/systemd
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro # required by systemd

- name: ubuntu-20.04
driver:
pid_one_command: /bin/systemd

- name: ubuntu-18.04
driver:
pid_one_command: /bin/systemd

- name: ubuntu-16.04
driver:
pid_one_command: /bin/systemd

0 comments on commit 6866e53

Please sign in to comment.