kitchen-ec2 0.9.4 → 0.9.5

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: ce1e378058d18afcc07e2f59a986588f9e05887f
4
- data.tar.gz: 2e902c288551eab23b6f0ed314dd7616277a13de
3
+ metadata.gz: 3a4c3c1651c87e7efe1021c8c7f42eea85b1bd50
4
+ data.tar.gz: 4f9beb18601e10e003b579da74f2920061040543
5
5
  SHA512:
6
- metadata.gz: ef7beeddeeca20586ef7800e42c841b530f04fc2bc16098e79478e37654770c1bf163ea9a9e3707827d3f060eda2b71886eb50d7b3123740932d060dcac0297f
7
- data.tar.gz: 3bd25b6b3654267dfe2262a796659e647749f57fd1095551e414ded3c5fc5f327965eb0f2b719369e290c94536ed5ff6fd2aef265340e84af9927c44495f8253
6
+ metadata.gz: 0a8da55831097f198d69c3de6c0474cc9a85aedbaf15b96180a198c9ce3455ef5ce8081f75aeecb80a211ca0d2002118f39a1e5b23ae83d3f41aa692d7adcf01
7
+ data.tar.gz: 5aa911a240efb08e0fce0d17adab20a7851fd8ec4ec1718459739e8ad5a0a264f10e7c4267b1fb0cdbb231d3973aec9b7067570f5364ed3074c7273900b4e8fc
@@ -2,6 +2,9 @@ Style/FileName:
2
2
  Exclude:
3
3
  - 'data/**/*'
4
4
 
5
+ Style/Lambda:
6
+ Enabled: false
7
+
5
8
  Style/Next:
6
9
  Enabled: false
7
10
 
