test-kitchen 1.0.0.beta.4 → 1.0.0.rc.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.
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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c66b46e1a915624ed333e89ef6e7c829db84cfd1
4
- data.tar.gz: 839dca4f7400f2dc66d4e5540684913cf586510e
3
+ metadata.gz: 531f23b775d0e1852010f3405773b4a36e938126
4
+ data.tar.gz: 7d447f5dca58df770141b9184606632bc4ae4a61
5
5
  SHA512:
6
- metadata.gz: 87dfa48955478b2a69137244a9bef11763662af13ceae16218499ee95da0b6971cbeedd441486d1d88d74665562b09b81077e89113788b0e293c4ce09c9ece01
7
- data.tar.gz: e60dbac3c1567c35eca1d819210d3298d564ce33cab87da49ff5a2a1a45d4bc0130c713a71cebdcf651db09b19a2b74088d20da9032c9864e809753a71c03464
6
+ metadata.gz: 39879c2db849837769c3375cae413a18521fd28978456336703c005c4aef3913dd1e20e83d55485ae9e8e9cd5dd0b7d2f7f1fa3f5d9c5aa51aab5e8995c482fb
7
+ data.tar.gz: fb4e14f632ae4fecb40cb34c83df2cdad2bcb784bd41168cae3fbe2ffad8e043399444ac721b44c907dafddcd9f55c3ae834f4b9e3d208c1e4c911999f284a36
data/CHANGELOG.md CHANGED
@@ -1,4 +1,53 @@
1
- ## 1.0.0.beta.4 / 2013-01-11
1
+ ## 1.0.0.rc.1 / 2013-11-28
2
+
3
+ ### Changes
4
+
5
+ * Busser now installs into /tmp/busser by default on instances. (@fnichol)
6
+ * Test Kitchen now works out of /tmp/kitchen for all providers by default. (@fnichol)
7
+ * Remove Chef Omnibus `GEM_PATH` inclusion in Busser `GEM_PATH`. This fully isolates Busser and its runner plugins to a `GEM_HOME` and `GEM_PATH` in `<busser_root_path>/gems`. (@fnichol)
8
+ * Add --provisioner to `kitchen init` to override default, chef\_solo. (@fnichol)
9
+
10
+ ### Bug fixes
11
+
12
+ * Issue #240, issue #242, pull request #258: Fix Busser and Chef Zero sandboxing so that each tool is completely isolated from the Omnibus packages gems and each other. (@fnichol, @schisamo)
13
+
14
+ ### New features
15
+
16
+ * Beef up Provisioners so that they resemble Drivers with user, default, inherited, and computed configuration..
17
+ * Use `chef-client -z` (local mode) with ChefZero Provisioner for Chef versions >= 11.8.0. Support older versions of Chef with a best-effort fallback shim to use chef-zero. (@fnichol)
18
+ * `kitchen list --debug` mode greatly improved showing rendered configuration for each Instance's Driver, Provisioner, and Busser configuration. (@fnichol)
19
+ * Pull request #249: Add a data\_path which will be sync'd to the instance in the same manner as roles and data bags. (@oferrigni)
20
+ * Test Kitchen no longer requires a cookbook to run; kitchen init anywhere! (@fnichol)
21
+ * All settings in solo.rb (for ChefSolo) and client.rb (for ChefZero) can be modified or added with a `solo_rb:` or `client_rb:` block inside a `provisioner:` block. (@fnichol)
22
+ * Add :ruby_bindr in a busser config block to set Busser's alternative remote path to Ruby. (@fnichol)
23
+ * Busser install root can be configured and is relocatable, defaults to /tmp/busser. (@fnichol)
24
+ * Test Kitchen root can be configured and is relocatable, defaults to /tmp/kitchen. (@fnichol)
25
+ * Support installing a specific version of Busser. (@fnichol)
26
+
27
+ ### Improvements
28
+
29
+ * Greatly simplify default .kitchen.yml. (@fnichol, @sethvargo)
30
+ * Massive internal refactoring data manipulation logic. Data code now lives in Kitchen::DataMunger and was properly TDD'ed from the ground up with a full test suite. (@fnichol)
31
+ * `require_chef_ommnibus` will default to `true` for all Chef provisioners and so can be omitted from .kitchen.yml files in most cases. (@fnichol)
32
+ * Pull request #262: Use a configurable glob pattern to select Chef cookbook files. (@fnichol)
33
+ * Pull request #141: Do not create a gitignore if there is no git repo. (@sethvargo)
34
+ * Improve `kitchen init` smarts for detecting gems already in Gemfile. (@fnichol)
35
+ * Expand all Chef-related local paths in Provisioner::ChefBase. (@fnichol)
36
+ * Issue #227: Handle absolute paths. (@sethvargo)
37
+ * Cope with nil values for run\_list and attributes entries in .kitchen.yml. (@fnichol)
38
+ * Allow for nil values for `provisioner:`, `driver:`, & `busser:`. (@fnichol)
39
+ * Pull request #253: Fix TravisCI badges. (@arangamani)
40
+ * Pull request #254: Update references to test-kitchen org. (@josephholsten)
41
+ * Pull request #256: Changed 'passed' to 'passing' in the Destroy options documentation. (@scarolan)
42
+ * Pull request #259: Fix inconsistent date in CHANGELOG. (@ryansouza)
43
+ * Extract Berkshelf & Librarian-Chef resolver code to classes. (@fnichol)
44
+ * Full spec coverage for Suite. (@fnichol)
45
+ * Full spec coverage for Platform. (@fnichol)
46
+ * Full spec coverage for Instance. (@fnichol)
47
+ * Full spec coverage for Kitchen::Provisioner.for\_plugin (@fnichol)
48
+
49
+
50
+ ## 1.0.0.beta.4 / 2013-11-01
2
51
 
