Revision 67f78b9b
Added by Ewoud Kohl van Wijngaarden about 3 years ago
spec/defines/foreman_dynflow_worker_spec.rb | ||
---|---|---|
require 'spec_helper'
|
||
|
||
describe 'foreman::dynflow::worker' do
|
||
let :title do 'test_worker' end
|
||
let(:title) { 'test_worker' }
|
||
|
||
on_supported_os.each do |os, facts|
|
||
context "on #{os}" do
|
||
let(:facts) { facts }
|
||
|
||
let :pre_condition do
|
||
'include foreman'
|
||
end
|
||
context 'ensure => present' do
|
||
let(:params) do
|
||
{ensure: 'absent'}
|
||
end
|
||
|
||
context 'default parameters' do
|
||
it {
|
||
it { should compile.with_all_deps }
|
||
it do
|
||
should contain_file('/etc/foreman/dynflow/test_worker.yml')
|
||
.with_ensure('file')
|
||
.with_owner('root')
|
||
.with_group('foreman')
|
||
.with_mode('0644')
|
||
.with_content(/:concurrency: 5/)
|
||
.with_content(/:queues:\n - default\n - remote_execution/)
|
||
}
|
||
it {
|
||
.with_ensure('absent')
|
||
end
|
||
it do
|
||
should contain_service('dynflow-sidekiq@test_worker')
|
||
.with_ensure('running')
|
||
.with_enable(true)
|
||
}
|
||
.with_ensure('stopped')
|
||
.with_enable(false)
|
||
end
|
||
end
|
||
|
||
context 'with custom concurrency and queues' do
|
||
let :params do
|
||
{
|
||
concurrency: 10,
|
||
queues: ['katello']
|
||
context 'ensure => present' do
|
||
let :pre_condition do
|
||
<<-PUPPET
|
||
class { 'foreman':
|
||
dynflow_manage_services => false,
|
||
}
|
||
PUPPET
|
||
end
|
||
|
||
it { should contain_file('/etc/foreman/dynflow/test_worker.yml')
|
||
.with_ensure('file')
|
||
.with_owner('root')
|
||
.with_group('foreman')
|
||
.with_mode('0644')
|
||
.with_content(/:concurrency: 10/)
|
||
.with_content(/:queues:\n - katello\n$/) }
|
||
context 'default parameters' do
|
||
it { should compile.and_raise_error(/expects size to be at least 1, got 0/) }
|
||
end
|
||
|
||
context 'with multiple queues' do
|
||
let(:params) do
|
||
{queues: ['default', 'remote_execution']}
|
||
end
|
||
|
||
it { should compile.with_all_deps }
|
||
it {
|
||
should contain_file('/etc/foreman/dynflow/test_worker.yml')
|
||
.with_ensure('file')
|
||
.with_owner('root')
|
||
.with_group('foreman')
|
||
.with_mode('0644')
|
||
.with_content(/:concurrency: 1/)
|
||
.with_content(/:queues:\n - default\n - remote_execution/)
|
||
}
|
||
it {
|
||
should contain_service('dynflow-sidekiq@test_worker')
|
||
.with_ensure('running')
|
||
.with_enable(true)
|
||
}
|
||
end
|
||
|
||
context 'with custom concurrency and queues' do
|
||
let :params do
|
||
{
|
||
concurrency: 10,
|
||
queues: ['katello']
|
||
}
|
||
end
|
||
|
||
it { should compile.with_all_deps }
|
||
it { should contain_file('/etc/foreman/dynflow/test_worker.yml')
|
||
.with_ensure('file')
|
||
.with_owner('root')
|
||
.with_group('foreman')
|
||
.with_mode('0644')
|
||
.with_content(/:concurrency: 10/)
|
||
.with_content(/:queues:\n - katello\n$/) }
|
||
end
|
||
end
|
||
end
|
||
end
|
Also available in: Unified diff
Fixes #29817 - Implement a dynflow worker pool