Commit 0928d54f authored by Tim Smith's avatar Tim Smith
Browse files

Merge pull request #68 from josacar/test/restart-action-broken

Restart action breaks in rsyslog >= 5.1.3
parents a75e455f 2a2ce95d
......@@ -32,10 +32,10 @@ suites:
- omnios-r151006c
- name: client
run_list:
- recipe[rsyslog::client]
- recipe[rsyslog_test::client]
attributes:
rsyslog:
server_ip: 10.0.0.50
- name: server
run_list:
- recipe[rsyslog::server]
- recipe[rsyslog_test::server]
......@@ -3,5 +3,5 @@ metadata
group :integration do
cookbook 'apt', '~> 2.0'
cookbook 'rsyslog_test', path: 'test/fixtures/rsyslog_test'
end
......@@ -68,5 +68,5 @@ end
file "#{node['rsyslog']['config_prefix']}/rsyslog.d/server.conf" do
action :delete
notifies :reload, "service[#{node['rsyslog']['service_name']}]"
notifies :restart, "service[#{node['rsyslog']['service_name']}]"
end
......@@ -91,7 +91,7 @@ else
end
service node['rsyslog']['service_name'] do
supports :restart => true, :reload => true, :status => true
supports :restart => true, :status => true
action [:enable, :start]
provider service_provider
end
......@@ -39,6 +39,6 @@ end
file "#{node['rsyslog']['config_prefix']}/rsyslog.d/remote.conf" do
action :delete
notifies :reload, "service[#{node['rsyslog']['service_name']}]"
notifies :restart, "service[#{node['rsyslog']['service_name']}]"
only_if { ::File.exist?("#{node['rsyslog']['config_prefix']}/rsyslog.d/remote.conf") }
end
......@@ -3,17 +3,17 @@ require 'spec_helper'
describe 'rsyslog::client' do
context "when node['rsyslog']['server_ip'] is not set" do
before do
Chef::Log.stub(:fatal)
$stdout.stub(:puts)
allow(Chef::Log).to receive(:fatal)
allow($stdout).to receive(:puts)
end
it 'exits fatally' do
expect { ChefSpec::Runner.new.converge(described_recipe) }.to raise_error(SystemExit)
expect { ChefSpec::SoloRunner.new.converge(described_recipe) }.to raise_error(SystemExit)
end
end
let(:chef_run) do
ChefSpec::Runner.new(platform: 'ubuntu', version: '12.04') do |node|
ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '12.04') do |node|
node.set['rsyslog']['server_ip'] = server_ip
end.converge(described_recipe)
end
......@@ -47,7 +47,7 @@ describe 'rsyslog::client' do
context 'on SmartOS' do
let(:chef_run) do
ChefSpec::Runner.new(platform: 'smartos', version: 'joyent_20130111T180733Z') do |node|
ChefSpec::SoloRunner.new(platform: 'smartos', version: 'joyent_20130111T180733Z') do |node|
node.set['rsyslog']['server_ip'] = server_ip
end.converge(described_recipe)
end
......@@ -81,12 +81,12 @@ describe 'rsyslog::client' do
end
it 'notifies restarting the service' do
expect(file).to notify(service_resource).to(:reload)
expect(file).to notify(service_resource).to(:restart)
end
context 'on SmartOS' do
let(:chef_run) do
ChefSpec::Runner.new(platform: 'smartos', version: 'joyent_20130111T180733Z') do |node|
ChefSpec::SoloRunner.new(platform: 'smartos', version: 'joyent_20130111T180733Z') do |node|
node.set['rsyslog']['server_ip'] = server_ip
end.converge(described_recipe)
end
......@@ -98,7 +98,7 @@ describe 'rsyslog::client' do
end
it 'notifies restarting the service' do
expect(file).to notify(service_resource).to(:reload)
expect(file).to notify(service_resource).to(:restart)
end
end
end
......
......@@ -2,7 +2,7 @@ require 'spec_helper'
describe 'rsyslog::default' do
let(:chef_run) do
ChefSpec::Runner.new(platform: 'ubuntu', version: '12.04').converge(described_recipe)
ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '12.04').converge(described_recipe)
end
let(:service_resource) { 'service[rsyslog]' }
......@@ -13,7 +13,7 @@ describe 'rsyslog::default' do
context "when node['rsyslog']['relp'] is true" do
let(:chef_run) do
ChefSpec::Runner.new(platform: 'ubuntu', version: '12.04') do |node|
ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '12.04') do |node|
node.set['rsyslog']['use_relp'] = true
end.converge(described_recipe)
end
......@@ -26,7 +26,7 @@ describe 'rsyslog::default' do
context "when node['rsyslog']['enable_tls'] is true" do
context "when node['rsyslog']['tls_ca_file'] is not set" do
let(:chef_run) do
ChefSpec::Runner.new(platform: 'ubuntu', version: '12.04') do |node|
ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '12.04') do |node|
node.set['rsyslog']['enable_tls'] = true
end.converge(described_recipe)
end
......@@ -38,7 +38,7 @@ describe 'rsyslog::default' do
context "when node['rsyslog']['tls_ca_file'] is set" do
let(:chef_run) do
ChefSpec::Runner.new(platform: 'ubuntu', version: '12.04') do |node|
ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '12.04') do |node|
node.set['rsyslog']['enable_tls'] = true
node.set['rsyslog']['tls_ca_file'] = '/etc/path/to/ssl-ca.crt'
end.converge(described_recipe)
......@@ -50,12 +50,12 @@ describe 'rsyslog::default' do
context "when protocol is not 'tcp'" do
before do
Chef::Log.stub(:fatal)
$stdout.stub(:puts)
allow(Chef::Log).to receive(:fatal)
allow($stdout).to receive(:puts)
end
let(:chef_run) do
ChefSpec::Runner.new(platform: 'ubuntu', version: '12.04') do |node|
ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '12.04') do |node|
node.set['rsyslog']['enable_tls'] = true
node.set['rsyslog']['tls_ca_file'] = '/etc/path/to/ssl-ca.crt'
node.set['rsyslog']['protocol'] = 'udp'
......@@ -88,7 +88,7 @@ describe 'rsyslog::default' do
context 'on SmartOS' do
let(:chef_run) do
ChefSpec::Runner.new(platform: 'smartos', version: 'joyent_20130111T180733Z').converge(described_recipe)
ChefSpec::SoloRunner.new(platform: 'smartos', version: 'joyent_20130111T180733Z').converge(described_recipe)
end
let(:directory) { chef_run.directory('/opt/local/etc/rsyslog.d') }
......@@ -120,8 +120,8 @@ describe 'rsyslog::default' do
expect(directory.group).to eq('root')
end
it 'has 0755 permissions' do
expect(directory.mode).to eq('0755')
it 'has 0700 permissions' do
expect(directory.mode).to eq('0700')
end
end
......@@ -130,7 +130,7 @@ describe 'rsyslog::default' do
let(:modules) { %w(imuxsock imklog) }
it 'creates the template' do
expect(chef_run).to render_file(template.path).with_content('Configuration file for rsyslog v3')
expect(chef_run).to render_file(template.path).with_content('rsyslog configuration file - Generated by Chef')
end
it 'is owned by root:root' do
......@@ -154,14 +154,14 @@ describe 'rsyslog::default' do
context 'on SmartOS' do
let(:chef_run) do
ChefSpec::Runner.new(platform: 'smartos', version: 'joyent_20130111T180733Z').converge(described_recipe)
ChefSpec::SoloRunner.new(platform: 'smartos', version: 'joyent_20130111T180733Z').converge(described_recipe)
end
let(:template) { chef_run.template('/opt/local/etc/rsyslog.conf') }
let(:modules) { %w(immark imsolaris imtcp imudp) }
it 'creates the template' do
expect(chef_run).to render_file(template.path).with_content('Configuration file for rsyslog v3')
expect(chef_run).to render_file(template.path).with_content('rsyslog configuration file - Generated by Chef')
end
it 'is owned by root:root' do
......@@ -207,7 +207,7 @@ describe 'rsyslog::default' do
context 'on SmartOS' do
let(:chef_run) do
ChefSpec::Runner.new(platform: 'smartos', version: 'joyent_20130111T180733Z').converge(described_recipe)
ChefSpec::SoloRunner.new(platform: 'smartos', version: 'joyent_20130111T180733Z').converge(described_recipe)
end
let(:template) { chef_run.template('/opt/local/etc/rsyslog.d/50-default.conf') }
......@@ -237,7 +237,7 @@ describe 'rsyslog::default' do
context 'COOK-3608 maillog regression test' do
let(:chef_run) do
ChefSpec::Runner.new(platform: 'redhat', version: '6.3').converge(described_recipe)
ChefSpec::SoloRunner.new(platform: 'redhat', version: '6.3').converge(described_recipe)
end
it 'outputs mail.* to /var/log/maillog' do
......@@ -247,7 +247,7 @@ describe 'rsyslog::default' do
context 'syslog service' do
let(:chef_run) do
ChefSpec::Runner.new(platform: 'redhat', version: '5.8').converge(described_recipe)
ChefSpec::SoloRunner.new(platform: 'redhat', version: '5.8').converge(described_recipe)
end
it 'stops and starts the syslog service on RHEL' do
......@@ -259,7 +259,7 @@ describe 'rsyslog::default' do
context 'system-log service' do
{ 'omnios' => '151002', 'smartos' => 'joyent_20130111T180733Z' }.each do |p, pv|
let(:chef_run) do
ChefSpec::Runner.new(platform: p, version: pv).converge(described_recipe)
ChefSpec::SoloRunner.new(platform: p, version: pv).converge(described_recipe)
end
it "stops the system-log service on #{p}" do
......@@ -270,7 +270,7 @@ describe 'rsyslog::default' do
context 'on OmniOS' do
let(:chef_run) do
ChefSpec::Runner.new(platform: 'omnios', version: '151002').converge(described_recipe)
ChefSpec::SoloRunner.new(platform: 'omnios', version: '151002').converge(described_recipe)
end
let(:template) { chef_run.template('/var/svc/manifest/system/rsyslogd.xml') }
......
......@@ -2,7 +2,7 @@ require 'spec_helper'
describe 'rsyslog::server' do
let(:chef_run) do
ChefSpec::Runner.new(platform: 'ubuntu', version: '12.04') do |node|
ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '12.04') do |node|
node.set['rsyslog']['server'] = false
end.converge(described_recipe)
end
......@@ -10,7 +10,7 @@ describe 'rsyslog::server' do
let(:service_resource) { 'service[rsyslog]' }
it "sets node['rsyslog']['server'] to true" do
expect(chef_run.node['rsyslog']['server']).to be_true
expect(chef_run.node['rsyslog']['server']).to be(true)
end
it 'includes the default recipe' do
......@@ -56,7 +56,7 @@ describe 'rsyslog::server' do
context 'on SmartOS' do
let(:chef_run) do
ChefSpec::Runner.new(platform: 'smartos', version: 'joyent_20130111T180733Z') do |node|
ChefSpec::SoloRunner.new(platform: 'smartos', version: 'joyent_20130111T180733Z') do |node|
node.set['rsyslog']['server'] = false
end.converge(described_recipe)
end
......@@ -91,12 +91,12 @@ describe 'rsyslog::server' do
end
it 'notifies restarting the service' do
expect(file).to notify(service_resource).to(:reload)
expect(file).to notify(service_resource).to(:restart)
end
context 'on SmartOS' do
let(:chef_run) do
ChefSpec::Runner.new(platform: 'smartos', version: 'joyent_20130111T180733Z') do |node|
ChefSpec::SoloRunner.new(platform: 'smartos', version: 'joyent_20130111T180733Z') do |node|
node.set['rsyslog']['server'] = false
end.converge(described_recipe)
end
......@@ -109,7 +109,7 @@ describe 'rsyslog::server' do
end
it 'notifies restarting the service' do
expect(file).to notify(service_resource).to(:reload)
expect(file).to notify(service_resource).to(:restart)
end
end
end
......
name 'rsyslog_test'
maintainer 'Chef Software, Inc.'
maintainer_email 'cookbooks@getchef.com'
license 'Apache 2.0'
description 'Tests rsyslog cookbook'
version '1.0'
depends 'rsyslog'
require 'fileutils'
FileUtils.touch("#{node['rsyslog']['config_prefix']}/rsyslog.d/server.conf")
include_recipe 'rsyslog::client'
require 'fileutils'
FileUtils.touch("#{node['rsyslog']['config_prefix']}/rsyslog.d/remote.conf")
include_recipe 'rsyslog::server'
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment