chef 12.2.1-x86-mingw32 → 12.3.0.rc.0-x86-mingw32

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 (70) hide show
  1. checksums.yaml +4 -4
  2. data/ext/win32-eventlog/Rakefile +10 -6
  3. data/lib/chef.rb +1 -0
  4. data/lib/chef/application/apply.rb +5 -0
  5. data/lib/chef/application/client.rb +10 -0
  6. data/lib/chef/application/knife.rb +5 -1
  7. data/lib/chef/application/solo.rb +5 -0
  8. data/lib/chef/chef_class.rb +130 -0
  9. data/lib/chef/client.rb +15 -7
  10. data/lib/chef/config.rb +13 -0
  11. data/lib/chef/event_loggers/windows_eventlog.rb +11 -5
  12. data/lib/chef/http.rb +13 -3
  13. data/lib/chef/http/basic_client.rb +21 -4
  14. data/lib/chef/http/socketless_chef_zero_client.rb +207 -0
  15. data/lib/chef/knife.rb +3 -0
  16. data/lib/chef/knife/bootstrap.rb +1 -1
  17. data/lib/chef/knife/core/status_presenter.rb +12 -11
  18. data/lib/chef/knife/ssh.rb +3 -1
  19. data/lib/chef/knife/status.rb +32 -7
  20. data/lib/chef/local_mode.rb +13 -3
  21. data/lib/chef/mixin/provides.rb +32 -0
  22. data/lib/chef/platform/provider_priority_map.rb +16 -7
  23. data/lib/chef/platform/resource_priority_map.rb +37 -0
  24. data/lib/chef/policy_builder/expand_node_object.rb +14 -0
  25. data/lib/chef/policy_builder/policyfile.rb +0 -1
  26. data/lib/chef/provider.rb +5 -20
  27. data/lib/chef/provider/package/rubygems.rb +4 -1
  28. data/lib/chef/provider/service/macosx.rb +66 -30
  29. data/lib/chef/provider_resolver.rb +10 -5
  30. data/lib/chef/resource.rb +5 -39
  31. data/lib/chef/resource/gem_package.rb +5 -0
  32. data/lib/chef/resource/link.rb +1 -1
  33. data/lib/chef/resource/macosx_service.rb +59 -0
  34. data/lib/chef/resource/remote_file.rb +0 -4
  35. data/lib/chef/resource_resolver.rb +101 -0
  36. data/lib/chef/rest.rb +4 -5
  37. data/lib/chef/search/query.rb +1 -1
  38. data/lib/chef/server_api.rb +1 -0
  39. data/lib/chef/version.rb +1 -1
  40. data/spec/data/lwrp/providers/buck_passer.rb +2 -1
  41. data/spec/data/lwrp/resources/bar.rb +1 -1
  42. data/spec/data/{big_json.json → nested.json} +2 -2
  43. data/spec/functional/event_loggers/windows_eventlog_spec.rb +14 -0
  44. data/spec/functional/resource/execute_spec.rb +1 -1
  45. data/spec/integration/client/client_spec.rb +12 -1
  46. data/spec/integration/client/ipv6_spec.rb +1 -1
  47. data/spec/integration/knife/common_options_spec.rb +3 -3
  48. data/spec/integration/recipes/lwrp_inline_resources_spec.rb +1 -1
  49. data/spec/integration/solo/solo_spec.rb +7 -5
  50. data/spec/unit/application/client_spec.rb +10 -0
  51. data/spec/unit/chef_class_spec.rb +91 -0
  52. data/spec/unit/client_spec.rb +13 -0
  53. data/spec/unit/http/basic_client_spec.rb +43 -6
  54. data/spec/unit/http/socketless_chef_zero_client_spec.rb +174 -0
  55. data/spec/unit/http_spec.rb +14 -0
  56. data/spec/unit/json_compat_spec.rb +7 -20
  57. data/spec/unit/knife/ssh_spec.rb +18 -0
  58. data/spec/unit/knife/status_spec.rb +69 -3
  59. data/spec/unit/knife_spec.rb +5 -0
  60. data/spec/unit/provider/package/rubygems_spec.rb +19 -0
  61. data/spec/unit/provider/service/macosx_spec.rb +230 -203
  62. data/spec/unit/provider_resolver_spec.rb +1 -0
  63. data/spec/unit/recipe_spec.rb +48 -0
  64. data/spec/unit/resource/link_spec.rb +15 -0
  65. data/spec/unit/resource_spec.rb +6 -6
  66. data/spec/unit/rest_spec.rb +9 -0
  67. data/spec/unit/search/query_spec.rb +24 -0
  68. data/spec/unit/shell_spec.rb +3 -1
  69. metadata +16 -9
  70. data/spec/data/big_json_plus_one.json +0 -2
