test-kitchen 1.0.0.alpha.6 → 1.0.0.alpha.7
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 +49 -0
- data/Gemfile +0 -4
- data/README.md +12 -1
- data/features/sink_command.feature +30 -0
- data/lib/kitchen/busser.rb +5 -3
- data/lib/kitchen/chef_data_uploader.rb +15 -7
- data/lib/kitchen/cli.rb +26 -3
- data/lib/kitchen/driver/base.rb +11 -1
- data/lib/kitchen/driver/ssh_base.rb +22 -4
- data/lib/kitchen/instance.rb +4 -3
- data/lib/kitchen/loader/yaml.rb +12 -2
- data/lib/kitchen/shell_out.rb +1 -1
- data/lib/kitchen/util.rb +1 -0
- data/lib/kitchen/version.rb +1 -1
- data/spec/kitchen/loader/yaml_spec.rb +69 -2
- data/spec/kitchen/util_spec.rb +4 -0
- data/templates/init/kitchen.yml.erb +11 -10
- data/test-kitchen.gemspec +4 -1
- metadata +37 -3
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,30 @@
|
|
1
|
+
## 1.0.0.alpha.7 / 2013-05-23
|
2
|
+
|
3
|
+
### New features
|
4
|
+
|
5
|
+
* Pull request [#90][], issue [#31][]: Add a global user-level config file, located at `~/.kitchen/config.yml`. ([@thommay][])
|
6
|
+
* Pull request [#102][]: Allow a way to override remote sudo. ([@calavera][])
|
7
|
+
* Propagate default\_config from base driver classes into subclasses. ([@fnichol][])
|
8
|
+
* Pull request [#120][]: Add http and https_proxy support. ([@adamhjk][])
|
9
|
+
* Pull request [#111][]: Sink. Yeah, that one. ([@sethvargo][])
|
10
|
+
|
11
|
+
### Bug fixes
|
12
|
+
|
13
|
+
* Pull request [#99][], issue [#98][]: Ensure that destroy option is respected when --parallel is used. ([@stevendanna][])
|
14
|
+
* Pull request [#116][]: Require the 'name' attribute is present in `metadata.rb`. ([@sethvargo][])
|
15
|
+
* Pull request [#113][]: Handle case where YAML parses as nil. ([@smith][])
|
16
|
+
* Pass original exception's backtrace to InstanceFailure and ActionFailed. ([@fnichol][])
|
17
|
+
* Fix bug where action failures are swallowed with a nil inside an ensure. ([@fnichol][])
|
18
|
+
|
19
|
+
### Improvements
|
20
|
+
|
21
|
+
* Pull request [#104][]: Set the default ssh port in Driver::SSHBase. ([@calavera][])
|
22
|
+
* Pull request [#114][]: Update kitchen.yml template with provisionerless baseboxes. ([@jtimberman][])
|
23
|
+
* Pull request [#119][]: Test Kitchen works on Windows with Vagrant. ([@adamhjk][])
|
24
|
+
* Pull request [#108][]: Add version string to "Starting Kitchen" logging output. ([@fnichol][])
|
25
|
+
* Pull request [#105][]: Expand documentation around run-time switches in README. ([@grahamc][])
|
26
|
+
|
27
|
+
|
1
28
|
## 1.0.0.alpha.6 / 2013-05-08
|
2
29
|
|
3
30
|
### New features
|
@@ -97,6 +124,7 @@
|
|
97
124
|
The initial release.
|
98
125
|
|
99
126
|
<!--- The following link definition list is generated by PimpMyChangelog --->
|
127
|
+
[#31]: https://github.com/opscode/test-kitchen/issues/31
|
100
128
|
[#61]: https://github.com/opscode/test-kitchen/issues/61
|
101
129
|
[#64]: https://github.com/opscode/test-kitchen/issues/64
|
102
130
|
[#65]: https://github.com/opscode/test-kitchen/issues/65
|
@@ -109,10 +137,31 @@ The initial release.
|
|
109
137
|
[#81]: https://github.com/opscode/test-kitchen/issues/81
|
110
138
|
[#82]: https://github.com/opscode/test-kitchen/issues/82
|
111
139
|
[#84]: https://github.com/opscode/test-kitchen/issues/84
|
140
|
+
[#90]: https://github.com/opscode/test-kitchen/issues/90
|
112
141
|
[#92]: https://github.com/opscode/test-kitchen/issues/92
|
142
|
+
[#98]: https://github.com/opscode/test-kitchen/issues/98
|
143
|
+
[#99]: https://github.com/opscode/test-kitchen/issues/99
|
144
|
+
[#102]: https://github.com/opscode/test-kitchen/issues/102
|
145
|
+
[#104]: https://github.com/opscode/test-kitchen/issues/104
|
146
|
+
[#105]: https://github.com/opscode/test-kitchen/issues/105
|
147
|
+
[#108]: https://github.com/opscode/test-kitchen/issues/108
|
148
|
+
[#111]: https://github.com/opscode/test-kitchen/issues/111
|
149
|
+
[#113]: https://github.com/opscode/test-kitchen/issues/113
|
150
|
+
[#114]: https://github.com/opscode/test-kitchen/issues/114
|
151
|
+
[#116]: https://github.com/opscode/test-kitchen/issues/116
|
152
|
+
[#119]: https://github.com/opscode/test-kitchen/issues/119
|
153
|
+
[#120]: https://github.com/opscode/test-kitchen/issues/120
|
113
154
|
[@ChrisLundquist]: https://github.com/ChrisLundquist
|
155
|
+
[@adamhjk]: https://github.com/adamhjk
|
114
156
|
[@arunthampi]: https://github.com/arunthampi
|
115
157
|
[@bryanwb]: https://github.com/bryanwb
|
158
|
+
[@calavera]: https://github.com/calavera
|
116
159
|
[@fnichol]: https://github.com/fnichol
|
160
|
+
[@grahamc]: https://github.com/grahamc
|
161
|
+
[@jtimberman]: https://github.com/jtimberman
|
117
162
|
[@mattray]: https://github.com/mattray
|
118
163
|
[@reset]: https://github.com/reset
|
164
|
+
[@sethvargo]: https://github.com/sethvargo
|
165
|
+
[@smith]: https://github.com/smith
|
166
|
+
[@stevendanna]: https://github.com/stevendanna
|
167
|
+
[@thommay]: https://github.com/thommay
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -56,6 +56,17 @@ your tests in parallel. Trust us, it's faster!
|
|
56
56
|
|
57
57
|
$ bundle exec kitchen test
|
58
58
|
|
59
|
+
### Helpful Switches
|
60
|
+
|
61
|
+
- `--destroy=always|passed|never`
|
62
|
+
- `passed` (default): destroy the machine after a successful test
|
63
|
+
run (which implies passing tests.)
|
64
|
+
- `never`: Never clean up builds, even if they pass or fail.
|
65
|
+
- `always`: Regardless of the success or failure of the build,
|
66
|
+
destroy the machine.
|
67
|
+
- `--log-level=debug|info|warn|error|fatal` - Set the log-level of
|
68
|
+
the entire stack, including the chef-solo run.
|
69
|
+
|
59
70
|
## The Kitchen YAML format
|
60
71
|
|
61
72
|
Test-Kitchen reads its configuration from the .kitchen.yml
|
@@ -112,7 +123,7 @@ suites:
|
|
112
123
|
default_ruby: 1.8.7
|
113
124
|
```
|
114
125
|
|
115
|
-
## Overriding .kitchen.yaml with .kitchen
|
126
|
+
## Overriding .kitchen.yaml with .kitchen.<driver>.local.yml
|
116
127
|
|
117
128
|
TODO
|
118
129
|
|
@@ -0,0 +1,30 @@
|
|
1
|
+
Feature: The `kitchen sink` command
|
2
|
+
In order to have fun and provide an Easter Egg for users
|
3
|
+
As a Test Kitchen user
|
4
|
+
I want a `sink` command that displays ASCII art
|
5
|
+
|
6
|
+
Scenario: Displaying help
|
7
|
+
When I run `kitchen help`
|
8
|
+
Then the exit status should be 0
|
9
|
+
And the output should not contain "kitchen sink"
|
10
|
+
|
11
|
+
Scenario: Displaying the sink
|
12
|
+
When I run `kitchen sink`
|
13
|
+
Then the exit status should be 0
|
14
|
+
And the output should contain:
|
15
|
+
"""
|
16
|
+
___
|
17
|
+
' _ '.
|
18
|
+
/ /` `\ \
|
19
|
+
| | [__]
|
20
|
+
| | {{
|
21
|
+
| | }}
|
22
|
+
_ | | _ {{
|
23
|
+
___________<_>_| |_<_>}}________
|
24
|
+
.=======^=(___)=^={{====.
|
25
|
+
/ .----------------}}---. \
|
26
|
+
/ / {{ \ \
|
27
|
+
/ / }} \ \
|
28
|
+
( '=========================' )
|
29
|
+
'-----------------------------'
|
30
|
+
"""
|
data/lib/kitchen/busser.rb
CHANGED
@@ -55,11 +55,12 @@ module Kitchen
|
|
55
55
|
nil
|
56
56
|
else
|
57
57
|
<<-INSTALL_CMD.gsub(/^ {10}/, '')
|
58
|
+
bash -c '
|
58
59
|
if ! #{sudo}#{ruby_binpath}/gem list busser -i >/dev/null ; then
|
59
60
|
#{sudo}#{ruby_binpath}/gem install #{busser_gem} --no-rdoc --no-ri
|
60
61
|
fi
|
61
62
|
#{sudo}#{ruby_binpath}/busser setup
|
62
|
-
#{sudo}#{busser_bin} plugin install #{plugins.join(' ')}
|
63
|
+
#{sudo}#{busser_bin} plugin install #{plugins.join(' ')}'
|
63
64
|
INSTALL_CMD
|
64
65
|
end
|
65
66
|
end
|
@@ -77,8 +78,9 @@ module Kitchen
|
|
77
78
|
nil
|
78
79
|
else
|
79
80
|
<<-INSTALL_CMD.gsub(/^ {10}/, '')
|
81
|
+
bash -c '
|
80
82
|
#{sudo}#{busser_bin} suite cleanup
|
81
|
-
#{local_suite_files.map { |f| stream_file(f, remote_file(f)) }.join}
|
83
|
+
#{local_suite_files.map { |f| stream_file(f, remote_file(f)) }.join}'
|
82
84
|
INSTALL_CMD
|
83
85
|
end
|
84
86
|
end
|
@@ -142,7 +144,7 @@ module Kitchen
|
|
142
144
|
end
|
143
145
|
|
144
146
|
def sudo
|
145
|
-
@use_sudo ? "sudo " : ""
|
147
|
+
@use_sudo ? "sudo -E " : ""
|
146
148
|
end
|
147
149
|
|
148
150
|
def ruby_binpath
|
@@ -72,7 +72,7 @@ module Kitchen
|
|
72
72
|
cookbooks_dir = local_cookbooks
|
73
73
|
upload_path(scp, cookbooks_dir, "cookbooks")
|
74
74
|
ensure
|
75
|
-
FileUtils.rmtree(cookbooks_dir)
|
75
|
+
FileUtils.rmtree(cookbooks_dir) unless cookbooks_dir.nil?
|
76
76
|
end
|
77
77
|
|
78
78
|
def upload_data_bags(scp)
|
@@ -138,11 +138,16 @@ module Kitchen
|
|
138
138
|
end
|
139
139
|
|
140
140
|
def run_resolver(name, bin, tmpdir)
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
141
|
+
# Just going to have to take your chances on Windows - no way to
|
142
|
+
# check for a command without running it, and looking for an
|
143
|
+
# exit code. Good times.
|
144
|
+
if RUBY_PLATFORM !~ /mswin|mingw/
|
145
|
+
begin
|
146
|
+
run_command "if ! command -v #{bin} >/dev/null; then exit 1; fi"
|
147
|
+
rescue Kitchen::ShellOut::ShellCommandFailed
|
148
|
+
fatal("#{name} must be installed, add it to your Gemfile.")
|
149
|
+
raise UserError, "#{bin} command not found"
|
150
|
+
end
|
146
151
|
end
|
147
152
|
|
148
153
|
Kitchen.mutex.synchronize do
|
@@ -157,7 +162,10 @@ module Kitchen
|
|
157
162
|
|
158
163
|
def cp_this_cookbook(tmpdir)
|
159
164
|
metadata_rb = File.join(kitchen_root, "metadata.rb")
|
160
|
-
cb_name = MetadataChopper.extract(metadata_rb).first
|
165
|
+
cb_name = MetadataChopper.extract(metadata_rb).first or raise(UserError,
|
166
|
+
"The metadata.rb does not define the 'name' key." +
|
167
|
+
" Please add: `name '<cookbook_name>'` to metadata.rb and try again")
|
168
|
+
|
161
169
|
cb_path = File.join(tmpdir, cb_name)
|
162
170
|
glob = Dir.glob("#{kitchen_root}/{metadata.rb,README.*," +
|
163
171
|
"attributes,files,libraries,providers,recipes,resources,templates}")
|
data/lib/kitchen/cli.rb
CHANGED
@@ -100,7 +100,7 @@ module Kitchen
|
|
100
100
|
end
|
101
101
|
|
102
102
|
update_config!
|
103
|
-
banner "Starting Kitchen"
|
103
|
+
banner "Starting Kitchen (v#{Kitchen::VERSION})"
|
104
104
|
elapsed = Benchmark.measure do
|
105
105
|
ensure_initialized
|
106
106
|
destroy_mode = options[:destroy].to_sym
|
@@ -137,6 +137,29 @@ module Kitchen
|
|
137
137
|
end
|
138
138
|
map %w(-v --version) => :version
|
139
139
|
|
140
|
+
desc "sink", "Show the Kitchen sink!", :hide => true
|
141
|
+
def sink
|
142
|
+
say [
|
143
|
+
"",
|
144
|
+
" ___ ",
|
145
|
+
" ' _ '. ",
|
146
|
+
" / /` `\\ \\ ",
|
147
|
+
" | | [__] ",
|
148
|
+
" | | {{ ",
|
149
|
+
" | | }} ",
|
150
|
+
" _ | | _ {{ ",
|
151
|
+
" ___________<_>_| |_<_>}}________ ",
|
152
|
+
" .=======^=(___)=^={{====. ",
|
153
|
+
" / .----------------}}---. \\ ",
|
154
|
+
" / / {{ \\ \\ ",
|
155
|
+
" / / }} \\ \\ ",
|
156
|
+
" ( '=========================' ) ",
|
157
|
+
" '-----------------------------' ",
|
158
|
+
" ", # necessary newline
|
159
|
+
""
|
160
|
+
].map(&:rstrip).join("\n")
|
161
|
+
end
|
162
|
+
|
140
163
|
desc "console", "Kitchen Console!"
|
141
164
|
def console
|
142
165
|
require 'pry'
|
@@ -245,7 +268,7 @@ module Kitchen
|
|
245
268
|
|
246
269
|
def exec_action(action)
|
247
270
|
update_config!
|
248
|
-
banner "Starting Kitchen"
|
271
|
+
banner "Starting Kitchen (v#{Kitchen::VERSION})"
|
249
272
|
elapsed = Benchmark.measure do
|
250
273
|
@task = action
|
251
274
|
results = parse_subcommand(args.first)
|
@@ -259,7 +282,7 @@ module Kitchen
|
|
259
282
|
end
|
260
283
|
|
261
284
|
def run_parallel(instances, *args)
|
262
|
-
futures = Array(instances).map { |i| i.future.public_send(task) }
|
285
|
+
futures = Array(instances).map { |i| i.future.public_send(task, *args) }
|
263
286
|
futures.map { |i| i.value }
|
264
287
|
end
|
265
288
|
|
data/lib/kitchen/driver/base.rb
CHANGED
@@ -167,7 +167,17 @@ module Kitchen
|
|
167
167
|
end
|
168
168
|
|
169
169
|
def self.defaults
|
170
|
-
@defaults ||= Hash.new
|
170
|
+
@defaults ||= Hash.new.merge(super_defaults)
|
171
|
+
end
|
172
|
+
|
173
|
+
def self.super_defaults
|
174
|
+
klass = self.superclass
|
175
|
+
|
176
|
+
if klass.respond_to?(:defaults)
|
177
|
+
klass.defaults
|
178
|
+
else
|
179
|
+
Hash.new
|
180
|
+
end
|
171
181
|
end
|
172
182
|
|
173
183
|
def self.default_config(attr, value)
|
@@ -31,6 +31,9 @@ module Kitchen
|
|
31
31
|
# @author Fletcher Nichol <fnichol@nichol.ca>
|
32
32
|
class SSHBase < Base
|
33
33
|
|
34
|
+
default_config :sudo, true
|
35
|
+
default_config :port, 22
|
36
|
+
|
34
37
|
def create(state)
|
35
38
|
raise ClientError, "#{self.class}#create must be implemented"
|
36
39
|
end
|
@@ -117,9 +120,9 @@ module Kitchen
|
|
117
120
|
if [ ! -d "/opt/chef" ] || should_update_chef ; then
|
118
121
|
echo "-----> Installing Chef Omnibus (#{flag})"
|
119
122
|
if command -v wget >/dev/null ; then
|
120
|
-
wget #{url} -O - |
|
123
|
+
wget #{url} -O - | #{cmd('bash')} #{version}
|
121
124
|
elif command -v curl >/dev/null ; then
|
122
|
-
curl -sSL #{url} |
|
125
|
+
curl -sSL #{url} | #{cmd('bash')} #{version}
|
123
126
|
else
|
124
127
|
echo ">>>>>> Neither wget nor curl found on this instance."
|
125
128
|
exit 1
|
@@ -129,7 +132,7 @@ module Kitchen
|
|
129
132
|
end
|
130
133
|
|
131
134
|
def prepare_chef_home(ssh_args)
|
132
|
-
ssh(ssh_args, "
|
135
|
+
ssh(ssh_args, "#{cmd('rm')} -rf #{chef_home} && mkdir -p #{chef_home}/cache")
|
133
136
|
end
|
134
137
|
|
135
138
|
def upload_chef_data(ssh_args)
|
@@ -140,12 +143,23 @@ module Kitchen
|
|
140
143
|
|
141
144
|
def run_chef_solo(ssh_args)
|
142
145
|
ssh(ssh_args, <<-RUN_SOLO)
|
143
|
-
|
146
|
+
#{cmd('chef-solo')} -c #{chef_home}/solo.rb -j #{chef_home}/dna.json \
|
144
147
|
--log_level #{Util.from_logger_level(logger.level)}
|
145
148
|
RUN_SOLO
|
146
149
|
end
|
147
150
|
|
148
151
|
def ssh(ssh_args, cmd)
|
152
|
+
env = "env"
|
153
|
+
if config[:http_proxy]
|
154
|
+
env << " http_proxy=#{config[:http_proxy]}"
|
155
|
+
end
|
156
|
+
if config[:https_proxy]
|
157
|
+
env << " https_proxy=#{config[:https_proxy]}"
|
158
|
+
end
|
159
|
+
if env != "env"
|
160
|
+
cmd = "#{env} #{cmd}"
|
161
|
+
end
|
162
|
+
|
149
163
|
debug("[SSH] #{ssh_args[1]}@#{ssh_args[0]} (#{cmd})")
|
150
164
|
Net::SSH.start(*ssh_args) do |ssh|
|
151
165
|
exit_code = ssh_exec_with_exit!(ssh, cmd)
|
@@ -201,6 +215,10 @@ module Kitchen
|
|
201
215
|
ensure
|
202
216
|
socket && socket.close
|
203
217
|
end
|
218
|
+
|
219
|
+
def cmd(script)
|
220
|
+
config[:sudo] ? "sudo -E #{script}" : script
|
221
|
+
end
|
204
222
|
end
|
205
223
|
end
|
206
224
|
end
|
data/lib/kitchen/instance.rb
CHANGED
@@ -262,12 +262,13 @@ module Kitchen
|
|
262
262
|
elapsed
|
263
263
|
rescue ActionFailed => e
|
264
264
|
log_failure(what, e)
|
265
|
-
raise
|
266
|
-
" Please see .kitchen/logs/#{self.name}.log for more details",
|
265
|
+
raise(InstanceFailure, failure_message(what) +
|
266
|
+
" Please see .kitchen/logs/#{self.name}.log for more details",
|
267
|
+
e.backtrace)
|
267
268
|
rescue Exception => e
|
268
269
|
log_failure(what, e)
|
269
270
|
raise ActionFailed,
|
270
|
-
"Failed to complete ##{what} action: [#{e.message}]",
|
271
|
+
"Failed to complete ##{what} action: [#{e.message}]", e.backtrace
|
271
272
|
ensure
|
272
273
|
state_file.write(state)
|
273
274
|
end
|
data/lib/kitchen/loader/yaml.rb
CHANGED
@@ -47,6 +47,7 @@ module Kitchen
|
|
47
47
|
@config_file = File.expand_path(config_file || default_config_file)
|
48
48
|
@process_erb = options.fetch(:process_erb, true)
|
49
49
|
@process_local = options.fetch(:process_local, true)
|
50
|
+
@process_global = options.fetch(:process_global, true)
|
50
51
|
end
|
51
52
|
|
52
53
|
# Reads, parses, and merges YAML configuration files and returns a Hash
|
@@ -68,7 +69,8 @@ module Kitchen
|
|
68
69
|
end
|
69
70
|
|
70
71
|
def combined_hash
|
71
|
-
@process_local ? yaml.rmerge(local_yaml) : yaml
|
72
|
+
y = @process_local ? yaml.rmerge(local_yaml) : yaml
|
73
|
+
@process_global ? y.rmerge(global_yaml) : y
|
72
74
|
rescue NoMethodError
|
73
75
|
raise UserError, "Error merging #{File.basename(config_file)} and" +
|
74
76
|
"#{File.basename(local_config_file)}"
|
@@ -82,6 +84,10 @@ module Kitchen
|
|
82
84
|
parse_yaml_string(yaml_string(local_config_file), local_config_file)
|
83
85
|
end
|
84
86
|
|
87
|
+
def global_yaml
|
88
|
+
parse_yaml_string(yaml_string(global_config_file), global_config_file)
|
89
|
+
end
|
90
|
+
|
85
91
|
def yaml_string(file)
|
86
92
|
string = read_file(file)
|
87
93
|
|
@@ -96,10 +102,14 @@ module Kitchen
|
|
96
102
|
config_file.sub(/(#{File.extname(config_file)})$/, '.local\1')
|
97
103
|
end
|
98
104
|
|
105
|
+
def global_config_file
|
106
|
+
File.join(File.expand_path(ENV["HOME"]), ".kitchen", "config.yml")
|
107
|
+
end
|
108
|
+
|
99
109
|
def parse_yaml_string(string, file_name)
|
100
110
|
return Hash.new if string.nil? || string.empty?
|
101
111
|
|
102
|
-
::YAML.safe_load(string)
|
112
|
+
::YAML.safe_load(string) || Hash.new
|
103
113
|
rescue SyntaxError, Psych::SyntaxError
|
104
114
|
raise UserError, "Error parsing #{file_name}"
|
105
115
|
end
|
data/lib/kitchen/shell_out.rb
CHANGED
@@ -60,7 +60,7 @@ module Kitchen
|
|
60
60
|
def run_command(cmd, options = {})
|
61
61
|
use_sudo = options[:use_sudo].nil? ? false : options[:use_sudo]
|
62
62
|
quiet = options[:quiet]
|
63
|
-
cmd = "sudo #{cmd}" if use_sudo
|
63
|
+
cmd = "sudo -E #{cmd}" if use_sudo
|
64
64
|
subject = "[#{options[:log_subject] || "local"} command]"
|
65
65
|
|
66
66
|
info("#{subject} BEGIN (#{display_cmd(cmd)})") unless quiet
|
data/lib/kitchen/util.rb
CHANGED
@@ -93,6 +93,7 @@ module Kitchen
|
|
93
93
|
# @param total [Integer] the total number of seconds
|
94
94
|
# @return [String] a formatted string of the form (XmYY.00s)
|
95
95
|
def self.duration(total)
|
96
|
+
total = 0 if total.nil?
|
96
97
|
minutes = (total / 60).to_i
|
97
98
|
seconds = (total - (minutes * 60))
|
98
99
|
"(%dm%.2fs)" % [minutes, seconds]
|
data/lib/kitchen/version.rb
CHANGED
@@ -83,6 +83,28 @@ describe Kitchen::Loader::YAML do
|
|
83
83
|
})
|
84
84
|
end
|
85
85
|
|
86
|
+
it "deep merges in a global config file with all other configs" do
|
87
|
+
stub_yaml!(".kitchen.yml", {
|
88
|
+
'common' => { 'xx' => 1 },
|
89
|
+
'a' => 'b'
|
90
|
+
})
|
91
|
+
stub_yaml!(".kitchen.local.yml", {
|
92
|
+
'common' => { 'yy' => 2 },
|
93
|
+
'c' => 'd'
|
94
|
+
})
|
95
|
+
stub_global!({
|
96
|
+
'common' => { 'zz' => 3 },
|
97
|
+
'e' => 'f'
|
98
|
+
})
|
99
|
+
|
100
|
+
loader.read.must_equal({
|
101
|
+
:a => 'b',
|
102
|
+
:c => 'd',
|
103
|
+
:e => 'f',
|
104
|
+
:common => { :xx => 1, :yy => 2, :zz => 3 }
|
105
|
+
})
|
106
|
+
end
|
107
|
+
|
86
108
|
it "merges kitchen.local.yml over configuration in kitchen.yml" do
|
87
109
|
stub_yaml!(".kitchen.yml", {
|
88
110
|
'common' => { 'thekey' => 'nope' }
|
@@ -94,6 +116,20 @@ describe Kitchen::Loader::YAML do
|
|
94
116
|
loader.read.must_equal({ :common => { :thekey => 'yep' } })
|
95
117
|
end
|
96
118
|
|
119
|
+
it "merges global config over both kitchen.local.yml and kitchen.yml" do
|
120
|
+
stub_yaml!(".kitchen.yml", {
|
121
|
+
'common' => { 'thekey' => 'nope' }
|
122
|
+
})
|
123
|
+
stub_yaml!(".kitchen.local.yml", {
|
124
|
+
'common' => { 'thekey' => 'yep' }
|
125
|
+
})
|
126
|
+
stub_global!({
|
127
|
+
'common' => { 'thekey' => 'kinda' }
|
128
|
+
})
|
129
|
+
|
130
|
+
loader.read.must_equal({ :common => { :thekey => 'kinda' } })
|
131
|
+
end
|
132
|
+
|
97
133
|
it "handles a kitchen.local.yml with no yaml elements" do
|
98
134
|
stub_yaml!(".kitchen.yml", {
|
99
135
|
'a' => 'b'
|
@@ -112,6 +148,15 @@ describe Kitchen::Loader::YAML do
|
|
112
148
|
loader.read.must_equal({ :a => 'b' })
|
113
149
|
end
|
114
150
|
|
151
|
+
it "handles a kitchen.yml with yaml elements that parse as nil" do
|
152
|
+
stub_yaml!(".kitchen.yml", nil)
|
153
|
+
stub_yaml!(".kitchen.local.yml", {
|
154
|
+
'a' => 'b'
|
155
|
+
})
|
156
|
+
|
157
|
+
loader.read.must_equal({ :a => 'b' })
|
158
|
+
end
|
159
|
+
|
115
160
|
it "raises an UserError if the config_file does not exist" do
|
116
161
|
proc { loader.read }.must_raise Kitchen::UserError
|
117
162
|
end
|
@@ -239,12 +284,34 @@ describe Kitchen::Loader::YAML do
|
|
239
284
|
|
240
285
|
loader.read.must_equal({ :a => 'b' })
|
241
286
|
end
|
287
|
+
|
288
|
+
it "skips the global config if disabled" do
|
289
|
+
loader = Kitchen::Loader::YAML.new(
|
290
|
+
'/tmp/.kitchen.yml', :process_global => false)
|
291
|
+
stub_yaml!(".kitchen.yml", {
|
292
|
+
'a' => 'b'
|
293
|
+
})
|
294
|
+
stub_global!({
|
295
|
+
'superawesomesauceadditions' => 'enabled, yo'
|
296
|
+
})
|
297
|
+
|
298
|
+
loader.read.must_equal({ :a => 'b' })
|
299
|
+
end
|
242
300
|
end
|
243
301
|
|
244
302
|
private
|
245
303
|
|
304
|
+
def stub_file(path, hash)
|
305
|
+
FileUtils.mkdir_p(File.dirname(path))
|
306
|
+
File.open(path, "wb") { |f| f.write(hash.to_yaml) }
|
307
|
+
end
|
308
|
+
|
246
309
|
def stub_yaml!(name = ".kitchen.yml", hash)
|
247
|
-
|
248
|
-
|
310
|
+
stub_file(File.join("/tmp", name), hash)
|
311
|
+
end
|
312
|
+
|
313
|
+
def stub_global!(hash)
|
314
|
+
stub_file(File.join(File.expand_path(ENV["HOME"]),
|
315
|
+
".kitchen", "config.yml"), hash)
|
249
316
|
end
|
250
317
|
end
|
data/spec/kitchen/util_spec.rb
CHANGED
@@ -92,6 +92,10 @@ describe Kitchen::Util do
|
|
92
92
|
|
93
93
|
describe ".duration" do
|
94
94
|
|
95
|
+
it "turns nil into a zero" do
|
96
|
+
Kitchen::Util.duration(nil).must_equal "(0m0.00s)"
|
97
|
+
end
|
98
|
+
|
95
99
|
it "formats seconds to 2 digits" do
|
96
100
|
Kitchen::Util.duration(60).must_equal "(1m0.00s)"
|
97
101
|
end
|
@@ -1,24 +1,25 @@
|
|
1
1
|
---
|
2
2
|
driver_plugin: <%= config[:driver_plugin] %>
|
3
|
+
driver_config:
|
4
|
+
require_chef_omnibus: true
|
3
5
|
|
4
6
|
platforms:
|
5
7
|
- name: ubuntu-12.04
|
6
8
|
driver_config:
|
7
|
-
box:
|
8
|
-
box_url:
|
9
|
-
require_chef_omnibus: true
|
9
|
+
box: opscode-ubuntu-12.04
|
10
|
+
box_url: https://opscode-vm.s3.amazonaws.com/vagrant/opscode_ubuntu-12.04_provisionerless.box
|
10
11
|
- name: ubuntu-10.04
|
11
12
|
driver_config:
|
12
13
|
box: opscode-ubuntu-10.04
|
13
|
-
box_url:
|
14
|
-
- name: centos-6.
|
14
|
+
box_url: https://opscode-vm.s3.amazonaws.com/vagrant/opscode_ubuntu-10.04_provisionerless.box
|
15
|
+
- name: centos-6.4
|
15
16
|
driver_config:
|
16
|
-
box: opscode-centos-6.
|
17
|
-
box_url:
|
18
|
-
- name: centos-5.
|
17
|
+
box: opscode-centos-6.4
|
18
|
+
box_url: https://opscode-vm.s3.amazonaws.com/vagrant/opscode_centos-6.4_provisionerless.box
|
19
|
+
- name: centos-5.9
|
19
20
|
driver_config:
|
20
|
-
box: opscode-centos-5.
|
21
|
-
box_url:
|
21
|
+
box: opscode-centos-5.9
|
22
|
+
box_url: https://opscode-vm.s3.amazonaws.com/vagrant/opscode_centos-5.9_provisionerless.box
|
22
23
|
|
23
24
|
suites:
|
24
25
|
- name: default
|
data/test-kitchen.gemspec
CHANGED
@@ -28,7 +28,10 @@ Gem::Specification.new do |gem|
|
|
28
28
|
gem.add_dependency 'mixlib-shellout'
|
29
29
|
gem.add_dependency 'safe_yaml'
|
30
30
|
|
31
|
-
gem.add_development_dependency '
|
31
|
+
gem.add_development_dependency 'bundler', '~> 1.3'
|
32
|
+
gem.add_development_dependency 'rake'
|
33
|
+
|
34
|
+
gem.add_development_dependency 'minitest', '~> 4.7'
|
32
35
|
gem.add_development_dependency 'mocha'
|
33
36
|
gem.add_development_dependency 'fakefs'
|
34
37
|
gem.add_development_dependency 'guard-minitest'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: test-kitchen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.alpha.
|
4
|
+
version: 1.0.0.alpha.7
|
5
5
|
prerelease: 6
|
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: 2013-05-
|
12
|
+
date: 2013-05-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: celluloid
|
@@ -124,7 +124,23 @@ dependencies:
|
|
124
124
|
- !ruby/object:Gem::Version
|
125
125
|
version: '0'
|
126
126
|
- !ruby/object:Gem::Dependency
|
127
|
-
name:
|
127
|
+
name: bundler
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ~>
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '1.3'
|
134
|
+
type: :development
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ~>
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '1.3'
|
142
|
+
- !ruby/object:Gem::Dependency
|
143
|
+
name: rake
|
128
144
|
requirement: !ruby/object:Gem::Requirement
|
129
145
|
none: false
|
130
146
|
requirements:
|
@@ -139,6 +155,22 @@ dependencies:
|
|
139
155
|
- - ! '>='
|
140
156
|
- !ruby/object:Gem::Version
|
141
157
|
version: '0'
|
158
|
+
- !ruby/object:Gem::Dependency
|
159
|
+
name: minitest
|
160
|
+
requirement: !ruby/object:Gem::Requirement
|
161
|
+
none: false
|
162
|
+
requirements:
|
163
|
+
- - ~>
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '4.7'
|
166
|
+
type: :development
|
167
|
+
prerelease: false
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
none: false
|
170
|
+
requirements:
|
171
|
+
- - ~>
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '4.7'
|
142
174
|
- !ruby/object:Gem::Dependency
|
143
175
|
name: mocha
|
144
176
|
requirement: !ruby/object:Gem::Requirement
|
@@ -337,6 +369,7 @@ files:
|
|
337
369
|
- features/kitchen_driver_create_command.feature
|
338
370
|
- features/kitchen_driver_discover_command.feature
|
339
371
|
- features/kitchen_init_command.feature
|
372
|
+
- features/sink_command.feature
|
340
373
|
- features/step_definitions/gem_steps.rb
|
341
374
|
- features/support/env.rb
|
342
375
|
- lib/kitchen.rb
|
@@ -427,6 +460,7 @@ test_files:
|
|
427
460
|
- features/kitchen_driver_create_command.feature
|
428
461
|
- features/kitchen_driver_discover_command.feature
|
429
462
|
- features/kitchen_init_command.feature
|
463
|
+
- features/sink_command.feature
|
430
464
|
- features/step_definitions/gem_steps.rb
|
431
465
|
- features/support/env.rb
|
432
466
|
- spec/kitchen/collection_spec.rb
|