-
Notifications
You must be signed in to change notification settings - Fork 289
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from jlambert121/spec_tests
initial spec tests
- Loading branch information
Showing
14 changed files
with
504 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
fixtures: | ||
repositories: | ||
apt: git://github.com/puppetlabs/puppetlabs-apt.git | ||
stdlib: git://github.com/puppetlabs/puppetlabs-stdlib.git | ||
symlinks: | ||
sensu: "#{source_dir}" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
sensu.komodoproject | ||
pkg/* | ||
spec/fixtures |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
require 'rubygems' | ||
require 'puppetlabs_spec_helper/rake_tasks' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
require 'spec_helper' | ||
|
||
describe 'sensu', :type => :class do | ||
|
||
it { should create_class('sensu') } | ||
|
||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
require 'spec_helper' | ||
|
||
describe 'sensu::package', :type => :class do | ||
let(:facts) { { :fqdn => 'testhost.domain.com' } } | ||
|
||
it { should create_class('sensu::package') } | ||
it { should include_class('sensu::repo') } | ||
it { should contain_package('sensu').with_ensure('latest') } | ||
it { should contain_sensu_clean_config('testhost.domain.com') } | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
require 'spec_helper' | ||
|
||
describe 'sensu::repo::apt', :type => :class do | ||
|
||
define 'with puppet-apt installed' do | ||
context 'ensure: present' do | ||
let(:facts) { { :apt::source => true, :apt::key => true } } | ||
let(:params) { { :ensure => 'present', :repo => 'main' } } | ||
it { should contain_apt__source('sensu').with( | ||
'ensure' => 'present', | ||
'location' => 'http://repos.sensuapp.org/apt', | ||
'release' => 'sensu', | ||
'repos' => 'main', | ||
'include_src' => false, | ||
'before' => 'Package[sensu]' | ||
) } | ||
|
||
it { should contain_apt__key('sensu').with( | ||
'key' => '7580C77F', | ||
'key_source' => 'http://repos.sensuapp.org/apt/pubkey.gpg' | ||
) } | ||
end | ||
|
||
context 'ensure: absent' do | ||
let(:facts) { { :apt::source => true, :apt::key => true } } | ||
let(:params) { { :ensure => 'absent', :repo => 'main' } } | ||
it { should contain_apt__source('sensu').with( | ||
'ensure' => 'absent', | ||
'location' => 'http://repos.sensuapp.org/apt', | ||
'release' => 'sensu', | ||
'repos' => 'main', | ||
'include_src' => false, | ||
'before' => 'Package[sensu]' | ||
) } | ||
|
||
it { should contain_apt__key('sensu').with( | ||
'key' => '7580C77F', | ||
'key_source' => 'http://repos.sensuapp.org/apt/pubkey.gpg' | ||
) } | ||
end | ||
end | ||
|
||
context 'without puppet-apt installed' do | ||
let(:params) { { :ensure => 'present', :repo => 'main' } } | ||
xit { should contain_fail('This class requires puppet-apt module') } | ||
end | ||
|
||
end | ||
|
||
|
||
# if defined(apt::source) and defined(apt::key) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
require 'spec_helper' | ||
|
||
describe 'sensu::repo', :type => :class do | ||
|
||
it { should create_class('sensu::repo') } | ||
|
||
['Debian', 'Ubuntu' ].each do |os| | ||
describe "operatingsystem: #{os}" do | ||
let(:facts) { { :operatingsystem => os } } | ||
context 'no params' do | ||
it { should contain_class('sensu::repo::apt').with_ensure('present') } | ||
end | ||
|
||
['present', 'absent'].each do |state| | ||
context "ensure: #{state}" do | ||
let(:params) { { :ensure => state } } | ||
it { should contain_class('sensu::repo::apt').with_ensure(state) } | ||
end | ||
end | ||
end | ||
end | ||
|
||
['Rhel', 'CentOS' ].each do |os| | ||
describe "operatingsystem: #{os}" do | ||
let(:facts) { { :operatingsystem => os } } | ||
context 'no params' do | ||
it { should contain_class('sensu::repo::yum').with_ensure('present') } | ||
end | ||
|
||
['present', 'absent'].each do |state| | ||
context "ensure: #{state}" do | ||
let(:params) { { :ensure => state } } | ||
it { should contain_class('sensu::repo::yum').with_ensure(state) } | ||
end | ||
end | ||
end | ||
end | ||
|
||
describe 'operatingsystem: Darwin' do | ||
let(:facts) { { :operatingsystem => 'Darwin' } } | ||
context 'no params' do | ||
xit { should contain_alert } | ||
end | ||
|
||
['present', 'absent'].each do |state| | ||
context "ensure => #{state}" do | ||
let(:params) { { :ensure => state } } | ||
xit { should contain_alert('Darwin not supported yet') } | ||
end | ||
end | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
require 'spec_helper' | ||
|
||
describe 'sensu::repo::yum', :type => :class do | ||
|
||
context 'ensure: present' do | ||
let(:params) { { :ensure => 'present', :repo => 'main' } } | ||
it { should contain_yumrepo('sensu').with( | ||
'enabled' => 1, | ||
'baseurl' => 'http://repos.sensuapp.org/yum/el/$releasever/$basearch/', | ||
'gpgcheck' => 0, | ||
'before' => 'Package[sensu]' | ||
) } | ||
end | ||
|
||
context 'ensure: absent' do | ||
let(:params) { { :ensure => 'absent', :repo => 'main' } } | ||
it { should contain_yumrepo('sensu').with( | ||
'enabled' => 'absent', | ||
'before' => 'Package[sensu]' | ||
) } | ||
end | ||
|
||
context 'ensure: foo' do | ||
let(:params) { { :ensure => 'foo', :repo => 'main' } } | ||
it { should contain_yumrepo('sensu').with( | ||
'enabled' => 'absent', | ||
'before' => 'Package[sensu]' | ||
) } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
require 'spec_helper' | ||
|
||
describe 'sensu::check', :type => :define do | ||
let(:title) { 'mycheck' } | ||
|
||
context 'defaults' do | ||
let(:params) { { :command => '/etc/sensu/somecommand.rb' } } | ||
|
||
it { should contain_sensu_check_config('mycheck').with( | ||
'realname' => 'mycheck', | ||
'command' => '/etc/sensu/somecommand.rb', | ||
'handlers' => [], | ||
'interval' => '60', | ||
'subscribers' => [] | ||
) } | ||
end | ||
|
||
context 'setting params' do | ||
let(:params) { { | ||
:command => '/etc/sensu/command2.rb', | ||
:handlers => ['/handler1', '/handler2'], | ||
:interval => '10', | ||
:subscribers => ['all'] | ||
} } | ||
|
||
it { should contain_sensu_check_config('mycheck').with( | ||
'realname' => 'mycheck', | ||
'command' => '/etc/sensu/command2.rb', | ||
'handlers' => ['/handler1', '/handler2'], | ||
'interval' => '10', | ||
'subscribers' => ['all'] | ||
) } | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
require 'spec_helper' | ||
|
||
describe 'sensu::client', :type => :define do | ||
let(:title) { 'myclient' } | ||
|
||
context 'defaults' do | ||
let(:facts) { { :ipaddress => '2.3.4.5', :fqdn => 'host.domain.com' } } | ||
let(:params) { { :rabbitmq_password => 'asdfjkl' } } | ||
|
||
it { should include_class('sensu::package') } | ||
it { should contain_sensu__rabbitmq('client').with( | ||
'ssl_cert_chain' => '', | ||
'ssl_private_key' => '', | ||
'port' => '5671', | ||
'host' => 'localhost', | ||
'user' => 'sensu', | ||
'vhost' => '/sensu', | ||
'password' => 'asdfjkl' | ||
) } | ||
|
||
it { should contain_sensu_client_config('host.domain.com').with( | ||
'client_name' => 'myclient', | ||
'address' => '2.3.4.5', | ||
'subscriptions' => [] | ||
) } | ||
|
||
it { should contain_service('sensu-client').with( | ||
'ensure' => 'running', | ||
'enable' => true, | ||
'hasrestart' => true, | ||
'require' => ['Sensu_rabbitmq_config[host.domain.com]', 'Sensu_client_config[host.domain.com]'] | ||
) } | ||
end | ||
|
||
context 'setting params' do | ||
let(:facts) { { :fqdn => 'host.domain.com' } } | ||
let(:params) { { | ||
:rabbitmq_password => 'asdfjkl', | ||
:rabbitmq_ssl_private_key => '/etc/sensu/ssl/key.pem', | ||
:rabbitmq_ssl_cert_chain => '/etc/sensu/ssl/chain.pem', | ||
:rabbitmq_port => '1234', | ||
:rabbitmq_host => 'rabbithost', | ||
:rabbitmq_user => 'sensuuser', | ||
:rabbitmq_vhost => '/myvhost', | ||
:address => '1.2.3.4', | ||
:subscriptions => ['all'] | ||
} } | ||
|
||
it { should include_class('sensu::package') } | ||
it { should contain_sensu__rabbitmq('client').with( | ||
'ssl_cert_chain' => '/etc/sensu/ssl/chain.pem', | ||
'ssl_private_key' => '/etc/sensu/ssl/key.pem', | ||
'port' => '1234', | ||
'host' => 'rabbithost', | ||
'user' => 'sensuuser', | ||
'vhost' => '/myvhost', | ||
'password' => 'asdfjkl' | ||
) } | ||
|
||
it { should contain_sensu_client_config('host.domain.com').with( | ||
'client_name' => 'myclient', | ||
'address' => '1.2.3.4', | ||
'subscriptions' => ['all'] | ||
) } | ||
|
||
it { should contain_service('sensu-client').with( | ||
'ensure' => 'running', | ||
'enable' => true, | ||
'hasrestart' => true, | ||
'require' => ['Sensu_rabbitmq_config[host.domain.com]', 'Sensu_client_config[host.domain.com]'] | ||
) } | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
require 'spec_helper' | ||
|
||
describe 'sensu::handler', :type => :define do | ||
let(:title) { 'myhandler' } | ||
let(:params) { { :type => 'pipe', :command => '/etc/sensu/mycommand.rb' } } | ||
|
||
it { should contain_sensu_handler_config('myhandler').with( | ||
'type' => 'pipe', | ||
'command' => '/etc/sensu/mycommand.rb', | ||
'before' => 'Service[sensu-server]' | ||
) } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
require 'spec_helper' | ||
|
||
describe 'sensu::rabbitmq', :type => :define do | ||
let(:title) { 'myrabbit' } | ||
let(:facts) { { :fqdn => 'hostname.domain.com' } } | ||
|
||
let(:params) { { | ||
:ssl_cert_chain => '/etc/sensu/ssl/chain.pem', | ||
:ssl_private_key => '/etc/sensu/ssl/key.pem', | ||
:port => '1234', | ||
:host => 'myhost', | ||
:user => 'sensuuser', | ||
:password => 'sensupass', | ||
:vhost => '/myvhost' | ||
} } | ||
|
||
pending "it should test cert installs" do | ||
# if $ssl_cert_chain != '' { | ||
# file { '/etc/sensu/ssl': | ||
# ensure => directory, | ||
# owner => 'sensu', | ||
# group => 'sensu', | ||
# mode => '0755', | ||
# require => Package['sensu'], | ||
# } | ||
# | ||
# if $ssl_cert_chain =~ /^puppet:\/\// { | ||
# file { '/etc/sensu/ssl/cert.pem': | ||
# ensure => present, | ||
# source => $ssl_cert_chain, | ||
# owner => 'sensu', | ||
# group => 'sensu', | ||
# mode => '0444', | ||
# require => File['/etc/sensu/ssl'], | ||
# before => Sensu_rabbitmq_config[$::fqdn], | ||
# } | ||
# | ||
# Sensu_rabbitmq_config { | ||
# ssl_cert_chain => '/etc/sensu/ssl/cert.pem', | ||
# } | ||
# } else { | ||
# Sensu_rabbitmq_config { | ||
# ssl_cert_chain => $ssl_cert_chain, | ||
# } | ||
# } | ||
# | ||
# if $ssl_private_key =~ /^puppet:\/\// { | ||
# file { '/etc/sensu/ssl/key.pem': | ||
# ensure => present, | ||
# source => $ssl_private_key, | ||
# owner => 'sensu', | ||
# group => 'sensu', | ||
# mode => '0440', | ||
# require => File['/etc/sensu/ssl'], | ||
# before => Sensu_rabbitmq_config[$::fqdn], | ||
# } | ||
# Sensu_rabbitmq_config { | ||
# ssl_private_key => '/etc/sensu/ssl/key.pem', | ||
# } | ||
# } else { | ||
# Sensu_rabbitmq_config { | ||
# ssl_private_key => $ssl_private_key, | ||
# } | ||
# } | ||
end | ||
|
||
it { should contain_sensu_rabbitmq_config('hostname.domain.com').with( | ||
'port' => '1234', | ||
'host' => 'myhost', | ||
'user' => 'sensuuser', | ||
'password' => 'sensupass', | ||
'vhost' => '/myvhost' | ||
) } | ||
|
||
end | ||
|
||
|
||
|
||
|
||
|
Oops, something went wrong.