summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/chef/event_loggers/windows_eventlog.rb20
-rw-r--r--lib/chef/resource/windows_package.rb1
-rw-r--r--lib/chef/resource/windows_service.rb1
-rw-r--r--spec/functional/event_loggers/windows_eventlog_spec.rb10
-rw-r--r--spec/unit/resource/windows_package_spec.rb8
-rw-r--r--spec/unit/resource/windows_service_spec.rb12
6 files changed, 31 insertions, 21 deletions
diff --git a/lib/chef/event_loggers/windows_eventlog.rb b/lib/chef/event_loggers/windows_eventlog.rb
index e3bbbfa1e6..b8d279594b 100644
--- a/lib/chef/event_loggers/windows_eventlog.rb
+++ b/lib/chef/event_loggers/windows_eventlog.rb
@@ -19,7 +19,7 @@
require 'chef/event_loggers/base'
require 'chef/platform/query_helpers'
-if Chef::Platform::windows?
+if Chef::Platform::windows? and not Chef::Platform::windows_server_2003?
[:INFINITE, :WAIT_FAILED, :FORMAT_MESSAGE_IGNORE_INSERTS, :ERROR_INSUFFICIENT_BUFFER].each do |c|
# These are redefined in 'win32/eventlog'
Windows::Constants.send(:remove_const, c)
@@ -56,7 +56,7 @@ class Chef
def run_start(version)
@eventlog.report_event(
- :event_type => EventLog::INFO_TYPE,
+ :event_type => EventLog::INFO_TYPE,
:source => SOURCE,
:event_id => RUN_START_EVENT_ID,
:data => [version]
@@ -66,7 +66,7 @@ class Chef
def run_started(run_status)
@run_status = run_status
@eventlog.report_event(
- :event_type => EventLog::INFO_TYPE,
+ :event_type => EventLog::INFO_TYPE,
:source => SOURCE,
:event_id => RUN_STARTED_EVENT_ID,
:data => [run_status.run_id]
@@ -75,7 +75,7 @@ class Chef
def run_completed(node)
@eventlog.report_event(
- :event_type => EventLog::INFO_TYPE,
+ :event_type => EventLog::INFO_TYPE,
:source => SOURCE,
:event_id => RUN_COMPLETED_EVENT_ID,
:data => [@run_status.run_id, @run_status.elapsed_time.to_s]
@@ -88,13 +88,13 @@ class Chef
#Exception backtrace: %5
def run_failed(e)
@eventlog.report_event(
- :event_type => EventLog::ERROR_TYPE,
- :source => SOURCE,
+ :event_type => EventLog::ERROR_TYPE,
+ :source => SOURCE,
:event_id => RUN_FAILED_EVENT_ID,
- :data => [@run_status.run_id,
- @run_status.elapsed_time.to_s,
- e.class.name,
- e.message,
+ :data => [@run_status.run_id,
+ @run_status.elapsed_time.to_s,
+ e.class.name,
+ e.message,
e.backtrace.join("\n")]
)
end
diff --git a/lib/chef/resource/windows_package.rb b/lib/chef/resource/windows_package.rb
index b1ef2c288e..c1d49f2178 100644
--- a/lib/chef/resource/windows_package.rb
+++ b/lib/chef/resource/windows_package.rb
@@ -30,7 +30,6 @@ class Chef
def initialize(name, run_context=nil)
super
@allowed_actions = [ :install, :remove ]
- @resource_name = :windows_package
@source ||= source(@package_name)
# Unique to this resource
diff --git a/lib/chef/resource/windows_service.rb b/lib/chef/resource/windows_service.rb
index 2aec4d6304..e5179981c6 100644
--- a/lib/chef/resource/windows_service.rb
+++ b/lib/chef/resource/windows_service.rb
@@ -34,7 +34,6 @@ class Chef
def initialize(name, run_context=nil)
super
- @resource_name = :windows_service
@allowed_actions.push(:configure_startup)
@startup_type = :automatic
end
diff --git a/spec/functional/event_loggers/windows_eventlog_spec.rb b/spec/functional/event_loggers/windows_eventlog_spec.rb
index 9da9f60fa9..c50bc7e00f 100644
--- a/spec/functional/event_loggers/windows_eventlog_spec.rb
+++ b/spec/functional/event_loggers/windows_eventlog_spec.rb
@@ -19,12 +19,12 @@
require 'spec_helper'
require 'securerandom'
require 'chef/event_loggers/windows_eventlog'
-if Chef::Platform.windows?
+if Chef::Platform.windows? and not Chef::Platform::windows_server_2003?
require 'win32/eventlog'
include Win32
end
-describe Chef::EventLoggers::WindowsEventLogger, :windows_only do
+describe Chef::EventLoggers::WindowsEventLogger, :windows_only, :not_supported_on_win2k3 do
let(:run_id) { SecureRandom.uuid }
let(:version) { SecureRandom.uuid }
let(:elapsed_time) { SecureRandom.random_number(100) }
@@ -43,14 +43,14 @@ describe Chef::EventLoggers::WindowsEventLogger, :windows_only do
it 'writes run_start event with event_id 10000 and contains version' do
logger.run_start(version)
- expect(event_log.read(flags, offset).any? { |e| e.source == 'Chef' && e.event_id == 10000 &&
+ expect(event_log.read(flags, offset).any? { |e| e.source == 'Chef' && e.event_id == 10000 &&
e.string_inserts[0].include?(version)}).to be_true
end
it 'writes run_started event with event_id 10001 and contains the run_id' do
logger.run_started(run_status)
- expect(event_log.read(flags, offset).any? { |e| e.source == 'Chef' && e.event_id == 10001 &&
+ expect(event_log.read(flags, offset).any? { |e| e.source == 'Chef' && e.event_id == 10001 &&
e.string_inserts[0].include?(run_id)}).to be_true
end
@@ -58,7 +58,7 @@ describe Chef::EventLoggers::WindowsEventLogger, :windows_only do
logger.run_started(run_status)
logger.run_completed(node)
- expect(event_log.read(flags, offset).any? { |e| e.source == 'Chef' && e.event_id == 10002 &&
+ expect(event_log.read(flags, offset).any? { |e| e.source == 'Chef' && e.event_id == 10002 &&
e.string_inserts[0].include?(run_id) &&
e.string_inserts[1].include?(elapsed_time.to_s)
}).to be_true
diff --git a/spec/unit/resource/windows_package_spec.rb b/spec/unit/resource/windows_package_spec.rb
index 1e02f2449b..9f15b45eda 100644
--- a/spec/unit/resource/windows_package_spec.rb
+++ b/spec/unit/resource/windows_package_spec.rb
@@ -31,6 +31,14 @@ describe Chef::Resource::WindowsPackage, "initialize" do
action: :start
)
+ static_provider_resolution(
+ resource: Chef::Resource::WindowsPackage,
+ provider: Chef::Provider::Package::Windows,
+ os: "windows",
+ name: :package,
+ action: :start
+ )
+
let(:resource) { Chef::Resource::WindowsPackage.new("solitaire.msi") }
it "returns a Chef::Resource::WindowsPackage" do
diff --git a/spec/unit/resource/windows_service_spec.rb b/spec/unit/resource/windows_service_spec.rb
index 45a295c24e..056fd70781 100644
--- a/spec/unit/resource/windows_service_spec.rb
+++ b/spec/unit/resource/windows_service_spec.rb
@@ -27,16 +27,20 @@ describe Chef::Resource::WindowsService, "initialize" do
action: :start
)
+ static_provider_resolution(
+ resource: Chef::Resource::WindowsService,
+ provider: Chef::Provider::Service::Windows,
+ os: "windows",
+ name: :service,
+ action: :start
+ )
+
let(:resource) { Chef::Resource::WindowsService.new("BITS") }
it "returns a Chef::Resource::WindowsService" do
expect(resource).to be_a_kind_of(Chef::Resource::WindowsService)
end
- it "sets the resource_name to :windows_service" do
- expect(resource.resource_name).to eql(:windows_service)
- end
-
it "supports setting startup_type" do
resource.startup_type(:manual)
expect(resource.startup_type).to eql(:manual)