mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 10:08:40 -05:00
Host snapshot rspec tests
This commit is contained in:
parent
1c3045fd65
commit
93acc8327b
2 changed files with 95 additions and 0 deletions
|
|
@ -211,4 +211,72 @@ describe 'Pool Manager' do
|
|||
end
|
||||
end
|
||||
|
||||
describe '#_create_vm_snapshot' do
|
||||
let(:snapshot_manager) { 'snapshot_manager' }
|
||||
let(:pool_helper) { double('snapshot_manager') }
|
||||
let(:vsphere) { {snapshot_manager => pool_helper} }
|
||||
|
||||
before do
|
||||
expect(subject).not_to be_nil
|
||||
$vsphere = vsphere
|
||||
end
|
||||
|
||||
context '(valid host)' do
|
||||
let(:vm_host) { double('vmhost') }
|
||||
|
||||
it 'creates a snapshot' do
|
||||
expect(pool_helper).to receive(:find_vm).and_return vm_host
|
||||
expect(logger).to receive(:log)
|
||||
expect(vm_host).to receive_message_chain(:CreateSnapshot_Task, :wait_for_completion)
|
||||
expect(redis).to receive(:hset).with('vmpooler__vm__testvm', 'snapshot:testsnapshot', Time.now.to_s)
|
||||
expect(logger).to receive(:log)
|
||||
|
||||
subject._create_vm_snapshot('testvm', 'testsnapshot')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#_revert_vm_snapshot' do
|
||||
let(:snapshot_manager) { 'snapshot_manager' }
|
||||
let(:pool_helper) { double('snapshot_manager') }
|
||||
let(:vsphere) { {snapshot_manager => pool_helper} }
|
||||
|
||||
before do
|
||||
expect(subject).not_to be_nil
|
||||
$vsphere = vsphere
|
||||
end
|
||||
|
||||
context '(valid host)' do
|
||||
let(:vm_host) { double('vmhost') }
|
||||
let(:vm_snapshot) { double('vmsnapshot') }
|
||||
|
||||
it 'reverts a snapshot' do
|
||||
expect(pool_helper).to receive(:find_vm).and_return vm_host
|
||||
expect(pool_helper).to receive(:find_snapshot).and_return vm_snapshot
|
||||
expect(logger).to receive(:log)
|
||||
expect(vm_snapshot).to receive_message_chain(:RevertToSnapshot_Task, :wait_for_completion)
|
||||
expect(logger).to receive(:log)
|
||||
|
||||
subject._revert_vm_snapshot('testvm', 'testsnapshot')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#_check_snapshot_queue' do
|
||||
let(:pool_helper) { double('pool') }
|
||||
let(:vsphere) { {pool => pool_helper} }
|
||||
|
||||
before do
|
||||
expect(subject).not_to be_nil
|
||||
$vsphere = vsphere
|
||||
end
|
||||
|
||||
it 'checks appropriate redis queues' do
|
||||
expect(redis).to receive(:spop).with('vmpooler__tasks__snapshot')
|
||||
expect(redis).to receive(:spop).with('vmpooler__tasks__snapshot-revert')
|
||||
|
||||
subject._check_snapshot_queue
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue