kitchen-ec2 0.9.2 → 0.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 28b62273c1ee5fb17313f193f401ddef8298c801
4
- data.tar.gz: fd9d69df55c2f0e669e00cf41b050ac41b2f8492
3
+ metadata.gz: 21b2743d4aad92b8fb4f5d02d3619c0b1b83c6eb
4
+ data.tar.gz: 6dc57776d894c34fad0da0701e4c6d4a59076698
5
5
  SHA512:
6
- metadata.gz: 6962df92e7ffd49fb287f84d325950484729e777bc54c90380fd8e699caa273631e8003ca597de9cb274020519f187d65c23e916eaa3f2be9a0c8cb34774d7dd
7
- data.tar.gz: 47489808c46515f9e0541e7fe060b90bf7f94012398765d49ad20037c9eca1dc2e61b18bed6badf2cbf2434cb0d5a3c036a50e738f90f497dbf175ef3463ffb0
6
+ metadata.gz: 3358dc9d1df3053b5f6efaf4f4ec2673f46eb3b81a1b81d080a22f92203bf851abe1133429a16dd5d78adf0ca1cf5d62298c632b011b58d1ce3d9651e4dcc950
7
+ data.tar.gz: 430c0e2766480db4d1053afa73f2b609d9379e283d139fe2e6a36cfbf9f21e386ab0853ec26b417ec5fcfda6e640775b0b31a5af5c80c6f58961d4457498bd62
data/.cane CHANGED
@@ -1,2 +1,2 @@
1
- --abc-max 30
1
+ --abc-max 40
2
2
  --style-measure 100
data/CHANGELOG.md CHANGED
@@ -1,8 +1,18 @@
1
- ## 0.9.2 / 2015-05-26
1
+ ## 0.9.3 / 2015-05-29
2
2
 
3
3
  ### Bug Fixes
4
4
 
