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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +50 -1
- data/Gemfile +1 -1
- data/README.md +18 -7
- data/Rakefile +8 -1
- data/features/kitchen_init_command.feature +90 -11
- data/features/step_definitions/git_steps.rb +3 -0
- data/lib/kitchen/busser.rb +79 -45
- data/lib/kitchen/cli.rb +14 -13
- data/lib/kitchen/config.rb +79 -138
- data/lib/kitchen/data_munger.rb +224 -0
- data/lib/kitchen/driver/base.rb +4 -31
- data/lib/kitchen/driver/ssh_base.rb +6 -16
- data/lib/kitchen/driver.rb +4 -0
- data/lib/kitchen/generator/init.rb +20 -9
- data/lib/kitchen/instance.rb +53 -58
- data/lib/kitchen/lazy_hash.rb +50 -0
- data/lib/kitchen/platform.rb +2 -31
- data/lib/kitchen/provisioner/base.rb +55 -9
- data/lib/kitchen/provisioner/chef/berkshelf.rb +76 -0
- data/lib/kitchen/provisioner/chef/librarian.rb +72 -0
- data/lib/kitchen/provisioner/chef_base.rb +159 -78
- data/lib/kitchen/provisioner/chef_solo.rb +6 -36
- data/lib/kitchen/provisioner/chef_zero.rb +70 -59
- data/lib/kitchen/provisioner/dummy.rb +28 -0
- data/lib/kitchen/provisioner.rb +6 -4
- data/lib/kitchen/shell_out.rb +2 -5
- data/lib/kitchen/ssh.rb +1 -1
- data/lib/kitchen/suite.rb +10 -79
- data/lib/kitchen/util.rb +2 -2
- data/lib/kitchen/version.rb +2 -2
- data/lib/kitchen.rb +5 -0
- data/spec/kitchen/config_spec.rb +84 -123
- data/spec/kitchen/data_munger_spec.rb +1412 -0
- data/spec/kitchen/driver/base_spec.rb +30 -0
- data/spec/kitchen/instance_spec.rb +868 -86
- data/spec/kitchen/lazy_hash_spec.rb +63 -0
- data/spec/kitchen/platform_spec.rb +0 -22
- data/spec/kitchen/provisioner/base_spec.rb +210 -0
- data/spec/kitchen/provisioner_spec.rb +70 -0
- data/spec/kitchen/suite_spec.rb +25 -38
- data/spec/spec_helper.rb +1 -0
- data/support/chef-client-zero.rb +51 -35
- data/support/dummy-validation.pem +27 -0
- data/templates/init/kitchen.yml.erb +10 -22
- data/test-kitchen.gemspec +1 -2
- metadata +20 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 531f23b775d0e1852010f3405773b4a36e938126
|
4
|
+
data.tar.gz: 7d447f5dca58df770141b9184606632bc4ae4a61
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39879c2db849837769c3375cae413a18521fd28978456336703c005c4aef3913dd1e20e83d55485ae9e8e9cd5dd0b7d2f7f1fa3f5d9c5aa51aab5e8995c482fb
|
7
|
+
data.tar.gz: fb4e14f632ae4fecb40cb34c83df2cdad2bcb784bd41168cae3fbe2ffad8e043399444ac721b44c907dafddcd9f55c3ae834f4b9e3d208c1e4c911999f284a36
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,53 @@
|
|
1
|
-
## 1.0.0.
|
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
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Test Kitchen
|
2
2
|
|
3
|
-
[](https://travis-ci.org/test-kitchen/test-kitchen)
|
4
|
+
[](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/
|
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|
|
44
|
-
- `
|
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/
|
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, :
|
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 "
|
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
|
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
|
-
|
40
|
-
|
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 "
|
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 "
|
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
|
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
|
-
|
107
|
-
|
108
|
-
|
183
|
+
- name: default
|
184
|
+
run_list:
|
185
|
+
- recipe[ntp::default]
|
186
|
+
attributes:
|
187
|
+
|
109
188
|
"""
|
data/lib/kitchen/busser.rb
CHANGED
@@ -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 [
|
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
|
-
|
42
|
-
|
43
|
-
|
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
|
-
#{
|
64
|
-
if ! #{sudo}#{
|
65
|
-
|
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,
|
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 : "#{
|
135
|
+
@run_cmd ||= local_suite_files.empty? ? nil : "#{sudo}#{busser_bin} test"
|
105
136
|
end
|
106
137
|
|
107
138
|
private
|
108
139
|
|
109
|
-
|
110
|
-
|
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 :
|
114
|
-
attr_reader :
|
115
|
-
attr_reader :
|
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(
|
130
|
-
File.directory?(d)
|
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(
|
136
|
-
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(
|
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(
|
146
|
-
"$(#{
|
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
|
-
|
204
|
+
use_sudo ? "sudo -E " : ""
|
171
205
|
end
|
172
206
|
|
173
|
-
def
|
174
|
-
|
207
|
+
def busser_gem
|
208
|
+
"busser"
|
175
209
|
end
|
176
210
|
|
177
|
-
def
|
178
|
-
|
211
|
+
def non_suite_dirs
|
212
|
+
%w{data data_bags environments nodes roles}
|
179
213
|
end
|
180
214
|
|
181
|
-
def
|
182
|
-
|
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
|
186
|
-
|
187
|
-
|
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
|
-
|
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
|