vm_shepherd 1.11.1 → 1.11.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 158b8027d9711d2346b03702c5a3302d9f723f35
4
- data.tar.gz: ad05a0ea0e8928fd0bbbae0db8c833ef0edd08ee
3
+ metadata.gz: 3b121dee2dca3c6d42da8b7476e5ae4cf6013345
4
+ data.tar.gz: ee6729d0c2c9b75efd53c3cb5936089ac6551c4f
5
5
  SHA512:
6
- metadata.gz: ebc04c69df9a355dd6cd9424463f591142ac1d74414677df1c3ddf8965564afa02a1d8176afb73bc92fd8083a3935c546cdcf50273cd5c5e244b9584a8f9e324
7
- data.tar.gz: 9031ac449813be9d4f4986a00d345cd03edc2c73603ad727790e12063ee6940a805867f77d7cc435e2ad80e6b77e81407123bb101cdebab11108a0649d21cddb
6
+ metadata.gz: c35492e9a7324acaca7e5fe2385cca91ad9188581f96ff4ebe5632b288918a93cc36b757ab06b26bc239ad3fb62bbcd7bce39bd72ea30a8e36814e229259b412
7
+ data.tar.gz: d57003cb209534a08752db05c2ac7c96dd5bfe36b5f343d3673acc5f9133af3f79b520228205bb13de6e5a6b8ec115c8eeee7df9bbd4c5152caebf208231168a
@@ -54,6 +54,10 @@ module VmShepherd
54
54
  if server
55
55
  say("Found running Ops Manager instance #{server.id}")
56
56
  server.destroy
57
+ retry_until(retry_limit: 30) do
58
+ say(" Waiting for #{vm_options[:name]} server to be destroyed")
59
+ service.servers.find { |srv| srv.name == vm_options[:name] }.nil?
60
+ end
57
61
  say('Ops Manager instance destroyed')
58
62
  end
59
63
 
@@ -1,3 +1,3 @@
1
1
  module VmShepherd
2
- VERSION = '1.11.1'.freeze
2
+ VERSION = '1.11.2'.freeze
3
3
  end
@@ -32,6 +32,8 @@ module VmShepherd
32
32
 
33
33
  subject(:openstack_vm_manager) { OpenstackManager.new(openstack_options) }
34
34
 
35
+ before { stub_const('VmShepherd::RetryHelper::RETRY_INTERVAL', 0) }
36
+
35
37
  describe '#service' do
36
38
  it 'creates a Fog::Compute connection' do
37
39
  expect(Fog::Compute).to receive(:new).with(
@@ -189,11 +191,9 @@ module VmShepherd
189
191
  let(:compute_service) { openstack_vm_manager.service }
190
192
  let(:image_service) { openstack_vm_manager.image_service }
191
193
 
192
- let(:servers) { compute_service.servers }
193
- let(:flavors) { compute_service.flavors }
194
+ let(:flavors) { [compute_service.flavors.create(name: 'some-flavor', ram: 1, vcpus: 1, disk: 1)] }
194
195
  let(:images) { image_service.images }
195
- let(:image) { images.find { |image| image.name == openstack_vm_options[:name] } }
196
- let(:instance) { servers.find { |server| server.name == openstack_vm_options[:name] } }
196
+ let(:server) { instance_double(Fog::Compute::OpenStack::Server, id: openstack_vm_options[:name], destroy: true) }
197
197
 
198
198
  before do
199
199
  allow(File).to receive(:size).with(path).and_return(file_size)
@@ -204,10 +204,9 @@ module VmShepherd
204
204
  Fog::Mock.delay = 0
205
205
 
206
206
  allow(compute_service).to receive(:flavors).and_return(flavors)
207
- allow(compute_service).to receive(:servers).and_return(servers)
208
- allow(image_service).to receive(:images).and_return(images)
207
+ allow(openstack_vm_manager.service).to receive(:servers).and_return(compute_service.servers)
208
+ allow(compute_service.servers).to receive(:find).and_return(server, nil)
209
209
 
210
- flavors << flavors.create(name: 'some-flavor', ram: 1, vcpus: 1, disk: 1)
211
210
  openstack_vm_manager.deploy(path, openstack_vm_options)
212
211
  end
213
212
 
@@ -220,21 +219,26 @@ module VmShepherd
220
219
 
221
220
  it 'calls destroy on the correct instance' do
222
221
  destroy_correct_server = change do
223
- servers.reload
224
- servers.find { |server| server.name == openstack_vm_options[:name] }
222
+ compute_service.servers.reload
223
+ compute_service.servers.find { |server| server.name == openstack_vm_options[:name] }
225
224
  end.to(nil)
226
225
 
227
226
  expect { openstack_vm_manager.destroy(openstack_vm_options) }.to(destroy_correct_server)
228
227
  end
229
228
 
229
+ it 'waits until the correct server is gone before deleting the image' do
230
+ expect(compute_service.servers).to receive(:find).exactly(OpenstackManager::RETRY_LIMIT - 1).times.and_return(server)
231
+ expect(compute_service.servers).to receive(:find).exactly(1).times.and_return(nil)
232
+
233
+ openstack_vm_manager.destroy(openstack_vm_options)
234
+ end
235
+
230
236
  it 'calls destroy on the correct image' do
231
237
  expect { openstack_vm_manager.destroy(openstack_vm_options) }.to(destroy_correct_image)
232
238
  end
233
239
 
234
240
  context 'when the server does not exist' do
235
- before do
236
- allow(servers).to receive(:find).and_return(nil)
237
- end
241
+ before { allow(compute_service.servers).to receive(:find).and_return(nil) }
238
242
 
239
243
  it 'returns without error' do
240
244
  expect { openstack_vm_manager.destroy(openstack_vm_options) }.not_to raise_error
@@ -323,8 +327,6 @@ module VmShepherd
323
327
  end
324
328
 
325
329
  it 'waits until there are no servers before deleting images' do
326
- stub_const("VmShepherd::RetryHelper::RETRY_INTERVAL", 0)
327
-
328
330
  servers = instance_double(Array)
329
331
  allow(openstack_vm_manager.service).to receive(:servers).and_return(servers)
330
332
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vm_shepherd
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.11.1
4
+ version: 1.11.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ops Manager Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-31 00:00:00.000000000 Z
11
+ date: 2015-08-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-v1