summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornimisha <nimisha.sharad@msystechnologies.com>2017-06-15 17:44:17 +0530
committernimisha <nimisha.sharad@msystechnologies.com>2017-06-19 12:09:15 +0530
commit326e6eb64d463aee2e0889b7adbae5696ba3ab6f (patch)
tree8ab354021a38cd11360d17298517d0d1e9adf884
parente1695dc8005ea7d24ffc24c75098b976adbd1c9c (diff)
downloadchef-326e6eb64d463aee2e0889b7adbae5696ba3ab6f.tar.gz
Fixing build failures of Windows Server 2016
Signed-off-by: nimisha <nimisha.sharad@msystechnologies.com>
-rw-r--r--spec/functional/mixin/powershell_out_spec.rb24
-rw-r--r--spec/functional/resource/group_spec.rb1
-rw-r--r--spec/spec_helper.rb1
-rw-r--r--spec/support/platform_helpers.rb5
4 files changed, 27 insertions, 4 deletions
diff --git a/spec/functional/mixin/powershell_out_spec.rb b/spec/functional/mixin/powershell_out_spec.rb
index 66214cb0c7..c0af8ab48e 100644
--- a/spec/functional/mixin/powershell_out_spec.rb
+++ b/spec/functional/mixin/powershell_out_spec.rb
@@ -22,8 +22,16 @@ describe Chef::Mixin::PowershellOut, windows_only: true do
include Chef::Mixin::PowershellOut
describe "#powershell_out" do
- it "runs a powershell command and collects stdout" do
- expect(powershell_out("get-process").run_command.stdout).to match /Handles\s+NPM\(K\)\s+PM\(K\)\s+WS\(K\)\s+VM\(M\)\s+CPU\(s\)\s+Id\s+/
+ context "for windows version less than 10", windows_10_or_2016: false do
+ it "runs a powershell command and collects stdout" do
+ expect(powershell_out("get-process").run_command.stdout).to match /Handles\s+NPM\(K\)\s+PM\(K\)\s+WS\(K\)\s+VM\(M\)\s+CPU\(s\)\s+Id\s+/
+ end
+ end
+
+ context "for windows version greater than 10", windows_10_or_2016: true do
+ it "runs a powershell command and collects stdout" do
+ expect(powershell_out("get-process").run_command.stdout).to match /Handles\s+NPM\(K\)\s+PM\(K\)\s+WS\(K\)\s+CPU\(s\)\s+Id\s+SI\s+ProcessName\s+/
+ end
end
it "does not raise exceptions when the command is invalid" do
@@ -32,8 +40,16 @@ describe Chef::Mixin::PowershellOut, windows_only: true do
end
describe "#powershell_out!" do
- it "runs a powershell command and collects stdout" do
- expect(powershell_out!("get-process").run_command.stdout).to match /Handles\s+NPM\(K\)\s+PM\(K\)\s+WS\(K\)\s+VM\(M\)\s+CPU\(s\)\s+Id\s+/
+ context "for windows version less than 10", windows_10_or_2016: false do
+ it "runs a powershell command and collects stdout" do
+ expect(powershell_out!("get-process").run_command.stdout).to match /Handles\s+NPM\(K\)\s+PM\(K\)\s+WS\(K\)\s+VM\(M\)\s+CPU\(s\)\s+Id\s+/
+ end
+ end
+
+ context "for windows version less than 10", windows_10_or_2016: true do
+ it "runs a powershell command and collects stdout" do
+ expect(powershell_out("get-process").run_command.stdout).to match /Handles\s+NPM\(K\)\s+PM\(K\)\s+WS\(K\)\s+CPU\(s\)\s+Id\s+SI\s+ProcessName\s+/
+ end
end
it "raises exceptions when the command is invalid" do
diff --git a/spec/functional/resource/group_spec.rb b/spec/functional/resource/group_spec.rb
index 7effd386a4..00f0e61a34 100644
--- a/spec/functional/resource/group_spec.rb
+++ b/spec/functional/resource/group_spec.rb
@@ -58,6 +58,7 @@ describe Chef::Resource::Group, :requires_root_or_running_windows, :not_supporte
when "debian", "fedora", "rhel", "suse", "gentoo", "slackware", "arch"
expect { Etc.getgrnam(group) }.to raise_error(ArgumentError, "can't find group for #{group}")
when "windows"
+ sleep(5)
expect { Chef::Util::Windows::NetGroup.new(group).local_get_members }.to raise_error(ArgumentError, /The group name could not be found./)
end
end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index edb5491100..0579e34f4b 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -149,6 +149,7 @@ RSpec.configure do |config|
config.filter_run_excluding :windows64_only => true unless windows64?
config.filter_run_excluding :windows32_only => true unless windows32?
config.filter_run_excluding :windows_nano_only => true unless windows_nano_server?
+ config.filter_run_excluding :windows_10_or_2016 => true unless windows_10_or_2016?
config.filter_run_excluding :ruby64_only => true unless ruby_64bit?
config.filter_run_excluding :ruby32_only => true unless ruby_32bit?
config.filter_run_excluding :windows_powershell_dsc_only => true unless windows_powershell_dsc?
diff --git a/spec/support/platform_helpers.rb b/spec/support/platform_helpers.rb
index 019cb9a912..2d4dd2ff7e 100644
--- a/spec/support/platform_helpers.rb
+++ b/spec/support/platform_helpers.rb
@@ -70,6 +70,11 @@ def windows_2012r2?
(host_version && host_version.start_with?("6.3"))
end
+def windows_10_or_2016?
+ return false unless windows?
+ (host_version && host_version.start_with?("10.0"))
+end
+
def host_version
@host_version ||= begin
wmi = WmiLite::Wmi.new