Skip to content

Commit

Permalink
Merge pull request jhoblitt#48 from jhoblitt/maint/plumbing
Browse files Browse the repository at this point in the history
plumbing update
  • Loading branch information
jhoblitt committed Nov 24, 2015
2 parents 468b608 + 97ddb33 commit d5d6f66
Show file tree
Hide file tree
Showing 16 changed files with 73 additions and 84 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Copyright 2012 Massachusetts Institute of Technology
Copyright (C) 2013-2014 Joshua Hoblitt <[email protected]>
Copyright (C) 2013-2015 Joshua Hoblitt <[email protected]>

Permission to use, copy, modify, and distribute this software and
its documentation for any purpose and without fee is hereby
Expand Down
4 changes: 2 additions & 2 deletions spec/unit/classes/params_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
end

describe 'unsupported osfamily' do
let :facts do
let :facts do
{
:osfamily => 'Solaris',
:operatingsystem => 'Solaris',
}
end

it 'should fail' do
expect { should contain_class('smartd::params') }.
to raise_error(Puppet::Error, /not supported on Solaris/)
Expand Down
6 changes: 3 additions & 3 deletions spec/unit/facts/megacli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
Facter.fact(:kernel).stubs(:value).returns('Linux')
Facter::Util::Resolution.stubs(:which).with('MegaCli').returns(nil)
Facter::Util::Resolution.stubs(:which).with('megacli').returns(nil)
Facter.fact(:megacli).value.should be_nil
expect(Facter.fact(:megacli).value).to be_nil
end
end

context 'in path mixed case' do
it do
Facter.fact(:kernel).stubs(:value).returns('Linux')
Facter::Util::Resolution.stubs(:which).with('MegaCli').returns('/usr/bin/MegaCli')
Facter.fact(:megacli).value.should == '/usr/bin/MegaCli'
expect(Facter.fact(:megacli).value).to eq('/usr/bin/MegaCli')
end
end

Expand All @@ -26,7 +26,7 @@
Facter.fact(:kernel).stubs(:value).returns('Linux')
Facter::Util::Resolution.stubs(:which).with('MegaCli').returns(nil)
Facter::Util::Resolution.stubs(:which).with('megacli').returns('/usr/bin/megacli')
Facter.fact(:megacli).value.should == '/usr/bin/megacli'
expect(Facter.fact(:megacli).value).to eq('/usr/bin/megacli')
end
end
end
Expand Down
8 changes: 4 additions & 4 deletions spec/unit/facts/megacli_version_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
context 'megacli fact not set' do
it 'should return nil' do
Facter.fact(:megacli).stubs(:value).returns(nil)
Facter.fact(:megacli_version).value.should be_nil
expect(Facter.fact(:megacli_version).value).to be_nil
end
end

context 'megacli fact is broken' do
it 'should return nil' do
Facter.fact(:megacli).stubs(:value).returns('foobar')
Facter.fact(:megacli_version).value.should be_nil
expect(Facter.fact(:megacli_version).value).to be_nil
end
end

Expand All @@ -23,7 +23,7 @@
Facter::Util::Resolution.stubs(:exec).
with('/usr/bin/MegaCli -Version -Cli -aALL -NoLog').
returns(File.read(fixtures('megacli', 'version-cli-aall-8.07.07')))
Facter.fact(:megacli_version).value.should == '8.07.07'
expect(Facter.fact(:megacli_version).value).to eq('8.07.07')
end

it 'should get the version string using legacy binary' do
Expand All @@ -34,7 +34,7 @@
Facter::Util::Resolution.stubs(:exec).
with('/usr/bin/MegaCli -v -aALL -NoLog').
returns(File.read(fixtures('megacli', 'version-aall-8.00.11')))
Facter.fact(:megacli_version).value.should == '8.00.11'
expect(Facter.fact(:megacli_version).value).to eq('8.00.11')
end
end

Expand Down
21 changes: 10 additions & 11 deletions spec/unit/facts/megaraid_adapters_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,52 +6,51 @@
context 'on linux' do
context 'megacli not in path' do
it do
Facter.fact(:kernel).stubs(:value).returns('Linux')
Facter.fact(:kernel).stubs(:value).returns('Linux')
Facter.fact(:megacli).stubs(:value).returns(nil)