@@ -47,7 +47,7 @@ class Chef
47
47
  def enabled_handlers
48
48
  @enabled_handlers ||=
49
49
  providers.select do |klass|
50
- klass.provides?(node, resource)
50
+ klass.provides?(node, resource.resource_name)
51
51
  end.sort {|a,b| a.to_s <=> b.to_s }
52
52
  end
53
53
 
@@ -84,8 +84,13 @@ class Chef
84
84
  if handlers.count >= 2
85
85
  # this magic stack ranks the providers by where they appear in the provider_priority_map, it is mostly used
86
86
  # to pick amongst N different ways to start init scripts on different debian/ubuntu systems.
87
- priority_list = [ get_provider_priority_map(resource.resource_name, node) ].flatten.compact
87
+ priority_list = [ get_priority_array(node, resource.resource_name) ].flatten.compact
88
88
  handlers = handlers.sort_by { |x| i = priority_list.index x; i.nil? ? Float::INFINITY : i }
89
+ if priority_list.index(handlers.first).nil?
90
+ # if we had more than one and we picked one with a precidence of infinity that means that the resource_priority_map
91
+ # entry for this resource is missing -- we should probably raise here and force resolution of the ambiguity.
92
+ Chef::Log.warn "Ambiguous provider precedence: #{handlers}, please use Chef.set_provider_priority_array to provide determinism"
93
+ end
89
94
  handlers = [ handlers.first ]
90
95
  end
91
96
 
@@ -106,12 +111,12 @@ class Chef
106
111
  end
107
112
 
108
113
  # dep injection hooks
109
- def get_provider_priority_map(resource_name, node)
110
- provider_priority_map.get(node, resource_name)
114
+ def get_priority_array(node, resource_name)
115
+ provider_priority_map.get_priority_array(node, resource_name)
111
116
  end
112
117
 
113
118
  def provider_priority_map
114
- Chef::Platform::ProviderPriorityMap.instance.priority_map
119
+ Chef::Platform::ProviderPriorityMap.instance
115
120
  end
116
121
  end
117
122
  end
@@ -33,7 +33,7 @@ require 'chef/platform'
33
33
  require 'chef/resource/resource_notification'
34
34
 
35
35
  require 'chef/mixin/deprecation'
36
- require 'chef/mixin/descendants_tracker'
36
+ require 'chef/mixin/provides'
37
37
 
38
38
  class Chef
39
39
  class Resource
@@ -46,6 +46,7 @@ class Chef
46
46
  include Chef::DSL::PlatformIntrospection
47
47
  include Chef::DSL::RegistryHelper
48
48
  include Chef::DSL::RebootPending
49
+ extend Chef::Mixin::Provides
49
50
 
50
51
  #
51
52
  # The node the current Chef run is using.
@@ -879,7 +880,6 @@ class Chef
879
880
 
880
881
  include Chef::Mixin::ConvertToClassName
881
882
  extend Chef::Mixin::ConvertToClassName
882
- extend Chef::Mixin::DescendantsTracker
883
883
 