5
- * Pull Request [#131][]: Adding back support for a proxy via config `http_proxy` which defaults to `ENV['HTTP_PROXY']`
5
+ * Pull Request [#140][]: Wait for an instance to pass existence check before tagging it
6
+
7
+ ### New Features
8
+
9
+ ### Improvements
10
+
11
+ ## 0.9.2 / 2015-05-27
12
+
13
+ ### Bug Fixes
14
+
15
+ * Pull Request [#131][]: Adding back support for a proxy via config `http_proxy` which defaults to `ENV[‘HTTPS_PROXY’] || ENV['HTTP_PROXY']`
6
16
  * Pull Request [#128][]:
7
17
  * Fixes [#121][]: Fixing error `Network interfaces and an instance-level security groups may not be specified on the same request`
8
18
  * Fixes [#127][]: User Data content should be base64 encoded when passed to aws sdk
@@ -143,6 +153,7 @@
143
153
  [#127]: https://github.com/test-kitchen/kitchen-ec2/issues/127
144
154
  [#128]: https://github.com/test-kitchen/kitchen-ec2/issues/128
145
155
  [#131]: https://github.com/test-kitchen/kitchen-ec2/issues/131
156
+ [#140]: https://github.com/test-kitchen/kitchen-ec2/issues/140
146
157
  [@Atalanta]: https://github.com/Atalanta
147
158
  [@Igorshp]: https://github.com/Igorshp
148
159
  [@JamesAwesome]: https://github.com/JamesAwesome
@@ -188,6 +188,10 @@ module Kitchen
188
188
  server = submit_server
189
189
  end
190
190
  info("Instance <#{server.id}> requested.")
191
+ ec2.client.wait_until(
192
+ :instance_exists,
193
+ :instance_ids => [server.id]
194
+ )
191
195
  tag_server(server)
192
196
 
193
197
  state[:server_id] = server.id
@@ -234,6 +238,7 @@ module Kitchen
234
238
  ec2.client.cancel_spot_instance_requests(
235
239
  :spot_instance_request_ids => [state[:spot_request_id]]
236
240
  )
241
+ state.delete(:spot_request_id)
237
242
  end
238
243
  info("EC2 instance <#{state[:server_id]}> destroyed.")
239
244
  state.delete(:server_id)
@@ -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.2"
24
+ EC2_VERSION = "0.9.3"
25
25
  end
26
26
  end
@@ -32,6 +32,12 @@ describe Kitchen::Driver::Ec2 do
32
32
  let(:provisioner) { Kitchen::Provisioner::Dummy.new }
33
33
  let(:transport) { Kitchen::Transport::Dummy.new }
34
34
  let(:state_file) { double("state_file") }
35
+ let(:generator) { instance_double(Kitchen::Driver::Aws::InstanceGenerator) }
36
+ # There is too much name overlap I let creep in - my `client` is actually
37
+ # a wrapper around the actual ec2 client
38
+ let(:actual_client) { double("actual ec2 client") }
39
+ let(:client) { double(Kitchen::Driver::Aws::Client, :client => actual_client) }
40
+ let(:server) { double("aws server object") }
35
41
 
36
42
  let(:driver) { Kitchen::Driver::Ec2.new(config) }
37
43
 
@@ -48,6 +54,11 @@ describe Kitchen::Driver::Ec2 do
48
54
  )
49
55
  end
50
56
 
57
+ before do
58
+ allow(Kitchen::Driver::Aws::InstanceGenerator).to receive(:new).and_return(generator)
59
+ allow(Kitchen::Driver::Aws::Client).to receive(:new).and_return(client)
60
+ end
61
+
51
62
  it "driver api_version is 2" do
52
63
  expect(driver.diagnose_plugin[:api_version]).to eq(2)
53
64
  end
@@ -159,4 +170,87 @@ describe Kitchen::Driver::Ec2 do
159
170
  end
160
171
  end
161
172
 
173
+ describe "#submit_server" do
174
+ it "submits the server request" do
175
+ expect(generator).to receive(:ec2_instance_data).and_return({})
176
+ expect(client).to receive(:create_instance).with(:min_count => 1, :max_count => 1)
177
+ driver.submit_server
178
+ end
179
+ end
180
+
181
+ describe "#submit_spot" do
182
+ let(:state) { {} }
183
+ let(:response) {
184
+ { :spot_instance_requests => [{ :spot_instance_request_id => "id" }] }
185
+ }
186
+
187
+ it "submits the server request" do
188
+ expect(generator).to receive(:ec2_instance_data).and_return({})
189
+ expect(actual_client).to receive(:request_spot_instances).with(
190
+ :spot_price => "", :launch_specification => {}
191
+ ).and_return(response)
192
+ expect(actual_client).to receive(:wait_until)
193
+ expect(client).to receive(:get_instance_from_spot_request).with("id")
194
+ driver.submit_spot(state)
195
+ expect(state).to eq(:spot_request_id => "id")
196
+ end
197
+ end
198
+
199
+ describe "#tag_server" do
200
+ it "tags the server" do
201
+ config[:tags] = { :key1 => :value1, :key2 => :value2 }
202
+ expect(server).to receive(:create_tags).with(
203
+ :tags => [
204
+ { :key => :key1, :value => :value1 },
205
+ { :key => :key2, :value => :value2 }
206
+ ]
207
+ )
208
+ driver.tag_server(server)
209
+ end
210
+ end
211
+
212
+ describe "#destroy" do
213
+ context "when state[:server_id] is nil" do
214
+ let(:state) { {} }
215
+ it "returns nil" do
216
+ expect(driver.destroy(state)).to eq(nil)
217
+ end
218
+ end
219
+
220
+ context "when state has a normal server_id" do
221
+ let(:state) { { :server_id => "id", :hostname => "name" } }
222
+
223
+ context "the server is already destroyed" do
224
+ it "does nothing" do
225
+ expect(client).to receive(:get_instance).with("id").and_return nil
226
+ driver.destroy(state)
227
+ expect(state).to eq({})
228
+ end
229
+ end
230
+
231
+ it "destroys the server" do
232
+ expect(client).to receive(:get_instance).with("id").and_return(server)
233
+ expect(instance).to receive_message_chain("transport.connection.close")
234
+ expect(server).to receive(:terminate)
235
+ driver.destroy(state)
236
+ expect(state).to eq({})
237
+ end
238
+ end
239
+
240
+ context "when state has a spot request" do
241
+ let(:state) { { :server_id => "id", :hostname => "name", :spot_request_id => "spot" } }
242
+
243
+ it "destroys the server" do
244
+ expect(client).to receive(:get_instance).with("id").and_return(server)
245
+ expect(instance).to receive_message_chain("transport.connection.close")
246
+ expect(server).to receive(:terminate)
247
+ expect(actual_client).to receive(:cancel_spot_instance_requests).with(
248
+ :spot_instance_request_ids => ["spot"]
249
+ )
250
+ driver.destroy(state)
251
+ expect(state).to eq({})
252
+ end
253
+ end
254
+ end
255
+
162
256
  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.2
4
+ version: 0.9.3
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-05-27 00:00:00.000000000 Z
11
+ date: 2015-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: test-kitchen