diff options
author | Tim Smith <tsmith@chef.io> | 2020-06-23 23:01:51 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-23 23:01:51 -0700 |
commit | cecf7a1aeea15132b5505e523b9330e4d5162fe0 (patch) | |
tree | 75e433e340d3d0d3ddfd6d1fce2985ff6f03fbb1 | |
parent | 434c86b30314fc4a348917f2804318d895c25bab (diff) | |
parent | c4cf61a552c3c2c5aed3d7f086f4fcb5ed9655ca (diff) | |
download | chef-cecf7a1aeea15132b5505e523b9330e4d5162fe0.tar.gz |
Merge pull request #10056 from chef/msu_15
fix msu_package installation and extend the timeout to 60 minutes with a new property
-rw-r--r-- | lib/chef/provider/package/cab.rb | 2 | ||||
-rw-r--r-- | lib/chef/provider/package/msu.rb | 1 | ||||
-rw-r--r-- | lib/chef/resource/msu_package.rb | 5 | ||||
-rw-r--r-- | spec/functional/resource/msu_package_spec.rb | 7 | ||||
-rw-r--r-- | spec/unit/resource/msu_package_spec.rb | 4 |
5 files changed, 16 insertions, 3 deletions
diff --git a/lib/chef/provider/package/cab.rb b/lib/chef/provider/package/cab.rb index 71b33eccbe..b1cd791c4b 100644 --- a/lib/chef/provider/package/cab.rb +++ b/lib/chef/provider/package/cab.rb @@ -94,7 +94,7 @@ class Chef split_package_identity(p["package_identity"]) end found_packages = existing_package_identities.select do |existing_package_ident| - existing_package_ident["name"] == package["name"] + existing_package_ident["version"] == package["version"].chomp && existing_package_ident["name"] == package["name"] end if found_packages.empty? nil diff --git a/lib/chef/provider/package/msu.rb b/lib/chef/provider/package/msu.rb index 0ac77e90f4..c5345d884e 100644 --- a/lib/chef/provider/package/msu.rb +++ b/lib/chef/provider/package/msu.rb @@ -109,6 +109,7 @@ class Chef @cab_files.each do |cab_file| declare_resource(:cab_package, new_resource.name) do source cab_file + timeout new_resource.timeout action :install end end diff --git a/lib/chef/resource/msu_package.rb b/lib/chef/resource/msu_package.rb index 12cd0bc590..6028f3853b 100644 --- a/lib/chef/resource/msu_package.rb +++ b/lib/chef/resource/msu_package.rb @@ -44,6 +44,11 @@ class Chef property :checksum, String, desired_state: false, description: "SHA-256 digest used to verify the checksum of the downloaded MSU package." + + property :timeout, [String, Integer], + default: 3600, + description: "The amount of time (in seconds) to wait before timing out.", + desired_state: false end end end diff --git a/spec/functional/resource/msu_package_spec.rb b/spec/functional/resource/msu_package_spec.rb index 0609c8d6ea..1161049571 100644 --- a/spec/functional/resource/msu_package_spec.rb +++ b/spec/functional/resource/msu_package_spec.rb @@ -23,6 +23,8 @@ describe Chef::Resource::MsuPackage, :win2012r2_only do let(:package_name) { "Package_for_KB2959977" } let(:package_source) { "https://download.microsoft.com/download/3/B/3/3B320C07-B7B1-41E5-81F4-79EBC02DF7D3/Windows8.1-KB2959977-x64.msu" } + let(:package_identity) { "Package_for_KB2959977~31bf3856ad364e35~amd64~~6.3.1.1" } + let(:timeout) { 3600 } let(:new_resource) { Chef::Resource::CabPackage.new("windows_test_pkg") } let(:cab_provider) do @@ -36,6 +38,7 @@ describe Chef::Resource::MsuPackage, :win2012r2_only do new_resource = Chef::Resource::MsuPackage.new("test msu package", run_context) new_resource.package_name package_name new_resource.source package_source + new_resource.timeout timeout new_resource end @@ -44,7 +47,7 @@ describe Chef::Resource::MsuPackage, :win2012r2_only do it "installs the package successfully" do subject.run_action(:install) - found_packages = cab_provider.installed_packages.select { |p| p["package_identity"] =~ /^#{package_name}~/ } + found_packages = cab_provider.installed_packages.select { |p| p["package_identity"] == package_identity } expect(found_packages.length).to be == 1 end end @@ -53,7 +56,7 @@ describe Chef::Resource::MsuPackage, :win2012r2_only do it "removes an installed package" do subject.run_action(:install) remove_package - found_packages = cab_provider.installed_packages.select { |p| p["package_identity"] =~ /^#{package_name}~/ } + found_packages = cab_provider.installed_packages.select { |p| p["package_identity"] == package_identity } expect(found_packages.length).to be == 0 end end diff --git a/spec/unit/resource/msu_package_spec.rb b/spec/unit/resource/msu_package_spec.rb index 49fe61b7b9..3c7462a1a7 100644 --- a/spec/unit/resource/msu_package_spec.rb +++ b/spec/unit/resource/msu_package_spec.rb @@ -60,4 +60,8 @@ describe Chef::Resource::MsuPackage do resource.source("package.msu") expect(resource.source).not_to eq("package.msu") end + + it "sets timeout property to 3600 by default" do + expect(resource.timeout).to eql(3600) + end end |