spec/unit/plugins/linux/filesystem_spec.rb in ohai-14.15.0 vs spec/unit/plugins/linux/filesystem_spec.rb in ohai-15.0.35

- old
+ new

@@ -14,11 +14,11 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # -require_relative "../../../spec_helper.rb" +require "spec_helper" describe Ohai::System, "Linux filesystem plugin" do let(:plugin) { get_plugin("filesystem") } before(:each) do allow(plugin).to receive(:collect_os).and_return(:linux) @@ -67,21 +67,21 @@ /dev/mapper/sys.vg-special.lv 97605057 53563253 44041805 56% /special /dev/mapper/sys.vg-tmp.lv 1919048 46588 1774976 3% /tmp /dev/mapper/sys.vg-usr.lv 19223252 5479072 12767696 31% /usr /dev/mapper/sys.vg-var.lv 19223252 3436556 14810212 19% /var /dev/md0 960492 36388 875312 4% /boot -DF + DF allow(plugin).to receive(:shell_out).with("df -P").and_return(mock_shell_out(0, @stdout, "")) @inode_stdout = <<~DFI Filesystem Inodes IUsed IFree IUse% Mounted on /dev/xvda1 1310720 107407 1203313 9% / /dev/mapper/sys.vg-special.lv 124865 380 124485 1% /special tmpfs 126922 273 126649 1% /run none 126922 1 126921 1% /run/lock none 126922 1 126921 1% /run/shm -DFI + DFI allow(plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, @inode_stdout, "")) end it "should run df -P and df -iP" do expect(plugin).to receive(:shell_out).ordered.with("df -P").and_return(mock_shell_out(0, @stdout, "")) @@ -146,11 +146,11 @@ /dev/mapper/sys.vg-usr.lv on /usr type ext4 (rw,noatime) /dev/mapper/sys.vg-var.lv on /var type ext4 (rw,noatime) /dev/md0 on /boot type ext3 (rw,noatime,errors=remount-ro) fusectl on /sys/fs/fuse/connections type fusectl (rw) binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,noexec,nosuid,nodev) -MOUNT + MOUNT allow(plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, @stdout, "")) end it "should run mount" do expect(plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, @stdout, "")) @@ -187,21 +187,21 @@ /dev/mapper/sys.vg-special.lv 97605057 53563253 44041805 56% /special /dev/mapper/sys.vg-tmp.lv 1919048 46588 1774976 3% /tmp /dev/mapper/sys.vg-usr.lv 19223252 5479072 12767696 31% /usr /dev/mapper/sys.vg-var.lv 19223252 3436556 14810212 19% /var /dev/md0 960492 36388 875312 4% /boot -DF + DF allow(plugin).to receive(:shell_out).with("df -P").and_return(mock_shell_out(0, @dfstdout, "")) @inode_stdout = <<~DFI Filesystem Inodes IUsed IFree IUse% Mounted on /dev/xvda1 1310720 107407 1203313 9% / /dev/mapper/sys.vg-special.lv 124865 380 124485 1% /special tmpfs 126922 273 126649 1% /run none 126922 1 126921 1% /run/lock none 126922 1 126921 1% /run/shm -DFI + DFI allow(plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, @inode_stdout, "")) @stdout = <<~BLKID_TYPE /dev/sdb1: LABEL=\"fuego:0\" UUID=\"bd1197e0-6997-1f3a-e27e-7801388308b5\" TYPE=\"linux_raid_member\" /dev/sdb2: LABEL=\"fuego:1\" UUID=\"e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa\" TYPE=\"linux_raid_member\" @@ -213,11 +213,11 @@ /dev/mapper/sys.vg-swap.lv: UUID=\"9bc2e515-8ddc-41c3-9f63-4eaebde9ce96\" TYPE=\"swap\" /dev/mapper/sys.vg-tmp.lv: LABEL=\"/tmp\" UUID=\"74cf7eb9-428f-479e-9a4a-9943401e81e5\" TYPE=\"ext4\" /dev/mapper/sys.vg-usr.lv: LABEL=\"/usr\" UUID=\"26ec33c5-d00b-4f88-a550-492def013bbc\" TYPE=\"ext4\" /dev/mapper/sys.vg-var.lv: LABEL=\"/var\" UUID=\"6b559c35-7847-4ae2-b512-c99012d3f5b3\" TYPE=\"ext4\" /dev/mapper/sys.vg-home.lv: LABEL=\"/home\" UUID=\"d6efda02-1b73-453c-8c74-7d8dee78fa5e\" TYPE=\"xfs\" -BLKID_TYPE + BLKID_TYPE allow(plugin).to receive(:shell_out).with("/sbin/blkid", timeout: 60).and_return(mock_shell_out(0, @stdout, "")) end it "should run blkid" do plugin.run @@ -243,21 +243,21 @@ /dev/mapper/sys.vg-special.lv 97605057 53563253 44041805 56% /special /dev/mapper/sys.vg-tmp.lv 1919048 46588 1774976 3% /tmp /dev/mapper/sys.vg-usr.lv 19223252 5479072 12767696 31% /usr /dev/mapper/sys.vg-var.lv 19223252 3436556 14810212 19% /var /dev/md0 960492 36388 875312 4% /boot -DF + DF allow(plugin).to receive(:shell_out).with("df -P").and_return(mock_shell_out(0, @dfstdout, "")) @inode_stdout = <<~DFI Filesystem Inodes IUsed IFree IUse% Mounted on /dev/xvda1 1310720 107407 1203313 9% / /dev/mapper/sys.vg-special.lv 124865 380 124485 1% /special tmpfs 126922 273 126649 1% /run none 126922 1 126921 1% /run/lock none 126922 1 126921 1% /run/shm -DFI + DFI allow(plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, @inode_stdout, "")) allow(plugin).to receive(:which).with("lsblk").and_return("/sbin/lsblk") allow(plugin).to receive(:which).with("blkid").and_return(nil) @stdout = <<~BLKID_TYPE @@ -272,11 +272,11 @@ NAME=\"sys.vg-tmp.lv\" UUID=\"74cf7eb9-428f-479e-9a4a-9943401e81e5\" LABEL=\"/tmp\" FSTYPE=\"ext4\" NAME=\"sys.vg-usr.lv\" UUID=\"26ec33c5-d00b-4f88-a550-492def013bbc\" LABEL=\"/usr\" FSTYPE=\"ext4\" NAME=\"sys.vg-var.lv\" UUID=\"6b559c35-7847-4ae2-b512-c99012d3f5b3\" LABEL=\"/var\" FSTYPE=\"ext4\" NAME=\"sys.vg-home.lv\" UUID=\"d6efda02-1b73-453c-8c74-7d8dee78fa5e\" LABEL=\"/home\" FSTYPE=\"xfs\" NAME=\"debian--7-root (dm-0)\" UUID=\"09187faa-3512-4505-81af-7e86d2ccb99a\" LABEL=\"root\" FSTYPE=\"ext4\" -BLKID_TYPE + BLKID_TYPE allow(plugin).to receive(:shell_out) .with("/sbin/lsblk -n -P -o NAME,UUID,LABEL,FSTYPE", timeout: 60) .and_return(mock_shell_out(0, @stdout, "")) end @@ -310,21 +310,21 @@ /dev/mapper/sys.vg-special.lv 97605057 53563253 44041805 56% /special /dev/mapper/sys.vg-tmp.lv 1919048 46588 1774976 3% /tmp /dev/mapper/sys.vg-usr.lv 19223252 5479072 12767696 31% /usr /dev/mapper/sys.vg-var.lv 19223252 3436556 14810212 19% /var /dev/md0 960492 36388 875312 4% /boot -DF + DF allow(plugin).to receive(:shell_out).with("df -P").and_return(mock_shell_out(0, @dfstdout, "")) @inode_stdout = <<~DFI Filesystem Inodes IUsed IFree IUse% Mounted on /dev/xvda1 1310720 107407 1203313 9% / /dev/mapper/sys.vg-special.lv 124865 380 124485 1% /special tmpfs 126922 273 126649 1% /run none 126922 1 126921 1% /run/lock none 126922 1 126921 1% /run/shm -DFI + DFI allow(plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, @inode_stdout, "")) allow(plugin).to receive(:which).with("lsblk").and_return("/sbin/lsblk") allow(plugin).to receive(:which).with("blkid").and_return("/sbin/blkid") @stdout = <<~BLKID_TYPE @@ -339,11 +339,11 @@ NAME=\"sys.vg-tmp.lv\" UUID=\"74cf7eb9-428f-479e-9a4a-9943401e81e5\" LABEL=\"/tmp\" FSTYPE=\"ext4\" NAME=\"sys.vg-usr.lv\" UUID=\"26ec33c5-d00b-4f88-a550-492def013bbc\" LABEL=\"/usr\" NAME=\"sys.vg-var.lv\" UUID=\"6b559c35-7847-4ae2-b512-c99012d3f5b3\" LABEL=\"/var\" FSTYPE=\"ext4\" NAME=\"sys.vg-home.lv\" UUID=\"d6efda02-1b73-453c-8c74-7d8dee78fa5e\" LABEL=\"/BADhome\" FSTYPE=\"xfs\" NAME=\"debian--7-root (dm-0)\" UUID=\"09187faa-3512-4505-81af-7e86d2ccb99a\" LABEL=\"root\" FSTYPE=\"ext4\" -BLKID_TYPE + BLKID_TYPE allow(plugin).to receive(:shell_out) .with("/sbin/lsblk -n -P -o NAME,UUID,LABEL,FSTYPE", timeout: 60) .and_return(mock_shell_out(0, @stdout, "")) @stdout = <<~BLKID_TYPE /dev/sdb1: LABEL=\"fuego:0\" TYPE=\"linux_raid_member\" @@ -356,11 +356,11 @@ /dev/mapper/sys.vg-swap.lv: UUID=\"9bc2e515-8ddc-41c3-9f63-4eaebde9ce96\" TYPE=\"swap\" /dev/mapper/sys.vg-tmp.lv: LABEL=\"/tmp\" UUID=\"74cf7eb9-428f-479e-9a4a-9943401e81e5\" TYPE=\"ext4\" /dev/mapper/sys.vg-usr.lv: LABEL=\"/usr\" UUID=\"26ec33c5-d00b-4f88-a550-492def013bbc\" TYPE=\"ext4\" /dev/mapper/sys.vg-var.lv: LABEL=\"/var\" UUID=\"6b559c35-7847-4ae2-b512-c99012d3f5b3\" TYPE=\"ext4\" /dev/mapper/sys.vg-home.lv: LABEL=\"/home\" UUID=\"d6efda02-1b73-453c-8c74-7d8dee78fa5e\" TYPE=\"xfs\" -BLKID_TYPE + BLKID_TYPE allow(plugin).to receive(:shell_out).with("/sbin/blkid", timeout: 60).and_return(mock_shell_out(0, @stdout, "")) end it "should fill in missing FS data from lsblk using blkid" do plugin.run @@ -403,11 +403,11 @@ /dev/mapper/sys.vg-usr.lv /usr ext4 rw,noatime,barrier=1,data=ordered 0 0 /dev/mapper/sys.vg-var.lv /var ext4 rw,noatime,barrier=1,data=ordered 0 0 /dev/md0 /boot ext3 rw,noatime,errors=remount-ro,data=ordered 0 0 fusectl /sys/fs/fuse/connections fusectl rw,relatime 0 0 binfmt_misc /proc/sys/fs/binfmt_misc binfmt_misc rw,nosuid,nodev,noexec,relatime 0 0 -MOUNTS + MOUNTS @counter = 0 allow(@double_file).to receive(:read_nonblock) do @counter += 1 raise EOFError if @counter == 2 @mounts @@ -446,11 +446,11 @@ udev 2025576 228 2025348 1% /dev tmpfs 2030944 2960 2027984 1% /dev/shm /dev/mapper/sys.vg-home.lv 97605056 53563252 44041804 55% /home /dev/mapper/sys.vg-home.lv 97605056 53563252 44041804 55% /home2 /dev/mapper/sys.vg-root.lv 4805760 378716 4182924 9% /var/chroot -DF + DF allow(plugin).to receive(:shell_out).with("df -P").and_return(mock_shell_out(0, @dfstdout, "")) @inode_stdout = <<~DFI Filesystem Inodes IUsed IFree IUse% Mounted on /dev/mapper/sys.vg-root.lv 1310720 107407 1203313 9% / @@ -458,19 +458,19 @@ none 126922 1 126921 1% /dev/shm udev 126922 1 126921 1% /dev /dev/mapper/sys.vg-home.lv 60891136 4696030 56195106 8% /home /dev/mapper/sys.vg-home.lv 60891136 4696030 56195106 8% /home2 /dev/mapper/sys.vg-root.lv 1310720 107407 1203313 9% /var/chroot -DFI + DFI allow(plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, @inode_stdout, "")) allow(plugin).to receive(:which).with("lsblk").and_return("/sbin/lsblk") allow(plugin).to receive(:which).with("blkid").and_return(nil) @stdout = <<~BLKID_TYPE NAME=\"/dev/mapper/sys.vg-root.lv\" UUID=\"7742d14b-80a3-4e97-9a32-478be9ea9aea\" LABEL=\"/\" FSTYPE=\"ext4\" NAME=\"/dev/mapper/sys.vg-home.lv\" UUID=\"d6efda02-1b73-453c-8c74-7d8dee78fa5e\" LABEL=\"/home\" FSTYPE=\"xfs\" -BLKID_TYPE + BLKID_TYPE allow(plugin).to receive(:shell_out) .with("/sbin/lsblk -n -P -o NAME,UUID,LABEL,FSTYPE", timeout: 60) .and_return(mock_shell_out(0, @stdout, "")) end @@ -491,11 +491,11 @@ udev 2025576 228 2025348 1% /dev tmpfs 2030944 2960 2027984 1% /dev/shm /dev/mapper/sys.vg-home.lv 97605056 53563252 44041804 55% /home /dev/sdb1 97605056 53563252 44041804 55% /mnt /dev/sdc1 4805760 378716 4182924 9% /mnt -DF + DF allow(plugin).to receive(:shell_out).with("df -P").and_return(mock_shell_out(0, @dfstdout, "")) @inode_stdout = <<~DFI Filesystem Inodes IUsed IFree IUse% Mounted on /dev/mapper/sys.vg-root.lv 1310720 107407 1203313 9% / @@ -503,20 +503,20 @@ none 126922 1 126921 1% /dev/shm udev 126922 1 126921 1% /dev /dev/mapper/sys.vg-home.lv 60891136 4696030 56195106 8% /home /dev/sdb1 60891136 4696030 56195106 8% /mnt /dev/sdc1 1310720 107407 1203313 9% /mnt -DFI + DFI allow(plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, @inode_stdout, "")) allow(plugin).to receive(:which).with("lsblk").and_return("/sbin/lsblk") allow(plugin).to receive(:which).with("blkid").and_return(nil) @stdout = <<~BLKID_TYPE NAME=\"/dev/mapper/sys.vg-root.lv\" UUID=\"7742d14b-80a3-4e97-9a32-478be9ea9aea\" LABEL=\"/\" FSTYPE=\"ext4\" NAME=\"/dev/sdb1\" UUID=\"6b559c35-7847-4ae2-b512-c99012d3f5b3\" LABEL=\"/mnt\" FSTYPE=\"ext4\" NAME=\"/dev/sdc1\" UUID=\"7f1e51bf-3608-4351-b7cd-379e39cff36a\" LABEL=\"/mnt\" FSTYPE=\"ext4\" NAME=\"/dev/mapper/sys.vg-home.lv\" UUID=\"d6efda02-1b73-453c-8c74-7d8dee78fa5e\" LABEL=\"/home\" FSTYPE=\"xfs\" -BLKID_TYPE + BLKID_TYPE allow(plugin).to receive(:shell_out) .with("/sbin/lsblk -n -P -o NAME,UUID,LABEL,FSTYPE", timeout: 60) .and_return(mock_shell_out(0, @stdout, "")) end