3
52
  ### Bug fixes
4
53
 
data/Gemfile CHANGED
@@ -5,6 +5,6 @@ group :guard do
5
5
  gem 'rb-inotify', :require => false
6
6
  gem 'rb-fsevent', :require => false
7
7
  gem 'rb-fchange', :require => false
8
- gem 'guard-minitest', '~> 1.3'
8
+ gem 'guard-minitest'
9
9
  gem 'guard-cucumber', '~> 1.4'
10
10
  end
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Test Kitchen
2
2
 
3
- [![Build Status](https://secure.travis-ci.org/opscode/test-kitchen.png?branch=master)](https://travis-ci.org/opscode/test-kitchen)
4
- [![Code Climate](https://codeclimate.com/github/opscode/test-kitchen.png)](https://codeclimate.com/github/opscode/test-kitchen)
3
+ [![Build Status](https://secure.travis-ci.org/test-kitchen/test-kitchen.png?branch=master)](https://travis-ci.org/test-kitchen/test-kitchen)
4
+ [![Code Climate](https://codeclimate.com/github/test-kitchen/test-kitchen.png)](https://codeclimate.com/github/test-kitchen/test-kitchen)
5
5
 
6
6
  A convergence integration test harness for configuration management systems.
7
7
 
@@ -23,7 +23,7 @@ $ kitchen init
23
23
  create .kitchen.yml
24
24
  ```
25
25
  In this guide, we
26
- will be using the [kitchen vagrant driver](https://github.com/opscode/kitchen-vagrant),
26
+ will be using the [kitchen vagrant driver](https://github.com/test-kitchen/kitchen-vagrant),
27
27
  so install that:
28
28
 
29
29
  ```text
@@ -40,14 +40,25 @@ your tests in parallel. Trust us, it's faster!
40
40
 
41
41
  ### Helpful Switches
42
42
 
43
- - `--destroy=always|passed|never`
44
- - `passed` (default): destroy the machine after a successful test
43
+ - `--destroy=always|passing|never`
44
+ - `passing` (default): destroy the machine after a successful test
45
45
  run (which implies passing tests.)
46
46
  - `never`: Never clean up builds, even if they pass or fail.
47
47
  - `always`: Regardless of the success or failure of the build,
48
48
  destroy the machine.
49
49
  - `--log-level=debug|info|warn|error|fatal` - Set the log-level of
50
- the entire stack, including the chef-solo run.
50
+ the entire stack, including the chef-solo run.
51
+
52
+ You can also specify these switches in the `settings` has in your YAML:
53
+
54
+ ```yaml
55
+ settings:
56
+ parallel: true
57
+ destroy: never
58
+ ```
59
+
60
+ Options specified via the CLI still take precedence over options specified
61
+ in the config.
51
62
 
52
63
  ## The Kitchen YAML format
53
64
 
@@ -121,4 +132,4 @@ via freenode/IRC (#chef-hacking),
121
132
  Twitter ([@fnichol](https://twitter.com/fnichol)),
122
133
  or Email ([fnichol@nichol.ca](mailto:fnichol@nichol.ca)).
123
134
 
124
- For everyone else, watch [this space](https://github.com/opscode/test-kitchen).
135
+ For everyone else, watch [this space](https://github.com/test-kitchen/test-kitchen).
data/Rakefile CHANGED
@@ -35,6 +35,7 @@ unless RUBY_ENGINE == 'jruby'
35
35
  Kitchen::RakeTasks#define
36
36
  Kitchen::ThorTasks#define
37
37
  Kitchen::CLI#pry_prompts
38
+ Kitchen::CLI#debug_instance
38
39
  Kitchen::Instance#synchronize_or_call
39
40
  Kitchen::Driver::SSHBase#converge
40
41
  )
@@ -64,10 +65,16 @@ unless RUBY_ENGINE == 'jruby'
64
65
  # allow vertical alignment of `let(:foo) { block }` blocks
65
66
  style.spaces_before_lbrace 1, level: :off
66
67
  end
68
+ task.file_set('spec/kitchen/data_munger_spec.rb', 'tests') do |style|
69
+ # allow data formatting in DataMunger
70
+ style.indentation_spaces 2, level: :off
71
+ # allow far larger spec file to cover all data input cases as possible
72
+ style.max_code_lines_in_class 600, level: :off
73
+ end
67
74
  end
68
75
 
69
76
  desc "Run all quality tasks"
70
- task :quality => [:cane, :tailor, :stats]
77
+ task :quality => [:cane, :stats]
71
78
  else
72
79
  desc "Run all quality tasks"
73
80
  task :quality => [:stats]
@@ -14,13 +14,14 @@ Feature: Add Test Kitchen support to an existing project
14
14
 
15
15
  Scenario: Running init with default values
16
16
  Given a sandboxed GEM_HOME directory named "kitchen-init"
17
+ And I have a git repository
17
18
  When I run `kitchen init`
18
19
  Then the exit status should be 0
19
20
  And a directory named ".kitchen" should exist
20
21
  And a directory named "test/integration/default" should exist
21
22
  And the file ".gitignore" should contain ".kitchen/"
22
23
  And the file ".gitignore" should contain ".kitchen.local.yml"
23
- And the file ".kitchen.yml" should contain "driver_plugin: vagrant"
24
+ And the file ".kitchen.yml" should contain "driver: vagrant"
24
25
  And a file named "Gemfile" should not exist
25
26
  And a file named "Rakefile" should not exist
26
27
  And a file named "Thorfile" should not exist
@@ -34,12 +35,64 @@ Feature: Add Test Kitchen support to an existing project
34
35
  And the output should contain "You must run `bundle install'"
35
36
 
36
37
  Scenario: Running init with an existing Gemfile appends to the Gemfile
37
- Given an empty file named "Gemfile"
38
+ Given a file named "Gemfile" with:
39
+ """
40
+ source "https://rubygems.org"
41
+
42
+
43
+ """
38
44
  When I successfully run `kitchen init`
39
- And the file "Gemfile" should contain "gem 'test-kitchen'"
40
- And the file "Gemfile" should contain "gem 'kitchen-vagrant'"
45
+ Then the file "Gemfile" should contain exactly:
46
+ """
47
+ source "https://rubygems.org"
48
+
49
+ gem 'test-kitchen'
50
+ gem 'kitchen-vagrant'
51
+
52
+ """
53
+ And the output should contain "You must run `bundle install'"
54
+
55
+ Scenario: Running init with a Gemfile containing test-kitchen does not
56
+ re-append
57
+ Given a file named "Gemfile" with:
58
+ """
59
+ source "https://rubygems.org"
60
+
61
+ gem "test-kitchen"
62
+
63
+ """
64
+ When I successfully run `kitchen init`
65
+ Then the file "Gemfile" should contain exactly:
66
+ """
67
+ source "https://rubygems.org"
68
+
69
+ gem "test-kitchen"
70
+ gem 'kitchen-vagrant'
71
+
72
+ """
41
73
  And the output should contain "You must run `bundle install'"
42
74
 
75
+ Scenario: Running init with a Gemfile containing the driver gem does not
76
+ re-append
77
+ Given a file named "Gemfile" with:
78
+ """
79
+ source "https://rubygems.org"
80
+
81
+ gem "test-kitchen"
82
+ gem "kitchen-ec2"
83
+
84
+ """
85
+ When I successfully run `kitchen init --driver=kitchen-ec2`
86
+ Then the file "Gemfile" should contain exactly:
87
+ """
88
+ source "https://rubygems.org"
89
+
90
+ gem "test-kitchen"
91
+ gem "kitchen-ec2"
92
+
93
+ """
94
+ And the output should not contain "You must run `bundle install'"
95
+
43
96
  Scenario: Running init with multiple drivers appends to the Gemfile
44
97
  Given an empty file named "Gemfile"
45
98
  When I successfully run `kitchen init --driver=kitchen-bluebox kitchen-wakka`
@@ -51,13 +104,24 @@ Feature: Add Test Kitchen support to an existing project
51
104
  first driver given
52
105
  Given an empty file named "Gemfile"
53
106
  When I successfully run `kitchen init --driver=kitchen-bluebox kitchen-wakka`
54
- Then the file ".kitchen.yml" should contain "driver_plugin: bluebox"
107
+ Then the file ".kitchen.yml" should contain "driver: bluebox"
55
108
 
56
109
  Scenario: Running init with no drivers sets the plugin_driver to the
57
110
  dummy driver
58
111
  Given an empty file named "Gemfile"
59
112
  When I successfully run `kitchen init --no-driver`
60
- Then the file ".kitchen.yml" should contain "driver_plugin: dummy"
113
+ Then the file ".kitchen.yml" should contain "driver: dummy"
114
+
115
+ Scenario: Running init without a provisioner sets the default provisioner
116
+ to chef_solo in .kitchen.yml
117
+ Given an empty file named "Gemfile"
118
+ When I successfully run `kitchen init --no-driver`
119
+ Then the file ".kitchen.yml" should contain "provisioner: chef_solo"
120
+
121
+ Scenario: Running init with a provisioner sets the provisioner in .kitchen.yml
122
+ Given an empty file named "Gemfile"
123
+ When I successfully run `kitchen init --no-driver --provisioner=chef_zero`
124
+ Then the file ".kitchen.yml" should contain "provisioner: chef_zero"
61
125
 
62
126
  Scenario: Running with a Rakefile file appends Kitchen tasks
63
127
  Given an empty file named "Gemfile"
@@ -73,6 +137,11 @@ Feature: Add Test Kitchen support to an existing project
73
137
  end
74
138
  """
75
139
 
140
+ Scenario: Running without git doesn't make a .gitignore
141
+ When I successfully run `kitchen init`
142
+ Then the exit status should be 0
143
+ And a file named ".gitignore" should not exist
144
+
76
145
  Scenario: Running with a Thorfile file appends Kitchen tasks
77
146
  Given an empty file named "Gemfile"
78
147
  Given an empty file named "Thorfile"
@@ -87,7 +156,7 @@ Feature: Add Test Kitchen support to an existing project
87
156
  end
88
157
  """
89
158
 
90
- Scenario: Running init with a the name attribute metadata.rb sets a run list
159
+ Scenario: Running init with a name in metadata.rb sets a run list
91
160
  Given an empty file named "Gemfile"
92
161
  Given a file named "metadata.rb" with:
93
162
  """
@@ -100,10 +169,20 @@ Feature: Add Test Kitchen support to an existing project
100
169
  support "centos"
101
170
  """
102
171
  When I successfully run `kitchen init`
103
- Then the file ".kitchen.yml" should contain:
172
+ Then the file ".kitchen.yml" should contain exactly:
104
173
  """
174
+ ---
175
+ driver: vagrant
176
+ provisioner: chef_solo
177
+
178
+ platforms:
179
+ - name: ubuntu-12.04
180
+ - name: centos-6.4
181
+
105
182
  suites:
106
- - name: default
107
- run_list: ["recipe[ntp]"]
108
- attributes: {}
183
+ - name: default
184
+ run_list:
185
+ - recipe[ntp::default]
186
+ attributes:
187
+
109
188
  """
@@ -0,0 +1,3 @@
1
+ Given /I have a git repository/ do
2
+ create_dir('.git')
3
+ end
@@ -2,7 +2,7 @@
2
2
  #
3
3
  # Author:: Fletcher Nichol (<fnichol@nichol.ca>)
4
4
  #
5
- # Copyright (C) 2012, Fletcher Nichol
5
+ # Copyright (C) 2012, 2013, Fletcher Nichol
6
6
  #
7
7
  # Licensed under the Apache License, Version 2.0 (the "License");
8
8
  # you may not use this file except in compliance with the License.
@@ -33,16 +33,47 @@ module Kitchen
33
33
  # @param [String] suite_name name of suite on which to operate
34
34
  # (**Required**)
35
35
  # @param [Hash] opts optional configuration
36
- # @option opts [TrueClass, FalseClass] :use_sudo whether or not to invoke
36
+ # @option opts [String] :kitchen_root local path to the root of the project
37
+ # @option opts [String] :instance_ruby_bindir path to the directory
38
+ # containing the Ruby binary on the remote instance
39
+ # @option opts [TrueClass, FalseClass] :sudo whether or not to invoke
37
40
  # sudo before commands requiring root access (default: `true`)
38
41
  def initialize(suite_name, opts = {})
39
42
  validate_options(suite_name)
40
43
 
41
- @ruby_binpath = opts.fetch(:ruby_binpath, DEFAULT_RUBY_BINPATH)
42
- @busser_root = opts.fetch(:busser_root, DEFAULT_BUSSER_ROOT)
43
- @test_root = opts.fetch(:test_root, DEFAULT_TEST_ROOT)
44
+ kitchen_root = opts.fetch(:kitchen_root) { Dir.pwd }
45
+ test_base_path = opts.fetch(:test_base_path, Kitchen::DEFAULT_TEST_DIR)
46
+
47
+ @test_base_path = File.expand_path(test_base_path, kitchen_root)
44
48
  @suite_name = suite_name
45
49
  @use_sudo = opts.fetch(:sudo, true)
50
+ @ruby_bindir = opts.fetch(:instance_ruby_bindir, DEFAULT_RUBY_BINDIR)
51
+ @root_path = opts.fetch(:root_path, DEFAULT_ROOT_PATH)
52
+ @version_string = opts.fetch(:version, "busser")
53
+ @busser_bin = File.join(@root_path, "bin/busser")
54
+ end
55
+
56
+ # Returns the name of this busser, suitable for display in a CLI.
57
+ #
58
+ # @return [String] name of this busser
59
+ def name
60
+ suite_name
61
+ end
62
+
63
+ # Returns an array of configuration keys.
64
+ #
65
+ # @return [Array] array of configuration keys
66
+ def config_keys
67
+ [:test_base_path, :ruby_bindir, :root_path, :version_string,
68
+ :busser_bin, :use_sudo, :suite_name]
69
+ end
70
+
71
+ # Provides hash-like access to configuration keys.
72
+ #
73
+ # @param attr [Object] configuration key
74
+ # @return [Object] value at configuration key
75
+ def [](attr)
76
+ config_keys.include?(attr) ? self.send(attr) : nil
46
77
  end
47
78
 
48
79
  # Returns a command string which installs Busser, and installs all
@@ -60,11 +91,12 @@ module Kitchen
60
91
  # use Bourne (/bin/sh) as Bash does not exist on all Unix flavors
61
92
  <<-INSTALL_CMD.gsub(/^ {10}/, '')
62
93
  sh -c '
63
- #{sandbox_env(true)}
64
- if ! #{sudo}#{gem_bin} list busser -i >/dev/null; then
65
- echo "-----> Installing busser and plugins"
66
- #{sudo}#{gem_bin} install busser --no-rdoc --no-ri
94
+ #{busser_setup_env}
95
+ if ! #{sudo}#{ruby_bindir}/gem list busser -i >/dev/null; then
96
+ #{sudo}#{ruby_bindir}/gem install #{gem_install_args}
67
97
  fi
98
+ gem_bindir=`#{ruby_bindir}/ruby -rrubygems -e "puts Gem.bindir"`
99
+ #{sudo}${gem_bindir}/busser setup
68
100
  #{sudo}#{busser_bin} plugin install #{plugins.join(' ')}'
69
101
  INSTALL_CMD
70
102
  end
@@ -85,9 +117,8 @@ module Kitchen
85
117
  # use Bourne (/bin/sh) as Bash does not exist on all Unix flavors
86
118
  <<-INSTALL_CMD.gsub(/^ {10}/, '')
87
119
  sh -c '
88
- #{sandbox_env(true)}
89
120
  #{sudo}#{busser_bin} suite cleanup
90
- #{local_suite_files.map { |f| stream_file(f, remote_file(f, @suite_name)) }.join}
121
+ #{local_suite_files.map { |f| stream_file(f, remote_file(f, suite_name)) }.join}
91
122
  #{helper_files.map { |f| stream_file(f, remote_file(f, "helpers")) }.join}'
92
123
  INSTALL_CMD
93
124
  end
@@ -101,18 +132,21 @@ module Kitchen
101
132
  # @return [String] a command string to run the test suites, or nil if no
102
133
  # work needs to be performed
103
134
  def run_cmd
104
- @run_cmd ||= local_suite_files.empty? ? nil : "#{sandbox_env} #{sudo}#{busser_bin} test"
135
+ @run_cmd ||= local_suite_files.empty? ? nil : "#{sudo}#{busser_bin} test"
105
136
  end
106
137
 
107
138
  private
108
139
 
109
- DEFAULT_RUBY_BINPATH = "/opt/chef/embedded/bin".freeze
110
- DEFAULT_BUSSER_ROOT = "/tmp/kitchen-busser".freeze
111
- DEFAULT_TEST_ROOT = File.join(Dir.pwd, "test/integration").freeze
140
+ DEFAULT_RUBY_BINDIR = "/opt/chef/embedded/bin".freeze
141
+ DEFAULT_ROOT_PATH = "/tmp/busser".freeze
112
142
 
113
- attr_reader :ruby_binpath
114
- attr_reader :busser_root
115
- attr_reader :test_root
143
+ attr_reader :test_base_path
144
+ attr_reader :ruby_bindir
145
+ attr_reader :root_path
146
+ attr_reader :version_string
147
+ attr_reader :busser_bin
148
+ attr_reader :use_sudo
149
+ attr_reader :suite_name
116
150
 
117
151
  def validate_options(suite_name)
118
152
  if suite_name.nil?
@@ -126,24 +160,24 @@ module Kitchen
126
160
  end
127
161
 
128
162
  def plugins
129
- Dir.glob(File.join(test_root, @suite_name, "*")).select { |d|
130
- File.directory?(d) && File.basename(d) != "data_bags"
163
+ Dir.glob(File.join(test_base_path, suite_name, "*")).reject { |d|
164
+ ! File.directory?(d) || non_suite_dirs.include?(File.basename(d))
131
165
  }.map { |d| "busser-#{File.basename(d)}" }.sort.uniq
132
166
  end
133
167
 
134
168
  def local_suite_files
135
- Dir.glob(File.join(test_root, @suite_name, "*/**/*")).reject do |f|
136
- f["data_bags"] || File.directory?(f)
169
+ Dir.glob(File.join(test_base_path, suite_name, "*/**/*")).reject do |f|
170
+ f[/(data|data_bags|environments|nodes|roles)/] || File.directory?(f)
137
171
  end
138
172
  end
139
173
 
140
174
  def helper_files
141
- Dir.glob(File.join(test_root, "helpers", "*/**/*"))
175
+ Dir.glob(File.join(test_base_path, "helpers", "*/**/*"))
142
176
  end
143
177
 
144
178
  def remote_file(file, dir)
145
- local_prefix = File.join(test_root, dir)
146
- "$(#{sandbox_env} #{sudo}#{busser_bin} suite path)/".concat(file.sub(%r{^#{local_prefix}/}, ''))
179
+ local_prefix = File.join(test_base_path, dir)
180
+ "$(#{sudo}#{busser_bin} suite path)/".concat(file.sub(%r{^#{local_prefix}/}, ''))
147
181
  end
148
182
 
149
183
  def stream_file(local_path, remote_path)
@@ -167,35 +201,35 @@ module Kitchen
167
201
  end
168
202
 
169
203
  def sudo
170
- @use_sudo ? "sudo -E " : ""
204
+ use_sudo ? "sudo -E " : ""
171
205
  end
172
206
 
173
- def ruby_bin
174
- @ruby_bin ||= File.join(ruby_binpath, 'ruby')
207
+ def busser_gem
208
+ "busser"
175
209
  end
176
210
 
177
- def gem_bin
178
- @gem_bin ||= File.join(ruby_binpath, 'gem')
211
+ def non_suite_dirs
212
+ %w{data data_bags environments nodes roles}
179
213
  end
180
214
 
181
- def busser_bin
182
- @busser_bin ||= "#{ruby_bin} #{File.join(busser_root, "gems", "bin", "busser")}"
215
+ def busser_setup_env
216
+ [
217
+ %{BUSSER_ROOT="#{root_path}"},
218
+ %{GEM_HOME="#{root_path}/gems"},
219
+ %{GEM_PATH="#{root_path}/gems"},
220
+ %{GEM_CACHE="#{root_path}/gems/cache"},
221
+ %{; export BUSSER_ROOT GEM_HOME GEM_PATH GEM_CACHE;}
222
+ ].join(" ")
183
223
  end
184
224
 
185
- def sandbox_env(export=false)
186
- env = [
187
- "BUSSER_ROOT=#{busser_root}",
188
- "GEM_HOME=#{busser_root}/gems",
189
- "GEM_PATH=$GEM_HOME",
190
- "GEM_CACHE=$GEM_HOME/cache",
191
- "PATH=$PATH:$GEM_HOME/bin"
192
- ]
193
-
194
- if export
195
- env << "; export BUSSER_ROOT GEM_HOME GEM_PATH GEM_CACHE PATH;"
196
- end
225
+ def gem_install_args
226
+ gem, version = version_string.split("@")
227
+ gem, version = "busser", gem if gem =~ /^\d+\.\d+\.\d+/
197
228
 
198
- env.join(" ")
229
+ args = gem
230
+ args += " --version #{version}" if version
231
+ args += " --no-rdoc --no-ri"
232
+ args
199
233
  end
200
234
  end
201
235
  end