summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThom May <thom@may.lt>2017-06-19 11:55:29 +0100
committerGitHub <noreply@github.com>2017-06-19 11:55:29 +0100
commit86a85c0b722ecf79f6fe6eeab8da7bf43eaf1b5c (patch)
tree1b8bc7957a2939782167383e1eca6740bde139cb
parente1695dc8005ea7d24ffc24c75098b976adbd1c9c (diff)
parente0d0ee167f97986987bdc2fda232286edd029b28 (diff)
downloadchef-86a85c0b722ecf79f6fe6eeab8da7bf43eaf1b5c.tar.gz
Merge pull request #6216 from MsysTechnologiesllc/nim/windows2016_powershell_specs
Fixing build failures of Windows Server 2016
-rw-r--r--spec/functional/mixin/powershell_out_spec.rb24
-rw-r--r--spec/functional/resource/group_spec.rb32
-rw-r--r--spec/spec_helper.rb2
-rw-r--r--spec/support/platform_helpers.rb5
4 files changed, 46 insertions, 17 deletions
diff --git a/spec/functional/mixin/powershell_out_spec.rb b/spec/functional/mixin/powershell_out_spec.rb
index 66214cb0c7..7fc8dc5957 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_lt_10: 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+VM\(M\)\s+CPU\(s\)\s+Id\s+/
+ end
+ end
+
+ context "for windows version greater than 10", windows_gte_10: 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_lt_10: 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+VM\(M\)\s+CPU\(s\)\s+Id\s+/
+ end
+ end
+
+ context "for windows version less than 10", windows_gte_10: 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..03c14382e9 100644
--- a/spec/functional/resource/group_spec.rb
+++ b/spec/functional/resource/group_spec.rb
@@ -335,19 +335,6 @@ downthestreetalwayshadagoodsmileonhisfacetheoldmanwalkingdownthestree" end
end
end
- describe "when group name length is more than 256", :windows_only do
- let!(:group_name) do
- "theoldmanwalkingdownthestreetalwayshadagood\
-smileonhisfacetheoldmanwalkingdownthestreetalwayshadagoodsmileonhisface\
-theoldmanwalkingdownthestreetalwayshadagoodsmileonhisfacetheoldmanwalking\
-downthestreetalwayshadagoodsmileonhisfacetheoldmanwalkingdownthestreeQQQQQQ" end
-
- it "should not create a group" do
- expect { group_resource.run_action(:create) }.to raise_error(ArgumentError)
- group_should_not_exist(group_name)
- end
- end
-
# not_supported_on_solaris because of the use of excluded_members
describe "should raise an error when same member is included in the members and excluded_members", :not_supported_on_solaris do
it "should raise an error" do
@@ -359,6 +346,25 @@ downthestreetalwayshadagoodsmileonhisfacetheoldmanwalkingdownthestreeQQQQQQ" end
end
end
+ # Note:This testcase is written separately from the `group create action` defined above because
+ # for group name > 256, Windows 2016 returns "The parameter is incorrect"
+ context "group create action: when group name length is more than 256", :windows_only do
+ let!(:group_name) do
+ "theoldmanwalkingdownthestreetalwayshadagood\
+smileonhisfacetheoldmanwalkingdownthestreetalwayshadagoodsmileonhisface\
+theoldmanwalkingdownthestreetalwayshadagoodsmileonhisfacetheoldmanwalking\
+downthestreetalwayshadagoodsmileonhisfacetheoldmanwalkingdownthestreeQQQQQQ" end
+
+ it "should not create a group" do
+ expect { group_resource.run_action(:create) }.to raise_error(ArgumentError)
+ if windows_gte_10?
+ expect { Chef::Util::Windows::NetGroup.new(group_name).local_get_members }.to raise_error(ArgumentError, /The parameter is incorrect./)
+ else
+ group_should_not_exist(group_name)
+ end
+ end
+ end
+
describe "group remove action" do
describe "when there is a group" do
before do
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index edb5491100..1a897ef95f 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -149,6 +149,8 @@ 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_gte_10 => true unless windows_gte_10?
+ config.filter_run_excluding :windows_lt_10 => true if windows_gte_10?
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..3cc8778f7a 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_gte_10?
+ return false unless windows?
+ Gem::Requirement.new(">= 10").satisfied_by?(Gem::Version.new(host_version))
+end
+
def host_version
@host_version ||= begin
wmi = WmiLite::Wmi.new