[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 2.6.5-303-gfcfa26a
Paul Berry
paul at puppetlabs.com
Thu Mar 17 10:48:00 UTC 2011
The following commit has been merged in the upstream branch:
commit a949a83c4f100be0254fadcb915f418f73705861
Author: Paul Berry <paul at puppetlabs.com>
Date: Fri Feb 25 15:14:26 2011 -0800
Revert "(#6309) Ensure the correct device is mounted when managing mounts"
This reverts commit 6cb365a887d47606bdfae0ff540038b0c49b7451, which
fixed bug #6309 but introduced bug #6411. In addition, it conflicts
with a significant patch to the mount provider that addresses #4914.
After merging in the fix for #4914 I will determine whether bug #6309
still exists, and if so work on an improved fix for it.
diff --git a/lib/puppet/provider/mount.rb b/lib/puppet/provider/mount.rb
index 81d93b5..354ddb1 100644
--- a/lib/puppet/provider/mount.rb
+++ b/lib/puppet/provider/mount.rb
@@ -6,28 +6,8 @@ require 'puppet'
# A module just to store the mount/unmount methods. Individual providers
# still need to add the mount commands manually.
module Puppet::Provider::Mount
- def mount
- # Make sure the fstab file & entry exists
- create
-
- if correctly_mounted?
- # Nothing to do!
- else
- if anything_mounted?
- unmount
-
- # We attempt to create the mount point here, because unmounting
- # certain file systems/devices can cause the mount point to be
- # deleted
- ::FileUtils.mkdir_p(resource[:name])
- end
-
- mount!
- end
- end
-
# This only works when the mount point is synced to the fstab.
- def mount!
+ def mount
# Manually pass the mount options in, since some OSes *cough*OS X*cough* don't
# read from /etc/fstab but still want to use this type.
args = []
@@ -53,8 +33,8 @@ module Puppet::Provider::Mount
umount resource[:name]
end
- # Is anything currently mounted at this point?
- def anything_mounted?
+ # Is the mount currently mounted?
+ def mounted?
platform = Facter.value("operatingsystem")
name = resource[:name]
mounts = mountcmd.split("\n").find do |line|
@@ -62,7 +42,6 @@ module Puppet::Provider::Mount
when "Darwin"
line =~ / on #{name} / or line =~ %r{ on /private/var/automount#{name}}
when "Solaris", "HP-UX"
- # Yes, Solaris does list mounts as "mount_point on device"
line =~ /^#{name} on /
when "AIX"
line.split(/\s+/)[2] == name
@@ -71,25 +50,4 @@ module Puppet::Provider::Mount
end
end
end
-
- # Is the desired thing mounted at this point?
- def correctly_mounted?
- platform = Facter.value("operatingsystem")
- name = resource[:name]
- device = resource[:device]
- mounts = mountcmd.split("\n").find do |line|
- case platform
- when "Darwin"
- line =~ /^#{device} on #{name} / or line =~ %r{^#{device} on /private/var/automount#{name}}
- when "Solaris", "HP-UX"
- # Yes, Solaris does list mounts as "mount_point on device"
- line =~ /^#{name} on #{device}/
- when "AIX"
- line.split(/\s+/)[2] == name &&
- line.split(/\s+/)[1] == device
- else
- line =~ /^#{device} on #{name} /
- end
- end
- end
end
diff --git a/lib/puppet/type/mount.rb b/lib/puppet/type/mount.rb
index 10eed53..da9a70b 100755
--- a/lib/puppet/type/mount.rb
+++ b/lib/puppet/type/mount.rb
@@ -29,7 +29,7 @@ module Puppet
aliasvalue :present, :defined
newvalue(:unmounted) do
- if provider.anything_mounted?
+ if provider.mounted?
syncothers
provider.unmount
return :mount_unmounted
@@ -40,15 +40,20 @@ module Puppet
end
newvalue(:absent, :event => :mount_deleted) do
- provider.unmount if provider.anything_mounted?
+ provider.unmount if provider.mounted?
provider.destroy
end
newvalue(:mounted, :event => :mount_mounted) do
+ # Create the mount point if it does not already exist.
+ current_value = self.retrieve
+ provider.create if current_value.nil? or current_value == :absent
+
syncothers
- provider.mount
+ # The fs can be already mounted if it was absent but mounted
+ provider.mount unless provider.mounted?
end
def insync?(is)
@@ -65,7 +70,7 @@ module Puppet
curval = super()
if curval == :absent
return :absent
- elsif provider.correctly_mounted?
+ elsif provider.mounted?
return :mounted
else
return :unmounted
@@ -205,7 +210,7 @@ module Puppet
def refresh
# Only remount if we're supposed to be mounted.
- provider.remount if self.should(:fstype) != "swap" and provider.anything_mounted?
+ provider.remount if self.should(:fstype) != "swap" and provider.mounted?
end
def value(name)
diff --git a/spec/fixtures/unit/provider/mount/mount-output.darwin.txt b/spec/fixtures/unit/provider/mount/mount-output.darwin.txt
deleted file mode 100644
index fbb9d98..0000000
--- a/spec/fixtures/unit/provider/mount/mount-output.darwin.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-/dev/disk0s2 on / (hfs, local, journaled)
-devfs on /dev (devfs, local, nobrowse)
-map -hosts on /net (autofs, nosuid, automounted, nobrowse)
-map auto_home on /home (autofs, automounted, nobrowse)
-/dev/disk0s3 on /usr (hfs, local, journaled)
diff --git a/spec/fixtures/unit/provider/mount/mount-output.hp-ux.txt b/spec/fixtures/unit/provider/mount/mount-output.hp-ux.txt
deleted file mode 100644
index 4779261..0000000
--- a/spec/fixtures/unit/provider/mount/mount-output.hp-ux.txt
+++ /dev/null
@@ -1,16 +0,0 @@
-/ on rpool/ROOT/opensolaris read/write/setuid/devices/dev=2d90002 on Wed Dec 31 16:00:00 1969
-/devices on /devices read/write/setuid/devices/dev=4a00000 on Thu Feb 17 14:34:02 2011
-/dev on /dev read/write/setuid/devices/dev=4a40000 on Thu Feb 17 14:34:02 2011
-/system/contract on ctfs read/write/setuid/devices/dev=4ac0001 on Thu Feb 17 14:34:02 2011
-/proc on proc read/write/setuid/devices/dev=4b00000 on Thu Feb 17 14:34:02 2011
-/etc/mnttab on mnttab read/write/setuid/devices/dev=4b40001 on Thu Feb 17 14:34:02 2011
-/etc/svc/volatile on swap read/write/setuid/devices/xattr/dev=4b80001 on Thu Feb 17 14:34:02 2011
-/system/object on objfs read/write/setuid/devices/dev=4bc0001 on Thu Feb 17 14:34:02 2011
-/etc/dfs/sharetab on sharefs read/write/setuid/devices/dev=4c00001 on Thu Feb 17 14:34:02 2011
-/lib/libc.so.1 on /usr/lib/libc/libc_hwcap1.so.1 read/write/setuid/devices/dev=2d90002 on Thu Feb 17 14:34:14 2011
-/dev/fd on fd read/write/setuid/devices/dev=4d00001 on Thu Feb 17 14:34:18 2011
-/tmp on swap read/write/setuid/devices/xattr/dev=4b80002 on Thu Feb 17 14:34:19 2011
-/var/run on swap read/write/setuid/devices/xattr/dev=4b80003 on Thu Feb 17 14:34:19 2011
-/export on rpool/export read/write/setuid/devices/nonbmand/exec/xattr/atime/dev=2d90006 on Thu Feb 17 14:37:48 2011
-/export/home on rpool/export/home read/write/setuid/devices/nonbmand/exec/xattr/atime/dev=2d90007 on Thu Feb 17 14:37:48 2011
-/rpool on rpool read/write/setuid/devices/nonbmand/exec/xattr/atime/dev=2d90009 on Thu Feb 17 14:37:48 2011
diff --git a/spec/fixtures/unit/provider/mount/mount-output.other.txt b/spec/fixtures/unit/provider/mount/mount-output.other.txt
deleted file mode 100644
index 0e4dff0..0000000
--- a/spec/fixtures/unit/provider/mount/mount-output.other.txt
+++ /dev/null
@@ -1,14 +0,0 @@
-/dev/sda1 on / type ext4 (rw,errors=remount-ro,commit=0)
-proc on /proc type proc (rw,noexec,nosuid,nodev)
-none on /sys type sysfs (rw,noexec,nosuid,nodev)
-fusectl on /sys/fs/fuse/connections type fusectl (rw)
-none on /sys/kernel/debug type debugfs (rw)
-none on /sys/kernel/security type securityfs (rw)
-none on /dev type devtmpfs (rw,mode=0755)
-none on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
-none on /dev/shm type tmpfs (rw,nosuid,nodev)
-none on /var/run type tmpfs (rw,nosuid,mode=0755)
-none on /var/lock type tmpfs (rw,noexec,nosuid,nodev)
-none on /proc/fs/vmblock/mountPoint type vmblock (rw)
-binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,noexec,nosuid,nodev)
-/dev/sda2 on /usr type ext4 (rw,errors=remount-ro,commit=0)
diff --git a/spec/fixtures/unit/provider/mount/mount-output.solaris.txt b/spec/fixtures/unit/provider/mount/mount-output.solaris.txt
deleted file mode 100644
index 4779261..0000000
--- a/spec/fixtures/unit/provider/mount/mount-output.solaris.txt
+++ /dev/null
@@ -1,16 +0,0 @@
-/ on rpool/ROOT/opensolaris read/write/setuid/devices/dev=2d90002 on Wed Dec 31 16:00:00 1969
-/devices on /devices read/write/setuid/devices/dev=4a00000 on Thu Feb 17 14:34:02 2011
-/dev on /dev read/write/setuid/devices/dev=4a40000 on Thu Feb 17 14:34:02 2011
-/system/contract on ctfs read/write/setuid/devices/dev=4ac0001 on Thu Feb 17 14:34:02 2011
-/proc on proc read/write/setuid/devices/dev=4b00000 on Thu Feb 17 14:34:02 2011
-/etc/mnttab on mnttab read/write/setuid/devices/dev=4b40001 on Thu Feb 17 14:34:02 2011
-/etc/svc/volatile on swap read/write/setuid/devices/xattr/dev=4b80001 on Thu Feb 17 14:34:02 2011
-/system/object on objfs read/write/setuid/devices/dev=4bc0001 on Thu Feb 17 14:34:02 2011
-/etc/dfs/sharetab on sharefs read/write/setuid/devices/dev=4c00001 on Thu Feb 17 14:34:02 2011
-/lib/libc.so.1 on /usr/lib/libc/libc_hwcap1.so.1 read/write/setuid/devices/dev=2d90002 on Thu Feb 17 14:34:14 2011
-/dev/fd on fd read/write/setuid/devices/dev=4d00001 on Thu Feb 17 14:34:18 2011
-/tmp on swap read/write/setuid/devices/xattr/dev=4b80002 on Thu Feb 17 14:34:19 2011
-/var/run on swap read/write/setuid/devices/xattr/dev=4b80003 on Thu Feb 17 14:34:19 2011
-/export on rpool/export read/write/setuid/devices/nonbmand/exec/xattr/atime/dev=2d90006 on Thu Feb 17 14:37:48 2011
-/export/home on rpool/export/home read/write/setuid/devices/nonbmand/exec/xattr/atime/dev=2d90007 on Thu Feb 17 14:37:48 2011
-/rpool on rpool read/write/setuid/devices/nonbmand/exec/xattr/atime/dev=2d90009 on Thu Feb 17 14:37:48 2011
diff --git a/spec/unit/provider/mount/parsed_spec.rb b/spec/unit/provider/mount/parsed_spec.rb
index 069d949..b4c2249 100755
--- a/spec/unit/provider/mount/parsed_spec.rb
+++ b/spec/unit/provider/mount/parsed_spec.rb
@@ -130,7 +130,7 @@ describe provider_class do
mount.stubs(:mountcmd) # just so we don't actually try to mount anything
mount.expects(:flush)
- mount.mount!
+ mount.mount
end
end
@@ -176,7 +176,7 @@ describe provider_class do
it "should determine that the root fs is mounted" do
@provider_class.prefetch("/" => @mount)
- @mount.provider.should be_anything_mounted
+ @mount.provider.should be_mounted
end
end
end
diff --git a/spec/unit/provider/mount_spec.rb b/spec/unit/provider/mount_spec.rb
index 1f25017..f567a4a 100755
--- a/spec/unit/provider/mount_spec.rb
+++ b/spec/unit/provider/mount_spec.rb
@@ -2,30 +2,28 @@
require File.dirname(__FILE__) + '/../../spec_helper'
-require 'puppet_spec/files'
require 'puppet/provider/mount'
describe Puppet::Provider::Mount do
- include PuppetSpec::Files
-
before :each do
+ @mounter = Object.new
+ @mounter.extend(Puppet::Provider::Mount)
+
@name = "/"
- @resource = Puppet::Type.type(:mount).new(
- :name => '/',
- :device => '/dev/sda1',
- :target => tmpfile("mount_provider")
- )
+ @resource = stub 'resource'
+ @resource.stubs(:[]).with(:name).returns(@name)
- @mounter = Puppet::Type.type(:mount).defaultprovider().new(@resource)
+ @mounter.stubs(:resource).returns(@resource)
end
- describe "when calling mount!" do
+ describe Puppet::Provider::Mount, " when mounting" do
+
it "should use the 'mountcmd' method to mount" do
@mounter.stubs(:options).returns(nil)
@mounter.expects(:mountcmd)
- @mounter.mount!
+ @mounter.mount
end
it "should flush before mounting if a flush method exists" do
@@ -34,169 +32,114 @@ describe Puppet::Provider::Mount do
@mounter.stubs(:mountcmd)
@mounter.stubs(:options).returns(nil)
- @mounter.mount!
+ @mounter.mount
end
it "should add the options following '-o' if they exist and are not set to :absent" do
@mounter.stubs(:options).returns("ro")
@mounter.expects(:mountcmd).with { |*ary| ary[0] == "-o" and ary[1] == "ro" }
- @mounter.mount!
+ @mounter.mount
end
it "should specify the filesystem name to the mount command" do
@mounter.stubs(:options).returns(nil)
@mounter.expects(:mountcmd).with { |*ary| ary[-1] == @name }
- @mounter.mount!
+ @mounter.mount
end
end
- describe "when remounting" do
+ describe Puppet::Provider::Mount, " when remounting" do
+
it "should use '-o remount' if the resource specifies it supports remounting" do
@mounter.stubs(:info)
- @resource[:remounts] = true
+ @resource.stubs(:[]).with(:remounts).returns(:true)
@mounter.expects(:mountcmd).with("-o", "remount", @name)
@mounter.remount
end
it "should unmount and mount if the resource does not specify it supports remounting" do
@mounter.stubs(:info)
- @resource[:remounts] = false
+ @resource.stubs(:[]).with(:remounts).returns(false)
@mounter.expects(:unmount)
@mounter.expects(:mount)
@mounter.remount
end
it "should log that it is remounting" do
- @resource[:remounts] = true
+ @resource.stubs(:[]).with(:remounts).returns(:true)
@mounter.stubs(:mountcmd)
@mounter.expects(:info).with("Remounting")
@mounter.remount
end
end
- describe "when unmounting" do
+ describe Puppet::Provider::Mount, " when unmounting" do
+
it "should call the :umount command with the resource name" do
@mounter.expects(:umount).with(@name)
@mounter.unmount
end
end
- %w{Darwin Solaris HP-UX AIX Other}.each do |platform|
- describe "on #{platform}" do
- before :each do
- case platform
- when 'Darwin'
- mount_fixture = 'mount-output.darwin.txt'
- @mount_device = '/dev/disk0s3'
- @mount_point = '/usr'
- when 'Solaris'
- mount_fixture = 'mount-output.solaris.txt'
- @mount_device = 'swap'
- @mount_point = '/tmp'
- when 'HP-UX'
- mount_fixture = 'mount-output.hp-ux.txt'
- @mount_device = 'swap'
- @mount_point = '/tmp'
- when 'AIX'
- mount_fixture = 'mount-output.aix.txt'
- @mount_device = '/dev/hd2'
- @mount_point = '/usr'
- when 'Other'
- mount_fixture = 'mount-output.other.txt'
- @mount_device = '/dev/sda2'
- @mount_point = '/usr'
- end
- @mount_data = File.read(File.join(File.dirname(__FILE__), '..', '..', 'fixtures', 'unit', 'provider', 'mount', mount_fixture))
- Facter.stubs(:value).with("operatingsystem").returns(platform)
- end
-
- describe "when the correct thing is mounted" do
- before :each do
- @mounter.expects(:mountcmd).returns(@mount_data)
- @resource.stubs(:[]).with(:name).returns(@mount_point)
- @resource.stubs(:[]).with(:device).returns(@mount_device)
- end
-
- it "should say anything_mounted?" do
- @mounter.should be_anything_mounted
- end
-
- it "should say correctly_mounted?" do
- @mounter.should be_correctly_mounted
- end
- end
-
- describe "when the wrong thing is mounted" do
- before :each do
- @mounter.expects(:mountcmd).returns(@mount_data)
- @resource.stubs(:[]).with(:name).returns(@mount_point)
- @resource.stubs(:[]).with(:device).returns('/dev/bogus/thing')
- end
-
- it "should say anything_mounted?" do
- @mounter.should be_anything_mounted
- end
-
- it "should not say correctly_mounted?" do
- @mounter.should_not be_correctly_mounted
- end
- end
-
- describe "when nothing is mounted" do
- before :each do
- @mounter.expects(:mountcmd).returns(@mount_data)
- @resource.stubs(:[]).with(:name).returns('/bogus/location')
- @resource.stubs(:[]).with(:device).returns(@mount_device)
- end
-
- it "should not say anything_mounted?" do
- @mounter.should_not be_anything_mounted
- end
-
- it "should not say correctly_mounted?" do
- @mounter.should_not be_correctly_mounted
- end
- end
+ describe Puppet::Provider::Mount, " when determining if it is mounted" do
+
+ it "should parse the results of running the mount command with no arguments" do
+ Facter.stubs(:value).returns("whatever")
+ @mounter.expects(:mountcmd).returns("")
+
+ @mounter.mounted?
end
- end
- describe "when mounting a device" do
- it "should not mount! or unmount anything when the correct device is mounted" do
- @mounter.stubs(:correctly_mounted?).returns(true)
+ it "should match ' on /private/var/automount<name>' if the operating system is Darwin" do
+ Facter.stubs(:value).with("operatingsystem").returns("Darwin")
+ @mounter.expects(:mountcmd).returns("/dev/whatever on /private/var/automount/\ndevfs on /dev")
- @mounter.expects(:anything_mounted?).never
- @mounter.expects(:create).once
- @mounter.expects(:mount!).never
- @mounter.expects(:unmount).never
- FileUtils.expects(:mkdir_p).never
+ @mounter.should be_mounted
+ end
- @mounter.mount
+ it "should match ' on <name>' if the operating system is Darwin" do
+ Facter.stubs(:value).with("operatingsystem").returns("Darwin")
+ @mounter.expects(:mountcmd).returns("/dev/disk03 on / (local, journaled)\ndevfs on /dev")
+
+ @mounter.should be_mounted
end
- it "should mount the device when nothing is mounted at the desired point" do
- @mounter.stubs(:correctly_mounted?).returns(false)
- @mounter.stubs(:anything_mounted?).returns(false)
+ it "should match '^<name> on' if the operating system is Solaris" do
+ Facter.stubs(:value).with("operatingsystem").returns("Solaris")
+ @mounter.expects(:mountcmd).returns("/ on /dev/dsk/whatever\n/var on /dev/dsk/other")
- @mounter.expects(:create).once
- @mounter.expects(:mount!).once
- @mounter.expects(:unmount).never
- FileUtils.expects(:mkdir_p).never
+ @mounter.should be_mounted
+ end
- @mounter.mount
+ it "should match '^<name> on' if the operating system is HP-UX" do
+ Facter.stubs(:value).with("operatingsystem").returns("HP-UX")
+ @mounter.expects(:mountcmd).returns("/ on /dev/dsk/whatever\n/var on /dev/dsk/other")
+
+ @mounter.should be_mounted
end
- it "should unmount the incorrect device and mount the correct device" do
- @mounter.stubs(:correctly_mounted?).returns(false)
- @mounter.stubs(:anything_mounted?).returns(true)
+ it "should match mounted devices if the operating system is AIX" do
+ Facter.stubs(:value).with("operatingsystem").returns("AIX")
+ mount_data = File.read(File.join(File.dirname(__FILE__), '..', '..', 'fixtures', 'unit', 'provider', 'mount', 'mount-output.aix.txt'))
+ @mounter.expects(:mountcmd).returns(mount_data)
- @mounter.expects(:create).once
- @mounter.expects(:mount!).once
- @mounter.expects(:unmount).once
- FileUtils.expects(:mkdir_p).with(@name).returns(true)
+ @mounter.should be_mounted
+ end
- @mounter.mount
+ it "should match ' on <name>' if the operating system is not Darwin, Solaris, or HP-UX" do
+ Facter.stubs(:value).with("operatingsystem").returns("Debian")
+ @mounter.expects(:mountcmd).returns("/dev/dsk/whatever on / and stuff\n/dev/other/disk on /var and stuff")
+
+ @mounter.should be_mounted
+ end
+
+ it "should not be considered mounted if it did not match the mount output" do
+ Facter.stubs(:value).with("operatingsystem").returns("Debian")
+ @mounter.expects(:mountcmd).returns("/dev/dsk/whatever on /something/else and stuff\n/dev/other/disk on /var and stuff")
+
+ @mounter.should_not be_mounted
end
end
end
diff --git a/spec/unit/type/mount_spec.rb b/spec/unit/type/mount_spec.rb
index c6d2b5b..0d74042 100755
--- a/spec/unit/type/mount_spec.rb
+++ b/spec/unit/type/mount_spec.rb
@@ -74,7 +74,8 @@ describe Puppet::Type.type(:mount)::Ensure do
end
end
- describe "when retrieving its current state" do
+ describe Puppet::Type.type(:mount)::Ensure, "when retrieving its current state" do
+
it "should return the provider's value if it is :absent" do
@provider.expects(:ensure).returns(:absent)
@ensure.retrieve.should == :absent
@@ -82,27 +83,28 @@ describe Puppet::Type.type(:mount)::Ensure do
it "should return :mounted if the provider indicates it is mounted and the value is not :absent" do
@provider.expects(:ensure).returns(:present)
- @provider.expects(:correctly_mounted?).returns(true)
+ @provider.expects(:mounted?).returns(true)
@ensure.retrieve.should == :mounted
end
it "should return :unmounted if the provider indicates it is not mounted and the value is not :absent" do
@provider.expects(:ensure).returns(:present)
- @provider.expects(:correctly_mounted?).returns(false)
+ @provider.expects(:mounted?).returns(false)
@ensure.retrieve.should == :unmounted
end
end
- describe "when changing the host" do
+ describe Puppet::Type.type(:mount)::Ensure, "when changing the host" do
+
it "should destroy itself if it should be absent" do
- @provider.stubs(:anything_mounted?).returns(false)
+ @provider.stubs(:mounted?).returns(false)
@provider.expects(:destroy)
@ensure.should = :absent
@ensure.sync
end
it "should unmount itself before destroying if it is mounted and should be absent" do
- @provider.expects(:anything_mounted?).returns(true)
+ @provider.expects(:mounted?).returns(true)
@provider.expects(:unmount)
@provider.expects(:destroy)
@ensure.should = :absent
@@ -111,9 +113,9 @@ describe Puppet::Type.type(:mount)::Ensure do
it "should create itself if it is absent and should be defined" do
@provider.stubs(:ensure).returns(:absent)
- @provider.stubs(:anything_mounted?).returns(true)
+ @provider.stubs(:mounted?).returns(true)
- @provider.stubs(:anything_mounted?).returns(false)
+ @provider.stubs(:mounted?).returns(false)
@provider.expects(:create)
@ensure.should = :defined
@ensure.sync
@@ -121,7 +123,7 @@ describe Puppet::Type.type(:mount)::Ensure do
it "should not unmount itself if it is mounted and should be defined" do
@provider.stubs(:ensure).returns(:mounted)
- @provider.stubs(:anything_mounted?).returns(true)
+ @provider.stubs(:mounted?).returns(true)
@provider.stubs(:create)
@provider.expects(:mount).never
@@ -132,7 +134,7 @@ describe Puppet::Type.type(:mount)::Ensure do
it "should not mount itself if it is unmounted and should be defined" do
@provider.stubs(:ensure).returns(:unmounted)
- @provider.stubs(:anything_mounted?).returns(false)
+ @provider.stubs(:mounted?).returns(false)
@ensure.stubs(:syncothers)
@provider.stubs(:create)
@@ -144,7 +146,7 @@ describe Puppet::Type.type(:mount)::Ensure do
it "should unmount itself if it is mounted and should be unmounted" do
@provider.stubs(:ensure).returns(:present)
- @provider.stubs(:anything_mounted?).returns(true)
+ @provider.stubs(:mounted?).returns(true)
@ensure.stubs(:syncothers)
@provider.expects(:unmount)
@@ -152,14 +154,34 @@ describe Puppet::Type.type(:mount)::Ensure do
@ensure.sync
end
- it "should ask the provider to mount itself" do
+ it "should create and mount itself if it does not exist and should be mounted" do
+ @provider.stubs(:ensure).returns(:absent)
+ @provider.stubs(:mounted?).returns(false)
+ @provider.expects(:create)
+ @ensure.stubs(:syncothers)
+ @provider.expects(:mount)
+ @ensure.should = :mounted
+ @ensure.sync
+ end
+
+ it "should mount itself if it is present and should be mounted" do
@provider.stubs(:ensure).returns(:present)
+ @provider.stubs(:mounted?).returns(false)
@ensure.stubs(:syncothers)
@provider.expects(:mount)
@ensure.should = :mounted
@ensure.sync
end
+ it "should create but not mount itself if it is absent and mounted and should be mounted" do
+ @provider.stubs(:ensure).returns(:absent)
+ @provider.stubs(:mounted?).returns(true)
+ @ensure.stubs(:syncothers)
+ @provider.expects(:create)
+ @ensure.should = :mounted
+ @ensure.sync
+ end
+
it "should be insync if it is mounted and should be defined" do
@ensure.should = :defined
@ensure.safe_insync?(:mounted).should == true
@@ -181,16 +203,17 @@ describe Puppet::Type.type(:mount)::Ensure do
end
end
- describe "when responding to events" do
+ describe Puppet::Type.type(:mount), "when responding to events" do
+
it "should remount if it is currently mounted" do
- @provider.expects(:anything_mounted?).returns(true)
+ @provider.expects(:mounted?).returns(true)
@provider.expects(:remount)
@mount.refresh
end
it "should not remount if it is not currently mounted" do
- @provider.expects(:anything_mounted?).returns(false)
+ @provider.expects(:mounted?).returns(false)
@provider.expects(:remount).never
@mount.refresh
@@ -218,8 +241,7 @@ describe Puppet::Type.type(:mount), "when modifying an existing mount entry" do
@mount[param] = value
end
- @mount.provider.stubs(:anything_mounted?).returns true
- @mount.provider.stubs(:correctly_mounted?).returns true
+ @mount.provider.stubs(:mounted?).returns true
# stub this to not try to create state.yaml
Puppet::Util::Storage.stubs(:store)
--
Puppet packaging for Debian
More information about the Pkg-puppet-devel
mailing list