884
884
  # XXX: this is required for definition params inside of the scope of a
885
885
  # subresource to work correctly.
@@ -1016,6 +1016,7 @@ class Chef
1016
1016
  end
1017
1017
 
1018
1018
  def provider_for_action(action)
1019
+ require 'chef/provider_resolver'
1019
1020
  provider = Chef::ProviderResolver.new(node, self, action).resolve.new(self, run_context)
1020
1021
  provider.action = action
1021
1022
  provider
@@ -1080,33 +1081,6 @@ class Chef
1080
1081
  end
1081
1082
  end
1082
1083
 
1083
- # Maps a short_name (and optionally a platform and version) to a
1084
- # Chef::Resource. This allows finer grained per platform resource
1085
- # attributes and the end of overloaded resource definitions
1086
- # (I'm looking at you Chef::Resource::Package)
1087
- # Ex:
1088
- # class WindowsFile < Chef::Resource
1089
- # provides :file, os: "linux", platform_family: "rhel", platform: "redhat"
1090
- # provides :file, os: "!windows
1091
- # provides :file, os: [ "linux", "aix" ]
1092
- # provides :file, os: "solaris2" do |node|
1093
- # node['platform_version'].to_f <= 5.11
1094
- # end
1095
- # # ...other stuff
1096
- # end
1097
- #
1098
- def self.provides(short_name, opts={}, &block)
1099
- short_name_sym = short_name
1100
- if short_name.kind_of?(String)
1101
- # YAGNI: this is probably completely unnecessary and can be removed?
1102
- Chef::Log.warn "[DEPRECATION] Passing a String to Chef::Resource#provides will be removed"
1103
- short_name.downcase!
1104
- short_name.gsub!(/\s/, "_")
1105
- short_name_sym = short_name.to_sym
1106
- end
1107
- node_map.set(short_name_sym, constantize(self.name), opts, &block)
1108
- end
1109
-
1110
1084
  # Returns a resource based on a short_name and node
1111
1085
  #
1112
1086
  # ==== Parameters
@@ -1116,16 +1090,12 @@ class Chef
1116
1090
  # === Returns
1117
1091
  # <Chef::Resource>:: returns the proper Chef::Resource class
1118
1092
  def self.resource_for_node(short_name, node)
1119
- klass = node_map.get(node, short_name) ||
1120
- resource_matching_short_name(short_name)
1093
+ require 'chef/resource_resolver'
1094
+ klass = Chef::ResourceResolver.new(node, short_name).resolve
1121
1095
  raise Chef::Exceptions::NoSuchResourceType.new(short_name, node) if klass.nil?
1122
1096
  klass
1123
1097
  end
1124
1098
 
1125
- def self.node_map
1126
- @@node_map ||= NodeMap.new
1127
- end
1128
-
1129
1099
  # Returns the class of a Chef::Resource based on the short name
1130
1100
  # ==== Parameters
1131
1101
  # short_name<Symbol>:: short_name of the resource (ie :directory)
@@ -1156,7 +1126,3 @@ class Chef
1156
1126
  end
1157
1127
  end
1158
1128
  end
1159
-
1160
- # We require this at the BOTTOM of this file to avoid circular requires (it is used
1161
- # at runtime but not load time)
1162
- require 'chef/provider_resolver'
@@ -27,12 +27,17 @@ class Chef
27
27
  def initialize(name, run_context=nil)
28
28
  super
29
29
  @resource_name = :gem_package
30
+ @clear_sources = false
30
31
  end
31
32
 
32
33
  def source(arg=nil)
33
34
  set_or_return(:source, arg, :kind_of => [ String, Array ])
34
35
  end
35
36
 
37
+ def clear_sources(arg=nil)
38
+ set_or_return(:clear_sources, arg, :kind_of => [ TrueClass, FalseClass ])
39
+ end
40
+
36
41
  # Sets a custom gem_binary to run for gem commands.
