Implement os_workers_heat_engine

Re-using the classic os_workers fact but changing the minimum from 2 to
4, specific to the fact Heat Engine can be stressed out.
Also cap to 24 workers at maximum.

Change-Id: I31d02bea6dd55d65a7014503398adc4422ce7303
This commit is contained in:
Emilien Macchi 2017-12-19 10:45:46 -08:00
parent b5bd19a630
commit 7df431c81e
3 changed files with 55 additions and 0 deletions

View File

@ -48,3 +48,16 @@ Facter.add(:os_workers_large) do
[ (processors.to_i / 2), 1 ].max
end
end
#
# Heat Engine service can be more stressed than other services, so
# a minimum of 4 and maximum of 24 workers should be fine, still
# calculating with the number of processors.
#
Facter.add(:os_workers_heat_engine) do
has_weight 100
setcode do
processors = Facter.value('processorcount')
[ [ (processors.to_i / 2), 4 ].max, 24 ].min
end
end

View File

@ -0,0 +1,6 @@
---
features:
- |
Implement a new fact, $::os_workers_heat_engine that is responding to
a specific need with Heat Engine service, where minimum of workers will
be 4 and maximum of 24.

View File

@ -0,0 +1,36 @@
require 'spec_helper'
describe 'os_workers_heat_engine' do
before { Facter.flush }
context 'with processorcount=1' do
before do
Facter.fact(:processorcount).stubs(:value).returns(1)
end
it 'returns a minimum of 2' do
expect(Facter.fact(:os_workers_heat_engine).value).to eq(4)
end
end
context 'with processorcount=8' do
before do
Facter.fact(:processorcount).stubs(:value).returns(8)
end
it 'returns processorcount/2' do
expect(Facter.fact(:os_workers_heat_engine).value).to eq(4)
end
end
context 'with processorcount=64' do
before do
Facter.fact(:processorcount).stubs(:value).returns(64)
end
it 'returns a maximum of 24' do
expect(Facter.fact(:os_workers_heat_engine).value).to eq(24)
end
end
end