ansible-role-sensu/test/integration/default/serverspec/default_spec.rb

91 lines
2.4 KiB
Ruby
Raw Normal View History

2019-01-01 19:44:04 +00:00
require 'serverspec'
set :backend, :exec
puts
puts '================================'
puts %x(ansible --version)
puts '================================'
%w[
sensu-go-agent
sensu-go-cli
sensu-go-backend
].each do |package|
describe package(package) do
it { should be_installed }
end
end
%w[
sensu-agent
sensu-backend
].each do |service|
describe service(service) do
it { should be_enabled }
it { should be_running }
it { should be_running.under('systemd') }
end
end
[3000, 8080, 8081].each do |port|
describe port(port) do
it { should be_listening.with('tcp6') }
end
end
describe command(
'sensuctl configure -n --password "P@ssw0rd!" ' \
'--url http://127.0.0.1:8080 --username admin --format tabular'
) do
its(:exit_status) { should eq 0 }
end
describe command('sensuctl namespace list') do
its(:exit_status) { should eq 0 }
its(:stdout) { should match 'production' }
its(:stdout) { should match 'dev' }
2019-01-01 19:44:04 +00:00
end
describe command('sensuctl user list') do
its(:exit_status) { should eq 0 }
its(:stdout) { should match(/johndoe.*\s+devops,users\s+.*true/) }
end
describe command('sensuctl entity info localhost --format json') do
its(:exit_status) { should eq 0 }
its(:stdout) { should match(/"supersecret": "REDACTED"/) }
end
%w[production dev].each do |namespace|
describe command("sensuctl asset list --namespace #{namespace}") do
its(:exit_status) { should eq 0 }
its(:stdout) { should match(/superasset.*\s+.*test.sh\s+cf83e13/) }
end
2019-01-01 19:44:04 +00:00
2019-03-13 22:16:50 +00:00
describe command("sensuctl mutator list --namespace #{namespace}") do
its(:exit_status) { should eq 0 }
its(:stdout) { should match(%r{transform.*\s+.*/path/value_to_csv}) }
end
describe command("sensuctl handler list --namespace #{namespace}") do
its(:exit_status) { should eq 0 }
its(:stdout) { should match(/mail.*\s+pipe\s+.*echo test \| mail -s coucou\s+/) }
end
2019-01-01 19:44:04 +00:00
describe command("sensuctl check list --namespace #{namespace}") do
its(:exit_status) { should eq 0 }
its(:stdout) { should match(/ping.*\s+ping -c 1 127.0.0.1\s+60\s+.*\s+linux\s+/) }
end
describe command("sensuctl filter list --namespace #{namespace}") do
its(:exit_status) { should eq 0 }
its(:stdout) { should match(/state_changed.*\s+allow\s+event\.check\.occurrences == 1/) }
end
2019-01-01 19:44:04 +00:00
end
describe command('sensuctl cluster-role list') do
its(:exit_status) { should eq 0 }
its(:stdout) { should match(/view.*\s+1/) }
end