@@ -1,3 +1,13 @@
1
+ ## 0.9.4 / 2015-06-05
2
+
3
+ ### Bug Fixes
4
+
5
+ * Pull Request [#151][]: Fixing a regression where we are fetching the hostname from an old server object even after waiting for it to update, causing us to get back an invalid hostname
6
+
7
+ ### New Features
8
+
9
+ ### Improvements
10
+
1
11
  ## 0.9.4 / 2015-06-03
2
12
 
3
13
  ### Bug Fixes
@@ -165,6 +175,7 @@
165
175
  [#131]: https://github.com/test-kitchen/kitchen-ec2/issues/131
166
176
  [#140]: https://github.com/test-kitchen/kitchen-ec2/issues/140
167
177
  [#142]: https://github.com/test-kitchen/kitchen-ec2/issues/142
178
+ [#151]: https://github.com/test-kitchen/kitchen-ec2/issues/151
168
179
  [@Atalanta]: https://github.com/Atalanta
169
180
  [@Igorshp]: https://github.com/Igorshp
170
181
  [@JamesAwesome]: https://github.com/JamesAwesome
@@ -201,7 +201,6 @@ module Kitchen
201
201
  wait_until_ready(server, state)
202
202
 
203
203
  info("EC2 instance <#{state[:server_id]}> ready.")
204
- state[:hostname] = hostname(server)
205
204
  instance.transport.connection(state).wait_until_ready
206
205
  create_ec2_json(state)
207
206
  debug("ec2:create '#{state[:hostname]}'")
@@ -317,24 +316,34 @@ module Kitchen
317
316
  end
318
317
 
319
318
  def wait_until_ready(server, state)
319
+ wait_with_destroy(server, state, "to become ready") do |aws_instance|
320
+ hostname = hostname(aws_instance, config[:interface])
321
+ # We aggressively store the hostname so if the process fails here
322
+ # we still have it, even if it will change later
323
+ state[:hostname] = hostname
324
+ # Euca instances often report ready before they have an IP
325
+ aws_instance.exists? &&
326
+ aws_instance.state.name == "running" &&
327
+ hostname != "0.0.0.0"
328
+ end
329
+ end
330
+
331
+ def wait_with_destroy(server, state, status_msg, &block)
320
332
  wait_log = proc do |attempts|
321
333
  c = attempts * config[:retryable_sleep]
322
334
  t = config[:retryable_tries] * config[:retryable_sleep]
323
- info "Waited #{c}/#{t}s for instance <#{state[:server_id]}> to become ready."
335
+ info "Waited #{c}/#{t}s for instance <#{state[:server_id]}> #{status_msg}."
324
336
  end
325
337
  begin
326
338
  server.wait_until(
327
339
  :max_attempts => config[:retryable_tries],
328
340
  :delay => config[:retryable_sleep],
329
- :before_attempt => wait_log
330
- ) do |s|
331
- hostname = hostname(s, config[:interface])
332
- # Euca instances often report ready before they have an IP
333
- s.exists? && s.state.name == "running" && !hostname.nil? && hostname != "0.0.0.0"
334
- end
341
+ :before_attempt => wait_log,
342
+ &block
343
+ )
335
344
  rescue ::Aws::Waiters::Errors::WaiterFailed
336
345
  error("Ran out of time waiting for the server with id [#{state[:server_id]}]" \
337
- " to become ready, attempting to destroy it")
346
+ " #{status_msg}, attempting to destroy it")
338
347
  destroy(state)
339
348
  raise
340
349
  end
@@ -21,6 +21,6 @@ module Kitchen
21
21
  module Driver
22
22
 
23
23
  # Version string for EC2 Test Kitchen driver
24
- EC2_VERSION = "0.9.4"
24
+ EC2_VERSION = "0.9.5"
25
25
  end
26
26
  end
@@ -38,6 +38,7 @@ describe Kitchen::Driver::Ec2 do
38
38
  let(:actual_client) { double("actual ec2 client") }
39
39
  let(:client) { double(Kitchen::Driver::Aws::Client, :client => actual_client) }
40
40
  let(:server) { double("aws server object") }
41
+ let(:state) { {} }
41
42
 
42
43
  let(:driver) { Kitchen::Driver::Ec2.new(config) }
43
44
 
@@ -223,9 +224,83 @@ describe Kitchen::Driver::Ec2 do
223
224
  end
224
225
  end
225
226
 
227
+ describe "#wait_until_ready" do
228
+ let(:hostname) { "0.0.0.0" }
229
+ let(:msg) { "to become ready" }
230
+ let(:aws_instance) { double("aws instance") }
231
+
232
+ before do
233
+ config[:interface] = :i
234
+ expect(driver).to receive(:wait_with_destroy).with(server, state, msg).and_yield(aws_instance)
235
+ expect(driver).to receive(:hostname).with(aws_instance, :i).and_return(hostname)
236
+ end
237
+
238
+ after do
239
+ expect(state[:hostname]).to eq(hostname)
240
+ end
241
+
242
+ it "first checks instance existence" do
243
+ expect(aws_instance).to receive(:exists?).and_return(false)
244
+ expect(driver.wait_until_ready(server, state)).to eq(false)
245
+ end
246
+
247
+ it "second checks instance state" do
248
+ expect(aws_instance).to receive(:exists?).and_return(true)
249
+ expect(aws_instance).to receive_message_chain("state.name").and_return("nope")
250
+ expect(driver.wait_until_ready(server, state)).to eq(false)
251
+ end
252
+
253
+ it "third checks hostname" do
254
+ expect(aws_instance).to receive(:exists?).and_return(true)
255
+ expect(aws_instance).to receive_message_chain("state.name").and_return("running")
256
+ expect(driver.wait_until_ready(server, state)).to eq(false)
257
+ end
258
+
259
+ context "when it exists, has a valid state and a valid hostname" do
260
+ let(:hostname) { "host" }
261
+
262
+ it "returns true" do
263
+ expect(aws_instance).to receive(:exists?).and_return(true)
264
+ expect(aws_instance).to receive_message_chain("state.name").and_return("running")
265
+ expect(driver.wait_until_ready(server, state)).to eq(true)
266
+ end
267
+ end
268
+ end
269
+
270
+ describe "#wait_with_destroy" do
271
+ let(:tries) { 111 }
272
+ let(:sleep) { 222 }
273
+ let(:msg) { "msg" }
274
+ given_block = lambda do; end
275
+
276
+ before do
277
+ config[:retryable_sleep] = sleep
278
+ config[:retryable_tries] = tries
279
+ end
280
+
281
+ it "calls wait and exits successfully if there is no error" do
282
+ expect(server).to receive(:wait_until) do |args, &block|
283
+ expect(args[:max_attempts]).to eq(tries)
284
+ expect(args[:delay]).to eq(sleep)
285
+ expect(block).to eq(given_block)
286
+ expect(driver).to receive(:info).with(/#{msg}/)
287
+ args[:before_attempt].call(0)
288
+ end
289
+ driver.wait_with_destroy(server, state, msg, &given_block)
290
+ end
291
+
292
+ it "attempts to destroy the instance if the waiter fails" do
293
+ expect(server).to receive(:wait_until).and_raise(::Aws::Waiters::Errors::WaiterFailed)
294
+ expect(driver).to receive(:destroy).with(state)
295
+ expect(driver).to receive(:error).with(/#{msg}/)
296
+ expect {
297
+ driver.wait_with_destroy(server, state, msg, &given_block)
298
+ }.to raise_error(::Aws::Waiters::Errors::WaiterFailed)
299
+ end
300
+ end
301
+
226
302
  describe "#destroy" do
227
303
  context "when state[:server_id] is nil" do
228
- let(:state) { {} }
229
304
  it "returns nil" do
230
305
  expect(driver.destroy(state)).to eq(nil)
231
306
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kitchen-ec2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.4
4
+ version: 0.9.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fletcher Nichol
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-03 00:00:00.000000000 Z
11
+ date: 2015-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: test-kitchen