kitchen-digitalocean 0.9.0 → 0.9.1

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: 78427c396eb24d16b2db9592aa9deaa0b224858c
4
- data.tar.gz: b514d8afe3e1c558255adfc2236a3bb11aa5fecd
3
+ metadata.gz: 2fe7bdd3909e3ae69b7ba50a20c5e5b2ca191e41
4
+ data.tar.gz: 5f831d21a8ad796d97bf15893d819ac8701a5d49
5
5
  SHA512:
6
- metadata.gz: 68800f8ffe2ebfb87b58b9cc2d40930156a32e8b51d0134cc151546cf3632ae690fc6a5f129ba9aba1704f55c3fa33436d5be05a775fcb4c64b26b0b2cb5ddbd
7
- data.tar.gz: c31f73d02199d4b08c5bd83a0f2c58ed55577bdd8ee5d310f90264fbedbd231247034c50d1fdb014e0fa9bcbaa8ffb6b617563991bfd6b68167a72c54fc36e08
6
+ metadata.gz: 0dd3a4eba799d56a8c108d4ce00d059c7d3b348be9b4fc4ae58e7cd489eb4d52dfd211752405ba58318234d3f2be48631dec4b6618bfc92c638854e6e286cb0b
7
+ data.tar.gz: 42500ab5e6e2d158ccd477b1f2551198fc817367e1e044908e567d13bf8890759c79e471c94af0829ac21e0126279191b9830d39cd2dcbdb7a2e96d279b5f6ac
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 0.9.1 / 2015-06-19
2
+
3
+ * [@olivielpeau](https://github.com/olivielpeau) [PR #40] Destroy properly droplets that are still "new"
4
+
1
5
  # 0.9.0 / 2015-04-17
2
6
 
3
7
  * [@juliandunn](https://github.com/juliandunn) [PR #37] Added the ability to pass user_data into droplet creation.
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/kitchen-digitalocean.png)](http://badge.fury.io/rb/kitchen-digitalocean)
2
2
  [![Build Status](https://travis-ci.org/test-kitchen/kitchen-digitalocean.png?branch=master)](https://travis-ci.org/test-kitchen/kitchen-digitalocean)
3
3
  [![Code Climate](https://codeclimate.com/github/test-kitchen/kitchen-digitalocean.png)](https://codeclimate.com/github/test-kitchen/kitchen-digitalocean)
4
+ [![Coverage Status](https://coveralls.io/repos/test-kitchen/kitchen-digitalocean/badge.svg?branch=master)](https://coveralls.io/r/test-kitchen/kitchen-digitalocean?branch=master)
4
5
  [![Dependency Status](https://gemnasium.com/test-kitchen/kitchen-digitalocean.png)](https://gemnasium.com/test-kitchen/kitchen-digitalocean)
5
6
 
6
7
  # Kitchen::Digitalocean
@@ -21,16 +21,16 @@ Gem::Specification.new do |spec|
21
21
  spec.add_dependency 'test-kitchen', '~> 1.2'
22
22
  spec.add_dependency 'droplet_kit', '~> 1.0'
23
23
 
24
- spec.add_development_dependency 'bundler'
25
- spec.add_development_dependency 'rake'
26
- spec.add_development_dependency 'rubocop'
27
- spec.add_development_dependency 'cane'
28
- spec.add_development_dependency 'countloc'
29
- spec.add_development_dependency 'rspec'
30
- spec.add_development_dependency 'webmock'
31
- spec.add_development_dependency 'simplecov'
32
- spec.add_development_dependency 'simplecov-console'
33
- spec.add_development_dependency 'coveralls'
24
+ spec.add_development_dependency 'bundler', '~> 1.0'
25
+ spec.add_development_dependency 'rake', '~> 10.0'
26
+ spec.add_development_dependency 'rubocop', '~> 0.30'
27
+ spec.add_development_dependency 'cane', '~> 2.6'
28
+ spec.add_development_dependency 'countloc', '~> 0.4'
29
+ spec.add_development_dependency 'rspec', '~> 3.0'
30
+ spec.add_development_dependency 'webmock', '~> 1.2'
31
+ spec.add_development_dependency 'simplecov', '~> 0.9'
32
+ spec.add_development_dependency 'simplecov-console', '~> 0.2'
33
+ spec.add_development_dependency 'coveralls', '~> 0.8'
34
34
  end
35
35
 
36
36
  # vim: ai et ts=2 sts=2 sw=2 ft=ruby
@@ -57,12 +57,13 @@ module Kitchen
57
57
 
58
58
  info("Digital Ocean instance <#{state[:server_id]}> created.")
59
59
 
60
- while true
60
+ loop do
61
61
  sleep 8
62
62
  droplet = client.droplets.find(id: state[:server_id])
63
63
 
64
64
  break if droplet && droplet.networks[:v4] && droplet.networks[:v4].any? { |n| n[:type] == 'public' }
65
65
  end
66
+ droplet ||= client.droplets.find(id: state[:server_id])
66
67
 
67
68
  state[:hostname] = droplet.networks[:v4]
68
69
  .find { |n| n[:type] == 'public' }['ip_address']
@@ -74,7 +75,21 @@ module Kitchen
74
75
  def destroy(state)
75
76
  return if state[:server_id].nil?
76
77
 
77
- client.droplets.delete(id: state[:server_id])
78
+ # A new droplet cannot be destroyed before it is active
79
+ # Retry destroying the droplet as long as its status is "new"
80
+ loop do
81
+ droplet = client.droplets.find(id: state[:server_id])
82
+
83
+ break if !droplet
84
+ if droplet.status != 'new'
85
+ client.droplets.delete(id: state[:server_id])
86
+ break
87
+ end
88
+
89
+ info("Waiting on Digital Ocean instance <#{state[:server_id]}> to be active to destroy it, retrying in 8 seconds")
90
+ sleep 8
91
+ end
92
+
78
93
  info("Digital Ocean instance <#{state[:server_id]}> destroyed.")
79
94
  state.delete(:server_id)
80
95
  state.delete(:hostname)
@@ -127,7 +142,7 @@ module Kitchen
127
142
 
128
143
  if resp.class != DropletKit::Droplet
129
144
  error JSON.parse(resp)['message']
130
- error "Please check your access token is set correctly."
145
+ error 'Please check your access token is set correctly.'
131
146
  else
132
147
  resp
133
148
  end
@@ -19,7 +19,7 @@
19
19
  module Kitchen
20
20
  module Driver
21
21
  # Version string for Digital Ocean Kitchen driver
22
- DIGITALOCEAN_VERSION = '0.9.0'
22
+ DIGITALOCEAN_VERSION = '0.9.1'
23
23
  end
24
24
  end
25
25
 
@@ -51,7 +51,7 @@ describe Kitchen::Driver::Digitalocean do
51
51
 
52
52
  describe '#initialize'do
53
53
  context 'default options' do
54
- it 'defaults to the smallest flavor size' do
54
+ it 'defaults to the smallest size' do
55
55
  expect(driver[:size]).to eq('512mb')
56
56
  end
57
57
 
@@ -88,7 +88,7 @@ describe Kitchen::Driver::Digitalocean do
88
88
  context 'overridden options' do
89
89
  config = {
90
90
  image: 'debian-7-0-x64',
91
- flavor: '1gb',
91
+ size: '1gb',
92
92
  ssh_key_ids: '5678',
93
93
  username: 'admin',
94
94
  port: '2222',
@@ -174,6 +174,8 @@ describe Kitchen::Driver::Digitalocean do
174
174
 
175
175
  context 'a live server that needs to be destroyed' do
176
176
  it 'destroys the server' do
177
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets/12345")
178
+ .to_return(find)
177
179
  stub_request(:delete, 'https://api.digitalocean.com/v2/droplets/12345')
178
180
  .to_return(delete)
179
181
  expect(state).to receive(:delete).with(:server_id)
@@ -212,6 +214,8 @@ describe Kitchen::Driver::Digitalocean do
212
214
  end
213
215
 
214
216
  it 'does not try to destroy the server again' do
217
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets/12345")
218
+ .to_return(find)
215
219
  stub_request(:delete, 'https://api.digitalocean.com/v2/droplets/12345')
216
220
  .to_return(delete)
217
221
  allow_message_expectations_on_nil
@@ -220,40 +224,37 @@ describe Kitchen::Driver::Digitalocean do
220
224
  end
221
225
  end
222
226
 
223
- # describe '#create_server' do
224
- # let(:config) do
225
- # {
226
- # server_name: 'test server',
227
- # image: 'debian-7-0-x64',
228
- # size: '2gb',
229
- # region: 'nyc3',
230
- # private_networking: true,
231
- # ssh_key_ids: '1234'
232
- # }
233
- # end
234
- # before(:each) do
235
- # @expected = config.merge(name: config[:server_name])
236
- # @expected.delete_if do |k, _v|
237
- # k == :server_name
238
- # end
239
- # end
240
- # let(:servers) do
241
- # s = double('servers')
242
- # allow(s).to receive(:create) { |arg| arg }
243
- # s
244
- # end
245
- # let(:create_server) { double(servers: servers) }
246
- # let(:driver) do
247
- # d = Kitchen::Driver::Digitalocean.new(config)
248
- # d.instance = instance
249
- # allow(d).to receive(:create_server).and_return(create_server)
250
- # d
251
- # end
252
-
253
- # it 'creates the server using a compute connection' do
254
- # expect(driver.send(:create_server)).to eq(@expected)
255
- # end
256
- # end
227
+ describe '#create_server' do
228
+ let(:config) do
229
+ {
230
+ server_name: 'hello',
231
+ image: 'debian-7-0-x64',
232
+ size: '1gb',
233
+ region: 'nyc3'
234
+ }
235
+ end
236
+ before(:each) do
237
+ @expected = config.merge(name: config[:server_name])
238
+ @expected.delete_if do |k, _|
239
+ k == :server_name
240
+ end
241
+ end
242
+ let(:droplets) do
243
+ s = double('droplets')
244
+ allow(s).to receive(:create) { |arg| arg }
245
+ s
246
+ end
247
+ let(:client) { double(droplets: droplets) }
248
+
249
+ before(:each) do
250
+ allow_any_instance_of(described_class).to receive(:client)
251
+ .and_return(client)
252
+ end
253
+
254
+ it 'creates the server using a compute connection' do
255
+ expect(driver.send(:create_server).to_h).to include(@expected)
256
+ end
257
+ end
257
258
 
258
259
  describe '#default_name' do
259
260
  let(:login) { 'user' }
@@ -0,0 +1,81 @@
1
+ HTTP/1.1 200 OK
2
+ Server: cloudflare-nginx
3
+ Date: Thu, 21 Aug 2014 23:51:40 GMT
4
+ Content-Type: application/json; charset=utf-8
5
+ Transfer-Encoding: chunked
6
+ Connection: keep-alive
7
+ Set-Cookie: __cfduid=de2ed0d345ecce441bb505881fcf50d341408665100399; expires=Mon, 23-Dec-2019 23:50:00 GMT; path=/; domain=.digitalocean.com; HttpOnly
8
+ Status: 200 OK
9
+ X-Frame-Options: SAMEORIGIN
10
+ X-XSS-Protection: 1; mode=block
11
+ X-Content-Type-Options: nosniff
12
+ RateLimit-Limit: 5000
13
+ RateLimit-Remaining: 4983
14
+ RateLimit-Reset: 1432053600
15
+ Cache-Control: max-age=0, private, must-revalidate
16
+ X-Request-Id: 49ed05f3-328b-406c-99b0-e3a2ddadafa3
17
+ X-Runtime: 0.236491
18
+ CF-RAY: 1e90fbb7d41b0707-SJC
19
+
20
+ {
21
+ "droplet": {
22
+ "id": 1234,
23
+ "name": "test-droplet",
24
+ "memory": 512,
25
+ "vcpus": 1,
26
+ "disk": 20,
27
+ "locked": false,
28
+ "status": "active",
29
+ "kernel": {
30
+ "id": 4703,
31
+ "name": "Ubuntu 14.04 x64 vmlinuz-3.13.0-52-generic",
32
+ "version": "3.13.0-52-generic"
33
+ },
34
+ "created_at": "2014-05-02T18:16:21Z",
35
+ "features": [
36
+ "virtio"
37
+ ],
38
+ "backup_ids": [],
39
+ "next_backup_window": null,
40
+ "snapshot_ids": [],
41
+ "image": {
42
+ "id": 11836690,
43
+ "name": "14.04 x64",
44
+ "distribution": "Ubuntu",
45
+ "slug": "ubuntu-14-04-x64",
46
+ "public": true,
47
+ "regions": ["nyc1", "ams1", "sfo1", "nyc2", "ams2", "sgp1", "lon1", "nyc3", "ams3", "fra1"],
48
+ "created_at": "2015-05-12T23:51:05Z",
49
+ "min_disk_size": 20,
50
+ "type": "snapshot"
51
+ },
52
+ "size": {
53
+ "slug": "512mb",
54
+ "memory": 512,
55
+ "vcpus": 1,
56
+ "disk": 20,
57
+ "transfer": 1.0,
58
+ "price_monthly": 5.0,
59
+ "price_hourly": 0.00744,
60
+ "regions": ["nyc1", "sgp1", "ams1", "sfo1", "nyc2", "lon1", "nyc3", "ams3", "ams2", "fra1"],
61
+ "available": true
62
+ },
63
+ "size_slug": "512mb",
64
+ "networks": {
65
+ "v4": [{
66
+ "ip_address": "45.55.141.244",
67
+ "netmask": "255.255.192.0",
68
+ "gateway": "45.55.128.1",
69
+ "type": "public"
70
+ }],
71
+ "v6": []
72
+ },
73
+ "region": {
74
+ "name": "New York 3",
75
+ "slug": "nyc3",
76
+ "sizes": ["32gb", "16gb", "2gb", "1gb", "4gb", "8gb", "512mb", "64gb", "48gb"],
77
+ "features": ["virtio", "private_networking", "backups", "ipv6", "metadata"],
78
+ "available": true
79
+ }
80
+ }
81
+ }
data/spec/spec_helper.rb CHANGED
@@ -45,4 +45,8 @@ def auth_error
45
45
  File.read(File.join(File.dirname(__FILE__), 'mocks', 'auth_error.txt'))
46
46
  end
47
47
 
48
+ def find
49
+ File.read(File.join(File.dirname(__FILE__), 'mocks', 'find.txt'))
50
+ end
51
+
48
52
  # vim: ai et ts=2 sts=2 sw=2 ft=ruby
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kitchen-digitalocean
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Fitzgerald
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-17 00:00:00.000000000 Z
11
+ date: 2015-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: test-kitchen
@@ -42,142 +42,142 @@ dependencies:
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '1.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: '1.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: '10.0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: '10.0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rubocop
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0'
75
+ version: '0.30'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">="
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0'
82
+ version: '0.30'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: cane
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '0'
89
+ version: '2.6'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '0'
96
+ version: '2.6'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: countloc
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ">="
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '0'
103
+ version: '0.4'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ">="
108
+ - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '0'
110
+ version: '0.4'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rspec
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ">="
115
+ - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '0'
117
+ version: '3.0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ">="
122
+ - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '0'
124
+ version: '3.0'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: webmock
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - ">="
129
+ - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: '0'
131
+ version: '1.2'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - ">="
136
+ - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: '0'
138
+ version: '1.2'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: simplecov
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - ">="
143
+ - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: '0'
145
+ version: '0.9'
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - ">="
150
+ - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: '0'
152
+ version: '0.9'
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: simplecov-console
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
- - - ">="
157
+ - - "~>"
158
158
  - !ruby/object:Gem::Version
159
- version: '0'
159
+ version: '0.2'
160
160
  type: :development
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
- - - ">="
164
+ - - "~>"
165
165
  - !ruby/object:Gem::Version
166
- version: '0'
166
+ version: '0.2'
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: coveralls
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
- - - ">="
171
+ - - "~>"
172
172
  - !ruby/object:Gem::Version
173
- version: '0'
173
+ version: '0.8'
174
174
  type: :development
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
- - - ">="
178
+ - - "~>"
179
179
  - !ruby/object:Gem::Version
180
- version: '0'
180
+ version: '0.8'
181
181
  description: A Test Kitchen Driver for Digital Ocean
182
182
  email:
183
183
  - greg@gregf.org
@@ -200,6 +200,7 @@ files:
200
200
  - spec/mocks/auth_error.txt
201
201
  - spec/mocks/create.txt
202
202
  - spec/mocks/delete.txt
203
+ - spec/mocks/find.txt
203
204
  - spec/spec_helper.rb
204
205
  homepage: https://github.com/test-kitchen/kitchen-digitalocean
205
206
  licenses:
@@ -221,7 +222,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
221
222
  version: '0'
222
223
  requirements: []
223
224
  rubyforge_project:
224
- rubygems_version: 2.4.6
225
+ rubygems_version: 2.4.8
225
226
  signing_key:
226
227
  specification_version: 4
227
228
  summary: A Test Kitchen Driver for Digital Ocean
@@ -230,4 +231,5 @@ test_files:
230
231
  - spec/mocks/auth_error.txt
231
232
  - spec/mocks/create.txt
232
233
  - spec/mocks/delete.txt
234
+ - spec/mocks/find.txt
233
235
  - spec/spec_helper.rb