spec/unit/plugins/linux/mdadm_spec.rb in ohai-15.2.5 vs spec/unit/plugins/linux/mdadm_spec.rb in ohai-15.3.1

- old
+ new

@@ -17,11 +17,11 @@ # require "spec_helper" describe Ohai::System, "Linux Mdadm Plugin" do - before(:each) do + before do @md0 = <<~MD /dev/md0: Version : 1.2 Creation Time : Thu Jan 30 03:11:40 2014 Raid Level : raid10 @@ -65,50 +65,50 @@ allow(@plugin).to receive(:shell_out).with("mdadm --detail /dev/md0").and_return(mock_shell_out(0, @md0, "")) end describe "gathering Mdadm information via /proc/mdstat and mdadm" do - it "should not raise an error" do + it "does not raise an error" do expect { @plugin.run }.not_to raise_error end - it "should detect raid level" do + it "detects raid level" do @plugin.run expect(@plugin[:mdadm][:md0][:level]).to eq(10) end - it "should detect raid state" do + it "detects raid state" do @plugin.run expect(@plugin[:mdadm][:md0][:state]).to eq("clean") end - it "should detect raid size" do + it "detects raid size" do @plugin.run expect(@plugin[:mdadm][:md0][:size]).to eq(2794.16) end - it "should detect raid metadata level" do + it "detects raid metadata level" do @plugin.run expect(@plugin[:mdadm][:md0][:version]).to eq(1.2) end device_counts = { raid: 6, total: 6, active: 6, working: 6, failed: 0, spare: 0 } device_counts.each_pair do |item, expected_value| - it "should detect device count of \"#{item}\"" do + it "detects device count of \"#{item}\"" do @plugin.run expect(@plugin[:mdadm][:md0][:device_counts][item]).to eq(expected_value) end end - it "should detect member devices" do + it "detects member devices" do @plugin.run expect(@plugin[:mdadm][:md0][:members].sort).to eq( %w{sdc sdd sde sdf sdg sdh} ) end - it "should detect member devices even if there are multi-digit numbers" do + it "detects member devices even if there are multi-digit numbers" do new_mdstat = double("/proc/mdstat2") allow(new_mdstat).to receive(:each) .and_yield("Personalities : [raid1] [raid6] [raid5] [raid4] [linear] [multipath] [raid0] [raid10]") .and_yield("md0 : active raid10 sdj[2010] sdi[99] sdh[5] sdg[4] sdf[3] sde[2] sdd[1] sdc[0]") .and_yield(" 2929893888 blocks super 1.2 256K chunks 2 near-copies [6/6] [UUUUUU]") @@ -118,11 +118,11 @@ expect(@plugin[:mdadm][:md0][:members].sort).to eq( %w{sdc sdd sde sdf sdg sdh sdi sdj} ) end - it "should detect member devices even if mdstat has extra entries" do + it "detects member devices even if mdstat has extra entries" do new_mdstat = double("/proc/mdstat2") allow(new_mdstat).to receive(:each) .and_yield("Personalities : [raid1] [raid6] [raid5] [raid4] [linear] [multipath] [raid0] [raid10]") .and_yield("md0 : active (somecraphere) <morestuff> raid10 sdh[5] sdg[4] sdf[3] sde[2] sdd[1] sdc[0]") .and_yield(" 2929893888 blocks super 1.2 256K chunks 2 near-copies [6/6] [UUUUUU]") @@ -132,32 +132,32 @@ expect(@plugin[:mdadm][:md0][:members].sort).to eq( %w{sdc sdd sde sdf sdg sdh} ) end - it "should accurately report inactive arrays" do + it "accuratelies report inactive arrays" do new_mdstat = double("/proc/mdstat_inactive") allow(new_mdstat).to receive(:each) .and_yield("Personalities :") .and_yield("md0 : inactive nvme2n1p3[2](S)") allow(File).to receive(:open).with("/proc/mdstat").and_return(new_mdstat) @plugin.run expect(@plugin[:mdadm][:md0][:spares]).to eq(%w{nvme2n1p3}) end - it "should report journal devices" do + it "reports journal devices" do new_mdstat = double("/proc/mdstat_journal") allow(new_mdstat).to receive(:each) .and_yield("Personalies : [raid6]") .and_yield("md0 : active (somecraphere) <morestuff raid6 sdbc1[7] sdd1[6] sde1[5] sdd1[4] sde1[3] sdf1[2] sdg1[1] nvme2n1p3[0](J)") allow(File).to receive(:open).with("/proc/mdstat").and_return(new_mdstat) @plugin.run expect(@plugin[:mdadm][:md0][:journal]).to eq("nvme2n1p3") end - it "should report spare devices" do + it "reports spare devices" do new_mdstat = double("/proc/mdstat_spare") allow(new_mdstat).to receive(:each) .and_yield("Personalies : [raid6]") .and_yield("md0 : active (somecraphere) <morestuff raid6 sdbc1[7] sdd1[6] sde1[5] sdd1[4] sde1[3] sdf1[2] sdg1[1] sdh1[0](S)") allow(File).to receive(:open).with("/proc/mdstat").and_return(new_mdstat)