Move to using redis to track the ondemand clone task count so it can be displayed by dashboard and API

This commit is contained in:
kirby@puppetlabs.com 2020-05-11 18:22:54 -07:00
parent 4de3490bfe
commit 8459e2ec21
4 changed files with 15 additions and 22 deletions

View file

@ -128,7 +128,7 @@ describe Vmpooler::API::Helpers do
]
allow(redis).to receive(:pipelined).with(no_args).and_return [1,1]
allow(redis).to receive(:get).and_return 1
allow(redis).to receive(:get).and_return(1,0)
expect(subject.get_queue_metrics(pools, redis)).to eq({pending: 2, cloning: 1, booting: 1, ready: 2, running: 2, completed: 2, total: 8})
end
@ -140,7 +140,7 @@ describe Vmpooler::API::Helpers do
]
allow(redis).to receive(:pipelined).with(no_args).and_return [1,1]
allow(redis).to receive(:get).and_return 5
allow(redis).to receive(:get).and_return(5,0)
expect(subject.get_queue_metrics(pools, redis)).to eq({pending: 2, cloning: 5, booting: 0, ready: 2, running: 2, completed: 2, total: 8})
end

View file

@ -867,14 +867,11 @@ EOT
end
end
it 'should reduce the ondemand clone count' do
count = { 'ondemand_clone_count' => 1 }
subject.instance_variable_set(:@tasks, count)
it 'should reduce the clone count' do
redis_connection_pool.with do |redis|
expect(redis).to receive(:decr).with('vmpooler__tasks__ondemandclone')
subject._clone_vm(pool,provider,request_id,pool)
end
count = subject.instance_variable_get(:@tasks)
expect(count['ondemand_clone_count']).to eq(0)
end
end
end
@ -3167,6 +3164,7 @@ EOT
it 'should run startup tasks only once' do
redis_connection_pool.with do |redis|
expect(redis).to receive(:set).with('vmpooler__tasks__clone', 0).once
expect(redis).to receive(:set).with('vmpooler__tasks__ondemandclone', 0).once
expect(redis).to receive(:del).with('vmpooler__migration').once
end