diff options
author | Phil Dibowitz <phild@fb.com> | 2015-06-25 04:56:28 -0700 |
---|---|---|
committer | Phil Dibowitz <phild@fb.com> | 2015-06-25 04:56:28 -0700 |
commit | 2477200a38325d0eb549d1dc6baa3427d933ba4d (patch) | |
tree | ec9aa2135475a9c51f418cae58719d16f2b280b1 | |
parent | d08e17f074c7a19ac7ccfb902e8db208359422c3 (diff) | |
download | ohai-2477200a38325d0eb549d1dc6baa3427d933ba4d.tar.gz |
Move filesystem-related specs to use `let`
Only because @mcquin is so awesome.
Currently based ontop of #567
-rw-r--r-- | spec/unit/plugins/darwin/filesystem2_spec.rb | 64 | ||||
-rw-r--r-- | spec/unit/plugins/darwin/filesystem_spec.rb | 50 | ||||
-rw-r--r-- | spec/unit/plugins/linux/filesystem2_spec.rb | 142 | ||||
-rw-r--r-- | spec/unit/plugins/linux/filesystem_spec.rb | 166 |
4 files changed, 211 insertions, 211 deletions
diff --git a/spec/unit/plugins/darwin/filesystem2_spec.rb b/spec/unit/plugins/darwin/filesystem2_spec.rb index e2e7fe6f..c34aa8bd 100644 --- a/spec/unit/plugins/darwin/filesystem2_spec.rb +++ b/spec/unit/plugins/darwin/filesystem2_spec.rb @@ -19,12 +19,12 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') describe Ohai::System, "darwin filesystem2 plugin" do + let (:plugin) { get_plugin("darwin/filesystem2") } before(:each) do - @plugin = get_plugin("darwin/filesystem2") - allow(@plugin).to receive(:collect_os).and_return(:darwin) + allow(plugin).to receive(:collect_os).and_return(:darwin) - allow(@plugin).to receive(:shell_out).with("df -i").and_return(mock_shell_out(0, "", "")) - allow(@plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, "", "")) + allow(plugin).to receive(:shell_out).with("df -i").and_return(mock_shell_out(0, "", "")) + allow(plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, "", "")) end describe "when gathering filesystem usage data from df" do @@ -38,33 +38,33 @@ map -hosts 0 0 0 100% 0 0 10 map -static 0 0 0 100% 0 0 100% /mobile_symbol deweyfs@osxfuse0 0 0 0 100% 0 0 100% /mnt/dewey DF - allow(@plugin).to receive(:shell_out).with("df -i").and_return(mock_shell_out(0, @stdout, "")) + allow(plugin).to receive(:shell_out).with("df -i").and_return(mock_shell_out(0, @stdout, "")) end it "should run df -i" do - expect(@plugin).to receive(:shell_out).ordered.with("df -i").and_return(mock_shell_out(0, @stdout, "")) - @plugin.run + expect(plugin).to receive(:shell_out).ordered.with("df -i").and_return(mock_shell_out(0, @stdout, "")) + plugin.run end it "should set size to value from df -i" do - @plugin.run - expect(@plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:kb_size]).to eq("244277768") - expect(@plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:kb_used]).to eq("156848224") - expect(@plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:kb_available]).to eq("87173544") - expect(@plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:percent_used]).to eq("65%") + plugin.run + expect(plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:kb_size]).to eq("244277768") + expect(plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:kb_used]).to eq("156848224") + expect(plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:kb_available]).to eq("87173544") + expect(plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:percent_used]).to eq("65%") end it "should set device and mount to value from df -i" do - @plugin.run - expect(@plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:mount]).to eq("/") - expect(@plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:device]).to eq("/dev/disk0s2") + plugin.run + expect(plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:mount]).to eq("/") + expect(plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:device]).to eq("/dev/disk0s2") end it "should set inode info to value from df -i" do - @plugin.run - expect(@plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:total_inodes]).to eq("61069440") - expect(@plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:inodes_used]).to eq("39276054") - expect(@plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:inodes_available]).to eq("21793386") + plugin.run + expect(plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:total_inodes]).to eq("61069440") + expect(plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:inodes_used]).to eq("39276054") + expect(plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:inodes_available]).to eq("21793386") end end @@ -78,19 +78,19 @@ map -hosts on /net (autofs, nosuid, automounted, nobrowse) map -static on /mobile_symbol (autofs, automounted, nobrowse) deweyfs@osxfuse0 on /mnt/dewey (osxfusefs, synchronous, nobrowse) MOUNT - allow(@plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, @stdout, "")) + 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, "")) - @plugin.run + expect(plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, @stdout, "")) + plugin.run end it "should set values from mount" do - @plugin.run - expect(@plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:mount]).to eq("/") - expect(@plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:fs_type]).to eq("hfs") - expect(@plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:mount_options]).to eq([ "local", "journaled" ]) + plugin.run + expect(plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:mount]).to eq("/") + expect(plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:fs_type]).to eq("hfs") + expect(plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:mount_options]).to eq([ "local", "journaled" ]) end end @@ -106,12 +106,12 @@ map -static 0 0 0 100% 0 0 10 deweyfs@osxfuse0 0 0 0 100% 0 0 100% /mnt/dewey /dev/disk0s2 488555536 313696448 174347088 65% 39276054 21793386 64% /another/mountpoint DF - allow(@plugin).to receive(:shell_out).with("df -i").and_return(mock_shell_out(0, @dfstdout, "")) + allow(plugin).to receive(:shell_out).with("df -i").and_return(mock_shell_out(0, @dfstdout, "")) end it "should provide a devices view with all mountpoints" do - @plugin.run - expect(@plugin[:filesystem2]["by_device"]["/dev/disk0s2"][:mounts]).to eq(['/', '/another/mountpoint']) + plugin.run + expect(plugin[:filesystem2]["by_device"]["/dev/disk0s2"][:mounts]).to eq(['/', '/another/mountpoint']) end end @@ -128,12 +128,12 @@ deweyfs@osxfuse0 0 0 0 100% 0 0 10 /dev/disk0s3 488555536 313696448 174347088 65% 39276054 21793386 64% /mnt /dev/disk0s4 488555536 313696448 174347088 65% 39276054 21793386 64% /mnt DF - allow(@plugin).to receive(:shell_out).with("df -i").and_return(mock_shell_out(0, @dfstdout, "")) + allow(plugin).to receive(:shell_out).with("df -i").and_return(mock_shell_out(0, @dfstdout, "")) end it "should provide a mounts view with all devices" do - @plugin.run - expect(@plugin[:filesystem2]["by_mountpoint"]["/mnt"][:devices]).to eq(['/dev/disk0s3', '/dev/disk0s4']) + plugin.run + expect(plugin[:filesystem2]["by_mountpoint"]["/mnt"][:devices]).to eq(['/dev/disk0s3', '/dev/disk0s4']) end end end diff --git a/spec/unit/plugins/darwin/filesystem_spec.rb b/spec/unit/plugins/darwin/filesystem_spec.rb index a97eaf62..4b798973 100644 --- a/spec/unit/plugins/darwin/filesystem_spec.rb +++ b/spec/unit/plugins/darwin/filesystem_spec.rb @@ -19,12 +19,12 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') describe Ohai::System, "darwin filesystem plugin" do + let (:plugin) { get_plugin("darwin/filesystem") } before(:each) do - @plugin = get_plugin("darwin/filesystem") - allow(@plugin).to receive(:collect_os).and_return(:darwin) + allow(plugin).to receive(:collect_os).and_return(:darwin) - allow(@plugin).to receive(:shell_out).with("df -i").and_return(mock_shell_out(0, "", "")) - allow(@plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, "", "")) + allow(plugin).to receive(:shell_out).with("df -i").and_return(mock_shell_out(0, "", "")) + allow(plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, "", "")) end describe "when gathering filesystem usage data from df" do @@ -38,32 +38,32 @@ map -hosts 0 0 0 100% 0 0 10 map -static 0 0 0 100% 0 0 100% /mobile_symbol deweyfs@osxfuse0 0 0 0 100% 0 0 100% /mnt/dewey DF - allow(@plugin).to receive(:shell_out).with("df -i").and_return(mock_shell_out(0, @stdout, "")) + allow(plugin).to receive(:shell_out).with("df -i").and_return(mock_shell_out(0, @stdout, "")) end it "should run df -i" do - expect(@plugin).to receive(:shell_out).ordered.with("df -i").and_return(mock_shell_out(0, @stdout, "")) - @plugin.run + expect(plugin).to receive(:shell_out).ordered.with("df -i").and_return(mock_shell_out(0, @stdout, "")) + plugin.run end it "should set size to value from df -i" do - @plugin.run - expect(@plugin[:filesystem]["/dev/disk0s2"][:kb_size]).to eq(244277768) - expect(@plugin[:filesystem]["/dev/disk0s2"][:kb_used]).to eq(156848224) - expect(@plugin[:filesystem]["/dev/disk0s2"][:kb_available]).to eq(87173544) - expect(@plugin[:filesystem]["/dev/disk0s2"][:percent_used]).to eq("65%") + plugin.run + expect(plugin[:filesystem]["/dev/disk0s2"][:kb_size]).to eq(244277768) + expect(plugin[:filesystem]["/dev/disk0s2"][:kb_used]).to eq(156848224) + expect(plugin[:filesystem]["/dev/disk0s2"][:kb_available]).to eq(87173544) + expect(plugin[:filesystem]["/dev/disk0s2"][:percent_used]).to eq("65%") end it "should set mount to value from df -i" do - @plugin.run - expect(@plugin[:filesystem]["/dev/disk0s2"][:mount]).to eq("/") + plugin.run + expect(plugin[:filesystem]["/dev/disk0s2"][:mount]).to eq("/") end it "should set inode info to value from df -i" do - @plugin.run - expect(@plugin[:filesystem]["/dev/disk0s2"][:total_inodes]).to eq("61069440") - expect(@plugin[:filesystem]["/dev/disk0s2"][:inodes_used]).to eq("39276054") - expect(@plugin[:filesystem]["/dev/disk0s2"][:inodes_available]).to eq("21793386") + plugin.run + expect(plugin[:filesystem]["/dev/disk0s2"][:total_inodes]).to eq("61069440") + expect(plugin[:filesystem]["/dev/disk0s2"][:inodes_used]).to eq("39276054") + expect(plugin[:filesystem]["/dev/disk0s2"][:inodes_available]).to eq("21793386") end end @@ -77,19 +77,19 @@ map -hosts on /net (autofs, nosuid, automounted, nobrowse) map -static on /mobile_symbol (autofs, automounted, nobrowse) deweyfs@osxfuse0 on /mnt/dewey (osxfusefs, synchronous, nobrowse) MOUNT - allow(@plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, @stdout, "")) + 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, "")) - @plugin.run + expect(plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, @stdout, "")) + plugin.run end it "should set values from mount" do - @plugin.run - expect(@plugin[:filesystem]["/dev/disk0s2"][:mount]).to eq("/") - expect(@plugin[:filesystem]["/dev/disk0s2"][:fs_type]).to eq("hfs") - expect(@plugin[:filesystem]["/dev/disk0s2"][:mount_options]).to eq([ "local", "journaled" ]) + plugin.run + expect(plugin[:filesystem]["/dev/disk0s2"][:mount]).to eq("/") + expect(plugin[:filesystem]["/dev/disk0s2"][:fs_type]).to eq("hfs") + expect(plugin[:filesystem]["/dev/disk0s2"][:mount_options]).to eq([ "local", "journaled" ]) end end end diff --git a/spec/unit/plugins/linux/filesystem2_spec.rb b/spec/unit/plugins/linux/filesystem2_spec.rb index b4a18a3d..4a45e9db 100644 --- a/spec/unit/plugins/linux/filesystem2_spec.rb +++ b/spec/unit/plugins/linux/filesystem2_spec.rb @@ -19,17 +19,17 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') describe Ohai::System, "Linux filesystem plugin" do + let (:plugin) { get_plugin("linux/filesystem2") } before(:each) do - @plugin = get_plugin("linux/filesystem2") - allow(@plugin).to receive(:collect_os).and_return(:linux) + allow(plugin).to receive(:collect_os).and_return(:linux) - allow(@plugin).to receive(:shell_out).with("df -P").and_return(mock_shell_out(0, "", "")) - allow(@plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, "", "")) - allow(@plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, "", "")) + allow(plugin).to receive(:shell_out).with("df -P").and_return(mock_shell_out(0, "", "")) + allow(plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, "", "")) + allow(plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, "", "")) allow(File).to receive(:exist?).with("/bin/lsblk").and_return(false) - allow(@plugin).to receive(:shell_out).with("blkid").and_return(mock_shell_out(0, "", "")) + allow(plugin).to receive(:shell_out).with("blkid").and_return(mock_shell_out(0, "", "")) - allow(@plugin).to receive(:shell_out). + allow(plugin).to receive(:shell_out). with("lsblk -n -P -o NAME,UUID,LABEL,FSTYPE"). and_return(mock_shell_out(0, "", "")) @@ -66,7 +66,7 @@ tmpfs 2030944 2960 2027984 1% /dev/shm /dev/mapper/sys.vg-var.lv 19223252 3436556 14810212 19% /var /dev/md0 960492 36388 875312 4% /boot DF - allow(@plugin).to receive(:shell_out).with("df -P").and_return(mock_shell_out(0, @stdout, "")) + 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 @@ -76,53 +76,53 @@ tmpfs 126922 273 126649 1% /run none 126922 1 126921 1% /run/lock none 126922 1 126921 1% /run/shm DFi - allow(@plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, @inode_stdout, "")) + 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, "")) - expect(@plugin).to receive(:shell_out).ordered.with("df -iP").and_return(mock_shell_out(0, @inode_stdout, "")) - @plugin.run + expect(plugin).to receive(:shell_out).ordered.with("df -P").and_return(mock_shell_out(0, @stdout, "")) + expect(plugin).to receive(:shell_out).ordered.with("df -iP").and_return(mock_shell_out(0, @inode_stdout, "")) + plugin.run end it "should set kb_size to value from df -P" do - @plugin.run - expect(@plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:kb_size]).to eq("97605057") + plugin.run + expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:kb_size]).to eq("97605057") end it "should set kb_used to value from df -P" do - @plugin.run - expect(@plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:kb_used]).to eq("53563253") + plugin.run + expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:kb_used]).to eq("53563253") end it "should set kb_available to value from df -P" do - @plugin.run - expect(@plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:kb_available]).to eq("44041805") + plugin.run + expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:kb_available]).to eq("44041805") end it "should set percent_used to value from df -P" do - @plugin.run - expect(@plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:percent_used]).to eq("56%") + plugin.run + expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:percent_used]).to eq("56%") end it "should set mount to value from df -P" do - @plugin.run - expect(@plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:mount]).to eq("/special") + plugin.run + expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:mount]).to eq("/special") end it "should set total_inodes to value from df -iP" do - @plugin.run - expect(@plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:total_inodes]).to eq("124865") + plugin.run + expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:total_inodes]).to eq("124865") end it "should set inodes_used to value from df -iP" do - @plugin.run - expect(@plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:inodes_used]).to eq("380") + plugin.run + expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:inodes_used]).to eq("380") end it "should set inodes_available to value from df -iP" do - @plugin.run - expect(@plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:inodes_available]).to eq("124485") + plugin.run + expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:inodes_available]).to eq("124485") end end @@ -145,27 +145,27 @@ devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=620) 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 - allow(@plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, @stdout, "")) + 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, "")) - @plugin.run + expect(plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, @stdout, "")) + plugin.run end it "should set mount to value from mount" do - @plugin.run - expect(@plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:mount]).to eq("/special") + plugin.run + expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:mount]).to eq("/special") end it "should set fs_type to value from mount" do - @plugin.run - expect(@plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:fs_type]).to eq("xfs") + plugin.run + expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:fs_type]).to eq("xfs") end it "should set mount_options to an array of values from mount" do - @plugin.run - expect(@plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:mount_options]).to eq([ "ro", "noatime" ]) + plugin.run + expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:mount_options]).to eq([ "ro", "noatime" ]) end end @@ -186,7 +186,7 @@ tmpfs 2030944 2960 2027984 1% /dev/shm /dev/mapper/sys.vg-var.lv 19223252 3436556 14810212 19% /var /dev/md0 960492 36388 875312 4% /boot DF - allow(@plugin).to receive(:shell_out).with("df -P").and_return(mock_shell_out(0, @dfstdout, "")) + 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 @@ -196,7 +196,7 @@ tmpfs 126922 273 126649 1% /run none 126922 1 126921 1% /run/lock none 126922 1 126921 1% /run/shm DFi - allow(@plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, @inode_stdout, "")) + 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\" @@ -212,18 +212,18 @@ DFi /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 - allow(@plugin).to receive(:shell_out).with("blkid").and_return(mock_shell_out(0, @stdout, "")) + allow(plugin).to receive(:shell_out).with("blkid").and_return(mock_shell_out(0, @stdout, "")) end it "should run blkid" do - @plugin.run + plugin.run end it "should set kb_size to value from blkid" do - @plugin.run - expect(@plugin[:filesystem2]["by_pair"]["/dev/md1,"][:fs_type]).to eq("LVM2_member") - expect(@plugin[:filesystem2]["by_pair"]["/dev/sda2,"][:uuid]).to eq("e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa") - expect(@plugin[:filesystem2]["by_pair"]["/dev/md0,/boot"][:label]).to eq("/boot") + plugin.run + expect(plugin[:filesystem2]["by_pair"]["/dev/md1,"][:fs_type]).to eq("LVM2_member") + expect(plugin[:filesystem2]["by_pair"]["/dev/sda2,"][:uuid]).to eq("e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa") + expect(plugin[:filesystem2]["by_pair"]["/dev/md0,/boot"][:label]).to eq("/boot") end end @@ -242,7 +242,7 @@ tmpfs 2030944 2960 2027984 1% /dev/shm /dev/mapper/sys.vg-var.lv 19223252 3436556 14810212 19% /var /dev/md0 960492 36388 875312 4% /boot DF - allow(@plugin).to receive(:shell_out).with("df -P").and_return(mock_shell_out(0, @dfstdout, "")) + 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 @@ -252,7 +252,7 @@ tmpfs 126922 273 126649 1% /run none 126922 1 126921 1% /run/lock none 126922 1 126921 1% /run/shm DFi - allow(@plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, @inode_stdout, "")) + allow(plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, @inode_stdout, "")) allow(File).to receive(:exist?).with("/bin/lsblk").and_return(true) @stdout = <<-BLKID_TYPE @@ -269,20 +269,20 @@ NAME=\"/dev/mapper/sys.vg-usr.lv\" UUID=\"26ec33c5-d00b-4f88-a550-492def013bbc\" NAME=\"/dev/mapper/sys.vg-var.lv\" UUID=\"6b559c35-7847-4ae2-b512-c99012d3f5b3\" LABEL=\"/var\" FSTYPE=\"ext4\" NAME=\"/dev/mapper/sys.vg-home.lv\" UUID=\"d6efda02-1b73-453c-8c74-7d8dee78fa5e\" LABEL=\"/home\" FSTYPE=\"xfs\" BLKID_TYPE - allow(@plugin).to receive(:shell_out). + allow(plugin).to receive(:shell_out). with("lsblk -n -P -o NAME,UUID,LABEL,FSTYPE"). and_return(mock_shell_out(0, @stdout, "")) end it "should run lsblk -n -P -o NAME,UUID,LABEL,FSTYPE" do - @plugin.run + plugin.run end it "should set kb_size to value from lsblk -n -P -o NAME,UUID,LABEL,FSTYPE" do - @plugin.run - expect(@plugin[:filesystem2]["by_pair"]["/dev/md1,"][:fs_type]).to eq("LVM2_member") - expect(@plugin[:filesystem2]["by_pair"]["/dev/sda2,"][:uuid]).to eq("e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa") - expect(@plugin[:filesystem2]["by_pair"]["/dev/md0,/boot"][:label]).to eq("/boot") + plugin.run + expect(plugin[:filesystem2]["by_pair"]["/dev/md1,"][:fs_type]).to eq("LVM2_member") + expect(plugin[:filesystem2]["by_pair"]["/dev/sda2,"][:uuid]).to eq("e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa") + expect(plugin[:filesystem2]["by_pair"]["/dev/md0,/boot"][:label]).to eq("/boot") end end @@ -319,18 +319,18 @@ MOUNTS end it "should set mount to value from /proc/mounts" do - @plugin.run - expect(@plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:mount]).to eq("/special") + plugin.run + expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:mount]).to eq("/special") end it "should set fs_type to value from /proc/mounts" do - @plugin.run - expect(@plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:fs_type]).to eq("xfs") + plugin.run + expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:fs_type]).to eq("xfs") end it "should set mount_options to an array of values from /proc/mounts" do - @plugin.run - expect(@plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:mount_options]).to eq([ "ro", "noatime", "attr2", "noquota" ]) + plugin.run + expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:mount_options]).to eq([ "ro", "noatime", "attr2", "noquota" ]) end end @@ -351,7 +351,7 @@ tmpfs 2030944 2960 2027984 1% /dev/shm /dev/mapper/sys.vg-home.lv 97605056 53563252 44041804 55% /home2 /dev/mapper/sys.vg-root.lv 4805760 378716 4182924 9% /var/chroot DF - allow(@plugin).to receive(:shell_out).with("df -P").and_return(mock_shell_out(0, @dfstdout, "")) + 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 @@ -363,23 +363,23 @@ udev 126922 1 126921 1% /dev /dev/mapper/sys.vg-home.lv 60891136 4696030 56195106 8% /home2 /dev/mapper/sys.vg-root.lv 1310720 107407 1203313 9% /var/chroot DFi - allow(@plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, @inode_stdout, "")) + allow(plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, @inode_stdout, "")) allow(File).to receive(:exist?).with("/bin/lsblk").and_return(true) @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 - allow(@plugin).to receive(:shell_out). + allow(plugin).to receive(:shell_out). with("lsblk -n -P -o NAME,UUID,LABEL,FSTYPE"). and_return(mock_shell_out(0, @stdout, "")) end it "should provide a devices view with all mountpoints" do - @plugin.run - expect(@plugin[:filesystem2]["by_device"]["/dev/mapper/sys.vg-root.lv"][:mounts]).to eq(['/', '/var/chroot']) - expect(@plugin[:filesystem2]["by_device"]["/dev/mapper/sys.vg-home.lv"][:mounts]).to eq(['/home', '/home2']) - expect(@plugin[:filesystem2]["by_device"]["tmpfs"][:mounts]).to eq(['/lib/init/rw', '/dev/shm']) + plugin.run + expect(plugin[:filesystem2]["by_device"]["/dev/mapper/sys.vg-root.lv"][:mounts]).to eq(['/', '/var/chroot']) + expect(plugin[:filesystem2]["by_device"]["/dev/mapper/sys.vg-home.lv"][:mounts]).to eq(['/home', '/home2']) + expect(plugin[:filesystem2]["by_device"]["tmpfs"][:mounts]).to eq(['/lib/init/rw', '/dev/shm']) end end @@ -395,7 +395,7 @@ tmpfs 2030944 2960 2027984 1% /dev/shm /dev/sdb1 97605056 53563252 44041804 55% /mnt /dev/sdc1 4805760 378716 4182924 9% /mnt DF - allow(@plugin).to receive(:shell_out).with("df -P").and_return(mock_shell_out(0, @dfstdout, "")) + 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 @@ -407,7 +407,7 @@ udev 126922 1 126921 1% /dev /dev/sdb1 60891136 4696030 56195106 8% /mnt /dev/sdc1 1310720 107407 1203313 9% /mnt DFi - allow(@plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, @inode_stdout, "")) + allow(plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, @inode_stdout, "")) allow(File).to receive(:exist?).with("/bin/lsblk").and_return(true) @stdout = <<-BLKID_TYPE @@ -416,14 +416,14 @@ NAME=\"/dev/sdb1\" UUID=\"6b559c35-7847-4ae2-b512-c99012d3f5b3\" LABEL=\"/mnt\" 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 - allow(@plugin).to receive(:shell_out). + allow(plugin).to receive(:shell_out). with("lsblk -n -P -o NAME,UUID,LABEL,FSTYPE"). and_return(mock_shell_out(0, @stdout, "")) end it "should provide a mounts view with all devices" do - @plugin.run - expect(@plugin[:filesystem2]["by_mountpoint"]["/mnt"][:devices]).to eq(['/dev/sdb1', '/dev/sdc1']) + plugin.run + expect(plugin[:filesystem2]["by_mountpoint"]["/mnt"][:devices]).to eq(['/dev/sdb1', '/dev/sdc1']) end end end diff --git a/spec/unit/plugins/linux/filesystem_spec.rb b/spec/unit/plugins/linux/filesystem_spec.rb index eac9dd55..42cd9b8c 100644 --- a/spec/unit/plugins/linux/filesystem_spec.rb +++ b/spec/unit/plugins/linux/filesystem_spec.rb @@ -19,23 +19,23 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') describe Ohai::System, "Linux filesystem plugin" do + let(:plugin) { get_plugin("linux/filesystem") } before(:each) do - @plugin = get_plugin("linux/filesystem") - allow(@plugin).to receive(:collect_os).and_return(:linux) + allow(plugin).to receive(:collect_os).and_return(:linux) - allow(@plugin).to receive(:shell_out).with("df -P").and_return(mock_shell_out(0, "", "")) - allow(@plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, "", "")) - allow(@plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, "", "")) + allow(plugin).to receive(:shell_out).with("df -P").and_return(mock_shell_out(0, "", "")) + allow(plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, "", "")) + allow(plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, "", "")) allow(File).to receive(:exist?).with("/bin/lsblk").and_return(false) - allow(@plugin).to receive(:shell_out).with("blkid -s TYPE").and_return(mock_shell_out(0, "", "")) - allow(@plugin).to receive(:shell_out).with("blkid -s UUID").and_return(mock_shell_out(0, "", "")) - allow(@plugin).to receive(:shell_out).with("blkid -s LABEL").and_return(mock_shell_out(0, "", "")) + allow(plugin).to receive(:shell_out).with("blkid -s TYPE").and_return(mock_shell_out(0, "", "")) + allow(plugin).to receive(:shell_out).with("blkid -s UUID").and_return(mock_shell_out(0, "", "")) + allow(plugin).to receive(:shell_out).with("blkid -s LABEL").and_return(mock_shell_out(0, "", "")) - allow(@plugin).to receive(:shell_out).with("lsblk -P -n -o NAME,FSTYPE"). + allow(plugin).to receive(:shell_out).with("lsblk -P -n -o NAME,FSTYPE"). and_return(mock_shell_out(0, "", "")) - allow(@plugin).to receive(:shell_out).with("lsblk -P -n -o NAME,UUID"). + allow(plugin).to receive(:shell_out).with("lsblk -P -n -o NAME,UUID"). and_return(mock_shell_out(0, "", "")) - allow(@plugin).to receive(:shell_out).with("lsblk -P -n -o NAME,LABEL"). + allow(plugin).to receive(:shell_out).with("lsblk -P -n -o NAME,LABEL"). and_return(mock_shell_out(0, "", "")) allow(File).to receive(:exist?).with("/proc/mounts").and_return(false) @@ -72,7 +72,7 @@ tmpfs 2030944 2960 2027984 1% /dev/shm /dev/mapper/sys.vg-var.lv 19223252 3436556 14810212 19% /var /dev/md0 960492 36388 875312 4% /boot DF - allow(@plugin).to receive(:shell_out).with("df -P").and_return(mock_shell_out(0, @stdout, "")) + 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 @@ -82,53 +82,53 @@ tmpfs 126922 273 126649 1% /run none 126922 1 126921 1% /run/lock none 126922 1 126921 1% /run/shm DFi - allow(@plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, @inode_stdout, "")) + 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, "")) - expect(@plugin).to receive(:shell_out).ordered.with("df -iP").and_return(mock_shell_out(0, @inode_stdout, "")) - @plugin.run + expect(plugin).to receive(:shell_out).ordered.with("df -P").and_return(mock_shell_out(0, @stdout, "")) + expect(plugin).to receive(:shell_out).ordered.with("df -iP").and_return(mock_shell_out(0, @inode_stdout, "")) + plugin.run end it "should set kb_size to value from df -P" do - @plugin.run - expect(@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:kb_size]).to eq("97605057") + plugin.run + expect(plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:kb_size]).to eq("97605057") end it "should set kb_used to value from df -P" do - @plugin.run - expect(@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:kb_used]).to eq("53563253") + plugin.run + expect(plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:kb_used]).to eq("53563253") end it "should set kb_available to value from df -P" do - @plugin.run - expect(@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:kb_available]).to eq("44041805") + plugin.run + expect(plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:kb_available]).to eq("44041805") end it "should set percent_used to value from df -P" do - @plugin.run - expect(@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:percent_used]).to eq("56%") + plugin.run + expect(plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:percent_used]).to eq("56%") end it "should set mount to value from df -P" do - @plugin.run - expect(@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount]).to eq("/special") + plugin.run + expect(plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount]).to eq("/special") end it "should set total_inodes to value from df -iP" do - @plugin.run - expect(@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:total_inodes]).to eq("124865") + plugin.run + expect(plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:total_inodes]).to eq("124865") end it "should set inodes_used to value from df -iP" do - @plugin.run - expect(@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:inodes_used]).to eq("380") + plugin.run + expect(plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:inodes_used]).to eq("380") end it "should set inodes_available to value from df -iP" do - @plugin.run - expect(@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:inodes_available]).to eq("124485") + plugin.run + expect(plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:inodes_available]).to eq("124485") end end @@ -151,27 +151,27 @@ devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=620) 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 - allow(@plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, @stdout, "")) + 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, "")) - @plugin.run + expect(plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, @stdout, "")) + plugin.run end it "should set mount to value from mount" do - @plugin.run - expect(@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount]).to eq("/special") + plugin.run + expect(plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount]).to eq("/special") end it "should set fs_type to value from mount" do - @plugin.run - expect(@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:fs_type]).to eq("xfs") + plugin.run + expect(plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:fs_type]).to eq("xfs") end it "should set mount_options to an array of values from mount" do - @plugin.run - expect(@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount_options]).to eq([ "ro", "noatime" ]) + plugin.run + expect(plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount_options]).to eq([ "ro", "noatime" ]) end end @@ -192,17 +192,17 @@ MOUNT /dev/mapper/sys.vg-home.lv: TYPE=\"xfs\" /dev/mapper/debian--7-root: TYPE=\"ext4\" BLKID_TYPE - allow(@plugin).to receive(:shell_out).with("blkid -s TYPE").and_return(mock_shell_out(0, @stdout, "")) + allow(plugin).to receive(:shell_out).with("blkid -s TYPE").and_return(mock_shell_out(0, @stdout, "")) end it "should run blkid -s TYPE" do - expect(@plugin).to receive(:shell_out).with("blkid -s TYPE").and_return(mock_shell_out(0, @stdout, "")) - @plugin.run + expect(plugin).to receive(:shell_out).with("blkid -s TYPE").and_return(mock_shell_out(0, @stdout, "")) + plugin.run end it "should set fs_type to value from blkid -s TYPE" do - @plugin.run - expect(@plugin[:filesystem]["/dev/md1"][:fs_type]).to eq("LVM2_member") + plugin.run + expect(plugin[:filesystem]["/dev/md1"][:fs_type]).to eq("LVM2_member") end end @@ -224,24 +224,24 @@ NAME="sys.vg-var.lv" FSTYPE="ext4" NAME="sys.vg-home.lv" FSTYPE="xfs" NAME="debian--7-root (dm-0)" FSTYPE="ext4" BLKID_TYPE - allow(@plugin).to receive(:shell_out).with("lsblk -P -n -o NAME,FSTYPE"). + allow(plugin).to receive(:shell_out).with("lsblk -P -n -o NAME,FSTYPE"). and_return(mock_shell_out(0, @stdout, "")) end it "should run lsblk -P -n -o NAME,FSTYPE" do - expect(@plugin).to receive(:shell_out).with("lsblk -P -n -o NAME,FSTYPE"). + expect(plugin).to receive(:shell_out).with("lsblk -P -n -o NAME,FSTYPE"). and_return(mock_shell_out(0, @stdout, "")) - @plugin.run + plugin.run end it "should set fs_type to value from lsblk -P -n -o NAME,FSTYPE" do - @plugin.run - expect(@plugin[:filesystem]["/dev/md1"][:fs_type]).to eq("LVM2_member") + plugin.run + expect(plugin[:filesystem]["/dev/md1"][:fs_type]).to eq("LVM2_member") end it "should ignore extra info in name and set fs_type to value from lsblk -P -n -o NAME,FSTYPE" do - @plugin.run - expect(@plugin[:filesystem]["/dev/mapper/debian--7-root"][:fs_type]).to eq("ext4") + plugin.run + expect(plugin[:filesystem]["/dev/mapper/debian--7-root"][:fs_type]).to eq("ext4") end end @@ -262,17 +262,17 @@ BLKID_TYPE /dev/mapper/sys.vg-home.lv: UUID=\"d6efda02-1b73-453c-8c74-7d8dee78fa5e\" /dev/mapper/debian--7-root: UUID=\"09187faa-3512-4505-81af-7e86d2ccb99a\" BLKID_UUID - allow(@plugin).to receive(:shell_out).with("blkid -s UUID").and_return(mock_shell_out(0, @stdout, "")) + allow(plugin).to receive(:shell_out).with("blkid -s UUID").and_return(mock_shell_out(0, @stdout, "")) end it "should run blkid -s UUID" do - expect(@plugin).to receive(:shell_out).with("blkid -s UUID").and_return(mock_shell_out(0, @stdout, "")) - @plugin.run + expect(plugin).to receive(:shell_out).with("blkid -s UUID").and_return(mock_shell_out(0, @stdout, "")) + plugin.run end it "should set uuid to value from blkid -s UUID" do - @plugin.run - expect(@plugin[:filesystem]["/dev/sda2"][:uuid]).to eq("e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa") + plugin.run + expect(plugin[:filesystem]["/dev/sda2"][:uuid]).to eq("e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa") end end @@ -294,26 +294,26 @@ NAME="sys.vg-var.lv" UUID="6b559c35-7847-4ae2-b512-c99012d3f5b3" NAME="sys.vg-home.lv" UUID="d6efda02-1b73-453c-8c74-7d8dee78fa5e" NAME="debian--7-root (dm-0)" UUID="09187faa-3512-4505-81af-7e86d2ccb99a" BLKID_UUID - allow(@plugin).to receive(:shell_out).with("lsblk -P -n -o NAME,UUID"). + allow(plugin).to receive(:shell_out).with("lsblk -P -n -o NAME,UUID"). and_return(mock_shell_out(0, @stdout, "")) end it "should run lsblk -P -n -o NAME,UUID" do - expect(@plugin).to receive(:shell_out).with("lsblk -P -n -o NAME,UUID"). + expect(plugin).to receive(:shell_out).with("lsblk -P -n -o NAME,UUID"). and_return(mock_shell_out(0, @stdout, "")) - @plugin.run + plugin.run end it "should set uuid to value from lsblk -P -n -o NAME,UUID" do - @plugin.run - expect(@plugin[:filesystem]["/dev/sda2"][:uuid]).to eq( + plugin.run + expect(plugin[:filesystem]["/dev/sda2"][:uuid]).to eq( "e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa" ) end it "should ignore extra info in name and set uuid to value from lsblk -P -n -o NAME,UUID" do - @plugin.run - expect(@plugin[:filesystem]["/dev/mapper/debian--7-root"][:uuid]).to eq( + plugin.run + expect(plugin[:filesystem]["/dev/mapper/debian--7-root"][:uuid]).to eq( "09187faa-3512-4505-81af-7e86d2ccb99a" ) end @@ -334,17 +334,17 @@ BLKID_UUID /dev/mapper/sys.vg-home.lv: LABEL=\"/home\" /dev/mapper/debian--7-root: LABEL=\"root\" BLKID_LABEL - allow(@plugin).to receive(:shell_out).with("blkid -s LABEL").and_return(mock_shell_out(0, @stdout, "")) + allow(plugin).to receive(:shell_out).with("blkid -s LABEL").and_return(mock_shell_out(0, @stdout, "")) end it "should run blkid -s LABEL" do - expect(@plugin).to receive(:shell_out).with("blkid -s LABEL").and_return(mock_shell_out(0, @stdout, "")) - @plugin.run + expect(plugin).to receive(:shell_out).with("blkid -s LABEL").and_return(mock_shell_out(0, @stdout, "")) + plugin.run end it "should set label to value from blkid -s LABEL" do - @plugin.run - expect(@plugin[:filesystem]["/dev/md0"][:label]).to eq("/boot") + plugin.run + expect(plugin[:filesystem]["/dev/md0"][:label]).to eq("/boot") end end @@ -364,24 +364,24 @@ NAME="sys.vg-var.lv" LABEL="/var" NAME="sys.vg-home.lv" LABEL="/home" NAME="debian--7-root (dm-0)" LABEL="root" BLKID_LABEL - allow(@plugin).to receive(:shell_out).with("lsblk -P -n -o NAME,LABEL"). + allow(plugin).to receive(:shell_out).with("lsblk -P -n -o NAME,LABEL"). and_return(mock_shell_out(0, @stdout, "")) end it "should run lsblk -P -n -o NAME,LABEL" do - expect(@plugin).to receive(:shell_out).with("lsblk -P -n -o NAME,LABEL"). + expect(plugin).to receive(:shell_out).with("lsblk -P -n -o NAME,LABEL"). and_return(mock_shell_out(0, @stdout, "")) - @plugin.run + plugin.run end it "should set label to value from lsblk -P -n -o NAME,LABEL" do - @plugin.run - expect(@plugin[:filesystem]["/dev/md0"][:label]).to eq("/boot") + plugin.run + expect(plugin[:filesystem]["/dev/md0"][:label]).to eq("/boot") end it "should ignore extra info in name and set label to value from lsblk -P -n -o NAME,LABEL" do - @plugin.run - expect(@plugin[:filesystem]["/dev/mapper/debian--7-root"][:label]).to eq("root") + plugin.run + expect(plugin[:filesystem]["/dev/mapper/debian--7-root"][:label]).to eq("root") end end @@ -419,18 +419,18 @@ MOUNTS end it "should set mount to value from /proc/mounts" do - @plugin.run - expect(@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount]).to eq("/special") + plugin.run + expect(plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount]).to eq("/special") end it "should set fs_type to value from /proc/mounts" do - @plugin.run - expect(@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:fs_type]).to eq("xfs") + plugin.run + expect(plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:fs_type]).to eq("xfs") end it "should set mount_options to an array of values from /proc/mounts" do - @plugin.run - expect(@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount_options]).to eq([ "ro", "noatime", "attr2", "noquota" ]) + plugin.run + expect(plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount_options]).to eq([ "ro", "noatime", "attr2", "noquota" ]) end end |