Facter.fact(:megaraid_adapters).value.should be_nil
expect(Facter.fact(:megaraid_adapters).value).to be_nil
end
end

context 'megacli is broken' do
it do
Facter.fact(:kernel).stubs(:value).returns('Linux')
Facter.fact(:kernel).stubs(:value).returns('Linux')
Facter.fact(:megacli).stubs(:value).returns('/usr/bin/MegaCli')
Facter::Util::Resolution.stubs(:exec).with('/usr/bin/MegaCli -adpCount -NoLog 2>&1').
returns(nil)

Facter.fact(:megaraid_adapters).value.should == '0'
expect(Facter.fact(:megaraid_adapters).value).to eq('0')
end
end

context 'megacli is working' do
it 'should find 0 adapters' do
Facter.fact(:kernel).stubs(:value).returns('Linux')
Facter.fact(:kernel).stubs(:value).returns('Linux')
Facter::Util::Resolution.stubs(:which).with('MegaCli').returns('/usr/bin/MegaCli')
Facter::Util::Resolution.stubs(:exec).with('/usr/bin/MegaCli -adpCount -NoLog 2>&1').
returns(File.read(fixtures('megacli', 'adpcount-count_0')))

Facter.fact(:megaraid_adapters).value.should == '0'
expect(Facter.fact(:megaraid_adapters).value).to eq('0')
end

it 'should find 1 adapters' do
Facter.fact(:kernel).stubs(:value).returns('Linux')
Facter.fact(:kernel).stubs(:value).returns('Linux')
Facter::Util::Resolution.stubs(:which).with('MegaCli').returns('/usr/bin/MegaCli')
Facter::Util::Resolution.stubs(:exec).with('/usr/bin/MegaCli -adpCount -NoLog 2>&1').
returns(File.read(fixtures('megacli', 'adpcount-count_1')))

Facter.fact(:megaraid_adapters).value.should == '1'
expect(Facter.fact(:megaraid_adapters).value).to eq('1')
end
end
end # on linux

context 'not on linux' do
it do
Facter.fact(:kernel).stubs(:value).returns('Solaris')
Facter.fact(:kernel).stubs(:value).returns('Solaris')

Facter.fact(:megaraid_adapters).value.should be_nil
expect(Facter.fact(:megaraid_adapters).value).to be_nil
end
end # not on linux

end

9 changes: 4 additions & 5 deletions spec/unit/facts/megaraid_fw_package_build_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
context 'megacli fact not set' do
it 'should return nil' do
Facter.fact(:megacli).stubs(:value).returns(nil)
Facter.fact(:megaraid_fw_package_build).value.should be_nil
expect(Facter.fact(:megaraid_fw_package_build).value).to be_nil
end
end

context 'megacli fact is broken' do
it 'should return nil' do
Facter.fact(:megacli).stubs(:value).returns('foobar')
Facter.fact(:megaraid_fw_package_build).value.should be_nil
expect(Facter.fact(:megaraid_fw_package_build).value).to be_nil
end
end

Expand All @@ -25,7 +25,7 @@
Facter::Util::Resolution.stubs(:exec).
with('/usr/bin/MegaCli -Version -Ctrl -aALL -NoLog').
returns(File.read(fixtures('megacli', 'version-ctrl-aall-8.07.07')))
Facter.fact(:megaraid_fw_package_build).value.should == '23.22.0-0012'
expect(Facter.fact(:megaraid_fw_package_build).value).to eq('23.22.0-0012')
end
end

Expand All @@ -36,10 +36,9 @@
Facter::Util::Resolution.stubs(:exec).
with('/usr/bin/MegaCli -AdpAllInfo -aALL -NoLog').
returns(File.read(fixtures('megacli', 'adpallinfo-aall-8.00.11')))
Facter.fact(:megaraid_fw_package_build).value.should == '20.12.0-0004'
expect(Facter.fact(:megaraid_fw_package_build).value).to eq('20.12.0-0004')
end
end
end

end

9 changes: 4 additions & 5 deletions spec/unit/facts/megaraid_fw_version_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
context 'megacli fact not set' do
it 'should return nil' do
Facter.fact(:megacli).stubs(:value).returns(nil)
Facter.fact(:megaraid_fw_version).value.should be_nil
expect(Facter.fact(:megaraid_fw_version).value).to be_nil
end
end

context 'megacli fact is broken' do
it 'should return nil' do
Facter.fact(:megacli).stubs(:value).returns('foobar')
Facter.fact(:megaraid_fw_version).value.should be_nil
expect(Facter.fact(:megaraid_fw_version).value).to be_nil
end
end

Expand All @@ -25,7 +25,7 @@
Facter::Util::Resolution.stubs(:exec).
with('/usr/bin/MegaCli -Version -Ctrl -aALL -NoLog').
returns(File.read(fixtures('megacli', 'version-ctrl-aall-8.07.07')))
Facter.fact(:megaraid_fw_version).value.should == '3.340.05-2939'
expect(Facter.fact(:megaraid_fw_version).value).to eq('3.340.05-2939')
end
end

Expand All @@ -36,10 +36,9 @@
Facter::Util::Resolution.stubs(:exec).
with('/usr/bin/MegaCli -AdpAllInfo -aALL -NoLog').
returns(File.read(fixtures('megacli', 'adpallinfo-aall-8.00.11')))
Facter.fact(:megaraid_fw_version).value.should == '2.120.14-2138'
expect(Facter.fact(:megaraid_fw_version).value).to eq('2.120.14-2138')
end
end
end

end

13 changes: 6 additions & 7 deletions spec/unit/facts/megaraid_physical_drives_sas_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Facter.fact(:kernel).stubs(:value).returns('Linux')
Facter.fact(:megacli).stubs(:value).returns(nil)

Facter.fact(:megaraid_physical_drives_sas).value.should be_nil
expect(Facter.fact(:megaraid_physical_drives_sas).value).to be_nil
end
end

Expand All @@ -19,7 +19,7 @@
Facter.fact(:megacli).stubs(:value).returns('/usr/bin/MegaCli')
Facter.fact(:megaraid_adapters).stubs(:value).returns(nil)

Facter.fact(:megaraid_physical_drives_sas).value.should be_nil
expect(Facter.fact(:megaraid_physical_drives_sas).value).to be_nil
end

it do
Expand All @@ -29,7 +29,7 @@
Facter::Util::Resolution.stubs(:exec).with('/usr/bin/MegaCli -PDList -aALL -NoLog').
returns(nil)

Facter.fact(:megaraid_physical_drives_sas).value.should be_nil
expect(Facter.fact(:megaraid_physical_drives_sas).value).to be_nil
end
end

Expand All @@ -39,7 +39,7 @@
Facter.fact(:megacli).stubs(:value).returns('/usr/bin/MegaCli')
Facter.fact(:megaraid_adapters).stubs(:value).returns('0')

Facter.fact(:megaraid_physical_drives_sas).value.should be_nil
expect(Facter.fact(:megaraid_physical_drives_sas).value).to be_nil
end
end

Expand All @@ -51,7 +51,7 @@
Facter::Util::Resolution.stubs(:exec).with('/usr/bin/MegaCli -PDList -aALL -NoLog').
returns(File.read(fixtures('megacli', 'pdlistaall')))

Facter.fact(:megaraid_physical_drives_sas).value.should == '188,189,190,192,194,197,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214'
expect(Facter.fact(:megaraid_physical_drives_sas).value).to eq('188,189,190,192,194,197,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214')
end
end
end # on linux
Expand All @@ -60,8 +60,7 @@
it do
Facter.fact(:kernel).stubs(:value).returns('Solaris')

Facter.fact(:megaraid_physical_drives_sas).value.should be_nil
expect(Facter.fact(:megaraid_physical_drives_sas).value).to be_nil
end
end # not on linux
end

13 changes: 6 additions & 7 deletions spec/unit/facts/megaraid_physical_drives_sata_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Facter.fact(:kernel).stubs(:value).returns('Linux')
Facter.fact(:megacli).stubs(:value).returns(nil)

Facter.fact(:megaraid_physical_drives_sata).value.should be_nil
expect(Facter.fact(:megaraid_physical_drives_sata).value).to be_nil
end
end

Expand All @@ -19,7 +19,7 @@
Facter.fact(:megacli).stubs(:value).returns('/usr/bin/MegaCli')
Facter.fact(:megaraid_adapters).stubs(:value).returns(nil)

Facter.fact(:megaraid_physical_drives_sata).value.should be_nil
expect(Facter.fact(:megaraid_physical_drives_sata).value).to be_nil
end

it do
Expand All @@ -29,7 +29,7 @@
Facter::Util::Resolution.stubs(:exec).with('/usr/bin/MegaCli -PDList -aALL -NoLog').
returns(nil)

Facter.fact(:megaraid_physical_drives_sata).value.should be_nil
expect(Facter.fact(:megaraid_physical_drives_sata).value).to be_nil
end
end

Expand All @@ -39,7 +39,7 @@
Facter.fact(:megacli).stubs(:value).returns('/usr/bin/MegaCli')
Facter.fact(:megaraid_adapters).stubs(:value).returns('0')

Facter.fact(:megaraid_physical_drives_sata).value.should be_nil
expect(Facter.fact(:megaraid_physical_drives_sata).value).to be_nil
end
end

Expand All @@ -51,7 +51,7 @@
Facter::Util::Resolution.stubs(:exec).with('/usr/bin/MegaCli -PDList -aALL -NoLog').
returns(File.read(fixtures('megacli', 'pdlistaall')))

Facter.fact(:megaraid_physical_drives_sata).value.should == '10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,184,185'
expect(Facter.fact(:megaraid_physical_drives_sata).value).to eq('10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,184,185')
end
end
end # on linux
Expand All @@ -60,8 +60,7 @@
it do
Facter.fact(:kernel).stubs(:value).returns('Solaris')

Facter.fact(:megaraid_physical_drives_sata).value.should be_nil
expect(Facter.fact(:megaraid_physical_drives_sata).value).to be_nil
end
end # not on linux
end

13 changes: 6 additions & 7 deletions spec/unit/facts/megaraid_physical_drives_size_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Facter.fact(:kernel).stubs(:value).returns('Linux')
Facter.fact(:megacli).stubs(:value).returns(nil)

Facter.fact(:megaraid_physical_drives_size).value.should be_nil
expect(Facter.fact(:megaraid_physical_drives_size).value).to be_nil
end
end

Expand All @@ -19,7 +19,7 @@
Facter.fact(:megacli).stubs(:value).returns('/usr/bin/MegaCli')
Facter.fact(:megaraid_adapters).stubs(:value).returns(nil)

Facter.fact(:megaraid_physical_drives_size).value.should be_nil
expect(Facter.fact(:megaraid_physical_drives_size).value).to be_nil
end

it do
Expand All @@ -29,7 +29,7 @@
Facter::Util::Resolution.stubs(:exec).with('/usr/bin/MegaCli -PDList -aALL -NoLog').
returns(nil)

Facter.fact(:megaraid_physical_drives_size).value.should be_nil
expect(Facter.fact(:megaraid_physical_drives_size).value).to be_nil
end
end

Expand All @@ -39,7 +39,7 @@
Facter.fact(:megacli).stubs(:value).returns('/usr/bin/MegaCli')
Facter.fact(:megaraid_adapters).stubs(:value).returns('0')

Facter.fact(:megaraid_physical_drives_size).value.should be_nil
expect(Facter.fact(:megaraid_physical_drives_size).value).to be_nil
end
end

Expand All @@ -62,7 +62,7 @@
'3.638 TB,3.638 TB,3.638 TB,3.638 TB,3.638 TB,3.638 TB,' +
'3.638 TB,3.638 TB,3.638 TB,3.638 TB,3.638 TB,3.638 TB,' +
'3.638 TB,3.638 TB,3.638 TB,3.638 TB,3.638 TB,3.638 TB'
Facter.fact(:megaraid_physical_drives_size).value.should == sizes
expect(Facter.fact(:megaraid_physical_drives_size).value).to eq(sizes)
end
end
end # on linux
Expand All @@ -71,8 +71,7 @@
it do
Facter.fact(:kernel).stubs(:value).returns('Solaris')

Facter.fact(:megaraid_physical_drives_size).value.should be_nil
expect(Facter.fact(:megaraid_physical_drives_size).value).to be_nil
end
end # not on linux
end

Loading

0 comments on commit d5d6f66

Please sign in to comment.