37
42
  def gem_binary(gem_cmd=nil)
38
43
  set_or_return(:gem_binary,gem_cmd,:kind_of => [ String ])
@@ -85,7 +85,7 @@ class Chef
85
85
 
86
86
  # make link quack like a file (XXX: not for public consumption)
87
87
  def path
88
- @target_file
88
+ target_file
89
89
  end
90
90
 
91
91
  private
@@ -0,0 +1,59 @@
1
+ #
2
+ # Author:: Mike Dodge (<mikedodge04@gmail.com>)
3
+ # Copyright:: Copyright (c) 2015 Facebook, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require 'chef/resource/service'
20
+
21
+ class Chef
22
+ class Resource
23
+ class MacosxService < Chef::Resource::Service
24
+
25
+ provides :service, os: "darwin"
26
+ provides :macosx_service, os: "darwin"
27
+
28
+ identity_attr :service_name
29
+
30
+ state_attrs :enabled, :running
31
+
32
+ def initialize(name, run_context=nil)
33
+ super
34
+ @resource_name = :macosx_service
35
+ @plist = nil
36
+ @session_type = nil
37
+ end
38
+
39
+ # This will enable user to pass a plist in the case
40
+ # that the filename and label for the service dont match
41
+ def plist(arg=nil)
42
+ set_or_return(
43
+ :plist,
44
+ arg,
45
+ :kind_of => String
46
+ )
47
+ end
48
+
49
+ def session_type(arg=nil)
50
+ set_or_return(
51
+ :session_type,
52
+ arg,
53
+ :kind_of => String
54
+ )
55
+ end
56
+
57
+ end
58
+ end
59
+ end
@@ -125,10 +125,6 @@ class Chef
125
125
  )
126
126
  end
127
127
 
128
- def after_created
129
- validate_source(@source)
130
- end
131
-
132
128
  private
133
129
 
134
130
  def validate_source(source)
@@ -0,0 +1,101 @@
1
+ #
2
+ # Author:: Lamont Granquist (<lamont@chef.io>)
3
+ # Copyright:: Copyright (c) 2015 Chef Software, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require 'chef/exceptions'
20
+ require 'chef/platform/resource_priority_map'
21
+
22
+ class Chef
23
+ class ResourceResolver
24
+
25
+ attr_reader :node
26
+ attr_reader :resource
27
+ attr_reader :action
28
+
29
+ def initialize(node, resource)
30
+ @node = node
31
+ @resource = resource
32
+ end
33
+
34
+ # return a deterministically sorted list of Chef::Resource subclasses
35
+ def resources
36
+ @resources ||= Chef::Resource.descendants
37
+ end
38
+
39
+ def resolve
40
+ maybe_dynamic_resource_resolution(resource) ||
41
+ maybe_chef_platform_lookup(resource)
42
+ end
43
+
44
+ # this cut looks at if the resource can handle the resource type on the node
45
+ def enabled_handlers
46
+ @enabled_handlers ||=
47
+ resources.select do |klass|
48
+ klass.provides?(node, resource)
49
+ end.sort {|a,b| a.to_s <=> b.to_s }
50
+ @enabled_handlers
51
+ end
52
+
53
+ private
54
+
55
+ # try dynamically finding a resource based on querying the resources to see what they support
56
+ def maybe_dynamic_resource_resolution(resource)
57
+ # log this so we know what resources will work for the generic resource on the node (early cut)
58
+ Chef::Log.debug "resources for generic #{resource} resource enabled on node include: #{enabled_handlers}"
59
+
60
+ # if none of the resources specifically support the resource, we still need to pick one of the resources that are
61
+ # enabled on the node to handle the why-run use case.
62
+ handlers = enabled_handlers
63
+
64
+ if handlers.count >= 2
65
+ # this magic stack ranks the resources by where they appear in the resource_priority_map
66
+ priority_list = [ get_priority_array(node, resource) ].flatten.compact
67
+ handlers = handlers.sort_by { |x| i = priority_list.index x; i.nil? ? Float::INFINITY : i }
68
+ if priority_list.index(handlers.first).nil?
69
+ # if we had more than one and we picked one with a precidence of infinity that means that the resource_priority_map
70
+ # entry for this resource is missing -- we should probably raise here and force resolution of the ambiguity.
71
+ Chef::Log.warn "Ambiguous resource precedence: #{handlers}, please use Chef.set_resource_priority_array to provide determinism"
72
+ end
73
+ handlers = [ handlers.first ]
74
+ end
75
+
76
+ Chef::Log.debug "resources that survived replacement include: #{handlers}"
77
+
78
+ raise Chef::Exceptions::AmbiguousResourceResolution.new(resource, handlers) if handlers.count >= 2
79
+
80
+ Chef::Log.debug "dynamic resource resolver FAILED to resolve a resouce" if handlers.empty?
81
+
82
+ return nil if handlers.empty?
83
+
84
+ handlers[0]
85
+ end
86
+
87
+ # try the old static lookup of resources by mangling name to resource klass
88
+ def maybe_chef_platform_lookup(resource)
89
+ Chef::Resource.resource_matching_short_name(resource)
90
+ end
91
+
92
+ # dep injection hooks
93
+ def get_priority_array(node, resource_name)
94
+ resource_priority_map.get_priority_array(node, resource_name)
95
+ end
96
+
97
+ def resource_priority_map
98
+ Chef::Platform::ResourcePriorityMap.instance
99
+ end
100
+ end
101
+ end
@@ -39,6 +39,7 @@ require 'chef/platform/query_helpers'
39
39
  require 'chef/http/remote_request_id'
40
40
 
41
41
  class Chef
42
+
42
43
  # == Chef::REST
43
44
  # Chef's custom REST client with built-in JSON support and RSA signed header
44
45
  # authentication.
@@ -57,6 +58,9 @@ class Chef
57
58
  # http://localhost:4000, a call to +get_rest+ with 'nodes' will make an
58
59
  # HTTP GET request to http://localhost:4000/nodes
59
60
  def initialize(url, client_name=Chef::Config[:node_name], signing_key_filename=Chef::Config[:client_key], options={})
61
+
62
+ signing_key_filename = nil if chef_zero_uri?(url)
63
+
60
64
  options = options.dup
61
65
  options[:client_name] = client_name
62
66
  options[:signing_key_filename] = signing_key_filename
@@ -188,11 +192,6 @@ class Chef
188
192
 
189
193
  public :create_url
190
194
 
191
- def http_client(base_url=nil)
192
- base_url ||= url
193
- BasicClient.new(base_url, :ssl_policy => Chef::HTTP::APISSLPolicy)
194
- end
195
-
196
195
  ############################################################################
197
196
  # DEPRECATED
198
197
  ############################################################################
@@ -89,7 +89,7 @@ WARNDEP
89
89
  if block
90
90
  response["rows"].each { |row| block.call(row) if row }
91
91
  unless (response["start"] + response["rows"].length) >= response["total"]
92
- args_h[:start] = response["start"] + (args_h[:rows] || 0)
92
+ args_h[:start] = response["start"] + response["rows"].length
93
93
  search(type, query, args_h, &block)
94
94
  end
95
95
  true
@@ -30,6 +30,7 @@ class Chef
30
30
  def initialize(url = Chef::Config[:chef_server_url], options = {})
31
31
  options[:client_name] ||= Chef::Config[:node_name]
32
32
  options[:signing_key_filename] ||= Chef::Config[:client_key]
33
+ options[:signing_key_filename] = nil if chef_zero_uri?(url)
33
34
  super(url, options)
34
35
  end
35
36
 
@@ -17,7 +17,7 @@
17
17
 
18
18
  class Chef
