diff --git a/manifests/service.pp b/manifests/service.pp index b1639c1cd..2f3b36182 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -41,8 +41,8 @@ } service { $foreman_service: - ensure => $foreman_service_ensure, - enable => $foreman_service_enable, - require => Service["${foreman_service}.socket"], + ensure => $foreman_service_ensure, + enable => $foreman_service_enable, + before => Service["${foreman_service}.socket"], } } diff --git a/spec/acceptance/foreman_service_spec.rb b/spec/acceptance/foreman_service_spec.rb new file mode 100644 index 000000000..21e23a16b --- /dev/null +++ b/spec/acceptance/foreman_service_spec.rb @@ -0,0 +1,45 @@ +require 'spec_helper_acceptance' + +describe 'configures puma worker count', :order => :defined do + context 'initial configuration with 2 puma workers' do + it_behaves_like 'an idempotent resource' do + let(:manifest) do + <<-PUPPET + class { 'foreman': + foreman_service_puma_workers => 2, + } + PUPPET + end + end + + describe service("foreman") do + it { is_expected.to be_enabled } + it { is_expected.to be_running } + end + + describe process('puma: cluster worker') do + its(:count) { is_expected.to eq 2 } + end + end + + context 'reconfigure to use 1 puma worker and restart foreman.service' do + it_behaves_like 'an idempotent resource' do + let(:manifest) do + <<-PUPPET + class { 'foreman': + foreman_service_puma_workers => 1, + } + PUPPET + end + end + + describe service("foreman") do + it { is_expected.to be_enabled } + it { is_expected.to be_running } + end + + describe process('puma: cluster worker') do + its(:count) { is_expected.to eq 1 } + end + end +end diff --git a/spec/classes/foreman_service_spec.rb b/spec/classes/foreman_service_spec.rb index 5384b49d6..188644814 100644 --- a/spec/classes/foreman_service_spec.rb +++ b/spec/classes/foreman_service_spec.rb @@ -23,7 +23,7 @@ it { is_expected.to compile.with_all_deps } it { is_expected.to contain_service('foreman.socket').with_ensure('running').with_enable(true) } - it { is_expected.to contain_service('foreman').with_ensure('running').with_enable(true) } + it { is_expected.to contain_service('foreman').with_ensure('running').with_enable(true).that_comes_before('Service[foreman.socket]') } end context 'with apache' do @@ -34,7 +34,7 @@ it { is_expected.to compile.with_all_deps } it { is_expected.to contain_class('foreman::service').that_requires('Class[apache::service]') } it { is_expected.to contain_service('foreman.socket').with_ensure('running').with_enable(true) } - it { is_expected.to contain_service('foreman').with_ensure('running').with_enable(true) } + it { is_expected.to contain_service('foreman').with_ensure('running').with_enable(true).that_comes_before('Service[foreman.socket]') } context 'without ssl' do let(:params) { super().merge(ssl: false) }