Merge pull request #271 from mattkirby/less_delta_disks

Ensure template deltas are created once
This commit is contained in:
mchllweeks 2018-07-09 12:49:08 -07:00 committed by GitHub
commit 2f98b1bd7a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 4 deletions

View file

@ -1838,8 +1838,26 @@ EOT
end
context 'when prepared template is nil' do
before(:each) do
it 'should prepare the template' do
expect(redis).to receive(:hget).with('vmpooler__template__prepared', pool).and_return(nil)
expect(subject).to receive(:prepare_template).with(config[:pools][0], provider)
subject.evaluate_template(config[:pools][0], provider)
end
it 'should not prepare the template again' do
expect(redis).to receive(:hget).with('vmpooler__template__prepared', pool).and_return(current_template)
expect(subject).to_not receive(:prepare_template).with(config[:pools][0], provider)
subject.evaluate_template(config[:pools][0], provider)
end
end
context 'when the configured pool template does not match the prepared template' do
before(:each) do
config[:pools][0]['template'] = new_template
expect(redis).to receive(:hget).with('vmpooler__template__prepared', pool).and_return(current_template)
end
it 'should prepare the template' do
@ -1847,6 +1865,15 @@ EOT
subject.evaluate_template(config[:pools][0], provider)
end
context 'if configured_template is provided' do
it 'should not run prepare_template' do
expect(redis).to receive(:hget).with('vmpooler__config__template', pool).and_return(current_template)
expect(subject).to_not receive(:prepare_template)
subject.evaluate_template(config[:pools][0], provider)
end
end
end
context 'when a new template is requested' do
@ -2299,7 +2326,6 @@ EOT
it 'should run startup tasks only once' do
expect(redis).to receive(:set).with('vmpooler__tasks__clone', 0).once
expect(redis).to receive(:del).with('vmpooler__migration').once
expect(redis).to receive(:del).with('vmpooler__template__prepared').once
subject.execute!(maxloop,0)
end