kitchen-gce 0.0.4 → 0.0.6
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.
- data/CHANGELOG.md +19 -1
- data/README.md +16 -5
- data/kitchen-gce.gemspec +9 -5
- data/lib/kitchen/driver/gce.rb +51 -45
- metadata +23 -10
data/CHANGELOG.md
CHANGED
|
@@ -1,11 +1,29 @@
|
|
|
1
|
+
## 0.0.6 / 2014-02-23:
|
|
2
|
+
|
|
3
|
+
* Require Ruby 1.9 or greater.
|
|
4
|
+
|
|
5
|
+
### Improvements
|
|
6
|
+
|
|
7
|
+
* Add support for specifying GCE network and tags.
|
|
8
|
+
|
|
9
|
+
### Bug fixes
|
|
10
|
+
|
|
11
|
+
* Temporarily pin Fog version to 1.19.0 until 1.20.0 support is added.
|
|
12
|
+
* Require Faraday Gem version to be ~> 0.8.9; 0.9.0 breaks test-kitchen.
|
|
13
|
+
|
|
14
|
+
## 0.0.4 / 2013-12-28
|
|
15
|
+
|
|
1
16
|
### Bug fixes
|
|
2
17
|
|
|
3
18
|
* In GCE, instance names must be unique; derive by default from
|
|
4
19
|
`<suite>-<platform>` and a UUID.
|
|
5
|
-
*
|
|
20
|
+
* Fix bug where running `kitchen create` multiple times would create
|
|
21
|
+
duplicate instances.
|
|
22
|
+
* Require version of Fog with exponential backoff in GCE API queries.
|
|
6
23
|
|
|
7
24
|
### Improvements
|
|
8
25
|
|
|
26
|
+
* README formatting and clarity fixes.
|
|
9
27
|
* Add concept of an "area" (us, europe, any) to automatically select
|
|
10
28
|
an availability zone from those that are up within the requested
|
|
11
29
|
area for each instance.
|
data/README.md
CHANGED
|
@@ -11,6 +11,8 @@ providers, GCE has a couple of advantages for Chef cookbook testing:
|
|
|
11
11
|
|
|
12
12
|
## Requirements
|
|
13
13
|
|
|
14
|
+
Ruby 1.9 or greater.
|
|
15
|
+
|
|
14
16
|
A [Google Cloud Platform](https://cloud.google.com) account is
|
|
15
17
|
required. If you do not already have an appropriate "project" in
|
|
16
18
|
which to run your test-kitchen instances, create one, noting the
|
|
@@ -38,7 +40,6 @@ source 'https://rubygems.org'
|
|
|
38
40
|
gem 'berkshelf'
|
|
39
41
|
|
|
40
42
|
group :integration do
|
|
41
|
-
gem 'test-kitchen', '~> 1.0.0.beta'
|
|
42
43
|
gem 'kitchen-gce'
|
|
43
44
|
end
|
|
44
45
|
```
|
|
@@ -77,10 +78,6 @@ instances will be launched.
|
|
|
77
78
|
|
|
78
79
|
**Required** Operating system image to deploy.
|
|
79
80
|
|
|
80
|
-
### machine_type
|
|
81
|
-
|
|
82
|
-
GCE instance type (size) to launch; default: `n1-standard-1`
|
|
83
|
-
|
|
84
81
|
### inst_name
|
|
85
82
|
|
|
86
83
|
Name to give to instance; unlike EC2's "Name" tag, this is used as an
|
|
@@ -89,6 +86,18 @@ name will be auto-generated; note that auto-generated names must be
|
|
|
89
86
|
used if there is more than one test suite. Default:
|
|
90
87
|
`<suite>-<platform>-<UUID>`
|
|
91
88
|
|
|
89
|
+
### machine_type
|
|
90
|
+
|
|
91
|
+
GCE instance type (size) to launch; default: `n1-standard-1`
|
|
92
|
+
|
|
93
|
+
### network
|
|
94
|
+
|
|
95
|
+
GCE network that instance will be attached to; default: `default`
|
|
96
|
+
|
|
97
|
+
### tags
|
|
98
|
+
|
|
99
|
+
Array of tags to associate with instance; default: `[]`
|
|
100
|
+
|
|
92
101
|
### username
|
|
93
102
|
|
|
94
103
|
Username to log into instance as; this user is assumed to have access
|
|
@@ -112,12 +121,14 @@ driver_config:
|
|
|
112
121
|
google_client_email: "123456789012@developer.gserviceaccount.com"
|
|
113
122
|
google_key_location: "<%= ENV['HOME']%>/gce/1234567890abcdef1234567890abcdef12345678-privatekey.p12"
|
|
114
123
|
google_project: "alpha-bravo-123"
|
|
124
|
+
network: "kitchenci"
|
|
115
125
|
|
|
116
126
|
platforms:
|
|
117
127
|
- name: debian-7
|
|
118
128
|
driver_config:
|
|
119
129
|
image_name: debian-7-wheezy-v20130926
|
|
120
130
|
require_chef_omnibus: true
|
|
131
|
+
tags: ["somerole"]
|
|
121
132
|
|
|
122
133
|
suites:
|
|
123
134
|
- name: default
|
data/kitchen-gce.gemspec
CHANGED
|
@@ -1,20 +1,24 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
1
2
|
Gem::Specification.new do |s|
|
|
2
3
|
s.name = 'kitchen-gce'
|
|
3
|
-
s.version = '0.0.
|
|
4
|
-
s.date = '
|
|
4
|
+
s.version = '0.0.6'
|
|
5
|
+
s.date = '2014-02-23'
|
|
5
6
|
s.summary = 'Kitchen::Driver::Gce'
|
|
6
7
|
s.description = 'A Test-Kitchen driver for Google Compute Engine'
|
|
7
8
|
s.authors = ['Andrew Leonard']
|
|
8
9
|
s.email = 'andy@hurricane-ridge.com'
|
|
9
|
-
s.files = `git ls-files`.split($/)
|
|
10
|
+
s.files = `git ls-files`.split($/) # rubocop:disable SpecialGlobalVars
|
|
10
11
|
s.homepage = 'https://github.com/anl/kitchen-gce'
|
|
11
12
|
s.license = 'Apache 2.0'
|
|
12
13
|
|
|
13
14
|
s.add_dependency 'test-kitchen'
|
|
14
|
-
s.add_dependency '
|
|
15
|
+
s.add_dependency 'faraday', '~> 0.8.9'
|
|
16
|
+
s.add_dependency 'fog', '1.19.0'
|
|
15
17
|
s.add_dependency 'google-api-client'
|
|
16
18
|
|
|
17
19
|
s.add_development_dependency 'bundler'
|
|
18
20
|
s.add_development_dependency 'rspec'
|
|
19
|
-
s.add_development_dependency '
|
|
21
|
+
s.add_development_dependency 'rubocop'
|
|
22
|
+
|
|
23
|
+
s.required_ruby_version = '>= 1.9'
|
|
20
24
|
end
|
data/lib/kitchen/driver/gce.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
#
|
|
1
3
|
# Author:: Andrew Leonard (<andy@hurricane-ridge.com>)
|
|
2
4
|
#
|
|
3
5
|
# Copyright (C) 2013, Andrew Leonard
|
|
@@ -21,11 +23,15 @@ require 'kitchen'
|
|
|
21
23
|
|
|
22
24
|
module Kitchen
|
|
23
25
|
module Driver
|
|
26
|
+
# Google Compute Engine driver for Test Kitchen
|
|
27
|
+
#
|
|
28
|
+
# @author Andrew Leonard <andy@hurricane-ridge.com>
|
|
24
29
|
class Gce < Kitchen::Driver::SSHBase
|
|
25
|
-
|
|
26
30
|
default_config :area, 'us'
|
|
27
31
|
default_config :machine_type, 'n1-standard-1'
|
|
32
|
+
default_config :network, 'default'
|
|
28
33
|
default_config :inst_name, nil
|
|
34
|
+
default_config :tags, []
|
|
29
35
|
default_config :username, ENV['USER']
|
|
30
36
|
default_config :zone_name, nil
|
|
31
37
|
|
|
@@ -37,15 +43,13 @@ module Kitchen
|
|
|
37
43
|
def create(state)
|
|
38
44
|
return if state[:server_id]
|
|
39
45
|
|
|
40
|
-
config[:inst_name] ||= generate_name
|
|
41
46
|
server = create_instance
|
|
42
47
|
state[:server_id] = server.identity
|
|
43
48
|
|
|
44
49
|
info("GCE instance <#{state[:server_id]}> created.")
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
puts '(ssh ready)'
|
|
50
|
+
|
|
51
|
+
wait_for_up_instance(server, state)
|
|
52
|
+
|
|
49
53
|
rescue Fog::Errors::Error, Excon::Errors::Error => ex
|
|
50
54
|
raise ActionFailed, ex.message
|
|
51
55
|
end
|
|
@@ -63,48 +67,26 @@ module Kitchen
|
|
|
63
67
|
private
|
|
64
68
|
|
|
65
69
|
def connection
|
|
66
|
-
Fog::Compute.new(
|
|
67
|
-
:
|
|
68
|
-
:
|
|
69
|
-
:
|
|
70
|
-
:
|
|
71
|
-
|
|
70
|
+
Fog::Compute.new(
|
|
71
|
+
provider: 'google',
|
|
72
|
+
google_client_email: config[:google_client_email],
|
|
73
|
+
google_key_location: config[:google_key_location],
|
|
74
|
+
google_project: config[:google_project]
|
|
75
|
+
)
|
|
72
76
|
end
|
|
73
77
|
|
|
74
78
|
def create_instance
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
:
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
connection.zones.each do |z|
|
|
87
|
-
case config[:area]
|
|
88
|
-
when 'us'
|
|
89
|
-
if z.name.match(/^us/) and z.status == 'UP'
|
|
90
|
-
zones.push(z)
|
|
91
|
-
end
|
|
92
|
-
when 'europe'
|
|
93
|
-
if z.name.match(/^europe/) and z.status == 'UP'
|
|
94
|
-
zones.push(z)
|
|
95
|
-
end
|
|
96
|
-
when 'any'
|
|
97
|
-
if z.status == 'UP'
|
|
98
|
-
zones.push(z)
|
|
99
|
-
end
|
|
100
|
-
else
|
|
101
|
-
raise ArgumentError, 'Unknown area'
|
|
102
|
-
end
|
|
103
|
-
end
|
|
104
|
-
return zones.sample.name
|
|
105
|
-
else
|
|
106
|
-
return config[:zone_name]
|
|
107
|
-
end
|
|
79
|
+
config[:inst_name] ||= generate_name
|
|
80
|
+
config[:zone_name] ||= select_zone
|
|
81
|
+
|
|
82
|
+
connection.servers.create(
|
|
83
|
+
name: config[:inst_name],
|
|
84
|
+
image_name: config[:image_name],
|
|
85
|
+
machine_type: config[:machine_type],
|
|
86
|
+
network: config[:network],
|
|
87
|
+
tags: config[:tags],
|
|
88
|
+
zone_name: config[:zone_name]
|
|
89
|
+
)
|
|
108
90
|
end
|
|
109
91
|
|
|
110
92
|
def generate_name
|
|
@@ -113,6 +95,30 @@ module Kitchen
|
|
|
113
95
|
"#{base_name}-#{SecureRandom.uuid}"
|
|
114
96
|
end
|
|
115
97
|
|
|
98
|
+
def select_zone
|
|
99
|
+
if config[:area] == 'any'
|
|
100
|
+
zone_regexp = /^[a-z]+\-/
|
|
101
|
+
else
|
|
102
|
+
zone_regexp = /^#{config[:area]}\-/
|
|
103
|
+
end
|
|
104
|
+
zones = connection.zones.select do |z|
|
|
105
|
+
z.status == 'UP' && z.name.match(zone_regexp)
|
|
106
|
+
end
|
|
107
|
+
fail 'No up zones in area' unless zones.length >= 1
|
|
108
|
+
zones.sample.name
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def wait_for_up_instance(server, state)
|
|
112
|
+
server.wait_for do
|
|
113
|
+
print '.'
|
|
114
|
+
ready?
|
|
115
|
+
end
|
|
116
|
+
print '(server ready)'
|
|
117
|
+
state[:hostname] = server.public_ip_address ||
|
|
118
|
+
server.private_ip_address
|
|
119
|
+
wait_for_sshd(state[:hostname], config[:username])
|
|
120
|
+
puts '(ssh ready)'
|
|
121
|
+
end
|
|
116
122
|
end
|
|
117
123
|
end
|
|
118
124
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: kitchen-gce
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.6
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date:
|
|
12
|
+
date: 2014-02-23 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: test-kitchen
|
|
@@ -27,12 +27,28 @@ dependencies:
|
|
|
27
27
|
- - ! '>='
|
|
28
28
|
- !ruby/object:Gem::Version
|
|
29
29
|
version: '0'
|
|
30
|
+
- !ruby/object:Gem::Dependency
|
|
31
|
+
name: faraday
|
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
|
33
|
+
none: false
|
|
34
|
+
requirements:
|
|
35
|
+
- - ~>
|
|
36
|
+
- !ruby/object:Gem::Version
|
|
37
|
+
version: 0.8.9
|
|
38
|
+
type: :runtime
|
|
39
|
+
prerelease: false
|
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
41
|
+
none: false
|
|
42
|
+
requirements:
|
|
43
|
+
- - ~>
|
|
44
|
+
- !ruby/object:Gem::Version
|
|
45
|
+
version: 0.8.9
|
|
30
46
|
- !ruby/object:Gem::Dependency
|
|
31
47
|
name: fog
|
|
32
48
|
requirement: !ruby/object:Gem::Requirement
|
|
33
49
|
none: false
|
|
34
50
|
requirements:
|
|
35
|
-
- -
|
|
51
|
+
- - '='
|
|
36
52
|
- !ruby/object:Gem::Version
|
|
37
53
|
version: 1.19.0
|
|
38
54
|
type: :runtime
|
|
@@ -40,7 +56,7 @@ dependencies:
|
|
|
40
56
|
version_requirements: !ruby/object:Gem::Requirement
|
|
41
57
|
none: false
|
|
42
58
|
requirements:
|
|
43
|
-
- -
|
|
59
|
+
- - '='
|
|
44
60
|
- !ruby/object:Gem::Version
|
|
45
61
|
version: 1.19.0
|
|
46
62
|
- !ruby/object:Gem::Dependency
|
|
@@ -92,7 +108,7 @@ dependencies:
|
|
|
92
108
|
- !ruby/object:Gem::Version
|
|
93
109
|
version: '0'
|
|
94
110
|
- !ruby/object:Gem::Dependency
|
|
95
|
-
name:
|
|
111
|
+
name: rubocop
|
|
96
112
|
requirement: !ruby/object:Gem::Requirement
|
|
97
113
|
none: false
|
|
98
114
|
requirements:
|
|
@@ -132,10 +148,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
132
148
|
requirements:
|
|
133
149
|
- - ! '>='
|
|
134
150
|
- !ruby/object:Gem::Version
|
|
135
|
-
version: '
|
|
136
|
-
segments:
|
|
137
|
-
- 0
|
|
138
|
-
hash: -3638187786435759861
|
|
151
|
+
version: '1.9'
|
|
139
152
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
153
|
none: false
|
|
141
154
|
requirements:
|
|
@@ -144,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
144
157
|
version: '0'
|
|
145
158
|
segments:
|
|
146
159
|
- 0
|
|
147
|
-
hash:
|
|
160
|
+
hash: 134419407739648312
|
|
148
161
|
requirements: []
|
|
149
162
|
rubyforge_project:
|
|
150
163
|
rubygems_version: 1.8.23
|