Created
September 1, 2016 19:35
-
-
Save cabecada/62f86fd3e8c291010f2b2b393e35ee0c to your computer and use it in GitHub Desktop.
example spec
This file contains hidden or 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
root@ubuntu1404-4:/var/tmp/serverspec# cat spec/localhost/sample_spec.rb | |
require 'spec_helper' | |
describe package('sensu') do | |
it { should be_installed } | |
end | |
describe package('sensu-plugin') do | |
it { should be_installed.by('gem').with_version('1.3.1') } | |
end | |
describe port(8081) do | |
it { should be_listening.with('tcp') } | |
end | |
describe process("ruby2.0") do | |
its(:user) { should eq "pagerduty" } | |
its(:args) { should match /-e production\b/ } | |
end | |
describe user('pagerduty') do | |
it { should exist } | |
end | |
describe user('pagerduty') do | |
it { should have_home_directory '/home/pagerduty' } | |
end | |
describe service('pagerduty') do | |
it { should be_running.under('upstart') } | |
end | |
describe service("sensu-server") do | |
it { should be_running } | |
end | |
describe service("sensu-api") do | |
it { should be_running } | |
end | |
describe service("sensu-client") do | |
it { should be_running } | |
end | |
describe host('ubuntu1404-3.vagrant.local') do | |
it { should be_reachable } | |
it { should be_reachable.with( :port => 6379, :proto => 'tcp' ) } | |
end | |
describe host('ubuntu1404-3.vagrant.local') do | |
it { should be_reachable } | |
it { should be_reachable.with( :port => 6379, :proto => 'tcp' ) } | |
end | |
describe host('ubuntu1404-2.vagrant.local') do | |
it { should be_reachable } | |
it { should be_reachable.with( :port => 5672, :proto => 'tcp' ) } | |
end | |
###results | |
root@ubuntu1404-4:/var/tmp/serverspec# PATH=/opt/sensu/embedded/bin/:$PATH bundle exec rspec spec | |
Package "sensu" | |
should be installed | |
Package "sensu-plugin" | |
should be installed by "gem" with version "1.3.1" | |
Port "8081" | |
should be listening with tcp | |
Process "ruby2.0" | |
user | |
should eq "pagerduty" | |
args | |
should match /-e production\b/ | |
User "pagerduty" | |
should exist | |
User "pagerduty" | |
should have home directory "/home/pagerduty" | |
Service "pagerduty" | |
should be running under upstart | |
Service "sensu-server" | |
should be running | |
Service "sensu-api" | |
should be running | |
Service "sensu-client" | |
should be running | |
Host "ubuntu1404-3.vagrant.local" | |
should be reachable | |
should be reachable | |
Host "ubuntu1404-3.vagrant.local" | |
should be reachable | |
should be reachable | |
Host "ubuntu1404-2.vagrant.local" | |
should be reachable | |
should be reachable | |
Finished in 3.62 seconds (files took 0.25773 seconds to load) | |
17 examples, 0 failures |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment