test-kitchen 1.13.2 → 1.14.0

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: 78c2cca699db03ee1a9909ea2f018596cf165ef2
4
- data.tar.gz: 7b290a7bf32a537d37f399df2f0efad8cf5021e3
3
+ metadata.gz: c64f3dcd66b57bf7ff548090514dc7c5e78a5de1
4
+ data.tar.gz: cd97121e6e1aa35a031223f95b2f16377bea1c04
5
5
  SHA512:
6
- metadata.gz: 8e1a6c1ebac8a6bf832e6d246ddf0ad3126c97e47fce9e92de74a4df5ed4373c927d4351a2b40d5b54fce8eb3fec392e48c14919a7f1205ba3e5aa10aeb7a4a5
7
- data.tar.gz: 1292bc9dab4afc3576b3b0e0242f701b2064601a6319c192914ba5268b7d1f9f5da8d4bfe8965b2bbab75256fb2de93d97db3554cfea2f631947f293afe56763
6
+ metadata.gz: bc16ba277000e21119a03f1cea8d5c0a4c1e1a9b781cff12965579a8618479ffb97e2770bb41356b7a9d4e0f15713975b1e4179f97fa4eb4d9624324dde53492
7
+ data.tar.gz: 29e6c5386aa55e37b418208f9967ef49595f5f7ca57082922f158360627e0c6559929b80c547842ea56275e2f5ccc59e3932d65e1bbe9c52d94515a9e25e3acd
data/.travis.yml CHANGED
@@ -23,6 +23,7 @@ bundler_args: --without guard integration
23
23
 
24
24
  script:
25
25
  - bundle exec rake
26
+ - bundle exec codeclimate-test-reporter
26
27
  - bundle install --with integration
27
28
  - export KITCHEN_YAML=.kitchen.ci.yml
28
29
  - bundle exec kitchen verify ubuntu
data/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # Change Log
2
2
 
3
+ ## [v1.14.0](https://github.com/test-kitchen/test-kitchen/tree/v1.14.0) (2016-11-22)
4
+ [Full Changelog](https://github.com/test-kitchen/test-kitchen/compare/v1.13.2...v1.14.0)
5
+
6
+ **Implemented enhancements:**
7
+
8
+ - Test Kitchen should use omnitruck's -d option by default [\#809](https://github.com/test-kitchen/test-kitchen/issues/809)
9
+
10
+ **Closed issues:**
11
+
12
+ - Kitchen converge fails, doesn't install omnibus, \[\[WinRM::FS::Core::FileTransporter\] Upload failed [\#1150](https://github.com/test-kitchen/test-kitchen/issues/1150)
13
+ - Re-Enable Code Climate [\#1146](https://github.com/test-kitchen/test-kitchen/issues/1146)
14
+ - kitchen + berkshelf don't work together with the latest versions of gems [\#1144](https://github.com/test-kitchen/test-kitchen/issues/1144)
15
+ - Vagrant drivers brings up virtualbox machine with 'cable connected' disabled option [\#1143](https://github.com/test-kitchen/test-kitchen/issues/1143)
16
+ - kitchen converge throws Berkshelf::LockfileNotFound on Windows [\#1140](https://github.com/test-kitchen/test-kitchen/issues/1140)
17
+ - Inspect tests is an empty value when using the kitchen\_ec2 driver [\#1136](https://github.com/test-kitchen/test-kitchen/issues/1136)
18
+ - kitchen test or verify with --parallel option fails [\#1125](https://github.com/test-kitchen/test-kitchen/issues/1125)
19
+
20
+ **Merged pull requests:**
21
+
22
+ - Added `cache` interface for Drivers so that provisioners can leverage [\#1149](https://github.com/test-kitchen/test-kitchen/pull/1149) ([afiune](https://github.com/afiune))
23
+ - Ensure that we only berks update with a lockfile [\#1145](https://github.com/test-kitchen/test-kitchen/pull/1145) ([thommay](https://github.com/thommay))
24
+ - Added `last\_error` and `--json` to `kitchen list` [\#1135](https://github.com/test-kitchen/test-kitchen/pull/1135) ([BackSlasher](https://github.com/BackSlasher))
25
+ - Allow the user to make deprecations errors [\#1117](https://github.com/test-kitchen/test-kitchen/pull/1117) ([thommay](https://github.com/thommay))
26
+
3
27
  ## [v1.13.2](https://github.com/test-kitchen/test-kitchen/tree/v1.13.2) (2016-09-26)
4
28
  [Full Changelog](https://github.com/test-kitchen/test-kitchen/compare/v1.13.1...v1.13.2)
5
29
 
data/Gemfile CHANGED
@@ -11,5 +11,5 @@ group :integration do
11
11
  end
12
12
 
13
13
  group :test do
14
- gem "codeclimate-test-reporter", :require => nil
14
+ gem "codeclimate-test-reporter", "~> 1.0", ">= 1.0.3", :require => nil
15
15
  end
data/bin/kitchen CHANGED
File without changes
@@ -28,12 +28,12 @@ Feature: Running instance actions
28
28
  @spawn
29
29
  Scenario: Creating a single instance
30
30
  When I successfully run `kitchen list client-beans`
31
- Then the stdout should match /^client-beans\s+.+\s+\<Not Created\>\Z/
31
+ Then the stdout should match /^client-beans\s+.+\s+\<Not Created\>\s+\<None\>\Z/
32
32
  When I run `kitchen create client-beans`
33
33
  Then the output should contain "Finished creating <client-beans>"
34
34
  And the exit status should be 0
35
35
  When I successfully run `kitchen list client-beans`
36
- Then the stdout should match /^client-beans\s+.+\s+Created\Z/
36
+ Then the stdout should match /^client-beans\s+.+\s+Created\s+\<None\>\Z/
37
37
 
38
38
  @spawn
39
39
  Scenario: Creating a single instance that fails
@@ -44,23 +44,23 @@ Feature: Running instance actions
44
44
  fail_create: true
45
45
  """
46
46
  When I successfully run `kitchen list client-beans`
47
- Then the stdout should match /^client-beans\s+.+\s+\<Not Created\>\Z/
47
+ Then the stdout should match /^client-beans\s+.+\s+\<Not Created\>\s+\<None\>\Z/
48
48
  When I run `kitchen create client-beans`
49
49
  Then the output should contain "Create failed on instance <client-beans>"
50
50
  And the exit status should not be 0
51
51
  When I successfully run `kitchen list client-beans`
52
- Then the stdout should match /^client-beans\s+.+\s+\<Not Created\>\Z/
52
+ Then the stdout should match /^client-beans\s+.+\s+\<Not Created\>\s+Kitchen::ActionFailed\Z/
53
53
 
54
54
  @spawn
55
55
  Scenario: Converging a single instance
56
56
  When I successfully run `kitchen create client-beans`
57
57
  And I successfully run `kitchen list client-beans`
58
- Then the stdout should match /^client-beans\s+.+\s+Created\Z/
58
+ Then the stdout should match /^client-beans\s+.+\s+Created\s+\<None\>\Z/
59
59
  When I run `kitchen converge client-beans`
60
60
  Then the output should contain "Finished converging <client-beans>"
61
61
  And the exit status should be 0
62
62
  When I successfully run `kitchen list client-beans`
63
- Then the stdout should match /^client-beans\s+.+\s+Converged\Z/
63
+ Then the stdout should match /^client-beans\s+.+\s+Converged\s+\<None\>\Z/
64
64
 
65
65
  @spawn
66
66
  Scenario: Converging a single instance that fails
@@ -72,23 +72,23 @@ Feature: Running instance actions
72
72
  """
73
73
  When I successfully run `kitchen create client-beans`
74
74
  And I successfully run `kitchen list client-beans`
75
- Then the stdout should match /^client-beans\s+.+\s+Created\Z/
75
+ Then the stdout should match /^client-beans\s+.+\s+Created\s+\<None\>\Z/
76
76
  When I run `kitchen converge client-beans`
77
77
  Then the output should contain "Converge failed on instance <client-beans>"
78
78
  And the exit status should not be 0
79
79
  When I successfully run `kitchen list client-beans`
80
- Then the stdout should match /^client-beans\s+.+\s+Created\Z/
80
+ Then the stdout should match /^client-beans\s+.+\s+Created\s+Kitchen::ActionFailed\Z/
81
81
 
82
82
  @spawn
83
83
  Scenario: Setting up a single instance
84
84
  When I successfully run `kitchen converge client-beans`
85
85
  And I successfully run `kitchen list client-beans`
86
- Then the stdout should match /^client-beans\s+.+\s+Converged\Z/
86
+ Then the stdout should match /^client-beans\s+.+\s+Converged\s+\<None\>\Z/
87
87
  When I run `kitchen setup client-beans`
88
88
  Then the output should contain "Finished setting up <client-beans>"
89
89
  And the exit status should be 0
90
90
  When I successfully run `kitchen list client-beans`
91
- Then the stdout should match /^client-beans\s+.+\s+Set Up\Z/
91
+ Then the stdout should match /^client-beans\s+.+\s+Set Up\s+\<None\>\Z/
92
92
 
93
93
  @spawn
94
94
  Scenario: Setting up a single instance that fails
@@ -100,23 +100,23 @@ Feature: Running instance actions
100
100
  """
101
101
  When I successfully run `kitchen converge client-beans`
102
102
  And I successfully run `kitchen list client-beans`
103
- Then the stdout should match /^client-beans\s+.+\s+Converged\Z/
103
+ Then the stdout should match /^client-beans\s+.+\s+Converged\s+\<None\>\Z/
104
104
  When I run `kitchen verify client-beans`
105
105
  Then the output should contain "Verify failed on instance <client-beans>"
106
106
  And the exit status should not be 0
107
107
  When I successfully run `kitchen list client-beans`
108
- Then the stdout should match /^client-beans\s+.+\s+Set Up\Z/
108
+ Then the stdout should match /^client-beans\s+.+\s+Set Up\s+Kitchen::ActionFailed\Z/
109
109
 
110
110
  @spawn
111
111
  Scenario: Verifying a single instance
112
112
  When I successfully run `kitchen setup client-beans`
113
113
  And I successfully run `kitchen list client-beans`
114
- Then the stdout should match /^client-beans\s+.+\s+Set Up\Z/
114
+ Then the stdout should match /^client-beans\s+.+\s+Set Up\s+\<None\>\Z/
115
115
  When I run `kitchen verify client-beans`
116
116
  Then the output should contain "Finished verifying <client-beans>"
117
117
  And the exit status should be 0
118
118
  When I successfully run `kitchen list client-beans`
119
- Then the stdout should match /^client-beans\s+.+\s+Verified\Z/
119
+ Then the stdout should match /^client-beans\s+.+\s+Verified\s+\<None\>\Z/
120
120
 
121
121
  @spawn
122
122
  Scenario: Verifying a single instance that fails
@@ -128,23 +128,23 @@ Feature: Running instance actions
128
128
  """
129
129
  When I successfully run `kitchen setup client-beans`
130
130
  And I successfully run `kitchen list client-beans`
131
- Then the stdout should match /^client-beans\s+.+\s+Set Up\Z/
131
+ Then the stdout should match /^client-beans\s+.+\s+Set Up\s+\<None\>\Z/
132
132
  When I run `kitchen verify client-beans`
133
133
  Then the output should contain "Verify failed on instance <client-beans>"
134
134
  And the exit status should not be 0
135
135
  When I successfully run `kitchen list client-beans`
136
- Then the stdout should match /^client-beans\s+.+\s+Set Up\Z/
136
+ Then the stdout should match /^client-beans\s+.+\s+Set Up\s+Kitchen::ActionFailed\Z/
137
137
 
138
138
  @spawn
139
139
  Scenario: Destroying a single instance
140
140
  When I successfully run `kitchen create client-beans`
141
141
  And I successfully run `kitchen list client-beans`
142
- Then the stdout should match /^client-beans\s+.+\s+Created\Z/
142
+ Then the stdout should match /^client-beans\s+.+\s+Created\s+\<None\>\Z/
143
143
  When I run `kitchen destroy client-beans`
144
144
  Then the output should contain "Finished destroying <client-beans>"
145
145
  And the exit status should be 0
146
146
  When I successfully run `kitchen list client-beans`
147
- Then the stdout should match /^client-beans\s+.+\s+\<Not Created\>\Z/
147
+ Then the stdout should match /^client-beans\s+.+\s+\<Not Created\>\s+\<None\>\Z/
148
148
 
149
149
  @spawn
150
150
  Scenario: Destroying a single instance that fails
@@ -156,9 +156,9 @@ Feature: Running instance actions
156
156
  """
157
157
  When I successfully run `kitchen create client-beans`
158
158
  And I successfully run `kitchen list client-beans`
159
- Then the stdout should match /^client-beans\s+.+\s+Created\Z/
159
+ Then the stdout should match /^client-beans\s+.+\s+Created\s+\<None\>\Z/
160
160
  When I run `kitchen destroy client-beans`
161
161
  Then the output should contain "Destroy failed on instance <client-beans>"
162
162
  And the exit status should not be 0
163
163
  When I successfully run `kitchen list client-beans`
164
- Then the stdout should match /^client-beans\s+.+\s+Created\Z/
164
+ Then the stdout should match /^client-beans\s+.+\s+Created\s+Kitchen::ActionFailed\Z/
@@ -18,7 +18,7 @@ Feature: Test Kitchen defaults
18
18
  - name: default
19
19
  """
20
20
  When I successfully run `kitchen list`
21
- Then the output should match /^default-win-81\s+Dummy\s+Dummy\s+Dummy\s+Winrm\s+\<Not Created\>$/
21
+ Then the output should match /^default-win-81\s+Dummy\s+Dummy\s+Dummy\s+Winrm\s+\<Not Created\>\s+\<None\>$/
22
22
 
23
23
  Scenario: Non-Windows platforms get the Ssh Transport by default
24
24
  Given a file named ".kitchen.yml" with:
@@ -35,4 +35,4 @@ Feature: Test Kitchen defaults
35
35
  - name: default
36
36
  """
37
37
  When I successfully run `kitchen list`
38
- Then the output should match /^default-ubuntu-1404\s+Dummy\s+Dummy\s+Dummy\s+Ssh\s+\<Not Created\>$/
38
+ Then the output should match /^default-ubuntu-1404\s+Dummy\s+Dummy\s+Dummy\s+Ssh\s+\<Not Created\>\s+\<None\>$/
@@ -22,8 +22,44 @@ Feature: Listing Test Kitchen instances
22
22
  Scenario: Listing instances
23
23
  When I run `kitchen list`
24
24
  Then the exit status should be 0
25
- And the output should match /^foobar-ubuntu-1304\s+Dummy\s+ChefSolo\s+Busser\s+Ssh\s+\<Not Created\>$/
26
- And the output should match /^foobar-centos-64\s+Dummy\s+ChefSolo\s+Busser\s+Ssh\s+\<Not Created\>$/
25
+ And the output should match /^foobar-ubuntu-1304\s+Dummy\s+ChefSolo\s+Busser\s+Ssh\s+\<Not Created\>\s+\<None\>$/
26
+ And the output should match /^foobar-centos-64\s+Dummy\s+ChefSolo\s+Busser\s+Ssh\s+\<Not Created\>\s+\<None\>$/
27
+
28
+ Scenario: Listing a single instance with the --json option
29
+ When I run `kitchen list --json`
30
+ Then the exit status should be 0
31
+ And the output should contain exactly:
32
+ """
33
+ [
34
+ {
35
+ "instance": "foobar-ubuntu-1304",
36
+ "driver": "Dummy",
37
+ "provisioner": "ChefSolo",
38
+ "verifier": "Busser",
39
+ "transport": "Ssh",
40
+ "last_action": null,
41
+ "last_error": null
42
+ },
43
+ {
44
+ "instance": "foobar-centos-64",
45
+ "driver": "Dummy",
46
+ "provisioner": "ChefSolo",
47
+ "verifier": "Busser",
48
+ "transport": "Ssh",
49
+ "last_action": null,
50
+ "last_error": null
51
+ },
52
+ {
53
+ "instance": "foobar-centos-64-with-small-mem",
54
+ "driver": "Dummy",
55
+ "provisioner": "ChefSolo",
56
+ "verifier": "Busser",
57
+ "transport": "Ssh",
58
+ "last_action": null,
59
+ "last_error": null
60
+ }
61
+ ]
62
+ """
27
63
 
28
64
  Scenario: Listing instances with the --bare option
29
65
  When I run `kitchen list --bare`
@@ -36,7 +36,7 @@ Feature: Running a full test instance test
36
36
  Scenario: Running a single instance never destroying an instance
37
37
  When I successfully run `kitchen test client-beans --destroy=never`
38
38
  And I successfully run `kitchen list client-beans`
39
- Then the output should match /^client-beans\s+.+\s+Verified$/
39
+ Then the output should match /^client-beans\s+.+\s+Verified\s+\<None\>$/
40
40
 
41
41
  @spawn
42
42
  Scenario: Running a single instance always destroying an instance
@@ -49,7 +49,7 @@ Feature: Running a full test instance test
49
49
  When I run `kitchen test client-beans --destroy=always`
50
50
  Then the exit status should not be 0
51
51
  When I successfully run `kitchen list client-beans`
52
- Then the output should match /^client-beans\s+.+\s+\<Not Created\>$/
52
+ Then the output should match /^client-beans\s+.+\s+\<Not Created\>\s+\<None\>$/
53
53
 
54
54
  @spawn
55
55
  Scenario: Running a single instance not destroying an instance on failure
@@ -62,14 +62,14 @@ Feature: Running a full test instance test
62
62
  When I run `kitchen test client-beans --destroy=passing`
63
63
  Then the exit status should not be 0
64
64
  When I successfully run `kitchen list client-beans`
65
- Then the output should match /^client-beans\s+.+\s+Created$/
65
+ Then the output should match /^client-beans\s+.+\s+Created\s+Kitchen::ActionFailed$/
66
66
 
67
67
  @spawn
68
68
  Scenario: Running a single instance destroying an instance on success
69
69
  When I run `kitchen test client-beans --destroy=passing`
70
70
  Then the exit status should be 0
71
71
  When I successfully run `kitchen list client-beans`
72
- Then the output should match /^client-beans\s+.+\s+\<Not Created\>$/
72
+ Then the output should match /^client-beans\s+.+\s+\<Not Created\>\s+\<None\>$/
73
73
 
74
74
  @spawn
75
75
  Scenario: Running all instances
@@ -82,7 +82,7 @@ Feature: Running a full test instance test
82
82
  Then the output should contain "Kitchen is finished."
83
83
  And the exit status should be 0
84
84
  When I successfully run `kitchen list`
85
- Then the output should match /^client-cool\s+.+\s+\<Not Created\>$/
86
- Then the output should match /^client-beans\s+.+\s+\<Not Created\>$/
87
- Then the output should match /^server-cool\s+.+\s+\<Not Created\>$/
88
- Then the output should match /^server-beans\s+.+\s+\<Not Created\>$/
85
+ Then the output should match /^client-cool\s+.+\s+\<Not Created\>\s+\<None\>$/
86
+ Then the output should match /^client-beans\s+.+\s+\<Not Created\>\s+\<None\>$/
87
+ Then the output should match /^server-cool\s+.+\s+\<Not Created\>\s+\<None\>$/
88
+ Then the output should match /^server-beans\s+.+\s+\<Not Created\>\s+\<None\>$/
data/lib/kitchen/cli.rb CHANGED
@@ -110,6 +110,10 @@ module Kitchen
110
110
  :aliases => "-b",
111
111
  :type => :boolean,
112
112
  :desc => "List the name of each instance only, one per line"
113
+ method_option :json,
114
+ :aliases => "-j",
115
+ :type => :boolean,
116
+ :desc => "Print data as JSON"
113
117
  method_option :debug,
114
118
  :aliases => "-d",
115
119
  :type => :boolean,
@@ -17,6 +17,7 @@
17
17
  # limitations under the License.
18
18
 
19
19
  require "kitchen/command"
20
+ require "json"
20
21
 
21
22
  module Kitchen
22
23
 
@@ -35,6 +36,8 @@ module Kitchen
35
36
  "please use `kitchen diagnose'."
36
37
  elsif options[:bare]
37
38
  puts Array(result).map(&:name).join("\n")
39
+ elsif options[:json]
40
+ puts JSON.pretty_generate(Array(result).map { |r| to_hash(r) })
38
41
  else
39
42
  list_table(result)
40
43
  end
@@ -64,7 +67,8 @@ module Kitchen
64
67
  color_pad(instance.provisioner.name),
65
68
  color_pad(instance.verifier.name),
66
69
  color_pad(instance.transport.name),
67
- format_last_action(instance.last_action)
70
+ format_last_action(instance.last_action),
71
+ format_last_error(instance.last_error)
68
72
  ]
69
73
  end
70
74
 
@@ -84,6 +88,18 @@ module Kitchen
84
88
  end
85
89
  end
86
90
 
91
+ # Format and color the given last error.
92
+ #
93
+ # @param last_error [String] the last error
94
+ # @return [String] formated last error
95
+ # @api private
96
+ def format_last_error(last_error)
97
+ case last_error
98
+ when nil then colorize("<None>", :white)
99
+ else colorize(last_error, :red)
100
+ end
101
+ end
102
+
87
103
  # Constructs a list display table and output it to the screen.
88
104
  #
89
105
  # @param result [Array<Instance>] an array of instances
@@ -93,13 +109,30 @@ module Kitchen
93
109
  [
94
110
  colorize("Instance", :green), colorize("Driver", :green),
95
111
  colorize("Provisioner", :green), colorize("Verifier", :green),
96
- colorize("Transport", :green), colorize("Last Action", :green)
112
+ colorize("Transport", :green), colorize("Last Action", :green),
113
+ colorize("Last Error", :green)
97
114
  ]
98
115
  ]
99
116
  table += Array(result).map { |i| display_instance(i) }
100
117
  print_table(table)
101
118
  end
102
119
 
120
+ # Constructs a hashtable representation of a single instance.
121
+ #
122
+ # @param result [Hash{Symbol => String}] hash of a single instance
123
+ # @api private
124
+ def to_hash(result)
125
+ {
126
+ :instance => result.name,
127
+ :driver => result.driver.name,
128
+ :provisioner => result.provisioner.name,
129
+ :verifier => result.verifier.name,
130
+ :transport => result.transport.name,
131
+ :last_action => result.last_action,
132
+ :last_error => result.last_error
133
+ }
134
+ end
135
+
103
136
  # Outputs a formatted display table.
104
137
  #
105
138
  # @api private
@@ -119,6 +119,13 @@ module Kitchen
119
119
  @api_version = version
120
120
  end
121
121
 
122
+ # Cache directory that a driver could implement to inform the provisioner
123
+ # that it can leverage it internally
124
+ #
125
+ # @return path [String] a path of the cache directory
126
+ def cache_directory
127
+ end
128
+
122
129
  private
123
130
 
124
131
  # Intercepts any bare #puts calls in subclasses and issues an INFO log
@@ -216,6 +216,13 @@ module Kitchen
216
216
  @serial_actions += methods
217
217
  end
218
218
 
219
+ # Cache directory that a driver could implement to inform the provisioner
220
+ # that it can leverage it internally
221
+ #
222
+ # @return path [String] a path of the cache directory
223
+ def cache_directory
224
+ end
225
+
219
226
  private
220
227
 
221
228
  def backcompat_merged_state(state)
@@ -274,6 +274,13 @@ module Kitchen
274
274
  state_file.read[:last_action]
275
275
  end
276
276
 
277
+ # Returns the error encountered on the last action on the instance
278
+ #
279
+ # @return [String] the message of the last error
280
+ def last_error
281
+ state_file.read[:last_error]
282
+ end
283
+
277
284
  # Clean up any per-instance resources before exiting.
278
285
  #
279
286
  # @return [void]
@@ -485,14 +492,17 @@ module Kitchen
485
492
  synchronize_or_call(what, state, &block)
486
493
  end
487
494
  state[:last_action] = what.to_s
495
+ state[:last_error] = nil
488
496
  elapsed
489
497
  rescue ActionFailed => e
490
498
  log_failure(what, e)
499
+ state[:last_error] = e.class.name
491
500
  raise(InstanceFailure, failure_message(what) +
492
501
  " Please see .kitchen/logs/#{name}.log for more details",
493
502
  e.backtrace)
494
503
  rescue Exception => e # rubocop:disable Lint/RescueException
495
504
  log_failure(what, e)
505
+ state[:last_error] = e.class.name
496
506
  raise ActionFailed,
497
507
  "Failed to complete ##{what} action: [#{e.message}]", e.backtrace
498
508
  ensure
@@ -64,7 +64,7 @@ module Kitchen
64
64
 
65
65
  ::Berkshelf.ui.mute do
66
66
  berksfile_obj = ::Berkshelf::Berksfile.from_file(berksfile)
67
- berksfile_obj.update if always_update
67
+ berksfile_obj.update if always_update && berkshelf_obj.lockfile.present?
68
68
  # Berkshelf requires the directory to not exist
69
69
  FileUtils.rm_rf(path)
70
70
  berksfile_obj.vendor(path)
@@ -67,6 +67,8 @@ module Kitchen
67
67
  attributes/**/* definitions/**/* files/**/* libraries/**/*
68
68
  providers/**/* recipes/**/* resources/**/* templates/**/*
69
69
  ].join(",")
70
+ # to ease upgrades, allow the user to turn deprecation warnings into errors
71
+ default_config :deprecations_as_errors, false
70
72
 
71
73
  default_config :data_path do |provisioner|
72
74
  provisioner.calculate_path("data")
@@ -154,6 +156,7 @@ module Kitchen
154
156
  # @return [Hash] an option hash for the install commands
155
157
  # @api private
156
158
  def install_options
159
+ add_omnibus_directory_option if instance.driver.cache_directory
157
160
  project = /\s*-P (\w+)\s*/.match(config[:chef_omnibus_install_options])
158
161
  {
159
162
  :omnibus_url => config[:chef_omnibus_url],
@@ -168,6 +171,19 @@ module Kitchen
168
171
  end
169
172
  end
170
173
 
174
+ # Verify if the "omnibus_dir_option" has already been passed, if so we
175
+ # don't use the @driver.cache_directory
176
+ #
177
+ # @api private
178
+ def add_omnibus_directory_option
179
+ cache_dir_option = "#{omnibus_dir_option} #{instance.driver.cache_directory}"
180
+ if config[:chef_omnibus_install_options].nil?
181
+ config[:chef_omnibus_install_options] = cache_dir_option
182
+ elsif config[:chef_omnibus_install_options].match(/\s*#{omnibus_dir_option}\s*/).nil?
183
+ config[:chef_omnibus_install_options] << " " << cache_dir_option
184
+ end
185
+ end
186
+
171
187
  # @return [String] an absolute path to a Policyfile, relative to the
172
188
  # kitchen root
173
189
  # @api private
@@ -218,7 +234,8 @@ module Kitchen
218
234
  :chef_server_url => "http://127.0.0.1:8889",
219
235
  :encrypted_data_bag_secret => remote_path_join(
220
236
  root, "encrypted_data_bag_secret"
221
- )
237
+ ),
238
+ :treat_deprecation_warnings_as_errors => config[:deprecations_as_errors]
222
239
  }
223
240
  end
224
241
 
@@ -327,6 +344,13 @@ module Kitchen
327
344
  end
328
345
  end
329
346
 
347
+ # @return [String] Correct option per platform to specify the the
348
+ # cache directory
349
+ # @api private
350
+ def omnibus_dir_option
351
+ windows_os? ? "-download_directory" : "-d"
352
+ end
353
+
330
354
  def install_from_file(command)
331
355
  install_file = "/tmp/chef-installer.sh"
332
356
  script = ["cat > #{install_file} <<\"EOL\""]
@@ -394,7 +394,7 @@ module Kitchen
394
394
  # @param data [Hash] merged configuration and mutable state data
395
395
  # @return [Hash] hash of connection options
396
396
  # @api private
397
- # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity
397
+ # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
398
398
  def connection_options(data)
399
399
  opts = {
400
400
  :logger => logger,
@@ -17,5 +17,5 @@
17
17
  # limitations under the License.
18
18
 
19
19
  module Kitchen
20
- VERSION = "1.13.2"
20
+ VERSION = "1.14.0"
21
21
  end
@@ -26,6 +26,7 @@ describe Kitchen::Provisioner::ChefBase do
26
26
  let(:logged_output) { StringIO.new }
27
27
  let(:logger) { Logger.new(logged_output) }
28
28
  let(:platform) { stub(:os_type => nil) }
29
+ let(:driver) { stub(:cache_directory => nil) }
29
30
  let(:suite) { stub(:name => "fries") }
30
31
  let(:default_version) { true }
31
32
 
@@ -38,7 +39,8 @@ describe Kitchen::Provisioner::ChefBase do
38
39
  :name => "coolbeans",
39
40
  :logger => logger,
40
41
  :suite => suite,
41
- :platform => platform
42
+ :platform => platform,
43
+ :driver => driver
42
44
  )
43
45
  end
44
46
 
@@ -74,7 +76,6 @@ describe Kitchen::Provisioner::ChefBase do
74
76
  provisioner[:chef_omnibus_url].
75
77
  must_equal "https://omnitruck.chef.io/install.sh"
76
78
  end
77
-
78
79
  end
79
80
 
80
81
  it ":require_chef_omnibus defaults to true" do
@@ -150,8 +151,9 @@ describe Kitchen::Provisioner::ChefBase do
150
151
 
151
152
  let(:install_opts) {
152
153
  { :omnibus_url => "https://omnitruck.chef.io/install.sh",
153
- :project => nil, :install_flags => nil, :sudo_command => "sudo -E",
154
- :http_proxy => nil, :https_proxy => nil }
154
+ :project => nil, :install_flags => nil,
155
+ :sudo_command => "sudo -E", :http_proxy => nil, :https_proxy => nil
156
+ }
155
157
  }
156
158
 
157
159
  it "returns nil if :require_chef_omnibus is falsey" do
@@ -313,6 +315,38 @@ describe Kitchen::Provisioner::ChefBase do
313
315
 
314
316
  cmd.wont_match(/\Amy_prefix /)
315
317
  end
318
+
319
+ describe "when driver implements the cache_directory interface" do
320
+ before { driver.stubs(:cache_directory).returns("/tmp/custom/place") }
321
+
322
+ it "will use driver.cache_directory to provide a cache directory" do
323
+ install_opts[:install_flags] = "-d /tmp/custom/place"
324
+
325
+ Mixlib::Install::ScriptGenerator.expects(:new).
326
+ with(default_version, false, install_opts).returns(installer)
327
+ cmd
328
+ end
329
+
330
+ it "will use driver.cache_directory even if other options are given" do
331
+ config[:chef_omnibus_install_options] = "-P cool -v 123"
332
+ install_opts[:install_flags] = "-P cool -v 123 -d /tmp/custom/place"
333
+ install_opts[:project] = "cool"
334
+
335
+ Mixlib::Install::ScriptGenerator.expects(:new).
336
+ with(default_version, false, install_opts).returns(installer)
337
+ cmd
338
+ end
339
+
340
+ it "will not use driver.cache_directory if -d options is given" do
341
+ config[:chef_omnibus_install_options] = "-P cool -d /path -v 123"
342
+ install_opts[:install_flags] = "-P cool -d /path -v 123"
343
+ install_opts[:project] = "cool"
344
+
345
+ Mixlib::Install::ScriptGenerator.expects(:new).
346
+ with(default_version, false, install_opts).returns(installer)
347
+ cmd
348
+ end
349
+ end
316
350
  end
317
351
 
318
352
  describe "for product" do
@@ -451,6 +485,21 @@ describe Kitchen::Provisioner::ChefBase do
451
485
  end.returns(installer)
452
486
  cmd
453
487
  end
488
+
489
+ describe "when driver implements the cache_directory" do
490
+ before { driver.stubs(:cache_directory).returns("$env:TEMP\\dummy\\place") }
491
+
492
+ it "will have the same behavior on windows" do
493
+ config[:chef_omnibus_install_options] = "-version 123"
494
+ install_opts_clone = install_opts.clone
495
+ install_opts_clone[:sudo_command] = ""
496
+ install_opts_clone[:install_flags] = "-version 123"
497
+ install_opts_clone[:install_flags] << " -download_directory $env:TEMP\\dummy\\place"
498
+ Mixlib::Install::ScriptGenerator.expects(:new).
499
+ with(default_version, true, install_opts_clone).returns(installer)
500
+ cmd
501
+ end
502
+ end
454
503
  end
455
504
  end
456
505
 
@@ -1321,6 +1370,10 @@ POLICYFILE
1321
1370
  file.must_include %{encrypted_data_bag_secret } +
1322
1371
  %{"/tmp/kitchen/encrypted_data_bag_secret"}
1323
1372
  end
1373
+
1374
+ it "disables deprecation warnings" do
1375
+ file.must_include %{treat_deprecation_warnings_as_errors false}
1376
+ end
1324
1377
  end
1325
1378
 
1326
1379
  it "supports overwriting defaults" do
data/spec/spec_helper.rb CHANGED
@@ -18,10 +18,7 @@
18
18
 
19
19
  gem "minitest"
20
20
 
21
- if ENV["CODECLIMATE_REPO_TOKEN"]
22
- require "codeclimate-test-reporter"
23
- CodeClimate::TestReporter.start
24
- elsif ENV["COVERAGE"]
21
+ if ENV["CODECLIMATE_REPO_TOKEN"] || ENV["COVERAGE"]
25
22
  require "simplecov"
26
23
  SimpleCov.profiles.define "gem" do
27
24
  command_name "Specs"
File without changes
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.13.2
4
+ version: 1.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fletcher Nichol
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-26 00:00:00.000000000 Z
11
+ date: 2016-11-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mixlib-shellout
@@ -634,7 +634,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
634
634
  version: '0'
635
635
  requirements: []
636
636
  rubyforge_project:
637
- rubygems_version: 2.6.4
637
+ rubygems_version: 2.6.7
638
638
  signing_key:
639
639
  specification_version: 4
640
640
  summary: Test Kitchen is an integration tool for developing and testing infrastructure