Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixing interval issues #104

Merged
merged 1 commit into from Oct 17, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions recipes/default.rb
Expand Up @@ -76,7 +76,8 @@
quiet node['audit']['quiet'] unless node['audit']['quiet'].nil?
only_if { profile_overdue_to_run?(p, interval_seconds) }
action [:fetch, :execute]
notifies :touch, "file[#{compliance_cache_directory}/#{p}]", :immediately
notifies :touch, "file[#{compliance_cache_directory}/#{p}]", :delayed
notifies :execute, "compliance_report[#{report_collector}]", :delayed
end
end

Expand All @@ -86,5 +87,5 @@
server server
collector report_collector
quiet node['audit']['quiet'] unless node['audit']['quiet'].nil?
action :execute
action :nothing
end if node['audit']['profiles'].values.any?
18 changes: 9 additions & 9 deletions spec/unit/recipes/default_spec.rb
Expand Up @@ -73,6 +73,7 @@
runner.node.override['audit']['quiet'] = true
runner.converge(described_recipe)
end
let(:myprofile) { chef_run.compliance_profile('myprofile') }

it 'fetches and executes compliance_profile[myprofile]' do
expect(chef_run).to fetch_compliance_profile('myprofile').with(
Expand All @@ -86,12 +87,10 @@
token: nil,
quiet: true,
)
expect(chef_run).to execute_compliance_report('chef-server').with(
owner: nil,
server: nil,
token: nil,
quiet: true,
)
end

it 'notifies compliance_report[chef-server]' do
expect(myprofile).to notify('compliance_report[chef-server]').delayed
end

it 'skips compliance_profile[ssh]' do
Expand Down Expand Up @@ -137,6 +136,8 @@
}
runner.converge(described_recipe)
end
let(:linux_profile) { chef_run.compliance_profile('linux') }

it 'executes base/linux in backward compatible mode' do
expect(chef_run).to execute_compliance_profile('linux').with(
path: nil,
Expand All @@ -160,10 +161,9 @@
it 'does not execute disabled exampleorg/myprofile' do
expect(chef_run).to_not execute_compliance_profile('myprofile')
end
it 'executes execute_compliance_report[chef-server]' do
expect(chef_run).to execute_compliance_report('chef-server')
it 'notifies compliance_report[chef-server]' do
expect(linux_profile).to notify('compliance_report[chef-server]').delayed
end

it 'converges successfully' do
expect { chef_run }.to_not raise_error
end
Expand Down