test-kitchen 1.0.0.alpha.7 → 1.0.0.beta.1
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 +7 -0
- data/.travis.yml +3 -0
- data/CHANGELOG.md +70 -2
- data/README.md +2 -2
- data/Rakefile +14 -11
- data/lib/kitchen.rb +7 -2
- data/lib/kitchen/busser.rb +19 -7
- data/lib/kitchen/cli.rb +29 -7
- data/lib/kitchen/color.rb +5 -5
- data/lib/kitchen/config.rb +49 -10
- data/lib/kitchen/driver.rb +4 -0
- data/lib/kitchen/driver/base.rb +42 -25
- data/lib/kitchen/driver/ssh_base.rb +45 -139
- data/lib/kitchen/errors.rb +3 -0
- data/lib/kitchen/generator/init.rb +41 -31
- data/lib/kitchen/instance.rb +34 -20
- data/lib/kitchen/login_command.rb +34 -0
- data/lib/kitchen/platform.rb +22 -12
- data/lib/kitchen/provisioner.rb +50 -0
- data/lib/kitchen/provisioner/base.rb +63 -0
- data/lib/kitchen/provisioner/chef_base.rb +290 -0
- data/lib/kitchen/provisioner/chef_solo.rb +69 -0
- data/lib/kitchen/provisioner/chef_zero.rb +92 -0
- data/lib/kitchen/ssh.rb +160 -0
- data/lib/kitchen/suite.rb +53 -33
- data/lib/kitchen/version.rb +1 -1
- data/spec/kitchen/config_spec.rb +40 -8
- data/spec/kitchen/driver/base_spec.rb +123 -0
- data/spec/kitchen/instance_spec.rb +61 -54
- data/spec/kitchen/platform_spec.rb +20 -13
- data/spec/kitchen/suite_spec.rb +34 -28
- data/support/chef-client-zero.rb +59 -0
- data/templates/init/kitchen.yml.erb +4 -4
- data/test-kitchen.gemspec +1 -1
- metadata +55 -90
- data/lib/kitchen/chef_data_uploader.rb +0 -177
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ea78b6f7069f03c81704ff35144fb2946803dea9
|
4
|
+
data.tar.gz: c22d68cbe08ce48169505a07f085da04da60abcf
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2811c0a0243a3a73570634dac3e2180bf6f53fb561413fb6c180e7c43d5cca7a06aa91624a822121c42a30d45c3e4e758d5d86c501cb5a597cb188e1ace52e20
|
7
|
+
data.tar.gz: fd8dea90199f09311862f7f63c89e8cfa620d18fc622016b9d28f632e42ebd31615fc08fad96e4ed773b9895ab440d389479aa03636d89807de864d05a7d8ae4
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,39 @@
|
|
1
|
+
## 1.0.0.beta.1 / 2013-07-23
|
2
|
+
|
3
|
+
### New features
|
4
|
+
|
5
|
+
* Pull request [#128][]: [Breaking] Introduce Provisioners to support chef-client (chef-zero), puppet-apply, and puppet-agent. ([@fnichol][])
|
6
|
+
* Pull request [#128][]: Add `chef_zero` provisioner type as an alternative to the iplicit default `chef_solo` provisioner. ([@fnichol][])
|
7
|
+
* Pull request [#171][]: Support computed default values for Driver authors (see pull request for light documentation). ([@fnichol][])
|
8
|
+
* Pull request [#161][], issue [#129][]: Allow custom paths for roles, data\_bags, and nodes by setting `roles_path`, `data_bags_path`, and `nodes_path`. ([@gondoi][])
|
9
|
+
* Pull request [#134][]: Add cross suite helpers. ([@rteabeault][])
|
10
|
+
|
11
|
+
### Bug fixes
|
12
|
+
|
13
|
+
* Pull request [#122][]: Adding missing sudo calls to busser. ([@adamhjk][])
|
14
|
+
* Pull request [#154][], issue [#163][]: Set a more sane default PATH for installing Chef. ([@jtimberman][])
|
15
|
+
* Issue [#153][]: Assign Celluloid.logger to Kitchen.logger which won't open a file. ([@fnichol][])
|
16
|
+
* Pull request [#155][], issue [#154][]: Setting :on_black when your default terminal text color is black results in unreadable (black on black) text. Or: The NSA censors your VM names when using a terminal with a light background. ([@mconigliaro][])
|
17
|
+
* Pull request [#140][]: Make `kitchen init` generator safe to run when given an explicit `:destination_root`. ([@reset][])
|
18
|
+
* Pull request [#170][]: Add asterisk to wait_for_sshd argument. ([@saketoba][])
|
19
|
+
* Pull request [#136][]: Fixes bundler ref for 1.0. ([@patcon][])
|
20
|
+
* Pull request [#142][], issue [#137][]: Require a safe\_yaml release with correct permissions. ([@josephholsten][])
|
21
|
+
|
22
|
+
### Improvements
|
23
|
+
|
24
|
+
* Pull request [#128][]: Add Driver and Provisioner columns to `kitchen list` output. ([@fnichol][])
|
25
|
+
* Pull request [#124][], issue [#132][]: Aggressively filter "non-cookbook" files before uploading to instances. ([@fnichol][])
|
26
|
+
* Pull request [#128][]: Suite run_list is no longer required. ([@fnichol][])
|
27
|
+
* Pull request [#123][]: Swap cookbook resolution strategy from shell outs to using Ruby APIs. ([@fnichol][])
|
28
|
+
* Pull request [#128][]: SSH and SCP commands share a single connection when transfering Chef artifacts to an instance (via the new `Kitchen::SSH` class). ([@fnichol][])
|
29
|
+
* Pull request [#128][]: Add more helpful output logging (info and debug) when creating and uploading the sandbox directory of Chef artifacts. ([@fnichol][])
|
30
|
+
* Issue [#97][]: Remove red as a candidate instance color. ([@fnichol][])
|
31
|
+
* Fix ANSI color codes for bright colors. ([@fnichol][])
|
32
|
+
* Pull request [#172][]: [Breaking] Update signature of Driver.required_config block. ([@fnichol][])
|
33
|
+
* Pull request [#152][], issue [#151][]: Update the bucket name for Opscode's Bento Boxes. ([@jtimberman][])
|
34
|
+
* Pull request [#131][]: Use ssh_args for test_ssh. ([@jonsmorrow][])
|
35
|
+
|
36
|
+
|
1
37
|
## 1.0.0.alpha.7 / 2013-05-23
|
2
38
|
|
3
39
|
### New features
|
@@ -14,7 +50,7 @@
|
|
14
50
|
* Pull request [#116][]: Require the 'name' attribute is present in `metadata.rb`. ([@sethvargo][])
|
15
51
|
* Pull request [#113][]: Handle case where YAML parses as nil. ([@smith][])
|
16
52
|
* Pass original exception's backtrace to InstanceFailure and ActionFailed. ([@fnichol][])
|
17
|
-
* Fix bug where action failures are swallowed with a nil inside an ensure. ([@
|
53
|
+
* Pull request [#112][]: Fix bug where action failures are swallowed with a nil inside an ensure. ([@manul][])
|
18
54
|
|
19
55
|
### Improvements
|
20
56
|
|
@@ -139,6 +175,7 @@ The initial release.
|
|
139
175
|
[#84]: https://github.com/opscode/test-kitchen/issues/84
|
140
176
|
[#90]: https://github.com/opscode/test-kitchen/issues/90
|
141
177
|
[#92]: https://github.com/opscode/test-kitchen/issues/92
|
178
|
+
[#97]: https://github.com/opscode/test-kitchen/issues/97
|
142
179
|
[#98]: https://github.com/opscode/test-kitchen/issues/98
|
143
180
|
[#99]: https://github.com/opscode/test-kitchen/issues/99
|
144
181
|
[#102]: https://github.com/opscode/test-kitchen/issues/102
|
@@ -146,22 +183,53 @@ The initial release.
|
|
146
183
|
[#105]: https://github.com/opscode/test-kitchen/issues/105
|
147
184
|
[#108]: https://github.com/opscode/test-kitchen/issues/108
|
148
185
|
[#111]: https://github.com/opscode/test-kitchen/issues/111
|
186
|
+
[#112]: https://github.com/opscode/test-kitchen/issues/112
|
149
187
|
[#113]: https://github.com/opscode/test-kitchen/issues/113
|
150
188
|
[#114]: https://github.com/opscode/test-kitchen/issues/114
|
151
189
|
[#116]: https://github.com/opscode/test-kitchen/issues/116
|
152
190
|
[#119]: https://github.com/opscode/test-kitchen/issues/119
|
153
191
|
[#120]: https://github.com/opscode/test-kitchen/issues/120
|
192
|
+
[#122]: https://github.com/opscode/test-kitchen/issues/122
|
193
|
+
[#123]: https://github.com/opscode/test-kitchen/issues/123
|
194
|
+
[#124]: https://github.com/opscode/test-kitchen/issues/124
|
195
|
+
[#128]: https://github.com/opscode/test-kitchen/issues/128
|
196
|
+
[#129]: https://github.com/opscode/test-kitchen/issues/129
|
197
|
+
[#131]: https://github.com/opscode/test-kitchen/issues/131
|
198
|
+
[#132]: https://github.com/opscode/test-kitchen/issues/132
|
199
|
+
[#134]: https://github.com/opscode/test-kitchen/issues/134
|
200
|
+
[#136]: https://github.com/opscode/test-kitchen/issues/136
|
201
|
+
[#137]: https://github.com/opscode/test-kitchen/issues/137
|
202
|
+
[#140]: https://github.com/opscode/test-kitchen/issues/140
|
203
|
+
[#142]: https://github.com/opscode/test-kitchen/issues/142
|
204
|
+
[#151]: https://github.com/opscode/test-kitchen/issues/151
|
205
|
+
[#152]: https://github.com/opscode/test-kitchen/issues/152
|
206
|
+
[#153]: https://github.com/opscode/test-kitchen/issues/153
|
207
|
+
[#154]: https://github.com/opscode/test-kitchen/issues/154
|
208
|
+
[#155]: https://github.com/opscode/test-kitchen/issues/155
|
209
|
+
[#161]: https://github.com/opscode/test-kitchen/issues/161
|
210
|
+
[#163]: https://github.com/opscode/test-kitchen/issues/163
|
211
|
+
[#170]: https://github.com/opscode/test-kitchen/issues/170
|
212
|
+
[#171]: https://github.com/opscode/test-kitchen/issues/171
|
213
|
+
[#172]: https://github.com/opscode/test-kitchen/issues/172
|
154
214
|
[@ChrisLundquist]: https://github.com/ChrisLundquist
|
155
215
|
[@adamhjk]: https://github.com/adamhjk
|
156
216
|
[@arunthampi]: https://github.com/arunthampi
|
157
217
|
[@bryanwb]: https://github.com/bryanwb
|
158
218
|
[@calavera]: https://github.com/calavera
|
159
219
|
[@fnichol]: https://github.com/fnichol
|
220
|
+
[@gondoi]: https://github.com/gondoi
|
160
221
|
[@grahamc]: https://github.com/grahamc
|
222
|
+
[@jonsmorrow]: https://github.com/jonsmorrow
|
223
|
+
[@josephholsten]: https://github.com/josephholsten
|
161
224
|
[@jtimberman]: https://github.com/jtimberman
|
225
|
+
[@manul]: https://github.com/manul
|
162
226
|
[@mattray]: https://github.com/mattray
|
227
|
+
[@mconigliaro]: https://github.com/mconigliaro
|
228
|
+
[@patcon]: https://github.com/patcon
|
163
229
|
[@reset]: https://github.com/reset
|
230
|
+
[@rteabeault]: https://github.com/rteabeault
|
231
|
+
[@saketoba]: https://github.com/saketoba
|
164
232
|
[@sethvargo]: https://github.com/sethvargo
|
165
233
|
[@smith]: https://github.com/smith
|
166
234
|
[@stevendanna]: https://github.com/stevendanna
|
167
|
-
[@thommay]: https://github.com/thommay
|
235
|
+
[@thommay]: https://github.com/thommay
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Test Kitchen
|
2
2
|
|
3
|
-
[](https://travis-ci.org/opscode/test-kitchen)
|
4
4
|
[](https://codeclimate.com/github/opscode/test-kitchen)
|
5
5
|
|
6
6
|
A convergence integration test harness for configuration management systems.
|
@@ -15,7 +15,7 @@ In your `Gemfile`, add `test-kitchen` as a
|
|
15
15
|
dependency:
|
16
16
|
|
17
17
|
```ruby
|
18
|
-
gem 'test-kitchen',
|
18
|
+
gem 'test-kitchen', '~> 1.0.0.alpha'
|
19
19
|
```
|
20
20
|
|
21
21
|
and run the `bundle` command to install:
|
data/Rakefile
CHANGED
@@ -16,7 +16,13 @@ end
|
|
16
16
|
desc "Run all test suites"
|
17
17
|
task :test => [:unit, :features]
|
18
18
|
|
19
|
-
|
19
|
+
desc "Display LOC stats"
|
20
|
+
task :stats do
|
21
|
+
puts "\n## Production Code Stats"
|
22
|
+
sh "countloc -r lib/kitchen lib/kitchen.rb"
|
23
|
+
puts "\n## Test Code Stats"
|
24
|
+
sh "countloc -r spec features"
|
25
|
+
end
|
20
26
|
|
21
27
|
unless RUBY_ENGINE == 'jruby'
|
22
28
|
require 'cane/rake_task'
|
@@ -29,6 +35,7 @@ unless RUBY_ENGINE == 'jruby'
|
|
29
35
|
Kitchen::ThorTasks#define
|
30
36
|
Kitchen::CLI#pry_prompts
|
31
37
|
Kitchen::Instance#synchronize_or_call
|
38
|
+
Kitchen::Driver::SSHBase#converge
|
32
39
|
)
|
33
40
|
cane.style_exclude = %w(
|
34
41
|
lib/vendor/hash_recursive_merge.rb
|
@@ -58,15 +65,11 @@ unless RUBY_ENGINE == 'jruby'
|
|
58
65
|
end
|
59
66
|
end
|
60
67
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
desc "
|
65
|
-
task :stats
|
66
|
-
puts "\n## Production Code Stats"
|
67
|
-
sh "countloc -r lib/kitchen lib/kitchen.rb"
|
68
|
-
puts "\n## Test Code Stats"
|
69
|
-
sh "countloc -r spec features"
|
68
|
+
desc "Run all quality tasks"
|
69
|
+
task :quality => [:cane, :tailor, :stats]
|
70
|
+
else
|
71
|
+
desc "Run all quality tasks"
|
72
|
+
task :quality => [:stats]
|
70
73
|
end
|
71
74
|
|
72
|
-
|
75
|
+
task :default => [:test, :quality]
|
data/lib/kitchen.rb
CHANGED
@@ -26,8 +26,9 @@ require 'kitchen/logging'
|
|
26
26
|
require 'kitchen/shell_out'
|
27
27
|
require 'kitchen/util'
|
28
28
|
|
29
|
+
require 'kitchen/provisioner'
|
30
|
+
require 'kitchen/provisioner/base'
|
29
31
|
require 'kitchen/busser'
|
30
|
-
require 'kitchen/chef_data_uploader'
|
31
32
|
require 'kitchen/color'
|
32
33
|
require 'kitchen/collection'
|
33
34
|
require 'kitchen/config'
|
@@ -41,9 +42,13 @@ require 'kitchen/manager'
|
|
41
42
|
require 'kitchen/metadata_chopper'
|
42
43
|
require 'kitchen/platform'
|
43
44
|
require 'kitchen/state_file'
|
45
|
+
require 'kitchen/ssh'
|
44
46
|
require 'kitchen/suite'
|
45
47
|
require 'kitchen/version'
|
46
48
|
|
49
|
+
# Test Kitchen base module.
|
50
|
+
#
|
51
|
+
# @author Fletcher Nichol <fnichol@nichol.ca>
|
47
52
|
module Kitchen
|
48
53
|
|
49
54
|
class << self
|
@@ -91,7 +96,7 @@ end
|
|
91
96
|
|
92
97
|
# Initialize the base logger and use that for Celluloid's logger
|
93
98
|
Kitchen.logger = Kitchen.default_logger
|
94
|
-
Celluloid.logger = Kitchen.
|
99
|
+
Celluloid.logger = Kitchen.logger
|
95
100
|
|
96
101
|
# Setup a collection of instance crash exceptions for error reporting
|
97
102
|
Kitchen.crashes = []
|
data/lib/kitchen/busser.rb
CHANGED
@@ -80,7 +80,8 @@ module Kitchen
|
|
80
80
|
<<-INSTALL_CMD.gsub(/^ {10}/, '')
|
81
81
|
bash -c '
|
82
82
|
#{sudo}#{busser_bin} suite cleanup
|
83
|
-
#{local_suite_files.map { |f| stream_file(f, remote_file(f)) }.join}
|
83
|
+
#{local_suite_files.map { |f| stream_file(f, remote_file(f, @suite_name)) }.join}
|
84
|
+
#{helper_files.map { |f| stream_file(f, remote_file(f, "helpers")) }.join}'
|
84
85
|
INSTALL_CMD
|
85
86
|
end
|
86
87
|
end
|
@@ -103,7 +104,14 @@ module Kitchen
|
|
103
104
|
DEFAULT_TEST_ROOT = File.join(Dir.pwd, "test/integration").freeze
|
104
105
|
|
105
106
|
def validate_options(suite_name)
|
106
|
-
|
107
|
+
if suite_name.nil?
|
108
|
+
raise ClientError, "Busser#new requires a suite_name"
|
109
|
+
end
|
110
|
+
|
111
|
+
if suite_name == 'helper'
|
112
|
+
raise UserError,
|
113
|
+
"Suite name invalid: 'helper' is a reserved directory name."
|
114
|
+
end
|
107
115
|
end
|
108
116
|
|
109
117
|
def plugins
|
@@ -118,9 +126,13 @@ module Kitchen
|
|
118
126
|
end
|
119
127
|
end
|
120
128
|
|
121
|
-
def
|
122
|
-
|
123
|
-
|
129
|
+
def helper_files
|
130
|
+
Dir.glob(File.join(test_root, "helpers", "*/**/*"))
|
131
|
+
end
|
132
|
+
|
133
|
+
def remote_file(file, dir)
|
134
|
+
local_prefix = File.join(test_root, dir)
|
135
|
+
"$(#{sudo}#{busser_bin} suite path)/".concat(file.sub(%r{^#{local_prefix}/}, ''))
|
124
136
|
end
|
125
137
|
|
126
138
|
def stream_file(local_path, remote_path)
|
@@ -128,7 +140,7 @@ module Kitchen
|
|
128
140
|
md5 = Digest::MD5.hexdigest(local_file)
|
129
141
|
perms = sprintf("%o", File.stat(local_path).mode)[2, 4]
|
130
142
|
stream_cmd = [
|
131
|
-
busser_bin,
|
143
|
+
"#{sudo}#{busser_bin}",
|
132
144
|
"deserialize",
|
133
145
|
"--destination=#{remote_path}",
|
134
146
|
"--md5sum=#{md5}",
|
@@ -137,7 +149,7 @@ module Kitchen
|
|
137
149
|
|
138
150
|
<<-STREAMFILE.gsub(/^ {8}/, '')
|
139
151
|
echo "Uploading #{remote_path} (mode=#{perms})"
|
140
|
-
cat <<"__EOFSTREAM__" | #{sudo}#{stream_cmd}
|
152
|
+
#{sudo}cat <<"__EOFSTREAM__" | #{sudo}#{stream_cmd}
|
141
153
|
#{Base64.encode64(local_file)}
|
142
154
|
__EOFSTREAM__
|
143
155
|
STREAMFILE
|
data/lib/kitchen/cli.rb
CHANGED
@@ -40,6 +40,7 @@ module Kitchen
|
|
40
40
|
super
|
41
41
|
$stdout.sync = true
|
42
42
|
Kitchen.logger = Kitchen.default_file_logger
|
43
|
+
Celluloid.logger = Kitchen.celluloid_file_logger
|
43
44
|
@config = Kitchen::Config.new(
|
44
45
|
:loader => Kitchen::Loader::YAML.new(ENV['KITCHEN_YAML']),
|
45
46
|
:log_level => ENV['KITCHEN_LOG'] && ENV['KITCHEN_LOG'].downcase.to_sym,
|
@@ -55,11 +56,7 @@ module Kitchen
|
|
55
56
|
if options[:bare]
|
56
57
|
say Array(result).map { |i| i.name }.join("\n")
|
57
58
|
else
|
58
|
-
|
59
|
-
[set_color("Instance", :green), set_color("Last Action", :green)]
|
60
|
-
]
|
61
|
-
table += Array(result).map { |i| display_instance(i) }
|
62
|
-
print_table(table)
|
59
|
+
list_table(result)
|
63
60
|
end
|
64
61
|
end
|
65
62
|
|
@@ -318,8 +315,30 @@ module Kitchen
|
|
318
315
|
end
|
319
316
|
end
|
320
317
|
|
318
|
+
def list_table(result)
|
319
|
+
table = [
|
320
|
+
[set_color("Instance", :green), set_color("Driver", :green),
|
321
|
+
set_color("Provisioner", :green), set_color("Last Action", :green)]
|
322
|
+
]
|
323
|
+
table += Array(result).map { |i| display_instance(i) }
|
324
|
+
print_table(table)
|
325
|
+
end
|
326
|
+
|
321
327
|
def display_instance(instance)
|
322
|
-
|
328
|
+
[
|
329
|
+
color_pad(instance.name),
|
330
|
+
color_pad(instance.driver.name),
|
331
|
+
color_pad(format_provisioner(instance.driver[:provisioner])),
|
332
|
+
format_last_action(instance.last_action)
|
333
|
+
]
|
334
|
+
end
|
335
|
+
|
336
|
+
def color_pad(string)
|
337
|
+
string + set_color("", :white)
|
338
|
+
end
|
339
|
+
|
340
|
+
def format_last_action(last_action)
|
341
|
+
case last_action
|
323
342
|
when 'create' then set_color("Created", :cyan)
|
324
343
|
when 'converge' then set_color("Converged", :magenta)
|
325
344
|
when 'setup' then set_color("Set Up", :blue)
|
@@ -327,7 +346,10 @@ module Kitchen
|
|
327
346
|
when nil then set_color("<Not Created>", :red)
|
328
347
|
else set_color("<Unknown>", :white)
|
329
348
|
end
|
330
|
-
|
349
|
+
end
|
350
|
+
|
351
|
+
def format_provisioner(name)
|
352
|
+
name.split('_').map { |word| word.capitalize }.join(' ')
|
331
353
|
end
|
332
354
|
|
333
355
|
def update_config!
|
data/lib/kitchen/color.rb
CHANGED
@@ -28,14 +28,14 @@ module Kitchen
|
|
28
28
|
ANSI = {
|
29
29
|
:reset => 0, :black => 30, :red => 31, :green => 32, :yellow => 33,
|
30
30
|
:blue => 34, :magenta => 35, :cyan => 36, :white => 37,
|
31
|
-
:bright_black =>
|
32
|
-
:bright_yellow =>
|
33
|
-
:bright_cyan =>
|
31
|
+
:bright_black => 90, :bright_red => 91, :bright_green => 92,
|
32
|
+
:bright_yellow => 93, :bright_blue => 94, :bright_magenta => 95,
|
33
|
+
:bright_cyan => 96, :bright_white => 97
|
34
34
|
}.freeze
|
35
35
|
|
36
36
|
COLORS = %w(
|
37
|
-
cyan yellow green magenta
|
38
|
-
bright_green bright_magenta
|
37
|
+
cyan yellow green magenta blue bright_cyan bright_yellow
|
38
|
+
bright_green bright_magenta bright_blue
|
39
39
|
).freeze
|
40
40
|
|
41
41
|
# Returns an ansi escaped string representing a color control sequence.
|
data/lib/kitchen/config.rb
CHANGED
@@ -37,6 +37,9 @@ module Kitchen
|
|
37
37
|
# Default driver plugin to use
|
38
38
|
DEFAULT_DRIVER_PLUGIN = "dummy".freeze
|
39
39
|
|
40
|
+
# Default provisioner to use
|
41
|
+
DEFAULT_PROVISIONER = "chef_solo".freeze
|
42
|
+
|
40
43
|
# Default base path which may contain `data_bags/` directories
|
41
44
|
DEFAULT_TEST_BASE_PATH = File.join(Dir.pwd, 'test/integration').freeze
|
42
45
|
|
@@ -94,8 +97,9 @@ module Kitchen
|
|
94
97
|
|
95
98
|
def new_suite(hash)
|
96
99
|
path_hash = {
|
97
|
-
:data_bags_path => calculate_path("data_bags", hash[:name]),
|
98
|
-
:roles_path => calculate_path("roles", hash[:name]),
|
100
|
+
:data_bags_path => calculate_path("data_bags", hash[:name], hash[:data_bags_path]),
|
101
|
+
:roles_path => calculate_path("roles", hash[:name], hash[:roles_path]),
|
102
|
+
:nodes_path => calculate_path("nodes", hash[:name], hash[:nodes_path]),
|
99
103
|
}
|
100
104
|
|
101
105
|
Suite.new(hash.rmerge(path_hash))
|
@@ -108,6 +112,7 @@ module Kitchen
|
|
108
112
|
def new_driver(hash)
|
109
113
|
hash[:driver_config] ||= Hash.new
|
110
114
|
hash[:driver_config][:kitchen_root] = kitchen_root
|
115
|
+
hash[:driver_config][:provisioner] = hash[:provisioner]
|
111
116
|
|
112
117
|
Driver.for_plugin(hash[:driver_plugin], hash[:driver_config])
|
113
118
|
end
|
@@ -126,13 +131,38 @@ module Kitchen
|
|
126
131
|
def new_instance(suite, platform, index)
|
127
132
|
platform_hash = platform_driver_hash(platform.name)
|
128
133
|
driver = new_driver(merge_driver_hash(platform_hash))
|
134
|
+
provisioner = driver[:provisioner]
|
129
135
|
|
130
|
-
Instance.new(
|
131
|
-
:suite => suite,
|
132
|
-
:platform => platform,
|
136
|
+
instance = Instance.new(
|
137
|
+
:suite => extend_suite(suite, provisioner),
|
138
|
+
:platform => extend_platform(platform, provisioner),
|
133
139
|
:driver => driver,
|
134
140
|
:logger => new_instance_logger(index)
|
135
141
|
)
|
142
|
+
extend_instance(instance, provisioner)
|
143
|
+
end
|
144
|
+
|
145
|
+
def extend_suite(suite, provisioner)
|
146
|
+
case provisioner.to_s.downcase
|
147
|
+
when /^chef_/ then suite.dup.extend(Suite::Cheflike)
|
148
|
+
when /^puppet_/ then suite.dup.extend(Suite::Puppetlike)
|
149
|
+
else suite.dup
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
def extend_platform(platform, provisioner)
|
154
|
+
case provisioner.to_s.downcase
|
155
|
+
when /^chef_/ then platform.dup.extend(Platform::Cheflike)
|
156
|
+
else platform.dup
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
def extend_instance(instance, provisioner)
|
161
|
+
case provisioner.to_s.downcase
|
162
|
+
when /^chef_/ then instance.extend(Instance::Cheflike)
|
163
|
+
when /^puppet_/ then instance.extend(Instance::Puppetlike)
|
164
|
+
else instance
|
165
|
+
end
|
136
166
|
end
|
137
167
|
|
138
168
|
def actor_registry(instance)
|
@@ -171,7 +201,9 @@ module Kitchen
|
|
171
201
|
def platform_driver_hash(platform_name)
|
172
202
|
h = data[:platforms].find { |p| p[:name] == platform_name } || Hash.new
|
173
203
|
|
174
|
-
h.select
|
204
|
+
h.select do |key, value|
|
205
|
+
[:driver_plugin, :driver_config, :provisioner].include?(key)
|
206
|
+
end
|
175
207
|
end
|
176
208
|
|
177
209
|
def new_instance_logger(index)
|
@@ -194,12 +226,15 @@ module Kitchen
|
|
194
226
|
default_driver_hash.rmerge(common_driver_hash.rmerge(driver_hash))
|
195
227
|
end
|
196
228
|
|
197
|
-
def calculate_path(path, suite_name)
|
229
|
+
def calculate_path(path, suite_name, local_path)
|
230
|
+
custom_path = File.join(kitchen_root, local_path) if local_path
|
198
231
|
suite_path = File.join(test_base_path, suite_name, path)
|
199
232
|
common_path = File.join(test_base_path, path)
|
200
233
|
top_level_path = File.join(Dir.pwd, path)
|
201
234
|
|
202
|
-
if File.directory?(
|
235
|
+
if custom_path and File.directory?(custom_path)
|
236
|
+
custom_path
|
237
|
+
elsif File.directory?(suite_path)
|
203
238
|
suite_path
|
204
239
|
elsif File.directory?(common_path)
|
205
240
|
common_path
|
@@ -211,12 +246,16 @@ module Kitchen
|
|
211
246
|
end
|
212
247
|
|
213
248
|
def default_driver_hash
|
214
|
-
{
|
249
|
+
{
|
250
|
+
:driver_plugin => DEFAULT_DRIVER_PLUGIN,
|
251
|
+
:driver_config => {},
|
252
|
+
:provisioner => DEFAULT_PROVISIONER
|
253
|
+
}
|
215
254
|
end
|
216
255
|
|
217
256
|
def common_driver_hash
|
218
257
|
data.select do |key, value|
|
219
|
-
[:driver_plugin, :driver_config].include?(key)
|
258
|
+
[:driver_plugin, :driver_config, :provisioner].include?(key)
|
220
259
|
end
|
221
260
|
end
|
222
261
|
end
|