test-kitchen 1.0.0.beta.2 → 1.0.0.beta.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2783a5d91e3ede1c1fbfbbd52d6b222e8ed1d627
4
- data.tar.gz: 4fbe18231333671c28f4e3966180f6ce3a367421
3
+ metadata.gz: 1e92b944518afe8ad9023cf97a51f14b427b28a0
4
+ data.tar.gz: e4f216d248e9e467eaa19b6c2049cb2d36cfc0f8
5
5
  SHA512:
6
- metadata.gz: 6730c6bd2bcf30b96606d58462d93223ad834a657fbec997f6df5200b139d119b56353999c1aa3a182734dff83a261bcba644893391e7a3160edb0a2eb8a8329
7
- data.tar.gz: 988e5ff4c304e3de8f77bc77b092d4abd1c8896d22ffff2ffcae8a6666c12709f1def87fb995415bffc522b1699f25ed10cf319b003c67a7f5daad659a074f61
6
+ metadata.gz: 368dd8fbff5b816cc4622533809dd0992a3074818c93d0881312a1b988d2e3bb8786085ef3b82f6f8afd9cdd036279030c085e7cee2b8fd27dace7754e4b436b
7
+ data.tar.gz: 78bc12ab69f016079a311da68c6122144dcd8c94849a7b2f4c8cc22155bc5fd484403fbfef057536eccdf9450ae6d892b2ce2d061ce6c5625525b4087c5db3d8
data/CHANGELOG.md CHANGED
@@ -1,3 +1,22 @@
1
+ ## 1.0.0.beta.3 / 2013-08-29
2
+
3
+ ### Bug fixes
4
+
5
+ * Pull request [#157][]: Include definitions directory when uploading the cookbooks. ([@jasonroelofs][])
6
+ * Pull request [#178][]: Fix SSH#wait's logger call to #info. ([@ryansouza][])
7
+ * Pull request [#188][]: Truthy default_configs can now be overridden. ([@thommay][])
8
+
9
+ ### Improvements
10
+
11
+ * Allow Test Kitchen to be used as a library; CWD is not enough. ([@portertech][])
12
+ * Add `kitchen list --debug` to display all merged & calculated config. ([@fnichol][])
13
+ * Add retry logic to Kitchen:SSH when initiating a connection. ([@fnichol][])
14
+ * Pull request [#147][]: Allow chef omnibus install.sh url to be configurable. ([@jrwesolo][])
15
+ * Pull request [#187][]: Add support for log file in chef solo. ([@arangamani][])
16
+ * Pull request [#179][]: Remove bundler references from README. ([@juliandunn][])
17
+ * Compute default test_base_path in Config based on kitchen_root. ([@fnichol][])
18
+
19
+
1
20
  ## 1.0.0.beta.2 / 2013-07-24
2
21
 
3
22
  ### Bug fixes
@@ -208,35 +227,47 @@ The initial release.
208
227
  [#137]: https://github.com/opscode/test-kitchen/issues/137
209
228
  [#140]: https://github.com/opscode/test-kitchen/issues/140
210
229
  [#142]: https://github.com/opscode/test-kitchen/issues/142
230
+ [#147]: https://github.com/opscode/test-kitchen/issues/147
211
231
  [#151]: https://github.com/opscode/test-kitchen/issues/151
212
232
  [#152]: https://github.com/opscode/test-kitchen/issues/152
213
233
  [#153]: https://github.com/opscode/test-kitchen/issues/153
214
234
  [#154]: https://github.com/opscode/test-kitchen/issues/154
215
235
  [#155]: https://github.com/opscode/test-kitchen/issues/155
236
+ [#157]: https://github.com/opscode/test-kitchen/issues/157
216
237
  [#161]: https://github.com/opscode/test-kitchen/issues/161
217
238
  [#163]: https://github.com/opscode/test-kitchen/issues/163
218
239
  [#170]: https://github.com/opscode/test-kitchen/issues/170
219
240
  [#171]: https://github.com/opscode/test-kitchen/issues/171
220
241
  [#172]: https://github.com/opscode/test-kitchen/issues/172
242
+ [#178]: https://github.com/opscode/test-kitchen/issues/178
243
+ [#179]: https://github.com/opscode/test-kitchen/issues/179
244
+ [#187]: https://github.com/opscode/test-kitchen/issues/187
245
+ [#188]: https://github.com/opscode/test-kitchen/issues/188
221
246
  [@ChrisLundquist]: https://github.com/ChrisLundquist
222
247
  [@adamhjk]: https://github.com/adamhjk
248
+ [@arangamani]: https://github.com/arangamani
223
249
  [@arunthampi]: https://github.com/arunthampi
224
250
  [@bryanwb]: https://github.com/bryanwb
225
251
  [@calavera]: https://github.com/calavera
226
252
  [@fnichol]: https://github.com/fnichol
227
253
  [@gondoi]: https://github.com/gondoi
228
254
  [@grahamc]: https://github.com/grahamc
255
+ [@jasonroelofs]: https://github.com/jasonroelofs
229
256
  [@jonsmorrow]: https://github.com/jonsmorrow
230
257
  [@josephholsten]: https://github.com/josephholsten
258
+ [@jrwesolo]: https://github.com/jrwesolo
231
259
  [@jtimberman]: https://github.com/jtimberman
260
+ [@juliandunn]: https://github.com/juliandunn
232
261
  [@manul]: https://github.com/manul
233
262
  [@mattray]: https://github.com/mattray
234
263
  [@mconigliaro]: https://github.com/mconigliaro
235
264
  [@patcon]: https://github.com/patcon
265
+ [@portertech]: https://github.com/portertech
236
266
  [@reset]: https://github.com/reset
237
267
  [@rteabeault]: https://github.com/rteabeault
268
+ [@ryansouza]: https://github.com/ryansouza
238
269
  [@saketoba]: https://github.com/saketoba
239
270
  [@sethvargo]: https://github.com/sethvargo
240
271
  [@smith]: https://github.com/smith
241
272
  [@stevendanna]: https://github.com/stevendanna
242
- [@thommay]: https://github.com/thommay
273
+ [@thommay]: https://github.com/thommay
data/README.md CHANGED
@@ -7,54 +7,36 @@ A convergence integration test harness for configuration management systems.
7
7
 
8
8
  # Getting started
9
9
 
10
-
11
10
  Project Setup
12
11
  -------------
13
12
 
14
- In your `Gemfile`, add `test-kitchen` as a
15
- dependency:
13
+ Install the `test-kitchen` gem. `--pre` is necessary because Test Kitchen 1.0.0 has not been released yet.
16
14
 
17
- ```ruby
18
- gem 'test-kitchen', '~> 1.0.0.alpha'
15
+ ```text
16
+ $ gem install test-kitchen --pre
19
17
  ```
20
18
 
21
- and run the `bundle` command to install:
22
-
23
- $ bundle install
24
-
25
- This will expose the `test-kitchen` CLI. Run `bundle exec kitchen init` to get started:
26
-
27
- $ kitchen init
28
-
29
- You will be prompted with a series of questions. In this guide, we
30
- will be using the [kitchen vagrant driver](https://github.com/opscode/kitchen-vagrant).
19
+ This will expose the `test-kitchen` CLI. Run `kitchen init` to get started:
31
20
 
32
21
  ```text
33
- $ bundle exec kitchen init
22
+ $ kitchen init
34
23
  create .kitchen.yml
35
- append Rakefile
36
- create test/integration/default
37
- append .gitignore
38
- append .gitignore
39
- Add a Driver plugin to your Gemfile?
40
- (y/n)> y
41
- Enter gem name, `list', or `skip'>
42
- kitchen-vagrant
43
- append Gemfile
44
- You must run `bundle install' to fetch any new gems.
45
24
  ```
25
+ In this guide, we
26
+ will be using the [kitchen vagrant driver](https://github.com/opscode/kitchen-vagrant),
27
+ so install that:
46
28
 
47
- Run the `bundle` command again to install the new vagrant driver:
48
-
49
- $ bundle install
29
+ ```text
30
+ $ gem install kitchen-vagrant
31
+ ```
50
32
 
51
33
  Open up the `.kitchen.yml` file created in the root of your
52
- repository.
34
+ repository and modify it if you wish.
53
35
 
54
36
  Now, it is time to get testing. Use the `--parallel` option to run
55
37
  your tests in parallel. Trust us, it's faster!
56
38
 
57
- $ bundle exec kitchen test
39
+ $ kitchen test
58
40
 
59
41
  ### Helpful Switches
60
42
 
@@ -35,11 +35,12 @@ module Kitchen
35
35
  # @param [Hash] opts optional configuration
36
36
  # @option opts [TrueClass, FalseClass] :use_sudo whether or not to invoke
37
37
  # sudo before commands requiring root access (default: `true`)
38
- def initialize(suite_name, opts = { :use_sudo => true })
38
+ def initialize(suite_name, opts = {})
39
39
  validate_options(suite_name)
40
40
 
41
+ @test_root = opts.fetch(:test_root, DEFAULT_TEST_ROOT)
41
42
  @suite_name = suite_name
42
- @use_sudo = opts[:use_sudo]
43
+ @use_sudo = opts.fetch(:use_sudo, true)
43
44
  end
44
45
 
45
46
  # Returns a command string which installs Busser, and installs all
@@ -103,6 +104,8 @@ module Kitchen
103
104
  DEFAULT_BUSSER_ROOT = "/opt/busser".freeze
104
105
  DEFAULT_TEST_ROOT = File.join(Dir.pwd, "test/integration").freeze
105
106
 
107
+ attr_reader :test_root
108
+
106
109
  def validate_options(suite_name)
107
110
  if suite_name.nil?
108
111
  raise ClientError, "Busser#new requires a suite_name"
@@ -170,9 +173,5 @@ module Kitchen
170
173
  def busser_gem
171
174
  "busser"
172
175
  end
173
-
174
- def test_root
175
- DEFAULT_TEST_ROOT
176
- end
177
176
  end
178
177
  end
data/lib/kitchen/cli.rb CHANGED
@@ -51,9 +51,13 @@ module Kitchen
51
51
  desc "list [(all|<REGEX>)]", "List all instances"
52
52
  method_option :bare, :aliases => "-b", :type => :boolean,
53
53
  :desc => "List the name of each instance only, one per line"
54
+ method_option :debug, :aliases => "-d", :type => :boolean,
55
+ :desc => "Show computed driver configuration for each instance"
54
56
  def list(*args)
55
57
  result = parse_subcommand(args.first)
56
- if options[:bare]
58
+ if options[:debug]
59
+ Array(result).each { |i| debug_instance(i) }
60
+ elsif options[:bare]
57
61
  say Array(result).map { |i| i.name }.join("\n")
58
62
  else
59
63
  list_table(result)
@@ -333,6 +337,22 @@ module Kitchen
333
337
  ]
334
338
  end
335
339
 
340
+ def debug_instance(instance)
341
+ say "--------"
342
+ say "Instance: #{instance.name}"
343
+ say "Driver: #{instance.driver.name}"
344
+ say "Driver Config:"
345
+ instance.driver.config_keys.sort.each do |key|
346
+ say " #{key}: #{instance.driver[key]}"
347
+ end
348
+ if instance.kind_of?(Instance::Cheflike)
349
+ say "Chef Config:"
350
+ say " attributes: #{instance.attributes.inspect}"
351
+ say " run_list: #{instance.run_list.inspect}"
352
+ end
353
+ say ""
354
+ end
355
+
336
356
  def color_pad(string)
337
357
  string + set_color("", :white)
338
358
  end
@@ -40,9 +40,6 @@ module Kitchen
40
40
  # Default provisioner to use
41
41
  DEFAULT_PROVISIONER = "chef_solo".freeze
42
42
 
43
- # Default base path which may contain `data_bags/` directories
44
- DEFAULT_TEST_BASE_PATH = File.join(Dir.pwd, 'test/integration').freeze
45
-
46
43
  # Creates a new configuration.
47
44
  #
48
45
  # @param [Hash] options configuration
@@ -54,7 +51,7 @@ module Kitchen
54
51
  def initialize(options = {})
55
52
  @loader = options[:loader] || Kitchen::Loader::YAML.new
56
53
  @kitchen_root = options[:kitchen_root] || Dir.pwd
57
- @test_base_path = options[:test_base_path] || DEFAULT_TEST_BASE_PATH
54
+ @test_base_path = options[:test_base_path] || default_test_base_path
58
55
  @log_level = options[:log_level] || Kitchen::DEFAULT_LOG_LEVEL
59
56
  @supervised = options[:supervised]
60
57
  end
@@ -258,5 +255,9 @@ module Kitchen
258
255
  [:driver_plugin, :driver_config, :provisioner].include?(key)
259
256
  end
260
257
  end
258
+
259
+ def default_test_base_path
260
+ File.join(kitchen_root, 'test/integration')
261
+ end
261
262
  end
262
263
  end
@@ -39,7 +39,7 @@ module Kitchen
39
39
  def initialize(config = {})
40
40
  @config = LazyDriverHash.new(config, self)
41
41
  self.class.defaults.each do |attr, value|
42
- @config[attr] = value unless @config[attr]
42
+ @config[attr] = value unless @config.has_key?(attr)
43
43
  end
44
44
  end
45
45
 
@@ -64,6 +64,13 @@ module Kitchen
64
64
  config[attr]
65
65
  end
66
66
 
67
+ # Returns an array of configuration keys.
68
+ #
69
+ # @return [Array] array of configuration keys
70
+ def config_keys
71
+ config.keys
72
+ end
73
+
67
74
  # Creates an instance.
68
75
  #
69
76
  # @param state [Hash] mutable instance and driver state
@@ -153,10 +160,11 @@ module Kitchen
153
160
  end
154
161
 
155
162
  def busser
163
+ test_root = File.join(config[:kitchen_root], 'test/integration')
156
164
  @busser ||= begin
157
165
  raise ClientError, "Instance must be set for Driver" if instance.nil?
158
166
 
159
- Busser.new(instance.suite.name)
167
+ Busser.new(instance.suite.name, :test_root => test_root)
160
168
  end
161
169
  end
162
170
 
@@ -227,6 +235,12 @@ module Kitchen
227
235
  proc_or_val
228
236
  end
229
237
  end
238
+
239
+ def to_hash
240
+ hash = Hash.new
241
+ __getobj__.keys.each { |key| hash[key] = self[key] }
242
+ hash
243
+ end
230
244
  end
231
245
  end
232
246
  end
@@ -85,7 +85,7 @@ module Kitchen
85
85
  end
86
86
 
87
87
  def build_ssh_args(state)
88
- combined = config.merge(state)
88
+ combined = config.to_hash.merge(state)
89
89
 
90
90
  opts = Hash.new
91
91
  opts[:user_known_hosts_file] = "/dev/null"
@@ -123,7 +123,7 @@ module Kitchen
123
123
  end
124
124
 
125
125
  def wait_for_sshd(hostname, username = nil, options = {})
126
- SSH.new(hostname, username, options).wait
126
+ SSH.new(hostname, username, { :logger => logger }.merge(options)).wait
127
127
  end
128
128
  end
129
129
  end
@@ -181,7 +181,7 @@ module Kitchen
181
181
  end
182
182
 
183
183
  def unbundlerize
184
- keys = %w[BUNDLER_EDITOR BUNDLE_BIN_PATH BUNDLE_GEMFILE RUBYOPT]
184
+ keys = ENV.keys.select { |key| key =~ /^BUNDLER?_/ } + %w[RUBYOPT]
185
185
 
186
186
  keys.each { |key| ENV["__#{key}"] = ENV[key] ; ENV.delete(key) }
187
187
  yield
@@ -31,7 +31,7 @@ module Kitchen
31
31
  def install_command
32
32
  return nil unless config[:require_chef_omnibus]
33
33
 
34
- url = "https://www.opscode.com/chef/install.sh"
34
+ url = config[:chef_omnibus_url] || "https://www.opscode.com/chef/install.sh"
35
35
  flag = config[:require_chef_omnibus]
36
36
  version = if flag.is_a?(String) && flag != "latest"
37
37
  "-s -- -v #{flag.downcase}"
@@ -237,7 +237,7 @@ module Kitchen
237
237
  " Please add: `name '<cookbook_name>'` to metadata.rb and retry")
238
238
 
239
239
  cb_path = File.join(tmpbooks_dir, cb_name)
240
- glob = Dir.glob("#{kitchen_root}/{metadata.rb,README.*," +
240
+ glob = Dir.glob("#{kitchen_root}/{metadata.rb,README.*,definitions," +
241
241
  "attributes,files,libraries,providers,recipes,resources,templates}")
242
242
 
243
243
  FileUtils.mkdir_p(cb_path)
@@ -279,7 +279,7 @@ module Kitchen
279
279
  end
280
280
 
281
281
  Kitchen.mutex.synchronize do
282
- env = Librarian::Chef::Environment.new
282
+ env = Librarian::Chef::Environment.new(:project_path => kitchen_root)
283
283
  env.config_db.local["path"] = tmpbooks_dir
284
284
  Librarian::Action::Resolve.new(env).run
285
285
  Librarian::Action::Install.new(env).run
@@ -36,6 +36,7 @@ module Kitchen
36
36
  sudo('chef-solo'),
37
37
  "--config #{home_path}/solo.rb",
38
38
  "--json-attributes #{home_path}/dna.json",
39
+ config[:log_file] ? "--logfile #{config[:log_file]}" : nil,
39
40
  "--log_level #{config[:log_level]}"
40
41
  ].join(" ")
41
42
  end
data/lib/kitchen/ssh.rb CHANGED
@@ -86,7 +86,7 @@ module Kitchen
86
86
  end
87
87
 
88
88
  def wait
89
- logger.log("Waiting for #{hostname}:#{port}...") until test_ssh
89
+ logger.info("Waiting for #{hostname}:#{port}...") until test_ssh
90
90
  end
91
91
 
92
92
  def login_command
@@ -105,9 +105,28 @@ module Kitchen
105
105
  attr_reader :hostname, :username, :options, :logger
106
106
 
107
107
  def session
108
- @session ||= begin
108
+ @session ||= establish_connection
109
+ end
110
+
111
+ def establish_connection
112
+ rescue_exceptions = [
113
+ Errno::EACCES, Errno::EADDRINUSE, Errno::ECONNREFUSED,
114
+ Errno::ECONNRESET, Errno::ENETUNREACH, Errno::EHOSTUNREACH,
115
+ Net::SSH::Disconnect
116
+ ]
117
+ retries = 3
118
+
119
+ begin
109
120
  logger.debug("[SSH] opening connection to #{self}")
110
121
  Net::SSH.start(hostname, username, options)
122
+ rescue *rescue_exceptions => e
123
+ if (retries -= 1) > 0
124
+ logger.info("[SSH] connection failed, retrying (#{e.inspect})")
125
+ retry
126
+ else
127
+ logger.warn("[SSH] connection failed, terminating (#{e.inspect})")
128
+ raise
129
+ end
111
130
  end
112
131
  end
113
132
 
@@ -18,5 +18,5 @@
18
18
 
19
19
  module Kitchen
20
20
 
21
- VERSION = "1.0.0.beta.2"
21
+ VERSION = "1.0.0.beta.3"
22
22
  end
@@ -30,6 +30,7 @@ module Kitchen
30
30
 
31
31
  default_config :beans, "kidney"
32
32
  default_config :tunables, { 'flimflam' => 'positate' }
33
+ default_config :edible, true
33
34
  end
34
35
 
35
36
  class ComputedDefaults < Base
@@ -88,12 +89,15 @@ describe Kitchen::Driver::Base do
88
89
  it "uses default config" do
89
90
  driver[:beans].must_equal "kidney"
90
91
  driver[:tunables]['flimflam'].must_equal 'positate'
92
+ driver[:edible].must_equal true
91
93
  end
92
94
 
93
95
  it "uses user config over default config" do
94
96
  config[:beans] = "pinto"
97
+ config[:edible] = false
95
98
 
96
99
  driver[:beans].must_equal "pinto"
100
+ driver[:edible].must_equal false
97
101
  end
98
102
  end
99
103
 
data/test-kitchen.gemspec CHANGED
@@ -26,7 +26,7 @@ Gem::Specification.new do |gem|
26
26
  gem.add_dependency 'net-ssh'
27
27
  gem.add_dependency 'net-scp'
28
28
  gem.add_dependency 'mixlib-shellout'
29
- gem.add_dependency 'safe_yaml', '~> 0.9.3'
29
+ gem.add_dependency 'safe_yaml', '~> 0.9.5'
30
30
 
31
31
  gem.add_development_dependency 'bundler', '~> 1.3'
32
32
  gem.add_development_dependency 'rake'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test-kitchen
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.beta.2
4
+ version: 1.0.0.beta.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fletcher Nichol
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-25 00:00:00.000000000 Z
11
+ date: 2013-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: celluloid
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - ~>
102
102
  - !ruby/object:Gem::Version
103
- version: 0.9.3
103
+ version: 0.9.5
104
104
  type: :runtime
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.9.3
110
+ version: 0.9.5
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: bundler
113
113
  requirement: !ruby/object:Gem::Requirement