19
19
  CHEF_ROOT = File.dirname(File.expand_path(File.dirname(__FILE__)))
20
- VERSION = '12.2.1'
20
+ VERSION = '12.3.0.rc.0'
21
21
  end
22
22
 
23
23
  #
@@ -1,4 +1,5 @@
1
- provides 'buck_passer'
1
+ provides :buck_passer
2
+
2
3
  action :pass_buck do
3
4
  lwrp_foo :prepared_thumbs do
4
5
  action :prepare_thumbs
@@ -1,2 +1,2 @@
1
- provides "lwrp_bar" # This makes sure that we cover the case of lwrps using provides
1
+ provides :lwrp_bar # This makes sure that we cover the case of lwrps using provides
2
2
  actions :pass_buck, :prepare_eyes, :watch_paint_dry
@@ -1,2 +1,2 @@
1
- {"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":"test"
2
- }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
1
+ {"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":{"key":"test"
2
+ }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
@@ -79,4 +79,18 @@ describe Chef::EventLoggers::WindowsEventLogger, :windows_only, :not_supported_o
79
79
  end).to be_truthy
80
80
  end
81
81
 
82
+ it 'writes run_failed event with event_id 10003 even when run_status is not set' do
83
+ logger.run_failed(mock_exception)
84
+
85
+ expect(event_log.read(flags, offset).any? do |e|
86
+ e.source == 'Chef' && e.event_id == 10003 &&
87
+ e.string_inserts[0].include?("UNKNOWN") &&
88
+ e.string_inserts[1].include?("UNKNOWN") &&
89
+ e.string_inserts[2].include?(mock_exception.class.name) &&
90
+ e.string_inserts[3].include?(mock_exception.message) &&
91
+ e.string_inserts[4].include?(mock_exception.backtrace[0]) &&
92
+ e.string_inserts[4].include?(mock_exception.backtrace[1])
93
+ end).to be_truthy
94
+ end
95
+
82
96
  end
@@ -62,7 +62,7 @@ describe Chef::Resource::Execute do
62
62
  end
63
63
 
64
64
  describe "when parent resource sets :cwd" do
65
- let(:guard) { %{ruby -e 'exit 1 unless File.exists?("./big_json_plus_one.json")'} }
65
+ let(:guard) { %{ruby -e 'exit 1 unless File.exists?("./nested.json")'} }
66
66
 
67
67
  it "guard inherits :cwd from resource and runs" do
68
68
  resource.cwd CHEF_SPEC_DATA
@@ -45,7 +45,7 @@ describe "chef-client" do
45
45
  # machine that has omnibus chef installed. In that case we need to ensure
46
46
  # we're running `chef-client` from the source tree and not the external one.
47
47
  # cf. CHEF-4914
48
- let(:chef_client) { "ruby '#{chef_dir}/chef-client'" }
48
+ let(:chef_client) { "ruby '#{chef_dir}/chef-client' --minimal-ohai" }
49
49
 
50
50
  when_the_repository "has a cookbook with a no-op recipe" do
51
51
  before { file 'cookbooks/x/recipes/default.rb', '' }
@@ -60,6 +60,17 @@ EOM
60
60
  result.error!
61
61
  end
62
62
 
63
+ it "should complete successfully with --no-listen" do
64
+ file 'config/client.rb', <<EOM
65
+ local_mode true
66
+ cookbook_path "#{path_to('cookbooks')}"
67
+ EOM
68
+
69
+ result = shell_out("#{chef_client} --no-listen -c \"#{path_to('config/client.rb')}\" -o 'x::default'", :cwd => chef_dir)
70
+ result.error!
71
+ end
72
+
73
+
63
74
  context 'and no config file' do
64
75
  it 'should complete with success when cwd is just above cookbooks and paths are not specified' do
65
76
  result = shell_out("#{chef_client} -z -o 'x::default' --disable-config", :cwd => path_to(''))