kitchen-digitalocean 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +88 -66
- data/data/images.json +14 -0
- data/lib/kitchen/driver/digitalocean.rb +46 -12
- data/lib/kitchen/driver/digitalocean_version.rb +1 -1
- data/spec/kitchen/driver/digitalocean_spec.rb +101 -70
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b165d6d82fa2603ed9cdb1afbf284a75d10b2b1
|
4
|
+
data.tar.gz: f4555427be6e7402c2d5a4db899d9d563febe2fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b433accd2962cf696ecf0aa187661265a53bbf152ca20969df0b2c06ee54c6c25ea146d6a21feabfd1339859b283928b33a7813e6bf53d93ad7a6019b423edb7
|
7
|
+
data.tar.gz: b9626c7fc0cba8b540efe016c43f6d8be988d063bc89abd436309393d0562cea7605059b865d66e5decd67388b8253ceb50d8a2bb33d81e5f4bc40768b1bfb6d
|
data/README.md
CHANGED
@@ -2,43 +2,92 @@
|
|
2
2
|
|
3
3
|
# Kitchen::Digitalocean
|
4
4
|
|
5
|
-
A
|
5
|
+
A Test Kitchen Driver for Digital Ocean
|
6
6
|
|
7
7
|
Shamelessly copied from [RoboticCheese](https://github.com/RoboticCheese)'s
|
8
8
|
awesome work on an [Rackspace driver](https://github.com/RoboticCheese/kitchen-rackspace).
|
9
9
|
|
10
|
-
|
10
|
+
# Requirements
|
11
11
|
|
12
|
-
|
12
|
+
There are no external system requirements for this driver. However you will need access to an [DigitalOcean](https://digitalocean.com/) account.
|
13
13
|
|
14
|
-
|
14
|
+
# Installation and Setup
|
15
15
|
|
16
|
-
|
16
|
+
You'll need to install the gem on your development machine.
|
17
17
|
|
18
|
-
|
18
|
+
```Bash
|
19
|
+
gem install kitchen-digitalocean
|
20
|
+
```
|
19
21
|
|
20
|
-
|
22
|
+
or add it to your Gemfile if you are using [Bundler](http://bundler.io/)
|
21
23
|
|
22
|
-
|
24
|
+
```ruby
|
25
|
+
source https://rubygems.org
|
23
26
|
|
24
|
-
|
27
|
+
gem 'test-kitchen'
|
28
|
+
gem 'kitchen-digitalocean'
|
29
|
+
```
|
25
30
|
|
26
|
-
|
31
|
+
At minimum, you'll need to tell test-kitchen to use the digitalocean driver.
|
27
32
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
+
```ruby
|
34
|
+
---
|
35
|
+
driver:
|
36
|
+
- name: digitalocean
|
37
|
+
platforms:
|
38
|
+
- name: ubuntu-12-10
|
39
|
+
```
|
33
40
|
|
34
|
-
|
35
|
-
|
41
|
+
You also have the option of providing some configs via environment variables.
|
42
|
+
|
43
|
+
```bash
|
44
|
+
export DIGITALOCEAN_CLIENT_ID="1234"
|
45
|
+
export DIGITALOCEAN_API_KEY="5678"
|
46
|
+
export SSH_KEY_IDS="1234, 5678"
|
47
|
+
```
|
48
|
+
|
49
|
+
Please refer to the [Getting Started Guide](http://kitchen.ci/) for any further documentation.
|
50
|
+
|
51
|
+
# Default Configuration
|
52
|
+
|
53
|
+
This driver can determine the image_id for a select number of platforms in each region. Currently, the following platform names are supported:
|
54
|
+
|
55
|
+
```ruby
|
56
|
+
---
|
57
|
+
platforms:
|
58
|
+
- name: ubuntu-10.04
|
59
|
+
- name: ubuntu-12.10
|
60
|
+
- name: ubuntu-13.04
|
61
|
+
- name: ubuntu-13.10
|
62
|
+
- name: centos-5.8
|
63
|
+
- name: centos-6.4
|
64
|
+
- name: centos-6.5
|
65
|
+
- name: debian-6.0
|
66
|
+
- name: debian-7.0
|
67
|
+
- name: fedora-17
|
68
|
+
- name: fedora-19
|
69
|
+
- name: archlinux-2013.05
|
70
|
+
```
|
71
|
+
|
72
|
+
This will effectively generate a configuration similar to:
|
73
|
+
|
74
|
+
```ruby
|
75
|
+
---
|
76
|
+
platforms:
|
77
|
+
- name: ubuntu-10.04
|
78
|
+
driver_config:
|
79
|
+
image_id: 14097
|
80
|
+
- name: ubuntu-12.10
|
81
|
+
driver_config:
|
82
|
+
image_id: 473123
|
83
|
+
# ...
|
84
|
+
- name: centos-5.8
|
85
|
+
driver_config:
|
86
|
+
image_id: 1601
|
87
|
+
# ...
|
88
|
+
```
|
36
89
|
|
37
|
-
|
38
|
-
flavor_id: [SERVER FLAVOR ID]
|
39
|
-
name: [A UNIQUE SERVER NAME]
|
40
|
-
region_id: [A VALID DIGITAL OCEAN REGION ID]
|
41
|
-
ssh_key_ids: [COMMA SEPERATED SSH KEY IDS FROM DIGITAL OCEAN]
|
90
|
+
For specific default values, please consult [images.json](https://github.com/gregf/kitchen-digitalocean/blob/master/data/images.json).
|
42
91
|
|
43
92
|
### List of Regions
|
44
93
|
|
@@ -49,47 +98,6 @@ ID Name
|
|
49
98
|
3 San Francisco 1
|
50
99
|
4 New York 2
|
51
100
|
```
|
52
|
-
|
53
|
-
### List of Images
|
54
|
-
```shell
|
55
|
-
ID Distribution Name
|
56
|
-
361740 Arch Linux Arch Linux 2013.05 x32
|
57
|
-
350424 Arch Linux Arch Linux 2013.05 x64
|
58
|
-
1602 CentOS CentOS 5.8 x32
|
59
|
-
1601 CentOS CentOS 5.8 x64
|
60
|
-
376568 CentOS CentOS 6.4 x32
|
61
|
-
562354 CentOS CentOS 6.4 x64
|
62
|
-
12575 Debian Debian 6.0 x32
|
63
|
-
12573 Debian Debian 6.0 x64
|
64
|
-
303619 Debian Debian 7.0 x32
|
65
|
-
308287 Debian Debian 7.0 x64
|
66
|
-
32387 Fedora Fedora 17 x32
|
67
|
-
32399 Fedora Fedora 17 x32 Desktop
|
68
|
-
32428 Fedora Fedora 17 x64
|
69
|
-
32419 Fedora Fedora 17 x64 Desktop
|
70
|
-
697056 Fedora Fedora 19 x86
|
71
|
-
696598 Fedora Fedora 19 x86-64
|
72
|
-
1004145 Ubuntu Docker on Ubuntu 13.04 x64
|
73
|
-
959207 Ubuntu Ghost 0.3.3 on Ubuntu 12.04
|
74
|
-
459444 Ubuntu LAMP on Ubuntu 12.04
|
75
|
-
483575 Ubuntu Redmine on Ubuntu 12.04
|
76
|
-
464235 Ubuntu Ruby on Rails on Ubuntu 12.10 (Nginx + Unicorn)
|
77
|
-
14098 Ubuntu Ubuntu 10.04 x32
|
78
|
-
14097 Ubuntu Ubuntu 10.04 x64
|
79
|
-
284211 Ubuntu Ubuntu 12.04 x32
|
80
|
-
284203 Ubuntu Ubuntu 12.04 x64
|
81
|
-
1015250 Ubuntu Ubuntu 12.04.3 x32
|
82
|
-
1015253 Ubuntu Ubuntu 12.04.3 x64
|
83
|
-
433240 Ubuntu Ubuntu 12.10 x32
|
84
|
-
473123 Ubuntu Ubuntu 12.10 x64
|
85
|
-
473136 Ubuntu Ubuntu 12.10 x64 Desktop
|
86
|
-
345791 Ubuntu Ubuntu 13.04 x32
|
87
|
-
350076 Ubuntu Ubuntu 13.04 x64
|
88
|
-
962304 Ubuntu Ubuntu 13.10 x32
|
89
|
-
961965 Ubuntu Ubuntu 13.10 x64
|
90
|
-
1061995 Ubuntu Wordpress on Ubuntu 12.10
|
91
|
-
```
|
92
|
-
|
93
101
|
### List of Flavors (Sizes)
|
94
102
|
```shell
|
95
103
|
ID Name
|
@@ -104,11 +112,25 @@ ID Name
|
|
104
112
|
68 96GB
|
105
113
|
66 512MB
|
106
114
|
```
|
115
|
+
# Development
|
116
|
+
|
117
|
+
* Source hosted at [GitHub](https://github.com/gregf/kitchen-digitalocean)
|
118
|
+
* Report issues/questions/feature requests on [GitHub Issues](https://github.com/gregf/kitchen-digitalocean/issues)
|
107
119
|
|
108
|
-
|
120
|
+
Pull requests are very welcome! Make sure your patches are well tested.
|
121
|
+
Ideally create a topic branch for every separate change you make. For
|
122
|
+
example:
|
109
123
|
|
110
|
-
1. Fork
|
124
|
+
1. Fork the repo
|
111
125
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
112
|
-
3. Commit your changes (`git commit -am '
|
126
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
113
127
|
4. Push to the branch (`git push origin my-new-feature`)
|
114
128
|
5. Create new Pull Request
|
129
|
+
|
130
|
+
# Authors
|
131
|
+
|
132
|
+
Created and maintained by [Greg Fitzgerald](https://github.com/gregf/) (<greg@gregf.org>)
|
133
|
+
|
134
|
+
# License
|
135
|
+
|
136
|
+
Apache 2.0 (see [LICENSE](https://github.com/gregf/kitchen-digitalocean/blob/master/LICENSE.txt))
|
data/data/images.json
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
{
|
2
|
+
"ubuntu-10.04": "14097",
|
3
|
+
"ubuntu-12.10": "473123",
|
4
|
+
"ubuntu-13.04": "350076",
|
5
|
+
"ubuntu-13.10": "1505699",
|
6
|
+
"centos-5.8": "1601",
|
7
|
+
"centos-6.5": "1646467",
|
8
|
+
"centos-6.4": "562354",
|
9
|
+
"debian-6.0": "12573",
|
10
|
+
"debian-7.0": "308287",
|
11
|
+
"fedora-17": "32428",
|
12
|
+
"fedora-19": "696598",
|
13
|
+
"archlinux-2013.05": "350424"
|
14
|
+
}
|
@@ -28,17 +28,36 @@ module Kitchen
|
|
28
28
|
#
|
29
29
|
# @author Greg Fitzgerald <greg@gregf.org>
|
30
30
|
class Digitalocean < Kitchen::Driver::SSHBase
|
31
|
-
default_config :image_id, '25489'
|
32
31
|
default_config :flavor_id, '66'
|
33
|
-
default_config :name, nil
|
34
|
-
default_config :ssh_key_ids, nil
|
35
32
|
default_config :region_id, '1'
|
36
33
|
default_config :username, 'root'
|
37
34
|
default_config :port, '22'
|
38
|
-
|
35
|
+
|
36
|
+
default_config :image_id do |driver|
|
37
|
+
driver.default_image
|
38
|
+
end
|
39
|
+
|
40
|
+
default_config :server_name do |driver|
|
41
|
+
driver.default_name
|
42
|
+
end
|
43
|
+
|
44
|
+
default_config :digitalocean_client_id do |driver|
|
45
|
+
ENV['DIGITALOCEAN_CLIENT_ID']
|
46
|
+
end
|
47
|
+
|
48
|
+
default_config :digitalocean_api_key do |driver|
|
49
|
+
ENV['DIGITALOCEAN_API_KEY']
|
50
|
+
end
|
51
|
+
|
52
|
+
default_config :ssh_key_ids do |driver|
|
53
|
+
ENV['SSH_KEY_IDS']
|
54
|
+
end
|
55
|
+
|
56
|
+
required_config :digitalocean_client_id
|
57
|
+
required_config :digitalocean_api_key
|
58
|
+
required_config :ssh_key_ids
|
39
59
|
|
40
60
|
def create(state)
|
41
|
-
config[:name] ||= generate_name(instance.name)
|
42
61
|
server = create_server
|
43
62
|
state[:server_id] = server.id
|
44
63
|
|
@@ -61,16 +80,27 @@ module Kitchen
|
|
61
80
|
state.delete(:hostname)
|
62
81
|
end
|
63
82
|
|
83
|
+
def default_image
|
84
|
+
images[instance.platform.name]
|
85
|
+
end
|
86
|
+
|
87
|
+
def default_name
|
88
|
+
# Generate what should be a unique server name
|
89
|
+
rand_str = Array.new(8) { rand(36).to_s(36) }.join
|
90
|
+
"#{instance.name}-#{Etc.getlogin}-#{Socket.gethostname}-#{rand_str}"
|
91
|
+
end
|
92
|
+
|
64
93
|
private
|
65
94
|
|
66
95
|
def compute
|
67
96
|
debug_compute_config
|
68
97
|
|
69
98
|
server_def = {
|
70
|
-
provider:
|
99
|
+
provider: 'Digitalocean',
|
71
100
|
digitalocean_api_key: config[:digitalocean_api_key],
|
72
101
|
digitalocean_client_id: config[:digitalocean_client_id]
|
73
102
|
}
|
103
|
+
|
74
104
|
Fog::Compute.new(server_def)
|
75
105
|
end
|
76
106
|
|
@@ -78,7 +108,7 @@ module Kitchen
|
|
78
108
|
debug_server_config
|
79
109
|
|
80
110
|
compute.servers.create(
|
81
|
-
name: config[:
|
111
|
+
name: config[:server_name],
|
82
112
|
image_id: config[:image_id],
|
83
113
|
flavor_id: config[:flavor_id],
|
84
114
|
region_id: config[:region_id],
|
@@ -86,14 +116,18 @@ module Kitchen
|
|
86
116
|
)
|
87
117
|
end
|
88
118
|
|
89
|
-
def
|
90
|
-
|
91
|
-
|
92
|
-
|
119
|
+
def images
|
120
|
+
@images ||= begin
|
121
|
+
json_file = File.expand_path(
|
122
|
+
File.join(%w{.. .. .. .. data images.json}),
|
123
|
+
__FILE__
|
124
|
+
)
|
125
|
+
JSON.load(IO.read(json_file))
|
126
|
+
end
|
93
127
|
end
|
94
128
|
|
95
129
|
def debug_server_config
|
96
|
-
debug("digitalocean:name #{config[:
|
130
|
+
debug("digitalocean:name #{config[:server_name]}")
|
97
131
|
debug("digitalocean:image_id #{config[:image_id]}")
|
98
132
|
debug("digitalocean:flavor_id #{config[:flavor_id]}")
|
99
133
|
debug("digitalocean:region_id #{config[:region_id]}")
|
@@ -1,8 +1,8 @@
|
|
1
|
-
#
|
2
1
|
# -*- encoding: utf-8 -*-
|
3
|
-
# Author:: Greg Fitzgerald (<greg@gregf.org>)
|
4
2
|
#
|
5
|
-
#
|
3
|
+
# Author:: Jonathan Hartman (<j@p4nt5.com>)
|
4
|
+
#
|
5
|
+
# Copyright (C) 2013, Jonathan Hartman
|
6
6
|
#
|
7
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
8
|
# you may not use this file except in compliance with the License.
|
@@ -16,20 +16,27 @@
|
|
16
16
|
# See the License for the specific language governing permissions and
|
17
17
|
# limitations under the License.
|
18
18
|
|
19
|
+
require_relative '../../spec_helper'
|
20
|
+
|
19
21
|
require 'logger'
|
20
22
|
require 'stringio'
|
21
23
|
require 'rspec'
|
22
24
|
require 'kitchen'
|
23
|
-
require_relative '../../spec_helper'
|
24
25
|
|
25
26
|
describe Kitchen::Driver::Digitalocean do
|
26
27
|
let(:logged_output) { StringIO.new }
|
27
28
|
let(:logger) { Logger.new(logged_output) }
|
28
29
|
let(:config) { Hash.new }
|
29
30
|
let(:state) { Hash.new }
|
31
|
+
let(:platform_name) { 'ubuntu' }
|
30
32
|
|
31
33
|
let(:instance) do
|
32
|
-
double(
|
34
|
+
double(
|
35
|
+
:name => 'potatoes',
|
36
|
+
:logger => logger,
|
37
|
+
:to_str => 'instance',
|
38
|
+
:platform => double(:name => platform_name)
|
39
|
+
)
|
33
40
|
end
|
34
41
|
|
35
42
|
let(:driver) do
|
@@ -38,51 +45,76 @@ describe Kitchen::Driver::Digitalocean do
|
|
38
45
|
d
|
39
46
|
end
|
40
47
|
|
48
|
+
before(:each) do
|
49
|
+
ENV['DIGITALOCEAN_CLIENT_ID'] = 'clientid'
|
50
|
+
ENV['DIGITALOCEAN_API_KEY'] = 'apikey'
|
51
|
+
ENV['SSH_KEY_IDS'] = '1234'
|
52
|
+
end
|
53
|
+
|
41
54
|
describe '#initialize'do
|
42
55
|
context 'default options' do
|
43
|
-
it 'defaults to
|
44
|
-
expect(driver[:image_id]).to eq('25489')
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'defaults to a 512MB flavor size' do
|
56
|
+
it 'defaults to the smallest flavor size' do
|
48
57
|
expect(driver[:flavor_id]).to eq('66')
|
49
58
|
end
|
50
59
|
|
51
|
-
it 'defaults to no SSH Key ID' do
|
52
|
-
expect(driver[:ssh_key_ids]).to eq(nil)
|
53
|
-
end
|
54
|
-
|
55
60
|
it 'defaults to SSH with root user on port 22' do
|
56
61
|
expect(driver[:username]).to eq('root')
|
57
62
|
expect(driver[:port]).to eq('22')
|
58
63
|
end
|
59
64
|
|
60
|
-
it 'defaults to
|
61
|
-
expect(driver[:
|
65
|
+
it 'defaults to a random server name' do
|
66
|
+
expect(driver[:server_name]).to be_a(String)
|
62
67
|
end
|
63
68
|
|
64
|
-
it 'defaults to
|
69
|
+
it 'defaults to region id 1' do
|
65
70
|
expect(driver[:region_id]).to eq('1')
|
66
71
|
end
|
72
|
+
|
73
|
+
it 'defaults to SSH Key Ids from $SSH_KEY_IDS' do
|
74
|
+
expect(driver[:ssh_key_ids]).to eq('1234')
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'defaults to Client ID from $DIGITALOCEAN_CLIENT_ID' do
|
78
|
+
expect(driver[:digitalocean_client_id]).to eq('clientid')
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'defaults to API key from $DIGITALOCEAN_API_KEY' do
|
82
|
+
expect(driver[:digitalocean_api_key]).to eq('apikey')
|
83
|
+
end
|
67
84
|
end
|
68
85
|
|
69
|
-
context '
|
70
|
-
let(:
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
ssh_key_ids: '1234',
|
75
|
-
username: 'admin',
|
76
|
-
port: '2222',
|
77
|
-
name: 'puppy',
|
78
|
-
region_id: '3'
|
79
|
-
}
|
86
|
+
context 'name is ubuntu-12.10' do
|
87
|
+
let(:platform_name) { 'ubuntu-12.10' }
|
88
|
+
|
89
|
+
it 'defaults to the correct image ID' do
|
90
|
+
expect(driver[:image_id]).to eq('473123')
|
80
91
|
end
|
92
|
+
end
|
93
|
+
|
94
|
+
context 'name is centos-6.4' do
|
95
|
+
let(:platform_name) { 'centos-6.4' }
|
96
|
+
|
97
|
+
it 'defaults to the correct image ID' do
|
98
|
+
expect(driver[:image_id]).to eq('562354')
|
99
|
+
end
|
100
|
+
end
|
81
101
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
102
|
+
context 'overridden options' do
|
103
|
+
config = {
|
104
|
+
:image_id => '22',
|
105
|
+
:flavor_id => '63',
|
106
|
+
:ssh_key_ids => '5678',
|
107
|
+
:username => 'admin',
|
108
|
+
:port => '2222',
|
109
|
+
:server_name => 'puppy',
|
110
|
+
:region_id => '3'
|
111
|
+
}
|
112
|
+
|
113
|
+
let(:config) { config }
|
114
|
+
|
115
|
+
config.each do |key, value|
|
116
|
+
it "it uses the overridden #{key} option" do
|
117
|
+
expect(driver[key]).to eq(value)
|
86
118
|
end
|
87
119
|
end
|
88
120
|
end
|
@@ -90,29 +122,29 @@ describe Kitchen::Driver::Digitalocean do
|
|
90
122
|
|
91
123
|
describe '#create' do
|
92
124
|
let(:server) do
|
93
|
-
double(
|
94
|
-
|
125
|
+
double(:id => 'test123', :wait_for => true,
|
126
|
+
:public_ip_address => '1.2.3.4')
|
95
127
|
end
|
96
128
|
let(:driver) do
|
97
129
|
d = Kitchen::Driver::Digitalocean.new(config)
|
98
130
|
d.instance = instance
|
99
|
-
d.stub(:
|
131
|
+
d.stub(:default_name).and_return('a_monkey!')
|
100
132
|
d.stub(:create_server).and_return(server)
|
101
133
|
d.stub(:wait_for_sshd).with('1.2.3.4').and_return(true)
|
102
134
|
d
|
103
135
|
end
|
104
136
|
|
105
|
-
context '
|
137
|
+
context 'username and API key only provided' do
|
106
138
|
let(:config) do
|
107
139
|
{
|
108
|
-
digitalocean_client_id
|
109
|
-
digitalocean_api_key
|
140
|
+
:digitalocean_client_id => 'hello',
|
141
|
+
:digitalocean_api_key => 'world'
|
110
142
|
}
|
111
143
|
end
|
112
144
|
|
113
145
|
it 'generates a server name in the absence of one' do
|
114
146
|
driver.create(state)
|
115
|
-
expect(driver[:
|
147
|
+
expect(driver[:server_name]).to eq('a_monkey!')
|
116
148
|
end
|
117
149
|
|
118
150
|
it 'gets a proper server ID' do
|
@@ -130,10 +162,10 @@ describe Kitchen::Driver::Digitalocean do
|
|
130
162
|
describe '#destroy' do
|
131
163
|
let(:server_id) { '12345' }
|
132
164
|
let(:hostname) { 'example.com' }
|
133
|
-
let(:state) { { server_id
|
134
|
-
let(:server) { double(nil
|
135
|
-
let(:servers) { double(get
|
136
|
-
let(:compute) { double(servers
|
165
|
+
let(:state) { { :server_id => server_id, :hostname => hostname } }
|
166
|
+
let(:server) { double(:nil? => false, :destroy => true) }
|
167
|
+
let(:servers) { double(:get => server) }
|
168
|
+
let(:compute) { double(:servers => servers) }
|
137
169
|
|
138
170
|
let(:driver) do
|
139
171
|
d = Kitchen::Driver::Digitalocean.new(config)
|
@@ -167,7 +199,7 @@ describe Kitchen::Driver::Digitalocean do
|
|
167
199
|
s.stub(:get).with('12345').and_return(nil)
|
168
200
|
s
|
169
201
|
end
|
170
|
-
let(:compute) { double(servers
|
202
|
+
let(:compute) { double(:servers => servers) }
|
171
203
|
let(:driver) do
|
172
204
|
d = Kitchen::Driver::Digitalocean.new(config)
|
173
205
|
d.instance = instance
|
@@ -185,21 +217,22 @@ describe Kitchen::Driver::Digitalocean do
|
|
185
217
|
describe '#compute' do
|
186
218
|
let(:config) do
|
187
219
|
{
|
188
|
-
digitalocean_client_id
|
189
|
-
digitalocean_api_key
|
220
|
+
:digitalocean_client_id => 'monkey',
|
221
|
+
:digitalocean_api_key => 'potato',
|
190
222
|
}
|
191
223
|
end
|
192
224
|
|
193
225
|
context 'all requirements provided' do
|
194
226
|
it 'creates a new compute connection' do
|
195
227
|
Fog::Compute.stub(:new) { |arg| arg }
|
196
|
-
|
197
|
-
expect(driver.send(:compute)).to eq(res)
|
228
|
+
expect(driver.send(:compute)).to be_a(Hash)
|
198
229
|
end
|
199
230
|
end
|
200
231
|
|
201
|
-
context 'no
|
202
|
-
let(:config)
|
232
|
+
context 'no username provided' do
|
233
|
+
let(:config) do
|
234
|
+
{ :digitalocean_client_id => nil, :digitalocean_api_key => '1234' }
|
235
|
+
end
|
203
236
|
|
204
237
|
it 'raises an error' do
|
205
238
|
expect { driver.send(:compute) }.to raise_error(ArgumentError)
|
@@ -207,40 +240,38 @@ describe Kitchen::Driver::Digitalocean do
|
|
207
240
|
end
|
208
241
|
|
209
242
|
context 'no API key provided' do
|
210
|
-
let(:config)
|
211
|
-
|
212
|
-
it 'raises an error' do
|
213
|
-
expect { driver.send(:compute) }.to raise_error(ArgumentError)
|
243
|
+
let(:config) do
|
244
|
+
{ :digitalocean_client_id => 'monkey', :digitalocean_api_key => nil }
|
214
245
|
end
|
215
|
-
end
|
216
|
-
|
217
|
-
context 'no region id provided' do
|
218
|
-
let(:config) { { region_id: '1' } }
|
219
246
|
|
220
247
|
it 'raises an error' do
|
221
248
|
expect { driver.send(:compute) }.to raise_error(ArgumentError)
|
222
249
|
end
|
223
250
|
end
|
224
|
-
|
225
251
|
end
|
226
252
|
|
227
253
|
describe '#create_server' do
|
228
254
|
let(:config) do
|
229
255
|
{
|
230
|
-
|
231
|
-
image_id
|
232
|
-
flavor_id
|
233
|
-
|
234
|
-
|
256
|
+
:server_name => 'hello',
|
257
|
+
:image_id => 'there',
|
258
|
+
:flavor_id => 'captain',
|
259
|
+
:region_id => '1',
|
260
|
+
:ssh_key_ids => '1234'
|
235
261
|
}
|
236
262
|
end
|
237
|
-
before(:each)
|
263
|
+
before(:each) do
|
264
|
+
@expected = config.merge(:name => config[:server_name])
|
265
|
+
@expected.delete_if do |k, v|
|
266
|
+
k == :server_name
|
267
|
+
end
|
268
|
+
end
|
238
269
|
let(:servers) do
|
239
270
|
s = double('servers')
|
240
271
|
s.stub(:create) { |arg| arg }
|
241
272
|
s
|
242
273
|
end
|
243
|
-
let(:compute) { double(servers
|
274
|
+
let(:compute) { double(:servers => servers) }
|
244
275
|
let(:driver) do
|
245
276
|
d = Kitchen::Driver::Digitalocean.new(config)
|
246
277
|
d.instance = instance
|
@@ -249,19 +280,19 @@ describe Kitchen::Driver::Digitalocean do
|
|
249
280
|
end
|
250
281
|
|
251
282
|
it 'creates the server using a compute connection' do
|
252
|
-
expect(driver.send(:create_server)).to eq(@
|
283
|
+
expect(driver.send(:create_server)).to eq(@expected)
|
253
284
|
end
|
254
285
|
end
|
255
286
|
|
256
|
-
describe '#
|
287
|
+
describe '#default_name' do
|
257
288
|
before(:each) do
|
258
289
|
Etc.stub(:getlogin).and_return('user')
|
259
290
|
Socket.stub(:gethostname).and_return('host')
|
260
291
|
end
|
261
292
|
|
262
293
|
it 'generates a name' do
|
263
|
-
expect(driver.
|
264
|
-
/^
|
294
|
+
expect(driver.default_name).to match(
|
295
|
+
/^potatoes-user-host-/)
|
265
296
|
end
|
266
297
|
end
|
267
298
|
end
|
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.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Greg Fitzgerald
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: test-kitchen
|
@@ -123,6 +123,7 @@ files:
|
|
123
123
|
- LICENSE.txt
|
124
124
|
- README.md
|
125
125
|
- Rakefile
|
126
|
+
- data/images.json
|
126
127
|
- kitchen-digitalocean.gemspec
|
127
128
|
- lib/kitchen/driver/digitalocean.rb
|
128
129
|
- lib/kitchen/driver/digitalocean_version.rb
|