mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 10:08:40 -05:00
Do not run duplicate instances of inventory check for a pool
This commit updates check_pool inventory check to prevent multiple instances from running at once. Without this change the inventory check may run in multiple threads simultaneously.
This commit is contained in:
parent
8be578493a
commit
df89617fdc
2 changed files with 37 additions and 12 deletions
|
|
@ -2685,6 +2685,7 @@ EOT
|
|||
let(:pool_object) { config[:pools][0] }
|
||||
let(:new_vm) { 'newvm'}
|
||||
let(:pool_name) { pool_object['name'] }
|
||||
let(:mutex) { Mutex.new }
|
||||
|
||||
before do
|
||||
expect(subject).not_to be_nil
|
||||
|
|
@ -2790,6 +2791,27 @@ EOT
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
it 'should get the pool mutex' do
|
||||
expect(subject).to receive(:pool_mutex).and_return(mutex).at_least(:once)
|
||||
|
||||
subject._check_pool(pool_object,provider)
|
||||
end
|
||||
|
||||
it 'should run synchronize' do
|
||||
expect(subject).to receive(:pool_mutex).and_return(mutex).at_least(:once)
|
||||
expect(mutex).to receive(:synchronize).at_least(:once)
|
||||
|
||||
subject._check_pool(pool_object,provider)
|
||||
end
|
||||
|
||||
it 'should yield when locked' do
|
||||
expect(subject).to receive(:pool_mutex).and_return(mutex).at_least(:once)
|
||||
mutex.lock
|
||||
expect(mutex).to receive(:synchronize).and_yield
|
||||
|
||||
subject._check_pool(pool_object,provider)
|
||||
end
|
||||
end
|
||||
|
||||
# RUNNING
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue