test-kitchen 1.0.0.beta.4 → 1.0.0.rc.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +50 -1
  3. data/Gemfile +1 -1
  4. data/README.md +18 -7
  5. data/Rakefile +8 -1
  6. data/features/kitchen_init_command.feature +90 -11
  7. data/features/step_definitions/git_steps.rb +3 -0
  8. data/lib/kitchen/busser.rb +79 -45
  9. data/lib/kitchen/cli.rb +14 -13
  10. data/lib/kitchen/config.rb +79 -138
  11. data/lib/kitchen/data_munger.rb +224 -0
  12. data/lib/kitchen/driver/base.rb +4 -31
  13. data/lib/kitchen/driver/ssh_base.rb +6 -16
  14. data/lib/kitchen/driver.rb +4 -0
  15. data/lib/kitchen/generator/init.rb +20 -9
  16. data/lib/kitchen/instance.rb +53 -58
  17. data/lib/kitchen/lazy_hash.rb +50 -0
  18. data/lib/kitchen/platform.rb +2 -31
  19. data/lib/kitchen/provisioner/base.rb +55 -9
  20. data/lib/kitchen/provisioner/chef/berkshelf.rb +76 -0
  21. data/lib/kitchen/provisioner/chef/librarian.rb +72 -0
  22. data/lib/kitchen/provisioner/chef_base.rb +159 -78
  23. data/lib/kitchen/provisioner/chef_solo.rb +6 -36
  24. data/lib/kitchen/provisioner/chef_zero.rb +70 -59
  25. data/lib/kitchen/provisioner/dummy.rb +28 -0
  26. data/lib/kitchen/provisioner.rb +6 -4
  27. data/lib/kitchen/shell_out.rb +2 -5
  28. data/lib/kitchen/ssh.rb +1 -1
  29. data/lib/kitchen/suite.rb +10 -79
  30. data/lib/kitchen/util.rb +2 -2
  31. data/lib/kitchen/version.rb +2 -2
  32. data/lib/kitchen.rb +5 -0
  33. data/spec/kitchen/config_spec.rb +84 -123
  34. data/spec/kitchen/data_munger_spec.rb +1412 -0
  35. data/spec/kitchen/driver/base_spec.rb +30 -0
  36. data/spec/kitchen/instance_spec.rb +868 -86
  37. data/spec/kitchen/lazy_hash_spec.rb +63 -0
  38. data/spec/kitchen/platform_spec.rb +0 -22
  39. data/spec/kitchen/provisioner/base_spec.rb +210 -0
  40. data/spec/kitchen/provisioner_spec.rb +70 -0
  41. data/spec/kitchen/suite_spec.rb +25 -38
  42. data/spec/spec_helper.rb +1 -0
  43. data/support/chef-client-zero.rb +51 -35
  44. data/support/dummy-validation.pem +27 -0
  45. data/templates/init/kitchen.yml.erb +10 -22
  46. data/test-kitchen.gemspec +1 -2
  47. metadata +20 -18
data/spec/spec_helper.rb CHANGED
@@ -31,6 +31,7 @@ SimpleCov.start 'gem'
31
31
  require 'fakefs/safe'
32
32
  require 'minitest/autorun'
33
33
  require 'mocha/setup'
34
+ require 'tempfile'
34
35
 
35
36
  # enable yaml symbol parsing if code is executing under guard
36
37
  if ENV['GUARD_NOTIFY']
@@ -18,42 +18,58 @@
18
18
  # limitations under the License.
19
19
 
20
20
  require 'rubygems'
21
- require 'chef'
22
- require 'chef/application/client'
21
+ require 'chef/config'
23
22
  require 'chef_zero/server'
24
- require 'chef_fs/chef_fs_data_store'
25
- require 'chef_fs/config'
26
- require 'tmpdir'
27
-
28
- client = Chef::Application::Client.new
29
- client.reconfigure
30
-
31
- data_store = ChefFS::ChefFSDataStore.new(
32
- ChefFS::Config.new(Chef::Config).local_fs
33
- )
34
-
35
- server_opts = {
36
- :host => "127.0.0.1",
37
- :port => 8889,
38
- :generate_real_keys => false,
39
- :data_store => data_store
40
- }
41
-
42
- Chef::Log.info("Starting Chef Zero server in background")
43
- server = ChefZero::Server.new(server_opts)
44
- server.start_background
45
- at_exit do
46
- Chef::Log.info("Shutting down Chef Zero server")
47
- server.stop
48
- end
23
+ require 'chef/chef_fs/chef_fs_data_store'
24
+ require 'chef/chef_fs/config'
25
+ require 'fileutils'
26
+
27
+ # Bust out of our self-imposed sandbox before running chef-client so
28
+ # gems installed via gem_package land in Chef's GEM_HOME.
29
+ #
30
+ # https://github.com/opscode/test-kitchen/issues/240
31
+ #
32
+ ENV['GEM_HOME'] = ENV['GEM_PATH'] = ENV['GEM_CACHE'] = nil
33
+
34
+ class ChefClientZero
35
+
36
+ def self.start
37
+ new.run
38
+ end
39
+
40
+ def run
41
+ create_chef_zero_server
42
+ run_chef_client
43
+ end
49
44
 
50
- Dir.mktmpdir do |tmpdir|
51
- File.open(File.join(tmpdir, "validation.pem"), "wb") do |f|
52
- f.write(server.gen_key_pair.first)
45
+ private
46
+
47
+ def create_chef_zero_server
48
+ Chef::Config.chef_repo_path = Chef::Config.find_chef_repo_path(repo_path)
49
+
50
+ chef_fs = Chef::ChefFS::Config.new.local_fs
51
+ chef_fs.write_pretty_json = true
52
+
53
+ @server = ChefZero::Server.new(
54
+ :generate_real_keys => false,
55
+ :data_store => Chef::ChefFS::ChefFSDataStore.new(chef_fs)
56
+ )
57
+ puts "-----> Starting Chef Zero server in #{chef_fs.fs_description}"
58
+ @server.start_background
59
+
60
+ at_exit do
61
+ puts "-----> Shutting down Chef Zero server"
62
+ @server.stop
63
+ end
64
+ end
65
+
66
+ def repo_path
67
+ ENV.fetch('CHEF_REPO_PATH', Dir.pwd)
68
+ end
69
+
70
+ def run_chef_client
71
+ system("chef-client", *ARGV)
53
72
  end
54
- Chef::Config[:validation_key] = File.join(tmpdir, "validation.pem")
55
- Chef::Config[:client_key] = File.join(tmpdir, "client.pem")
56
- Chef::Config[:chef_server_url] = server.url
57
- client.setup_application
58
- client.run_application
59
73
  end
74
+
75
+ ChefClientZero.start
@@ -0,0 +1,27 @@
1
+ -----BEGIN RSA PRIVATE KEY-----
2
+ MIIEpAIBAAKCAQEA0sOY9tHvVtLZ6xmVmH8d8LrRrNcWOXbrvvCrai+T3GtRvRSL
3
+ hksLrpOpD0L9EHM6NdThNF/eGA9Oq+UKAe6yXR0hwsKuxKXqQ8SEmlhZZ9GiuggD
4
+ B/zYD3ItB6SGpdkRe7kQqTChQyrIXqbRkJqxoTXLyeJDF0sCyTdp3L8IZCUWodM8
5
+ oV9TlQBJHYtG1gLUwIi8kcMVEoCn2Q8ltCj0/ftnwhTtwO52RkWA0uYOL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QKBgQCswfjX8Eg8KL/lJNpIOOE3j4XXE9ptksmJl2sB
22
+ jxDnQYoiMqVO808saHVquC/vTrpd6tKtNpehWwjeTFuqITWLi8jmmQ+gNTKsC9Gn
23
+ 1Pxf2Gb67PqnEpwQGln+TRtgQ5HBrdHiQIi+5am+gnw89pDrjjO5rZwhanAo6KPJ
24
+ 1zcPNQKBgQDxFu8v4frDmRNCVaZS4f1B6wTrcMrnibIDlnzrK9GG6Hz1U7dDv8s8
25
+ Nf4UmeMzDXjlPWZVOvS5+9HKJPdPj7/onv8B2m18+lcgTTDJBkza7R1mjL1Cje/Z
26
+ KcVGsryKN6cjE7yCDasnA7R2rVBV/7NWeJV77bmzT5O//rW4yIfUIg==
27
+ -----END RSA PRIVATE KEY-----
@@ -1,27 +1,15 @@
1
1
  ---
2
- driver_plugin: <%= config[:driver_plugin] %>
3
- driver_config:
4
- require_chef_omnibus: true
2
+ driver: <%= config[:driver_plugin] %>
3
+ provisioner: <%= config[:provisioner] %>
5
4
 
6
5
  platforms:
7
- - name: ubuntu-12.04
8
- driver_config:
9
- box: opscode-ubuntu-12.04
10
- box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_ubuntu-12.04_provisionerless.box
11
- - name: ubuntu-10.04
12
- driver_config:
13
- box: opscode-ubuntu-10.04
14
- box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_ubuntu-10.04_provisionerless.box
15
- - name: centos-6.4
16
- driver_config:
17
- box: opscode-centos-6.4
18
- box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_centos-6.4_provisionerless.box
19
- - name: centos-5.9
20
- driver_config:
21
- box: opscode-centos-5.9
22
- box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_centos-5.9_provisionerless.box
6
+ - name: ubuntu-12.04
7
+ - name: centos-6.4
23
8
 
24
9
  suites:
25
- - name: default
26
- run_list: <%= config[:run_list].inspect %>
27
- attributes: {}
10
+ - name: default
11
+ run_list:
12
+ <% config[:run_list].each do |recipe| -%>
13
+ - <%= recipe %>
14
+ <% end -%>
15
+ attributes:
data/test-kitchen.gemspec CHANGED
@@ -25,14 +25,13 @@ Gem::Specification.new do |gem|
25
25
  gem.add_dependency 'net-ssh', '~> 2.7'
26
26
  gem.add_dependency 'safe_yaml', '~> 0.9'
27
27
  gem.add_dependency 'thor', '~> 0.18'
28
- gem.add_dependency 'buff-ignore', '~> 1.1'
29
28
 
30
29
  gem.add_development_dependency 'bundler', '~> 1.3'
31
30
  gem.add_development_dependency 'rake'
32
31
 
33
32
  gem.add_development_dependency 'aruba', '~> 0.5'
34
33
  gem.add_development_dependency 'fakefs', '~> 0.4'
35
- gem.add_development_dependency 'minitest', '~> 4.7'
34
+ gem.add_development_dependency 'minitest', '~> 5'
36
35
  gem.add_development_dependency 'mocha', '~> 0.14'
37
36
 
38
37
  gem.add_development_dependency 'cane', '~> 2.6'
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.4
4
+ version: 1.0.0.rc.1
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-11-01 00:00:00.000000000 Z
11
+ date: 2013-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mixlib-shellout
@@ -80,20 +80,6 @@ dependencies:
80
80
  - - ~>
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0.18'
83
- - !ruby/object:Gem::Dependency
84
- name: buff-ignore
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ~>
88
- - !ruby/object:Gem::Version
89
- version: '1.1'
90
- type: :runtime
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ~>
95
- - !ruby/object:Gem::Version
96
- version: '1.1'
97
83
  - !ruby/object:Gem::Dependency
98
84
  name: bundler
99
85
  requirement: !ruby/object:Gem::Requirement
@@ -156,14 +142,14 @@ dependencies:
156
142
  requirements:
157
143
  - - ~>
158
144
  - !ruby/object:Gem::Version
159
- version: '4.7'
145
+ version: '5'
160
146
  type: :development
161
147
  prerelease: false
162
148
  version_requirements: !ruby/object:Gem::Requirement
163
149
  requirements:
164
150
  - - ~>
165
151
  - !ruby/object:Gem::Version
166
- version: '4.7'
152
+ version: '5'
167
153
  - !ruby/object:Gem::Dependency
168
154
  name: mocha
169
155
  requirement: !ruby/object:Gem::Requirement
@@ -286,6 +272,7 @@ files:
286
272
  - features/kitchen_init_command.feature
287
273
  - features/sink_command.feature
288
274
  - features/step_definitions/gem_steps.rb
275
+ - features/step_definitions/git_steps.rb
289
276
  - features/support/env.rb
290
277
  - lib/kitchen.rb
291
278
  - lib/kitchen/busser.rb
@@ -293,6 +280,7 @@ files:
293
280
  - lib/kitchen/collection.rb
294
281
  - lib/kitchen/color.rb
295
282
  - lib/kitchen/config.rb
283
+ - lib/kitchen/data_munger.rb
296
284
  - lib/kitchen/driver.rb
297
285
  - lib/kitchen/driver/base.rb
298
286
  - lib/kitchen/driver/dummy.rb
@@ -302,6 +290,7 @@ files:
302
290
  - lib/kitchen/generator/driver_create.rb
303
291
  - lib/kitchen/generator/init.rb
304
292
  - lib/kitchen/instance.rb
293
+ - lib/kitchen/lazy_hash.rb
305
294
  - lib/kitchen/loader/yaml.rb
306
295
  - lib/kitchen/logger.rb
307
296
  - lib/kitchen/logging.rb
@@ -310,9 +299,12 @@ files:
310
299
  - lib/kitchen/platform.rb
311
300
  - lib/kitchen/provisioner.rb
312
301
  - lib/kitchen/provisioner/base.rb
302
+ - lib/kitchen/provisioner/chef/berkshelf.rb
303
+ - lib/kitchen/provisioner/chef/librarian.rb
313
304
  - lib/kitchen/provisioner/chef_base.rb
314
305
  - lib/kitchen/provisioner/chef_solo.rb
315
306
  - lib/kitchen/provisioner/chef_zero.rb
307
+ - lib/kitchen/provisioner/dummy.rb
316
308
  - lib/kitchen/rake_tasks.rb
317
309
  - lib/kitchen/shell_out.rb
318
310
  - lib/kitchen/ssh.rb
@@ -325,17 +317,22 @@ files:
325
317
  - spec/kitchen/collection_spec.rb
326
318
  - spec/kitchen/color_spec.rb
327
319
  - spec/kitchen/config_spec.rb
320
+ - spec/kitchen/data_munger_spec.rb
328
321
  - spec/kitchen/driver/base_spec.rb
329
322
  - spec/kitchen/driver/dummy_spec.rb
330
323
  - spec/kitchen/driver_spec.rb
331
324
  - spec/kitchen/instance_spec.rb
325
+ - spec/kitchen/lazy_hash_spec.rb
332
326
  - spec/kitchen/loader/yaml_spec.rb
333
327
  - spec/kitchen/platform_spec.rb
328
+ - spec/kitchen/provisioner/base_spec.rb
329
+ - spec/kitchen/provisioner_spec.rb
334
330
  - spec/kitchen/state_file_spec.rb
335
331
  - spec/kitchen/suite_spec.rb
336
332
  - spec/kitchen/util_spec.rb
337
333
  - spec/spec_helper.rb
338
334
  - support/chef-client-zero.rb
335
+ - support/dummy-validation.pem
339
336
  - templates/driver/CHANGELOG.md.erb
340
337
  - templates/driver/Gemfile.erb
341
338
  - templates/driver/README.md.erb
@@ -383,16 +380,21 @@ test_files:
383
380
  - features/kitchen_init_command.feature
384
381
  - features/sink_command.feature
385
382
  - features/step_definitions/gem_steps.rb
383
+ - features/step_definitions/git_steps.rb
386
384
  - features/support/env.rb
387
385
  - spec/kitchen/collection_spec.rb
388
386
  - spec/kitchen/color_spec.rb
389
387
  - spec/kitchen/config_spec.rb
388
+ - spec/kitchen/data_munger_spec.rb
390
389
  - spec/kitchen/driver/base_spec.rb
391
390
  - spec/kitchen/driver/dummy_spec.rb
392
391
  - spec/kitchen/driver_spec.rb
393
392
  - spec/kitchen/instance_spec.rb
393
+ - spec/kitchen/lazy_hash_spec.rb
394
394
  - spec/kitchen/loader/yaml_spec.rb
395
395
  - spec/kitchen/platform_spec.rb
396
+ - spec/kitchen/provisioner/base_spec.rb
397
+ - spec/kitchen/provisioner_spec.rb
396
398
  - spec/kitchen/state_file_spec.rb
397
399
  - spec/kitchen/suite_spec.rb
398
400
  - spec/kitchen/util_spec.rb