summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantima-gupta <agupta@msystechnologies.com>2020-11-24 01:06:33 -0800
committerantima-gupta <agupta@msystechnologies.com>2020-11-24 01:07:29 -0800
commitc600ba4886fd5ab9af333f57ae95d5ed6a71164b (patch)
tree235790bf59b98f6bd1f52b004f99ffc37071e2ea
parent188839a87f2c81f6a8072af28aa3db99ae7cd68b (diff)
downloadchef-c600ba4886fd5ab9af333f57ae95d5ed6a71164b.tar.gz
Fixed aix spec failure when the target state is to disable the mount.
Added spec for device property value '/'. Signed-off-by: antima-gupta <agupta@msystechnologies.com>
-rw-r--r--lib/chef/provider/mount.rb2
-rw-r--r--lib/chef/provider/mount/mount.rb3
-rw-r--r--spec/functional/resource/mount_spec.rb12
3 files changed, 12 insertions, 5 deletions
diff --git a/lib/chef/provider/mount.rb b/lib/chef/provider/mount.rb
index f8c71c6706..44fb94ca01 100644
--- a/lib/chef/provider/mount.rb
+++ b/lib/chef/provider/mount.rb
@@ -176,7 +176,7 @@ class Chef
# Returns the new_resource device as per device_type
def device_fstab
# Removed "/" from the end of str, because it was causing idempotency issue.
- device = @new_resource.device.chomp("/")
+ device = @new_resource.device == "/" ? @new_resource.device : @new_resource.device.chomp("/")
case @new_resource.device_type
when :device
device
diff --git a/lib/chef/provider/mount/mount.rb b/lib/chef/provider/mount/mount.rb
index 71e103e4aa..0bd81d5453 100644
--- a/lib/chef/provider/mount/mount.rb
+++ b/lib/chef/provider/mount/mount.rb
@@ -203,8 +203,7 @@ class Chef
end
end
# Removed "/" from the end of str, because it was causing idempotency issue.
- # On AIX, device property value can be "/"
- !RUBY_PLATFORM.match?(/aix/i) ? @real_device.chomp("/") : @real_device
+ @real_device == "/" ? @real_device : @real_device.chomp("/")
end
def device_logstring
diff --git a/spec/functional/resource/mount_spec.rb b/spec/functional/resource/mount_spec.rb
index 55738a4326..f11f97d6c7 100644
--- a/spec/functional/resource/mount_spec.rb
+++ b/spec/functional/resource/mount_spec.rb
@@ -129,8 +129,9 @@ describe Chef::Resource::Mount, :requires_root, external: include_flag do
end
# Actual tests begin here.
- before(:all) do
+ before do |test|
@device, @fstype = setup_device_for_mount
+ @device = "/" if test.metadata[:skip_before]
@mount_point = Dir.mktmpdir("testmount")
@@ -145,13 +146,20 @@ describe Chef::Resource::Mount, :requires_root, external: include_flag do
end
after(:all) do
- Dir.rmdir(@mount_point)
+ Dir.rmdir(@mount_point) if @mount_point
end
after(:each) do
cleanup_mount(new_resource.mount_point)
end
+ describe "when device is '/'" do
+ it "should mount the filesystem if device is '/'", :skip_before do
+ new_resource.run_action(:mount)
+ mount_should_exist(new_resource.mount_point, new_resource.device)
+ end
+ end
+
describe "when the target state is a mounted filesystem" do
it "should mount the filesystem if it isn't mounted" do
expect(current_resource.enabled).to be_falsey