summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith84@gmail.com>2020-05-25 13:10:24 -0700
committerTim Smith <tsmith84@gmail.com>2020-05-25 14:08:42 -0700
commitf7049926f42e39d0d4bcfec33ab7ba8a9bbeee4f (patch)
tree885f25a090df7e3761f6a820fdb2f1d358e945b6
parentc01c03fba0834bcebb7f90c9c27dd720ab8b4a58 (diff)
downloadohai-spec_fixup.tar.gz
Convert some specs to use letspec_fixup
Modernize our specs a bit. There's tons of other issues, but this gets us into a slightly better state. Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--Gemfile2
-rw-r--r--spec/functional/plugins/powershell_spec.rb26
-rw-r--r--spec/spec_helper.rb24
-rw-r--r--spec/unit/plugins/aix/cpu_spec.rb53
-rw-r--r--spec/unit/plugins/aix/filesystem_spec.rb107
-rw-r--r--spec/unit/plugins/aix/hostname_spec.rb13
-rw-r--r--spec/unit/plugins/aix/kernel_spec.rb37
-rw-r--r--spec/unit/plugins/aix/memory_spec.rb25
-rw-r--r--spec/unit/plugins/aix/network_spec.rb116
-rw-r--r--spec/unit/plugins/aix/platform_spec.rb15
-rw-r--r--spec/unit/plugins/aix/uptime_spec.rb22
-rw-r--r--spec/unit/plugins/chef_spec.rb8
-rw-r--r--spec/unit/plugins/cloud_spec.rb260
-rw-r--r--spec/unit/plugins/darwin/cpu_spec.rb29
-rw-r--r--spec/unit/plugins/darwin/hostname_spec.rb19
-rw-r--r--spec/unit/plugins/darwin/kernel_spec.rb39
-rw-r--r--spec/unit/plugins/darwin/memory_spec.rb19
-rw-r--r--spec/unit/plugins/darwin/network_spec.rb721
-rw-r--r--spec/unit/plugins/darwin/platform_spec.rb39
-rw-r--r--spec/unit/plugins/freebsd/cpu_spec.rb68
-rw-r--r--spec/unit/plugins/freebsd/hostname_spec.rb11
-rw-r--r--spec/unit/plugins/freebsd/kernel_spec.rb17
-rw-r--r--spec/unit/plugins/freebsd/platform_spec.rb17
-rw-r--r--spec/unit/plugins/hostname_spec.rb60
-rw-r--r--spec/unit/plugins/kernel_spec.rb17
-rw-r--r--spec/unit/plugins/linux/block_device_spec.rb9
-rw-r--r--spec/unit/plugins/linux/hostname_spec.rb19
-rw-r--r--spec/unit/plugins/linux/kernel_spec.rb17
-rw-r--r--spec/unit/plugins/linux/lsb_spec.rb59
-rw-r--r--spec/unit/plugins/linux/mdadm_spec.rb53
-rw-r--r--spec/unit/plugins/linux/memory_spec.rb157
-rw-r--r--spec/unit/plugins/linux/uptime_spec.rb21
-rw-r--r--spec/unit/plugins/netbsd/hostname_spec.rb18
-rw-r--r--spec/unit/plugins/netbsd/kernel_spec.rb16
-rw-r--r--spec/unit/plugins/netbsd/platform_spec.rb17
-rw-r--r--spec/unit/plugins/network_spec.rb492
-rw-r--r--spec/unit/plugins/ohai_spec.rb8
-rw-r--r--spec/unit/plugins/ohai_time_spec.rb12
-rw-r--r--spec/unit/plugins/openbsd/hostname_spec.rb19
-rw-r--r--spec/unit/plugins/openbsd/kernel_spec.rb17
-rw-r--r--spec/unit/plugins/openbsd/platform_spec.rb13
-rw-r--r--spec/unit/plugins/os_spec.rb47
-rw-r--r--spec/unit/plugins/packages_spec.rb4
-rw-r--r--spec/unit/plugins/platform_spec.rb47
-rw-r--r--spec/unit/plugins/root_group_spec.rb20
-rw-r--r--spec/unit/plugins/ruby_spec.rb11
-rw-r--r--spec/unit/plugins/rust_spec.rb3
-rw-r--r--spec/unit/plugins/shells_spec.rb5
-rw-r--r--spec/unit/plugins/solaris2/cpu_spec.rb421
-rw-r--r--spec/unit/plugins/solaris2/dmi_spec.rb19
-rw-r--r--spec/unit/plugins/solaris2/hostname_spec.rb15
-rw-r--r--spec/unit/plugins/solaris2/kernel_spec.rb33
-rw-r--r--spec/unit/plugins/solaris2/memory_spec.rb21
-rw-r--r--spec/unit/plugins/solaris2/network_spec.rb48
-rw-r--r--spec/unit/plugins/solaris2/platform_spec.rb35
-rw-r--r--spec/unit/plugins/ssh_host_keys_spec.rb28
-rw-r--r--spec/unit/plugins/timezone_spec.rb7
-rw-r--r--spec/unit/plugins/windows/cpu_spec.rb33
-rw-r--r--spec/unit/plugins/windows/memory_spec.rb19
59 files changed, 1780 insertions, 1747 deletions
diff --git a/Gemfile b/Gemfile
index 2eceb4d4..b3636ab8 100644
--- a/Gemfile
+++ b/Gemfile
@@ -22,6 +22,6 @@ end
group :debug do
gem "pry"
gem "pry-byebug"
- gem "pry-stack_explorer"
+ gem "pry-stack_explorer", "~> 0.4.0" # 0.4 allows us to still test Ruby 2.5
gem "rb-readline"
end
diff --git a/spec/functional/plugins/powershell_spec.rb b/spec/functional/plugins/powershell_spec.rb
index c9e12a9a..98676972 100644
--- a/spec/functional/plugins/powershell_spec.rb
+++ b/spec/functional/plugins/powershell_spec.rb
@@ -30,12 +30,16 @@ describe Ohai::System, "languages plugin" do
expect(subject).to match(VERSION_MATCHING_REGEX)
end
end
- subject { @plugin[:languages][:powershell] }
+ subject { plugin[:languages][:powershell] }
+
+ let(:plugin) do
+ plugin_data = get_plugin("powershell")
+ plugin_data[:languages] = Mash.new
+ plugin_data
+ end
before(:all) do
- @plugin = get_plugin("powershell")
- @plugin[:languages] = Mash.new
- @plugin.run
+ plugin.run
end
it "has information about powershell" do
@@ -43,44 +47,44 @@ describe Ohai::System, "languages plugin" do
end
describe :version do
- subject { @plugin.languages[:powershell][described_class] }
+ subject { plugin.languages[:powershell][described_class] }
it_behaves_like "a version looking thing"
end
describe :ws_man_stack_version do
- subject { @plugin.languages[:powershell][described_class] }
+ subject { plugin.languages[:powershell][described_class] }
it_behaves_like "a version looking thing"
end
describe :serialization_version do
- subject { @plugin.languages[:powershell][described_class] }
+ subject { plugin.languages[:powershell][described_class] }
it_behaves_like "a version looking thing"
end
describe :clr_version do
- subject { @plugin.languages[:powershell][described_class] }
+ subject { plugin.languages[:powershell][described_class] }
it_behaves_like "a version looking thing"
end
describe :build_version do
- subject { @plugin.languages[:powershell][described_class] }
+ subject { plugin.languages[:powershell][described_class] }
it_behaves_like "a version looking thing"
end
describe :remoting_protocol_version do
- subject { @plugin.languages[:powershell][described_class] }
+ subject { plugin.languages[:powershell][described_class] }
it_behaves_like "a version looking thing"
end
describe :compatible_versions do
it "has compatible_versions that look like versions" do
- @plugin.languages[:powershell][described_class].each do |version|
+ plugin.languages[:powershell][described_class].each do |version|
expect(version).to match(VERSION_MATCHING_REGEX)
end
end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 0eaf93fb..93cd222a 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -37,20 +37,20 @@ end
def it_should_check_from(plugin, attribute, from, value)
it "sets the #{attribute} to the value from '#{from}'" do
- @plugin.run
- expect(@plugin[attribute]).to eq(value)
+ plugin.run
+ expect(plugin[attribute]).to eq(value)
end
end
def it_should_check_from_mash(plugin, attribute, from, value)
it "gets the #{plugin}[:#{attribute}] value from '#{from}'" do
- expect(@plugin).to receive(:shell_out).with(from).and_return(mock_shell_out(value[0], value[1], value[2]))
- @plugin.run
+ expect(plugin).to receive(:shell_out).with(from).and_return(mock_shell_out(value[0], value[1], value[2]))
+ plugin.run
end
it "sets the #{plugin}[:#{attribute}] to the value from '#{from}'" do
- @plugin.run
- expect(@plugin[plugin][attribute]).to eq(value[1].split($/)[0])
+ plugin.run
+ expect(plugin[plugin][attribute]).to eq(value[1].split($/)[0])
end
end
@@ -65,20 +65,20 @@ end
# the mash variable may be an array listing multiple levels of Mash hierarchy
def it_should_check_from_deep_mash(plugin, mash, attribute, from, value)
it "gets the #{mash.inspect}[:#{attribute}] value from '#{from}'" do
- expect(@plugin).to receive(:shell_out).with(from).and_return(mock_shell_out(value[0], value[1], value[2]))
- @plugin.run
+ expect(plugin).to receive(:shell_out).with(from).and_return(mock_shell_out(value[0], value[1], value[2]))
+ plugin.run
end
it "sets the #{mash.inspect}[:#{attribute}] to the value from '#{from}'" do
- @plugin.run
+ plugin.run
value = value[1].split($/)[0]
if mash.is_a?(String)
- expect(@plugin[mash][attribute]).to eq(value)
+ expect(plugin[mash][attribute]).to eq(value)
elsif mash.is_a?(Array)
if mash.length == 2
- expect(@plugin[mash[0]][mash[1]][attribute]).to eq value
+ expect(plugin[mash[0]][mash[1]][attribute]).to eq value
elsif mash.length == 3
- expect(@plugin[mash[0]][mash[1]][mash[2]][attribute]).to eq value
+ expect(plugin[mash[0]][mash[1]][mash[2]][attribute]).to eq value
else
return nil
end
diff --git a/spec/unit/plugins/aix/cpu_spec.rb b/spec/unit/plugins/aix/cpu_spec.rb
index 146534e2..19c1b6a7 100644
--- a/spec/unit/plugins/aix/cpu_spec.rb
+++ b/spec/unit/plugins/aix/cpu_spec.rb
@@ -19,6 +19,8 @@
require "spec_helper"
describe Ohai::System, "AIX cpu plugin" do
+ let(:plugin) { get_plugin("cpu") }
+
before do
@lsdev_cc_processor = <<~LSDEV_CC_PROCESSOR
proc0 Available 00-00 Processor
@@ -40,87 +42,86 @@ describe Ohai::System, "AIX cpu plugin" do
CPU 3 runs at 1654 MHz
PMCYCLES_M
- @plugin = get_plugin("cpu")
- allow(@plugin).to receive(:collect_os).and_return(:aix)
+ allow(plugin).to receive(:collect_os).and_return(:aix)
- allow(@plugin).to receive(:shell_out).with("lsdev -Cc processor").and_return(mock_shell_out(0, @lsdev_cc_processor, nil))
- allow(@plugin).to receive(:shell_out).with("lsattr -El proc0").and_return(mock_shell_out(0, @lsattr_el_proc0, nil))
- allow(@plugin).to receive(:shell_out).with("pmcycles -m").and_return(mock_shell_out(0, @pmcycles_m, nil))
+ allow(plugin).to receive(:shell_out).with("lsdev -Cc processor").and_return(mock_shell_out(0, @lsdev_cc_processor, nil))
+ allow(plugin).to receive(:shell_out).with("lsattr -El proc0").and_return(mock_shell_out(0, @lsattr_el_proc0, nil))
+ allow(plugin).to receive(:shell_out).with("pmcycles -m").and_return(mock_shell_out(0, @pmcycles_m, nil))
end
context "when run on an LPAR" do
before do
- allow(@plugin).to receive(:shell_out).with("uname -W").and_return(mock_shell_out(0, "0", nil))
- @plugin.run
+ allow(plugin).to receive(:shell_out).with("uname -W").and_return(mock_shell_out(0, "0", nil))
+ plugin.run
end
it "sets the vendor id to IBM" do
- expect(@plugin[:cpu]["0"][:vendor_id]).to eq("IBM")
+ expect(plugin[:cpu]["0"][:vendor_id]).to eq("IBM")
end
it "sets the available attribute" do
- expect(@plugin[:cpu][:available]).to eq(1)
+ expect(plugin[:cpu][:available]).to eq(1)
end
it "sets the total number of processors" do
- expect(@plugin[:cpu][:total]).to eq(4)
+ expect(plugin[:cpu][:total]).to eq(4)
end
it "sets the real number of processors" do
- expect(@plugin[:cpu][:real]).to eq(2)
+ expect(plugin[:cpu][:real]).to eq(2)
end
it "sets the number of cores" do
# from http://www-01.ibm.com/software/passportadvantage/pvu_terminology_for_customers.html
# on AIX number of cores and processors are considered same
- expect(@plugin[:cpu][:cores]).to eq(@plugin[:cpu][:real])
+ expect(plugin[:cpu][:cores]).to eq(plugin[:cpu][:real])
end
it "detects the model" do
- expect(@plugin[:cpu]["0"][:model_name]).to eq("PowerPC_POWER5")
+ expect(plugin[:cpu]["0"][:model_name]).to eq("PowerPC_POWER5")
end
it "detects the mhz" do
- expect(@plugin[:cpu]["0"][:mhz]).to eq(1654)
+ expect(plugin[:cpu]["0"][:mhz]).to eq(1654)
end
it "detects the status of the device" do
- expect(@plugin[:cpu]["0"][:status]).to eq("Available")
+ expect(plugin[:cpu]["0"][:status]).to eq("Available")
end
it "detects the location of the device" do
- expect(@plugin[:cpu]["0"][:location]).to eq("00-00")
+ expect(plugin[:cpu]["0"][:location]).to eq("00-00")
end
context "lsattr -El device_name" do
it "detects all the attributes of the device" do
- expect(@plugin[:cpu]["0"][:mhz]).to eq(1654)
- expect(@plugin[:cpu]["0"][:smt_enabled]).to eq("true")
- expect(@plugin[:cpu]["0"][:smt_threads]).to eq("2")
- expect(@plugin[:cpu]["0"][:state]).to eq("enable")
- expect(@plugin[:cpu]["0"][:model_name]).to eq("PowerPC_POWER5")
+ expect(plugin[:cpu]["0"][:mhz]).to eq(1654)
+ expect(plugin[:cpu]["0"][:smt_enabled]).to eq("true")
+ expect(plugin[:cpu]["0"][:smt_threads]).to eq("2")
+ expect(plugin[:cpu]["0"][:state]).to eq("enable")
+ expect(plugin[:cpu]["0"][:model_name]).to eq("PowerPC_POWER5")
end
end
end
context "when run on a WPAR" do
before do
- allow(@plugin).to receive(:shell_out).with("uname -W").and_return(mock_shell_out(0, "120", nil))
- @plugin.run
+ allow(plugin).to receive(:shell_out).with("uname -W").and_return(mock_shell_out(0, "120", nil))
+ plugin.run
end
it "sets the total number of processors" do
- expect(@plugin[:cpu][:total]).to eq(4)
+ expect(plugin[:cpu][:total]).to eq(4)
end
it "doesn't set the real number of CPUs" do
- expect(@plugin[:cpu][:real]).to be_nil
+ expect(plugin[:cpu][:real]).to be_nil
end
it "doesn't set mhz of a processor it can't see" do
# I'm so sorry
expect do
- expect(@plugin[:cpu]["0"][:mhz]).to eq(1654)
+ expect(plugin[:cpu]["0"][:mhz]).to eq(1654)
end.to raise_error(NoMethodError)
end
end
diff --git a/spec/unit/plugins/aix/filesystem_spec.rb b/spec/unit/plugins/aix/filesystem_spec.rb
index 87358b3c..59344cab 100644
--- a/spec/unit/plugins/aix/filesystem_spec.rb
+++ b/spec/unit/plugins/aix/filesystem_spec.rb
@@ -19,6 +19,8 @@
require "spec_helper"
describe Ohai::System, "AIX filesystem plugin" do
+ let(:plugin) { get_plugin("filesystem") }
+
before do
@df_pk_lpar = <<~DF_PK
Filesystem 1024-blocks Used Available Capacity Mounted on
@@ -85,79 +87,78 @@ describe Ohai::System, "AIX filesystem plugin" do
192.168.1.11 /stage/middleware3 /stage/middleware4 nfs3 Jul 17 13:24 ro,bg,hard,intr,sec=sys
MOUNT
- @plugin = get_plugin("filesystem")
- allow(@plugin).to receive(:collect_os).and_return(:aix)
- @plugin[:filesystem] = Mash.new
+ allow(plugin).to receive(:collect_os).and_return(:aix)
+ plugin[:filesystem] = Mash.new
end
context "when run within an LPAR" do
before do
- allow(@plugin).to receive(:shell_out).with("df -Pk").and_return(mock_shell_out(0, @df_pk_lpar, nil))
- allow(@plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, @mount_lpar, nil))
- @plugin.run
+ allow(plugin).to receive(:shell_out).with("df -Pk").and_return(mock_shell_out(0, @df_pk_lpar, nil))
+ allow(plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, @mount_lpar, nil))
+ plugin.run
end
describe "df -Pk" do
it "returns the filesystem block size" do
- expect(@plugin[:filesystem]["by_pair"]["/dev/hd4,/"]["kb_size"]).to eq("2097152")
- expect(@plugin[:filesystem2]["by_pair"]["/dev/hd4,/"]["kb_size"]).to eq("2097152")
+ expect(plugin[:filesystem]["by_pair"]["/dev/hd4,/"]["kb_size"]).to eq("2097152")
+ expect(plugin[:filesystem2]["by_pair"]["/dev/hd4,/"]["kb_size"]).to eq("2097152")
end
it "returns the filesystem used space in kb" do
- expect(@plugin[:filesystem]["by_pair"]["/dev/hd4,/"]["kb_used"]).to eq("219796")
- expect(@plugin[:filesystem2]["by_pair"]["/dev/hd4,/"]["kb_used"]).to eq("219796")
+ expect(plugin[:filesystem]["by_pair"]["/dev/hd4,/"]["kb_used"]).to eq("219796")
+ expect(plugin[:filesystem2]["by_pair"]["/dev/hd4,/"]["kb_used"]).to eq("219796")
end
it "returns the filesystem available space in kb" do
- expect(@plugin[:filesystem]["by_pair"]["/dev/hd4,/"]["kb_available"]).to eq("1877356")
- expect(@plugin[:filesystem2]["by_pair"]["/dev/hd4,/"]["kb_available"]).to eq("1877356")
+ expect(plugin[:filesystem]["by_pair"]["/dev/hd4,/"]["kb_available"]).to eq("1877356")
+ expect(plugin[:filesystem2]["by_pair"]["/dev/hd4,/"]["kb_available"]).to eq("1877356")
end
it "returns the filesystem capacity in percentage" do
- expect(@plugin[:filesystem]["by_pair"]["/dev/hd4,/"]["percent_used"]).to eq("11%")
- expect(@plugin[:filesystem2]["by_pair"]["/dev/hd4,/"]["percent_used"]).to eq("11%")
+ expect(plugin[:filesystem]["by_pair"]["/dev/hd4,/"]["percent_used"]).to eq("11%")
+ expect(plugin[:filesystem2]["by_pair"]["/dev/hd4,/"]["percent_used"]).to eq("11%")
end
it "returns the filesystem mounted location" do
- expect(@plugin[:filesystem]["by_pair"]["/dev/hd4,/"]["mount"]).to eq("/")
- expect(@plugin[:filesystem2]["by_pair"]["/dev/hd4,/"]["mount"]).to eq("/")
+ expect(plugin[:filesystem]["by_pair"]["/dev/hd4,/"]["mount"]).to eq("/")
+ expect(plugin[:filesystem2]["by_pair"]["/dev/hd4,/"]["mount"]).to eq("/")
end
end
describe "mount" do
it "returns the filesystem mount location" do
- expect(@plugin[:filesystem]["by_pair"]["/dev/hd4,/"]["mount"]).to eq("/")
- expect(@plugin[:filesystem2]["by_pair"]["/dev/hd4,/"]["mount"]).to eq("/")
+ expect(plugin[:filesystem]["by_pair"]["/dev/hd4,/"]["mount"]).to eq("/")
+ expect(plugin[:filesystem2]["by_pair"]["/dev/hd4,/"]["mount"]).to eq("/")
end
it "returns the filesystem type" do
- expect(@plugin[:filesystem]["by_pair"]["/dev/hd4,/"]["fs_type"]).to eq("jfs2")
- expect(@plugin[:filesystem2]["by_pair"]["/dev/hd4,/"]["fs_type"]).to eq("jfs2")
+ expect(plugin[:filesystem]["by_pair"]["/dev/hd4,/"]["fs_type"]).to eq("jfs2")
+ expect(plugin[:filesystem2]["by_pair"]["/dev/hd4,/"]["fs_type"]).to eq("jfs2")
end
it "returns the filesystem mount options" do
- expect(@plugin[:filesystem]["by_pair"]["/dev/hd4,/"]["mount_options"]).to eq(["rw", "log=/dev/hd8"])
- expect(@plugin[:filesystem2]["by_pair"]["/dev/hd4,/"]["mount_options"]).to eq(["rw", "log=/dev/hd8"])
+ expect(plugin[:filesystem]["by_pair"]["/dev/hd4,/"]["mount_options"]).to eq(["rw", "log=/dev/hd8"])
+ expect(plugin[:filesystem2]["by_pair"]["/dev/hd4,/"]["mount_options"]).to eq(["rw", "log=/dev/hd8"])
end
# For entries like 192.168.1.11 /stage/middleware1 /stage/middleware2 nfs3 Jul 17 13:24 ro,bg,hard,intr,sec=sys
context "having node values" do
it "returns the filesystem mount location" do
- expect(@plugin[:filesystem]["by_pair"]["192.168.1.11:/stage/middleware1,/stage/middleware2"]["mount"]).to eq("/stage/middleware2")
- expect(@plugin[:filesystem2]["by_pair"]["192.168.1.11:/stage/middleware1,/stage/middleware2"]["mount"]).to eq("/stage/middleware2")
+ expect(plugin[:filesystem]["by_pair"]["192.168.1.11:/stage/middleware1,/stage/middleware2"]["mount"]).to eq("/stage/middleware2")
+ expect(plugin[:filesystem2]["by_pair"]["192.168.1.11:/stage/middleware1,/stage/middleware2"]["mount"]).to eq("/stage/middleware2")
end
it "returns the filesystem type" do
- expect(@plugin[:filesystem]["by_pair"]["192.168.1.11:/stage/middleware1,/stage/middleware2"]["fs_type"]).to eq("nfs3")
- expect(@plugin[:filesystem2]["by_pair"]["192.168.1.11:/stage/middleware1,/stage/middleware2"]["fs_type"]).to eq("nfs3")
+ expect(plugin[:filesystem]["by_pair"]["192.168.1.11:/stage/middleware1,/stage/middleware2"]["fs_type"]).to eq("nfs3")
+ expect(plugin[:filesystem2]["by_pair"]["192.168.1.11:/stage/middleware1,/stage/middleware2"]["fs_type"]).to eq("nfs3")
end
it "returns the filesystem mount options" do
- expect(@plugin[:filesystem]["by_pair"]["192.168.1.11:/stage/middleware1,/stage/middleware2"]["mount_options"]).to eq(["ro", "bg", "hard", "intr", "sec=sys"])
- expect(@plugin[:filesystem2]["by_pair"]["192.168.1.11:/stage/middleware1,/stage/middleware2"]["mount_options"]).to eq(["ro", "bg", "hard", "intr", "sec=sys"])
+ expect(plugin[:filesystem]["by_pair"]["192.168.1.11:/stage/middleware1,/stage/middleware2"]["mount_options"]).to eq(["ro", "bg", "hard", "intr", "sec=sys"])
+ expect(plugin[:filesystem2]["by_pair"]["192.168.1.11:/stage/middleware1,/stage/middleware2"]["mount_options"]).to eq(["ro", "bg", "hard", "intr", "sec=sys"])
end
end
end
@@ -165,72 +166,72 @@ describe Ohai::System, "AIX filesystem plugin" do
context "when run within a WPAR" do
before do
- allow(@plugin).to receive(:shell_out).with("df -Pk").and_return(mock_shell_out(0, @df_pk_wpar, nil))
- allow(@plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, @mount_wpar, nil))
- @plugin.run
+ allow(plugin).to receive(:shell_out).with("df -Pk").and_return(mock_shell_out(0, @df_pk_wpar, nil))
+ allow(plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, @mount_wpar, nil))
+ plugin.run
end
describe "df -Pk" do
it "returns the filesystem block size" do
- expect(@plugin[:filesystem]["by_pair"]["Global:/,/"]["kb_size"]).to eq("10485760")
- expect(@plugin[:filesystem2]["by_pair"]["Global:/,/"]["kb_size"]).to eq("10485760")
+ expect(plugin[:filesystem]["by_pair"]["Global:/,/"]["kb_size"]).to eq("10485760")
+ expect(plugin[:filesystem2]["by_pair"]["Global:/,/"]["kb_size"]).to eq("10485760")
end
it "returns the filesystem used space in kb" do
- expect(@plugin[:filesystem]["by_pair"]["Global:/,/"]["kb_used"]).to eq("130872")
- expect(@plugin[:filesystem2]["by_pair"]["Global:/,/"]["kb_used"]).to eq("130872")
+ expect(plugin[:filesystem]["by_pair"]["Global:/,/"]["kb_used"]).to eq("130872")
+ expect(plugin[:filesystem2]["by_pair"]["Global:/,/"]["kb_used"]).to eq("130872")
end
it "returns the filesystem available space in kb" do
- expect(@plugin[:filesystem]["by_pair"]["Global:/,/"]["kb_available"]).to eq("10354888")
- expect(@plugin[:filesystem2]["by_pair"]["Global:/,/"]["kb_available"]).to eq("10354888")
+ expect(plugin[:filesystem]["by_pair"]["Global:/,/"]["kb_available"]).to eq("10354888")
+ expect(plugin[:filesystem2]["by_pair"]["Global:/,/"]["kb_available"]).to eq("10354888")
end
it "returns the filesystem capacity in percentage" do
- expect(@plugin[:filesystem]["by_pair"]["Global:/,/"]["percent_used"]).to eq("2%")
- expect(@plugin[:filesystem2]["by_pair"]["Global:/,/"]["percent_used"]).to eq("2%")
+ expect(plugin[:filesystem]["by_pair"]["Global:/,/"]["percent_used"]).to eq("2%")
+ expect(plugin[:filesystem2]["by_pair"]["Global:/,/"]["percent_used"]).to eq("2%")
end
it "returns the filesystem mounted location" do
- expect(@plugin[:filesystem]["by_pair"]["Global:/,/"]["mount"]).to eq("/")
- expect(@plugin[:filesystem2]["by_pair"]["Global:/,/"]["mount"]).to eq("/")
+ expect(plugin[:filesystem]["by_pair"]["Global:/,/"]["mount"]).to eq("/")
+ expect(plugin[:filesystem2]["by_pair"]["Global:/,/"]["mount"]).to eq("/")
end
end
describe "mount" do
it "returns the filesystem mount location" do
- expect(@plugin[:filesystem]["by_pair"]["Global:/,/"]["mount"]).to eq("/")
- expect(@plugin[:filesystem2]["by_pair"]["Global:/,/"]["mount"]).to eq("/")
+ expect(plugin[:filesystem]["by_pair"]["Global:/,/"]["mount"]).to eq("/")
+ expect(plugin[:filesystem2]["by_pair"]["Global:/,/"]["mount"]).to eq("/")
end
it "returns the filesystem type" do
- expect(@plugin[:filesystem]["by_pair"]["Global:/,/"]["fs_type"]).to eq("jfs2")
- expect(@plugin[:filesystem2]["by_pair"]["Global:/,/"]["fs_type"]).to eq("jfs2")
+ expect(plugin[:filesystem]["by_pair"]["Global:/,/"]["fs_type"]).to eq("jfs2")
+ expect(plugin[:filesystem2]["by_pair"]["Global:/,/"]["fs_type"]).to eq("jfs2")
end
it "returns the filesystem mount options" do
- expect(@plugin[:filesystem]["by_pair"]["Global:/,/"]["mount_options"]).to eq(["rw", "log=NULL"])
- expect(@plugin[:filesystem2]["by_pair"]["Global:/,/"]["mount_options"]).to eq(["rw", "log=NULL"])
+ expect(plugin[:filesystem]["by_pair"]["Global:/,/"]["mount_options"]).to eq(["rw", "log=NULL"])
+ expect(plugin[:filesystem2]["by_pair"]["Global:/,/"]["mount_options"]).to eq(["rw", "log=NULL"])
end
# For entries like 192.168.1.11 /stage/middleware3 /stage/middleware4 nfs3 Jul 17 13:24 ro,bg,hard,intr,sec=sys
context "having node values" do
it "returns the filesystem mount location" do
- expect(@plugin[:filesystem]["by_pair"]["192.168.1.11:/stage/middleware3,/stage/middleware4"]["mount"]).to eq("/stage/middleware4")
- expect(@plugin[:filesystem2]["by_pair"]["192.168.1.11:/stage/middleware3,/stage/middleware4"]["mount"]).to eq("/stage/middleware4")
+ expect(plugin[:filesystem]["by_pair"]["192.168.1.11:/stage/middleware3,/stage/middleware4"]["mount"]).to eq("/stage/middleware4")
+ expect(plugin[:filesystem2]["by_pair"]["192.168.1.11:/stage/middleware3,/stage/middleware4"]["mount"]).to eq("/stage/middleware4")
end
it "returns the filesystem type" do
- expect(@plugin[:filesystem]["by_pair"]["192.168.1.11:/stage/middleware3,/stage/middleware4"]["fs_type"]).to eq("nfs3")
- expect(@plugin[:filesystem2]["by_pair"]["192.168.1.11:/stage/middleware3,/stage/middleware4"]["fs_type"]).to eq("nfs3")
+ expect(plugin[:filesystem]["by_pair"]["192.168.1.11:/stage/middleware3,/stage/middleware4"]["fs_type"]).to eq("nfs3")
+ expect(plugin[:filesystem2]["by_pair"]["192.168.1.11:/stage/middleware3,/stage/middleware4"]["fs_type"]).to eq("nfs3")
end
it "returns the filesystem mount options" do
- expect(@plugin[:filesystem]["by_pair"]["192.168.1.11:/stage/middleware3,/stage/middleware4"]["mount_options"]).to eq(["ro", "bg", "hard", "intr", "sec=sys"])
- expect(@plugin[:filesystem2]["by_pair"]["192.168.1.11:/stage/middleware3,/stage/middleware4"]["mount_options"]).to eq(["ro", "bg", "hard", "intr", "sec=sys"])
+ expect(plugin[:filesystem]["by_pair"]["192.168.1.11:/stage/middleware3,/stage/middleware4"]["mount_options"]).to eq(["ro", "bg", "hard", "intr", "sec=sys"])
+ expect(plugin[:filesystem2]["by_pair"]["192.168.1.11:/stage/middleware3,/stage/middleware4"]["mount_options"]).to eq(["ro", "bg", "hard", "intr", "sec=sys"])
end
end
end
diff --git a/spec/unit/plugins/aix/hostname_spec.rb b/spec/unit/plugins/aix/hostname_spec.rb
index 0fcfcc5e..5c9df5fa 100644
--- a/spec/unit/plugins/aix/hostname_spec.rb
+++ b/spec/unit/plugins/aix/hostname_spec.rb
@@ -19,15 +19,16 @@
require "spec_helper"
describe Ohai::System, "AIX hostname plugin" do
+ let(:plugin) { get_plugin("hostname") }
+
before do
- @plugin = get_plugin("hostname")
- allow(@plugin).to receive(:collect_os).and_return(:aix)
- allow(@plugin).to receive(:from_cmd).with("hostname -s").and_return("aix_admin")
- allow(@plugin).to receive(:from_cmd).with("hostname").and_return("aix_admin.ponyville.com")
- @plugin.run
+ allow(plugin).to receive(:collect_os).and_return(:aix)
+ allow(plugin).to receive(:from_cmd).with("hostname -s").and_return("aix_admin")
+ allow(plugin).to receive(:from_cmd).with("hostname").and_return("aix_admin.ponyville.com")
+ plugin.run
end
it "sets the machinename" do
- expect(@plugin[:machinename]).to eql("aix_admin")
+ expect(plugin[:machinename]).to eql("aix_admin")
end
end
diff --git a/spec/unit/plugins/aix/kernel_spec.rb b/spec/unit/plugins/aix/kernel_spec.rb
index c9138bc8..a2af7c2c 100644
--- a/spec/unit/plugins/aix/kernel_spec.rb
+++ b/spec/unit/plugins/aix/kernel_spec.rb
@@ -19,43 +19,44 @@
require "spec_helper"
describe Ohai::System, "AIX kernel plugin" do
+ let(:plugin) { get_plugin("aix/kernel") }
+
before do
- @plugin = get_plugin("aix/kernel")
- allow(@plugin).to receive(:collect_os).and_return(:aix)
- allow(@plugin).to receive(:shell_out).with("uname -s").and_return(mock_shell_out(0, "AIX", nil))
- allow(@plugin).to receive(:shell_out).with("uname -r").and_return(mock_shell_out(0, "1", nil))
- allow(@plugin).to receive(:shell_out).with("uname -v").and_return(mock_shell_out(0, "6", nil))
- allow(@plugin).to receive(:shell_out).with("uname -p").and_return(mock_shell_out(0, "powerpc", nil))
- allow(@plugin).to receive(:shell_out).with("genkex -d").and_return(mock_shell_out(0, " Text address Size Data address Size File\nf1000000c0338000 77000 f1000000c0390000 1ec8c /usr/lib/drivers/cluster\n 6390000 20000 63a0000 ba8 /usr/lib/drivers/if_en", nil))
- allow(@plugin).to receive(:shell_out).with("getconf KERNEL_BITMODE").and_return(mock_shell_out(0, "64", nil))
- @plugin.run
+ allow(plugin).to receive(:collect_os).and_return(:aix)
+ allow(plugin).to receive(:shell_out).with("uname -s").and_return(mock_shell_out(0, "AIX", nil))
+ allow(plugin).to receive(:shell_out).with("uname -r").and_return(mock_shell_out(0, "1", nil))
+ allow(plugin).to receive(:shell_out).with("uname -v").and_return(mock_shell_out(0, "6", nil))
+ allow(plugin).to receive(:shell_out).with("uname -p").and_return(mock_shell_out(0, "powerpc", nil))
+ allow(plugin).to receive(:shell_out).with("genkex -d").and_return(mock_shell_out(0, " Text address Size Data address Size File\nf1000000c0338000 77000 f1000000c0390000 1ec8c /usr/lib/drivers/cluster\n 6390000 20000 63a0000 ba8 /usr/lib/drivers/if_en", nil))
+ allow(plugin).to receive(:shell_out).with("getconf KERNEL_BITMODE").and_return(mock_shell_out(0, "64", nil))
+ plugin.run
end
it "uname -s detects the name" do
- expect(@plugin[:kernel][:name]).to eq("aix")
+ expect(plugin[:kernel][:name]).to eq("aix")
end
it "uname -r detects the release" do
- expect(@plugin[:kernel][:release]).to eq("1")
+ expect(plugin[:kernel][:release]).to eq("1")
end
it "uname -v detects the version" do
- expect(@plugin[:kernel][:version]).to eq("6")
+ expect(plugin[:kernel][:version]).to eq("6")
end
it "uname -p detects the machine" do
- expect(@plugin[:kernel][:machine]).to eq("powerpc")
+ expect(plugin[:kernel][:machine]).to eq("powerpc")
end
it "getconf KERNEL_BITMODE detects the kernel's bittiness" do
- expect(@plugin[:kernel][:bits]).to eq("64")
+ expect(plugin[:kernel][:bits]).to eq("64")
end
it "detects the modules" do
- expect(@plugin[:kernel][:modules]["/usr/lib/drivers/cluster"]["text"]).to eq({ "address" => "f1000000c0338000", "size" => "77000" })
- expect(@plugin[:kernel][:modules]["/usr/lib/drivers/cluster"]["data"]).to eq({ "address" => "f1000000c0390000", "size" => "1ec8c" })
- expect(@plugin[:kernel][:modules]["/usr/lib/drivers/if_en"]["text"]).to eq({ "address" => "6390000", "size" => "20000" })
- expect(@plugin[:kernel][:modules]["/usr/lib/drivers/if_en"]["data"]).to eq({ "address" => "63a0000", "size" => "ba8" })
+ expect(plugin[:kernel][:modules]["/usr/lib/drivers/cluster"]["text"]).to eq({ "address" => "f1000000c0338000", "size" => "77000" })
+ expect(plugin[:kernel][:modules]["/usr/lib/drivers/cluster"]["data"]).to eq({ "address" => "f1000000c0390000", "size" => "1ec8c" })
+ expect(plugin[:kernel][:modules]["/usr/lib/drivers/if_en"]["text"]).to eq({ "address" => "6390000", "size" => "20000" })
+ expect(plugin[:kernel][:modules]["/usr/lib/drivers/if_en"]["data"]).to eq({ "address" => "63a0000", "size" => "ba8" })
end
end
diff --git a/spec/unit/plugins/aix/memory_spec.rb b/spec/unit/plugins/aix/memory_spec.rb
index e5b86b61..8dbea3e0 100644
--- a/spec/unit/plugins/aix/memory_spec.rb
+++ b/spec/unit/plugins/aix/memory_spec.rb
@@ -19,31 +19,32 @@
require "spec_helper"
describe Ohai::System, "AIX memory plugin" do
+ let(:plugin) { get_plugin("aix/memory") }
+
before do
- @plugin = get_plugin("aix/memory")
- allow(@plugin).to receive(:collect_os).and_return(:aix)
- allow(@plugin).to receive(:shell_out).with("svmon -G -O unit=MB,summary=longreal | grep '[0-9]'").and_return(mock_shell_out(0, " 513280.00 340034.17 173245.83 62535.17 230400.05 276950.14 70176.00\n", nil))
+ allow(plugin).to receive(:collect_os).and_return(:aix)
+ allow(plugin).to receive(:shell_out).with("svmon -G -O unit=MB,summary=longreal | grep '[0-9]'").and_return(mock_shell_out(0, " 513280.00 340034.17 173245.83 62535.17 230400.05 276950.14 70176.00\n", nil))
@swap_s = "allocated = 23887872 blocks used = 288912 blocks free = 23598960 blocks\n"
- allow(@plugin).to receive(:shell_out).with("swap -s").and_return(mock_shell_out(0, @swap_s, nil))
+ allow(plugin).to receive(:shell_out).with("swap -s").and_return(mock_shell_out(0, @swap_s, nil))
end
it "gets total memory" do
- @plugin.run
- expect(@plugin["memory"]["total"]).to eql("#{513280 * 1024}kB")
+ plugin.run
+ expect(plugin["memory"]["total"]).to eql("#{513280 * 1024}kB")
end
it "gets free memory" do
- @plugin.run
- expect(@plugin["memory"]["free"]).to eql("#{173245.83.to_i * 1024}kB")
+ plugin.run
+ expect(plugin["memory"]["free"]).to eql("#{173245.83.to_i * 1024}kB")
end
it "gets total swap" do
- @plugin.run
- expect(@plugin["memory"]["swap"]["total"]).to eql( "#{23887872 * 4}kB")
+ plugin.run
+ expect(plugin["memory"]["swap"]["total"]).to eql( "#{23887872 * 4}kB")
end
it "gets free swap" do
- @plugin.run
- expect(@plugin["memory"]["swap"]["free"]).to eql( "#{23598960 * 4}kB")
+ plugin.run
+ expect(plugin["memory"]["swap"]["free"]).to eql( "#{23598960 * 4}kB")
end
end
diff --git a/spec/unit/plugins/aix/network_spec.rb b/spec/unit/plugins/aix/network_spec.rb
index e96db800..be2f4bb9 100644
--- a/spec/unit/plugins/aix/network_spec.rb
+++ b/spec/unit/plugins/aix/network_spec.rb
@@ -19,6 +19,7 @@
require "spec_helper"
describe Ohai::System, "AIX network plugin" do
+ let(:plugin) { get_plugin("aix/network") }
before do
@netstat_rn_grep_default = <<~NETSTAT_RN_GREP_DEFAULT
@@ -74,35 +75,34 @@ describe Ohai::System, "AIX network plugin" do
There are 6 entries in the arp table.
ARP_AN
- @plugin = get_plugin("aix/network")
- allow(@plugin).to receive(:collect_os).and_return(:aix)
- @plugin[:network] = Mash.new
- allow(@plugin).to receive(:shell_out).with("uname -W").and_return(mock_shell_out(0, "0", nil))
- allow(@plugin).to receive(:shell_out).with("netstat -rn |grep default").and_return(mock_shell_out(0, @netstat_rn_grep_default, nil))
- allow(@plugin).to receive(:shell_out).with("ifconfig -a").and_return(mock_shell_out(0, @ifconfig, nil))
- allow(@plugin).to receive(:shell_out).with("entstat -d en0 | grep \"Hardware Address\"").and_return(mock_shell_out(0, "Hardware Address: be:42:80:00:b0:05", nil))
- allow(@plugin).to receive(:shell_out).with("entstat -d en1 | grep \"Hardware Address\"").and_return(mock_shell_out(0, @entstat_err, nil))
- allow(@plugin).to receive(:shell_out).with("entstat -d lo0 | grep \"Hardware Address\"").and_return(mock_shell_out(0, @entstat_err, nil))
- allow(@plugin).to receive(:shell_out).with("netstat -nrf inet").and_return(mock_shell_out(0, @netstat_nrf_inet, nil))
- allow(@plugin).to receive(:shell_out).with("netstat -nrf inet6").and_return(mock_shell_out(0, "::1%1 ::1%1 UH 1 109392 en0 - -", nil))
- allow(@plugin).to receive(:shell_out).with("arp -an").and_return(mock_shell_out(0, @aix_arp_an, nil))
+ allow(plugin).to receive(:collect_os).and_return(:aix)
+ plugin[:network] = Mash.new
+ allow(plugin).to receive(:shell_out).with("uname -W").and_return(mock_shell_out(0, "0", nil))
+ allow(plugin).to receive(:shell_out).with("netstat -rn |grep default").and_return(mock_shell_out(0, @netstat_rn_grep_default, nil))
+ allow(plugin).to receive(:shell_out).with("ifconfig -a").and_return(mock_shell_out(0, @ifconfig, nil))
+ allow(plugin).to receive(:shell_out).with("entstat -d en0 | grep \"Hardware Address\"").and_return(mock_shell_out(0, "Hardware Address: be:42:80:00:b0:05", nil))
+ allow(plugin).to receive(:shell_out).with("entstat -d en1 | grep \"Hardware Address\"").and_return(mock_shell_out(0, @entstat_err, nil))
+ allow(plugin).to receive(:shell_out).with("entstat -d lo0 | grep \"Hardware Address\"").and_return(mock_shell_out(0, @entstat_err, nil))
+ allow(plugin).to receive(:shell_out).with("netstat -nrf inet").and_return(mock_shell_out(0, @netstat_nrf_inet, nil))
+ allow(plugin).to receive(:shell_out).with("netstat -nrf inet6").and_return(mock_shell_out(0, "::1%1 ::1%1 UH 1 109392 en0 - -", nil))
+ allow(plugin).to receive(:shell_out).with("arp -an").and_return(mock_shell_out(0, @aix_arp_an, nil))
end
describe "run" do
before do
- @plugin.run
+ plugin.run
end
it "detects network information" do
- expect(@plugin["network"]).not_to be_nil
+ expect(plugin["network"]).not_to be_nil
end
it "detects the interfaces" do
- expect(@plugin["network"]["interfaces"].keys.sort).to eq(%w{en0 en1 lo0})
+ expect(plugin["network"]["interfaces"].keys.sort).to eq(%w{en0 en1 lo0})
end
it "detects the ip addresses of the interfaces" do
- expect(@plugin["network"]["interfaces"]["en0"]["addresses"].keys).to include("172.29.174.58")
+ expect(plugin["network"]["interfaces"]["en0"]["addresses"].keys).to include("172.29.174.58")
end
end
@@ -110,69 +110,69 @@ describe Ohai::System, "AIX network plugin" do
describe "sets the top-level attribute correctly" do
before do
- @plugin.run
+ plugin.run
end
it "for 'macaddress'" do
- expect(@plugin[:macaddress]).to eq("BE:42:80:00:B0:05")
+ expect(plugin[:macaddress]).to eq("BE:42:80:00:B0:05")
end
end
describe "netstat -rn |grep default" do
before do
- @plugin.run
+ plugin.run
end
it "returns the default gateway of the system's network" do
- expect(@plugin[:network][:default_gateway]).to eq("172.31.8.1")
+ expect(plugin[:network][:default_gateway]).to eq("172.31.8.1")
end
it "returns the default interface of the system's network" do
- expect(@plugin[:network][:default_interface]).to eq("en0")
+ expect(plugin[:network][:default_interface]).to eq("en0")
end
end
end
describe "when running on a WPAR" do
before do
- allow(@plugin).to receive(:shell_out).with("uname -W").and_return(mock_shell_out(0, "6", nil))
- @plugin.run
+ allow(plugin).to receive(:shell_out).with("uname -W").and_return(mock_shell_out(0, "6", nil))
+ plugin.run
end
it "avoids collecting routing information" do
- expect(@plugin[:network][:default_gateway]).to be_nil
+ expect(plugin[:network][:default_gateway]).to be_nil
end
it "avoids collecting default interface" do
- expect(@plugin[:network][:default_gateway]).to be_nil
+ expect(plugin[:network][:default_gateway]).to be_nil
end
it "avoids collecting a macaddress" do
- expect(@plugin[:macaddress]).to be_nil
+ expect(plugin[:macaddress]).to be_nil
end
end
describe "lsdev -Cc if" do
it "detects the state of the interfaces in the system" do
- @plugin.run
- expect(@plugin["network"]["interfaces"]["en0"][:state]).to eq("up")
+ plugin.run
+ expect(plugin["network"]["interfaces"]["en0"][:state]).to eq("up")
end
describe "ifconfig interface" do
it "detects the CHAIN network flag" do
- @plugin.run
- expect(@plugin["network"]["interfaces"]["en0"][:flags]).to include("CHAIN")
+ plugin.run
+ expect(plugin["network"]["interfaces"]["en0"][:flags]).to include("CHAIN")
end
it "detects the metric network flag" do
- @plugin.run
- expect(@plugin["network"]["interfaces"]["en0"][:metric]).to eq("1")
+ plugin.run
+ expect(plugin["network"]["interfaces"]["en0"][:metric]).to eq("1")
end
context "inet entries" do
before do
- @plugin.run
- @inet_entry = @plugin["network"]["interfaces"]["en0"][:addresses]["172.29.174.58"]
+ plugin.run
+ @inet_entry = plugin["network"]["interfaces"]["en0"][:addresses]["172.29.174.58"]
end
it "detects the family" do
@@ -188,24 +188,24 @@ describe Ohai::System, "AIX network plugin" do
end
it "detects all key-values" do
- expect(@plugin["network"]["interfaces"]["en0"][:tcp_sendspace]).to eq("262144")
- expect(@plugin["network"]["interfaces"]["en0"][:tcp_recvspace]).to eq("262144")
- expect(@plugin["network"]["interfaces"]["en0"][:rfc1323]).to eq("1")
+ expect(plugin["network"]["interfaces"]["en0"][:tcp_sendspace]).to eq("262144")
+ expect(plugin["network"]["interfaces"]["en0"][:tcp_recvspace]).to eq("262144")
+ expect(plugin["network"]["interfaces"]["en0"][:rfc1323]).to eq("1")
end
# For an output with no netmask like inet 172.29.174.59 broadcast 172.29.191.255
context "with no netmask in the output" do
before do
- allow(@plugin).to receive(:shell_out).with("ifconfig en0").and_return(mock_shell_out(0, "inet 172.29.174.59 broadcast 172.29.191.255", nil))
+ allow(plugin).to receive(:shell_out).with("ifconfig en0").and_return(mock_shell_out(0, "inet 172.29.174.59 broadcast 172.29.191.255", nil))
end
it "detects the default prefixlen" do
- @inet_entry = @plugin["network"]["interfaces"]["en0"][:addresses]["172.29.174.59"]
+ @inet_entry = plugin["network"]["interfaces"]["en0"][:addresses]["172.29.174.59"]
expect(@inet_entry[:prefixlen]).to eq("32")
end
it "detects the default netmask" do
- @inet_entry = @plugin["network"]["interfaces"]["en0"][:addresses]["172.29.174.59"]
+ @inet_entry = plugin["network"]["interfaces"]["en0"][:addresses]["172.29.174.59"]
expect(@inet_entry[:netmask]).to eq("255.255.255.255")
end
end
@@ -213,8 +213,8 @@ describe Ohai::System, "AIX network plugin" do
context "inet6 entries" do
before do
- @plugin.run
- @inet_entry = @plugin["network"]["interfaces"]["en0"][:addresses]["::1"]
+ plugin.run
+ @inet_entry = plugin["network"]["interfaces"]["en0"][:addresses]["::1"]
end
it "detects the prefixlen" do
@@ -229,8 +229,8 @@ describe Ohai::System, "AIX network plugin" do
context "entstat -d interface" do
before do
- @plugin.run
- @inet_interface_addresses = @plugin["network"]["interfaces"]["en0"][:addresses]["BE:42:80:00:B0:05"]
+ plugin.run
+ @inet_interface_addresses = plugin["network"]["interfaces"]["en0"][:addresses]["BE:42:80:00:B0:05"]
end
it "detects the family" do
@@ -241,63 +241,63 @@ describe Ohai::System, "AIX network plugin" do
describe "netstat -nrf family" do
before do
- @plugin.run
+ plugin.run
end
context "inet" do
it "detects the route destinations" do
- expect(@plugin["network"]["interfaces"]["en0"][:routes][0][:destination]).to eq("default")
- expect(@plugin["network"]["interfaces"]["en0"][:routes][1][:destination]).to eq("172.29.128.0")
+ expect(plugin["network"]["interfaces"]["en0"][:routes][0][:destination]).to eq("default")
+ expect(plugin["network"]["interfaces"]["en0"][:routes][1][:destination]).to eq("172.29.128.0")
end
it "detects the route family" do
- expect(@plugin["network"]["interfaces"]["en0"][:routes][0][:family]).to eq("inet")
+ expect(plugin["network"]["interfaces"]["en0"][:routes][0][:family]).to eq("inet")
end
it "detects the route gateway" do
- expect(@plugin["network"]["interfaces"]["en0"][:routes][0][:via]).to eq("172.29.128.13")
+ expect(plugin["network"]["interfaces"]["en0"][:routes][0][:via]).to eq("172.29.128.13")
end
it "detects the route flags" do
- expect(@plugin["network"]["interfaces"]["en0"][:routes][0][:flags]).to eq("UG")
+ expect(plugin["network"]["interfaces"]["en0"][:routes][0][:flags]).to eq("UG")
end
end
context "inet6" do
it "detects the route destinations" do
- expect(@plugin["network"]["interfaces"]["en0"][:routes][4][:destination]).to eq("::1%1")
+ expect(plugin["network"]["interfaces"]["en0"][:routes][4][:destination]).to eq("::1%1")
end
it "detects the route family" do
- expect(@plugin["network"]["interfaces"]["en0"][:routes][4][:family]).to eq("inet6")
+ expect(plugin["network"]["interfaces"]["en0"][:routes][4][:family]).to eq("inet6")
end
it "detects the route gateway" do
- expect(@plugin["network"]["interfaces"]["en0"][:routes][4][:via]).to eq("::1%1")
+ expect(plugin["network"]["interfaces"]["en0"][:routes][4][:via]).to eq("::1%1")
end
it "detects the route flags" do
- expect(@plugin["network"]["interfaces"]["en0"][:routes][4][:flags]).to eq("UH")
+ expect(plugin["network"]["interfaces"]["en0"][:routes][4][:flags]).to eq("UH")
end
end
end
describe "arp -an" do
before do
- @plugin.run
+ plugin.run
end
it "supresses the hostname entries" do
- expect(@plugin["network"]["arp"][0][:remote_host]).to eq("?")
+ expect(plugin["network"]["arp"][0][:remote_host]).to eq("?")
end
it "detects the remote ip entry" do
- expect(@plugin["network"]["arp"][0][:remote_ip]).to eq("172.29.131.16")
+ expect(plugin["network"]["arp"][0][:remote_ip]).to eq("172.29.131.16")
end
it "detects the remote mac entry" do
- expect(@plugin["network"]["arp"][0][:remote_mac]).to eq("6e:87:70:0:40:3")
+ expect(plugin["network"]["arp"][0][:remote_mac]).to eq("6e:87:70:0:40:3")
end
end
end
diff --git a/spec/unit/plugins/aix/platform_spec.rb b/spec/unit/plugins/aix/platform_spec.rb
index 32816d84..0e87b7ed 100644
--- a/spec/unit/plugins/aix/platform_spec.rb
+++ b/spec/unit/plugins/aix/platform_spec.rb
@@ -19,26 +19,27 @@
require "spec_helper"
describe Ohai::System, "Aix plugin platform" do
+ let(:plugin) { get_plugin("aix/platform") }
+
before do
- @plugin = get_plugin("aix/platform")
- allow(@plugin).to receive(:collect_os).and_return(:aix)
+ allow(plugin).to receive(:collect_os).and_return(:aix)
kernel = Mash.new
kernel[:name] = "aix"
kernel[:version] = "7"
kernel[:release] = "1"
- allow(@plugin).to receive(:kernel).and_return(kernel)
- @plugin.run
+ allow(plugin).to receive(:kernel).and_return(kernel)
+ plugin.run
end
it "sets platform to aix" do
- expect(@plugin[:platform]).to eq("aix")
+ expect(plugin[:platform]).to eq("aix")
end
it "sets the platform_version" do
- expect(@plugin[:platform_version]).to eq("7.1")
+ expect(plugin[:platform_version]).to eq("7.1")
end
it "sets platform_family" do
- expect(@plugin[:platform_family]).to eq(@plugin[:platform])
+ expect(plugin[:platform_family]).to eq(plugin[:platform])
end
end
diff --git a/spec/unit/plugins/aix/uptime_spec.rb b/spec/unit/plugins/aix/uptime_spec.rb
index 3023d41f..a6d9bc9f 100644
--- a/spec/unit/plugins/aix/uptime_spec.rb
+++ b/spec/unit/plugins/aix/uptime_spec.rb
@@ -19,24 +19,24 @@
require "spec_helper"
describe Ohai::System, "Aix plugin uptime" do
+ let(:plugin) { get_plugin("aix/uptime") }
before do
- @plugin = get_plugin("aix/uptime")
- allow(@plugin).to receive(:collect_os).and_return(:aix)
- allow(@plugin).to receive(:shell_out).and_call_original
+ allow(plugin).to receive(:collect_os).and_return(:aix)
+ allow(plugin).to receive(:shell_out).and_call_original
end
it "sets uptime_seconds and uptime standard case" do
- allow(@plugin).to receive(:shell_out).with("LC_ALL=POSIX ps -o etime= -p 1").and_return(mock_shell_out(0, "1148-20:54:50", nil))
- @plugin.run
- expect(@plugin[:uptime_seconds]).to eq(99262490)
- expect(@plugin[:uptime]).to eq("1148 days 20 hours 54 minutes 50 seconds")
+ allow(plugin).to receive(:shell_out).with("LC_ALL=POSIX ps -o etime= -p 1").and_return(mock_shell_out(0, "1148-20:54:50", nil))
+ plugin.run
+ expect(plugin[:uptime_seconds]).to eq(99262490)
+ expect(plugin[:uptime]).to eq("1148 days 20 hours 54 minutes 50 seconds")
end
it "sets uptime_seconds and uptime in the whitespace case" do
- allow(@plugin).to receive(:shell_out).with("LC_ALL=POSIX ps -o etime= -p 1").and_return(mock_shell_out(0, " 2-20:54:50", nil))
- @plugin.run
- expect(@plugin[:uptime_seconds]).to eq(248090)
- expect(@plugin[:uptime]).to eq("2 days 20 hours 54 minutes 50 seconds")
+ allow(plugin).to receive(:shell_out).with("LC_ALL=POSIX ps -o etime= -p 1").and_return(mock_shell_out(0, " 2-20:54:50", nil))
+ plugin.run
+ expect(plugin[:uptime_seconds]).to eq(248090)
+ expect(plugin[:uptime]).to eq("2 days 20 hours 54 minutes 50 seconds")
end
end
diff --git a/spec/unit/plugins/chef_spec.rb b/spec/unit/plugins/chef_spec.rb
index 1596e152..609597ee 100644
--- a/spec/unit/plugins/chef_spec.rb
+++ b/spec/unit/plugins/chef_spec.rb
@@ -23,13 +23,11 @@ begin
require "chef/version"
describe Ohai::System, "plugin chef" do
- before do
- @plugin = get_plugin("chef")
- end
+ let(:plugin) { get_plugin("chef") }
it "sets [:chef_packages][:chef][:version] to the current chef version", if: defined?(Chef) do
- @plugin.run
- expect(@plugin[:chef_packages][:chef][:version]).to eq(Chef::VERSION)
+ plugin.run
+ expect(plugin[:chef_packages][:chef][:version]).to eq(Chef::VERSION)
end
pending "would set [:chef_packages][:chef][:version] if chef was available", unless: defined?(Chef)
diff --git a/spec/unit/plugins/cloud_spec.rb b/spec/unit/plugins/cloud_spec.rb
index d805c93c..d79e0682 100644
--- a/spec/unit/plugins/cloud_spec.rb
+++ b/spec/unit/plugins/cloud_spec.rb
@@ -19,9 +19,7 @@ require "spec_helper"
require "ipaddr"
describe "CloudAttrs object" do
- before do
- @plugin = get_plugin("cloud")
- end
+ let(:plugin) { get_plugin("cloud") }
let(:cloud_node) do
{ "public_ipv4_addrs" => ["1.2.3.1"],
@@ -67,60 +65,58 @@ describe "CloudAttrs object" do
it "throws exception with ipv4 address passed to ipv6" do
@cloud_attr_obj = ::CloudAttrs.new
- expect { @cloud_attr_obj.add_ipv6_addr("1.2.3.4", :public) }.to raise_error(RuntimeError)
+ expect { @cloud_attr_obj.add_ipv6_addr("1.2.3.4", :public) }.to raise_error(RuntimeError)
end
end
describe Ohai::System, "plugin cloud" do
- before do
- @plugin = get_plugin("cloud")
- end
+ let(:plugin) { get_plugin("cloud") }
describe "with no cloud mashes" do
it "doesn't populate the cloud data" do
- @plugin[:ec2] = nil
- @plugin[:rackspace] = nil
- @plugin[:eucalyptus] = nil
- @plugin[:linode] = nil
- @plugin[:azure] = nil
- @plugin[:gce] = nil
- @plugin[:digital_ocean] = nil
- @plugin[:softlayer] = nil
- @plugin.run
- expect(@plugin[:cloud]).to be_nil
+ plugin[:ec2] = nil
+ plugin[:rackspace] = nil
+ plugin[:eucalyptus] = nil
+ plugin[:linode] = nil
+ plugin[:azure] = nil
+ plugin[:gce] = nil
+ plugin[:digital_ocean] = nil
+ plugin[:softlayer] = nil
+ plugin.run
+ expect(plugin[:cloud]).to be_nil
end
end
describe "with EC2 mash" do
before do
- @plugin[:ec2] = Mash.new
+ plugin[:ec2] = Mash.new
end
it "populates cloud public ip" do
- @plugin[:ec2]["public_ipv4"] = "174.129.150.8"
- @plugin.run
- expect(@plugin[:cloud][:public_ipv4_addrs][0]).to eq(@plugin[:ec2]["public_ipv4"])
+ plugin[:ec2]["public_ipv4"] = "174.129.150.8"
+ plugin.run
+ expect(plugin[:cloud][:public_ipv4_addrs][0]).to eq(plugin[:ec2]["public_ipv4"])
end
it "populates cloud private ip" do
- @plugin[:ec2]["local_ipv4"] = "10.252.42.149"
- @plugin.run
- expect(@plugin[:cloud][:local_ipv4_addrs][0]).to eq(@plugin[:ec2]["local_ipv4"])
+ plugin[:ec2]["local_ipv4"] = "10.252.42.149"
+ plugin.run
+ expect(plugin[:cloud][:local_ipv4_addrs][0]).to eq(plugin[:ec2]["local_ipv4"])
end
it "populates cloud provider" do
- @plugin.run
- expect(@plugin[:cloud][:provider]).to eq("ec2")
+ plugin.run
+ expect(plugin[:cloud][:provider]).to eq("ec2")
end
end
describe "with GCE mash" do
describe "with a public IP" do
before do
- @plugin[:gce] = Mash.new
- @plugin[:gce]["instance"] = Mash.new
- @plugin[:gce]["instance"]["networkInterfaces"] = [
+ plugin[:gce] = Mash.new
+ plugin[:gce]["instance"] = Mash.new
+ plugin[:gce]["instance"]["networkInterfaces"] = [
{
"accessConfigs" => [ { "externalIp" => "8.35.198.173", "type" => "ONE_TO_ONE_NAT" } ],
"ip" => "10.240.0.102",
@@ -130,26 +126,26 @@ describe Ohai::System, "plugin cloud" do
end
it "populates cloud public ip" do
- @plugin.run
- expect(@plugin[:cloud][:public_ipv4_addrs][0]).to eq("8.35.198.173")
+ plugin.run
+ expect(plugin[:cloud][:public_ipv4_addrs][0]).to eq("8.35.198.173")
end
it "populates cloud private ip" do
- @plugin.run
- expect(@plugin[:cloud][:local_ipv4_addrs][0]).to eq("10.240.0.102")
+ plugin.run
+ expect(plugin[:cloud][:local_ipv4_addrs][0]).to eq("10.240.0.102")
end
it "populates cloud provider" do
- @plugin.run
- expect(@plugin[:cloud][:provider]).to eq("gce")
+ plugin.run
+ expect(plugin[:cloud][:provider]).to eq("gce")
end
end
describe "with no public IP" do
before do
- @plugin[:gce] = Mash.new
- @plugin[:gce]["instance"] = Mash.new
- @plugin[:gce]["instance"]["networkInterfaces"] = [
+ plugin[:gce] = Mash.new
+ plugin[:gce]["instance"] = Mash.new
+ plugin[:gce]["instance"]["networkInterfaces"] = [
{
"accessConfigs" => [ { "externalIp" => "", "type" => "ONE_TO_ONE_NAT" } ],
"ip" => "10.240.0.102",
@@ -159,125 +155,125 @@ describe Ohai::System, "plugin cloud" do
end
it "does not populate cloud public ip" do
- @plugin.run
- expect(@plugin[:cloud][:public_ipv4_addrs]).to be_nil
+ plugin.run
+ expect(plugin[:cloud][:public_ipv4_addrs]).to be_nil
end
it "populates cloud private ip" do
- @plugin.run
- expect(@plugin[:cloud][:local_ipv4_addrs][0]).to eq("10.240.0.102")
+ plugin.run
+ expect(plugin[:cloud][:local_ipv4_addrs][0]).to eq("10.240.0.102")
end
it "populates cloud provider" do
- @plugin.run
- expect(@plugin[:cloud][:provider]).to eq("gce")
+ plugin.run
+ expect(plugin[:cloud][:provider]).to eq("gce")
end
end
end
describe "with rackspace" do
before do
- @plugin[:rackspace] = Mash.new
+ plugin[:rackspace] = Mash.new
end
it "populates cloud public ip" do
- @plugin[:rackspace][:public_ipv4] = "174.129.150.8"
- @plugin.run
- expect(@plugin[:cloud][:public_ipv4]).to eq(@plugin[:rackspace][:public_ipv4])
+ plugin[:rackspace][:public_ipv4] = "174.129.150.8"
+ plugin.run
+ expect(plugin[:cloud][:public_ipv4]).to eq(plugin[:rackspace][:public_ipv4])
end
it "populates cloud public ipv6" do
- @plugin[:rackspace][:public_ipv6] = "2a00:1a48:7805:111:e875:efaf:ff08:75"
- @plugin.run
- expect(@plugin[:cloud][:public_ipv6]).to eq(@plugin[:rackspace][:public_ipv6])
+ plugin[:rackspace][:public_ipv6] = "2a00:1a48:7805:111:e875:efaf:ff08:75"
+ plugin.run
+ expect(plugin[:cloud][:public_ipv6]).to eq(plugin[:rackspace][:public_ipv6])
end
it "populates cloud private ip" do
- @plugin[:rackspace][:local_ipv4] = "10.252.42.149"
- @plugin.run
- expect(@plugin[:cloud][:local_ipv4]).to eq(@plugin[:rackspace][:local_ipv4])
+ plugin[:rackspace][:local_ipv4] = "10.252.42.149"
+ plugin.run
+ expect(plugin[:cloud][:local_ipv4]).to eq(plugin[:rackspace][:local_ipv4])
end
it "populates cloud private ipv6" do
- @plugin[:rackspace][:local_ipv6] = "2a00:1a48:7805:111:e875:efaf:ff08:75"
- @plugin.run
- expect(@plugin[:cloud][:local_ipv6]).to eq(@plugin[:rackspace][:local_ipv6])
+ plugin[:rackspace][:local_ipv6] = "2a00:1a48:7805:111:e875:efaf:ff08:75"
+ plugin.run
+ expect(plugin[:cloud][:local_ipv6]).to eq(plugin[:rackspace][:local_ipv6])
end
it "populates first cloud public ip" do
- @plugin[:rackspace][:public_ipv4] = "174.129.150.8"
- @plugin.run
- expect(@plugin[:cloud][:public_ipv4_addrs].first).to eq(@plugin[:rackspace][:public_ipv4])
+ plugin[:rackspace][:public_ipv4] = "174.129.150.8"
+ plugin.run
+ expect(plugin[:cloud][:public_ipv4_addrs].first).to eq(plugin[:rackspace][:public_ipv4])
end
it "populates first cloud public ip" do
- @plugin[:rackspace][:local_ipv4] = "174.129.150.8"
- @plugin.run
- expect(@plugin[:cloud][:local_ipv4_addrs].first).to eq(@plugin[:rackspace][:local_ipv4])
+ plugin[:rackspace][:local_ipv4] = "174.129.150.8"
+ plugin.run
+ expect(plugin[:cloud][:local_ipv4_addrs].first).to eq(plugin[:rackspace][:local_ipv4])
end
it "populates cloud provider" do
- @plugin.run
- expect(@plugin[:cloud][:provider]).to eq("rackspace")
+ plugin.run
+ expect(plugin[:cloud][:provider]).to eq("rackspace")
end
end
describe "with linode mash" do
before do
- @plugin[:linode] = Mash.new
+ plugin[:linode] = Mash.new
end
it "populates cloud public ip" do
- @plugin[:linode]["public_ip"] = "174.129.150.8"
- @plugin.run
- expect(@plugin[:cloud][:public_ipv4_addrs][0]).to eq(@plugin[:linode][:public_ip])
+ plugin[:linode]["public_ip"] = "174.129.150.8"
+ plugin.run
+ expect(plugin[:cloud][:public_ipv4_addrs][0]).to eq(plugin[:linode][:public_ip])
end
it "populates cloud private ip" do
- @plugin[:linode]["private_ip"] = "10.252.42.149"
- @plugin.run
- expect(@plugin[:cloud][:local_ipv4_addrs][0]).to eq(@plugin[:linode][:private_ip])
+ plugin[:linode]["private_ip"] = "10.252.42.149"
+ plugin.run
+ expect(plugin[:cloud][:local_ipv4_addrs][0]).to eq(plugin[:linode][:private_ip])
end
it "populates first cloud public ip" do
- @plugin[:linode]["public_ip"] = "174.129.150.8"
- @plugin.run
- expect(@plugin[:cloud][:public_ipv4_addrs].first).to eq(@plugin[:linode][:public_ip])
+ plugin[:linode]["public_ip"] = "174.129.150.8"
+ plugin.run
+ expect(plugin[:cloud][:public_ipv4_addrs].first).to eq(plugin[:linode][:public_ip])
end
it "populates cloud provider" do
- @plugin.run
- expect(@plugin[:cloud][:provider]).to eq("linode")
+ plugin.run
+ expect(plugin[:cloud][:provider]).to eq("linode")
end
end
describe "with eucalyptus mash" do
before do
- @plugin[:eucalyptus] = Mash.new
+ plugin[:eucalyptus] = Mash.new
end
it "populates cloud public ip" do
- @plugin[:eucalyptus]["public_ipv4"] = "174.129.150.8"
- @plugin.run
- expect(@plugin[:cloud][:public_ipv4_addrs][0]).to eq(@plugin[:eucalyptus]["public_ipv4"])
+ plugin[:eucalyptus]["public_ipv4"] = "174.129.150.8"
+ plugin.run
+ expect(plugin[:cloud][:public_ipv4_addrs][0]).to eq(plugin[:eucalyptus]["public_ipv4"])
end
it "populates cloud private ip" do
- @plugin[:eucalyptus]["local_ipv4"] = "10.252.42.149"
- @plugin.run
- expect(@plugin[:cloud][:local_ipv4_addrs][0]).to eq(@plugin[:eucalyptus]["local_ipv4"])
+ plugin[:eucalyptus]["local_ipv4"] = "10.252.42.149"
+ plugin.run
+ expect(plugin[:cloud][:local_ipv4_addrs][0]).to eq(plugin[:eucalyptus]["local_ipv4"])
end
it "populates cloud provider" do
- @plugin.run
- expect(@plugin[:cloud][:provider]).to eq("eucalyptus")
+ plugin.run
+ expect(plugin[:cloud][:provider]).to eq("eucalyptus")
end
end
describe "with Azure mash" do
before do
- @plugin[:azure] = Mash.new
- @plugin[:azure][:metadata] = {
+ plugin[:azure] = Mash.new
+ plugin[:azure][:metadata] = {
"compute" =>
{
"location" => "westus",
@@ -314,50 +310,50 @@ describe Ohai::System, "plugin cloud" do
end
it "populates cloud public ip" do
- @plugin.run
- expect(@plugin[:cloud][:public_ipv4_addrs][0]).to eq("40.118.212.225")
+ plugin.run
+ expect(plugin[:cloud][:public_ipv4_addrs][0]).to eq("40.118.212.225")
end
it "doesn't populates cloud vm_name" do
- @plugin.run
- expect(@plugin[:cloud][:vm_name]).not_to eq("timtest")
+ plugin.run
+ expect(plugin[:cloud][:vm_name]).not_to eq("timtest")
end
it "populates cloud public_hostname" do
- @plugin[:azure]["public_fqdn"] = "linux-vm-svc.cloudapp.net"
- @plugin.run
- expect(@plugin[:cloud][:public_hostname]).to eq("linux-vm-svc.cloudapp.net")
+ plugin[:azure]["public_fqdn"] = "linux-vm-svc.cloudapp.net"
+ plugin.run
+ expect(plugin[:cloud][:public_hostname]).to eq("linux-vm-svc.cloudapp.net")
end
it "doesn't populate cloud public_ssh_port" do
- @plugin[:azure]["public_ssh_port"] = "22"
- @plugin.run
- expect(@plugin[:cloud][:public_ssh_port]).to be_nil
+ plugin[:azure]["public_ssh_port"] = "22"
+ plugin.run
+ expect(plugin[:cloud][:public_ssh_port]).to be_nil
end
it "does not populate cloud public_ssh_port when winrm is used" do
- @plugin[:azure]["public_winrm_port"] = "5985"
- @plugin.run
- expect(@plugin[:cloud][:public_ssh_port]).to be_nil
+ plugin[:azure]["public_winrm_port"] = "5985"
+ plugin.run
+ expect(plugin[:cloud][:public_ssh_port]).to be_nil
end
it "populates cloud public_winrm_port" do
- @plugin[:azure]["public_winrm_port"] = "5985"
- @plugin.run
- expect(@plugin[:cloud][:public_winrm_port]).to be_nil
+ plugin[:azure]["public_winrm_port"] = "5985"
+ plugin.run
+ expect(plugin[:cloud][:public_winrm_port]).to be_nil
end
it "populates cloud provider" do
- @plugin.run
- expect(@plugin[:cloud][:provider]).to eq("azure")
+ plugin.run
+ expect(plugin[:cloud][:provider]).to eq("azure")
end
end
describe "with digital_ocean mash" do
before do
- @plugin[:digital_ocean] = Mash.new
- @plugin[:digital_ocean][:interfaces] = Mash.new
- @plugin[:digital_ocean][:interfaces] = {
+ plugin[:digital_ocean] = Mash.new
+ plugin[:digital_ocean][:interfaces] = Mash.new
+ plugin[:digital_ocean][:interfaces] = {
"private" =>
[
{
@@ -400,84 +396,84 @@ describe Ohai::System, "plugin cloud" do
end
before do
- @plugin.run
+ plugin.run
end
it "populates cloud local hostname" do
- expect(@plugin[:cloud][:local_hostname]).to be_nil
+ expect(plugin[:cloud][:local_hostname]).to be_nil
end
it "populates cloud public_ipv4_addrs" do
- expect(@plugin[:cloud][:public_ipv4_addrs]).to eq(["207.154.221.42"])
+ expect(plugin[:cloud][:public_ipv4_addrs]).to eq(["207.154.221.42"])
end
it "populates cloud local_ipv4_addrs" do
- expect(@plugin[:cloud][:local_ipv4_addrs]).to eq(["10.135.32.4"])
+ expect(plugin[:cloud][:local_ipv4_addrs]).to eq(["10.135.32.4"])
end
it "populates cloud public_ipv4" do
- expect(@plugin[:cloud][:public_ipv4]).to eq("207.154.221.42")
+ expect(plugin[:cloud][:public_ipv4]).to eq("207.154.221.42")
end
it "populates cloud local_ipv4" do
- expect(@plugin[:cloud][:local_ipv4]).to eq("10.135.32.4")
+ expect(plugin[:cloud][:local_ipv4]).to eq("10.135.32.4")
end
it "populates cloud public_ipv6_addrs" do
- expect(@plugin[:cloud][:public_ipv6_addrs]).to eq(["2a03:b0c0:3:d0::3b15:b001"])
+ expect(plugin[:cloud][:public_ipv6_addrs]).to eq(["2a03:b0c0:3:d0::3b15:b001"])
end
it "populates cloud local_ipv6_addrs" do
- expect(@plugin[:cloud][:local_ipv6_addrs]).to be_nil
+ expect(plugin[:cloud][:local_ipv6_addrs]).to be_nil
end
it "populates cloud public_ipv6" do
- expect(@plugin[:cloud][:public_ipv6]).to eq("2a03:b0c0:3:d0::3b15:b001")
+ expect(plugin[:cloud][:public_ipv6]).to eq("2a03:b0c0:3:d0::3b15:b001")
end
it "populates cloud local_ipv6" do
- expect(@plugin[:cloud][:local_ipv6]).to be_nil
+ expect(plugin[:cloud][:local_ipv6]).to be_nil
end
it "populates cloud provider" do
- expect(@plugin[:cloud][:provider]).to eq("digital_ocean")
+ expect(plugin[:cloud][:provider]).to eq("digital_ocean")
end
end
describe "with softlayer mash" do
before do
- @plugin[:softlayer] = Mash.new
- @plugin[:softlayer] = { "local_ipv4" => "192.168.0.1",
+ plugin[:softlayer] = Mash.new
+ plugin[:softlayer] = { "local_ipv4" => "192.168.0.1",
"public_ipv4" => "8.8.8.8",
"public_fqdn" => "abc1234.public.com",
}
end
it "populates cloud public ip" do
- @plugin.run
- expect(@plugin[:cloud][:public_ipv4_addrs][0]).to eq(@plugin[:softlayer][:public_ipv4])
+ plugin.run
+ expect(plugin[:cloud][:public_ipv4_addrs][0]).to eq(plugin[:softlayer][:public_ipv4])
end
it "populates cloud private ip" do
- @plugin.run
- expect(@plugin[:cloud][:local_ipv4_addrs][0]).to eq(@plugin[:softlayer][:local_ipv4])
+ plugin.run
+ expect(plugin[:cloud][:local_ipv4_addrs][0]).to eq(plugin[:softlayer][:local_ipv4])
end
it "populates first cloud public ip" do
- @plugin.run
- expect(@plugin[:cloud][:public_ipv4_addrs].first).to eq(@plugin[:softlayer][:public_ipv4])
+ plugin.run
+ expect(plugin[:cloud][:public_ipv4_addrs].first).to eq(plugin[:softlayer][:public_ipv4])
end
it "populates cloud public_hostname" do
- @plugin.run
- expect(@plugin[:cloud][:public_hostname]).to eq(@plugin[:softlayer][:public_fqdn])
+ plugin.run
+ expect(plugin[:cloud][:public_hostname]).to eq(plugin[:softlayer][:public_fqdn])
end
it "populates cloud provider" do
- @plugin.run
- expect(@plugin[:cloud][:provider]).to eq("softlayer")
+ plugin.run
+ expect(plugin[:cloud][:provider]).to eq("softlayer")
end
end
diff --git a/spec/unit/plugins/darwin/cpu_spec.rb b/spec/unit/plugins/darwin/cpu_spec.rb
index 1c0313c4..f6104146 100644
--- a/spec/unit/plugins/darwin/cpu_spec.rb
+++ b/spec/unit/plugins/darwin/cpu_spec.rb
@@ -19,8 +19,9 @@
require "spec_helper"
describe Ohai::System, "Darwin cpu plugin" do
+ let(:plugin) { get_plugin("cpu") }
+
before do
- @plugin = get_plugin("cpu")
@stdout = <<~CTL
hw.ncpu: 8
hw.byteorder: 1234
@@ -77,48 +78,48 @@ describe Ohai::System, "Darwin cpu plugin" do
machdep.cpu.max_basic: 13
CTL
- allow(@plugin).to receive(:collect_os).and_return(:darwin)
- allow(@plugin).to receive(:shell_out).with("sysctl hw machdep").and_return(mock_shell_out(0, @stdout, ""))
- @plugin.run
+ allow(plugin).to receive(:collect_os).and_return(:darwin)
+ allow(plugin).to receive(:shell_out).with("sysctl hw machdep").and_return(mock_shell_out(0, @stdout, ""))
+ plugin.run
end
it "sets cpu[:cores] to 4" do
- expect(@plugin[:cpu][:cores]).to eq(4)
+ expect(plugin[:cpu][:cores]).to eq(4)
end
it "sets cpu[:total] to 8" do
- expect(@plugin[:cpu][:total]).to eq(8)
+ expect(plugin[:cpu][:total]).to eq(8)
end
it "sets cpu[:real] to 1" do
- expect(@plugin[:cpu][:real]).to eq(1)
+ expect(plugin[:cpu][:real]).to eq(1)
end
it "sets cpu[:mhz] to 2800" do
- expect(@plugin[:cpu][:mhz]).to eq(2800)
+ expect(plugin[:cpu][:mhz]).to eq(2800)
end
it "sets cpu[:vendor_id] to GenuineIntel" do
- expect(@plugin[:cpu][:vendor_id]).to eq("GenuineIntel")
+ expect(plugin[:cpu][:vendor_id]).to eq("GenuineIntel")
end
it "sets cpu[:model_name] to Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz" do
- expect(@plugin[:cpu][:model_name]).to eq("Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz")
+ expect(plugin[:cpu][:model_name]).to eq("Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz")
end
it "sets cpu[:model] to 70" do
- expect(@plugin[:cpu][:model]).to eq(70)
+ expect(plugin[:cpu][:model]).to eq(70)
end
it "sets cpu[:family] to 6" do
- expect(@plugin[:cpu][:family]).to eq(6)
+ expect(plugin[:cpu][:family]).to eq(6)
end
it "sets cpu[:stepping] to 1" do
- expect(@plugin[:cpu][:stepping]).to eq(1)
+ expect(plugin[:cpu][:stepping]).to eq(1)
end
it "sets cpu[:flags] to array of flags" do
- expect(@plugin[:cpu][:flags]).to eq(["fpu", "vme", "de", "pse", "tsc", "msr", "pae", "mce", "cx8", "apic", "sep", "mtrr", "pge", "mca", "cmov", "pat", "pse36", "clfsh", "ds", "acpi", "mmx", "fxsr", "sse", "sse2", "ss", "htt", "tm", "pbe", "sse3", "pclmulqdq", "dtes64", "mon", "dscpl", "vmx", "smx", "est", "tm2", "ssse3", "fma", "cx16", "tpr", "pdcm", "sse4.1", "sse4.2", "x2apic", "movbe", "popcnt", "aes", "pcid", "xsave", "osxsave", "seglim64", "tsctmr", "avx1.0", "rdrand", "f16c"])
+ expect(plugin[:cpu][:flags]).to eq(["fpu", "vme", "de", "pse", "tsc", "msr", "pae", "mce", "cx8", "apic", "sep", "mtrr", "pge", "mca", "cmov", "pat", "pse36", "clfsh", "ds", "acpi", "mmx", "fxsr", "sse", "sse2", "ss", "htt", "tm", "pbe", "sse3", "pclmulqdq", "dtes64", "mon", "dscpl", "vmx", "smx", "est", "tm2", "ssse3", "fma", "cx16", "tpr", "pdcm", "sse4.1", "sse4.2", "x2apic", "movbe", "popcnt", "aes", "pcid", "xsave", "osxsave", "seglim64", "tsctmr", "avx1.0", "rdrand", "f16c"])
end
end
diff --git a/spec/unit/plugins/darwin/hostname_spec.rb b/spec/unit/plugins/darwin/hostname_spec.rb
index b4ab4ccd..3dafcd12 100644
--- a/spec/unit/plugins/darwin/hostname_spec.rb
+++ b/spec/unit/plugins/darwin/hostname_spec.rb
@@ -19,12 +19,13 @@
require "spec_helper"
describe Ohai::System, "Darwin hostname plugin" do
+ let(:plugin) { get_plugin("hostname") }
+
before do
- @plugin = get_plugin("hostname")
- allow(@plugin).to receive(:collect_os).and_return(:darwin)
- allow(@plugin).to receive(:shell_out).with("hostname -s").and_return(mock_shell_out(0, "katie", ""))
- allow(@plugin).to receive(:shell_out).with("hostname").and_return(mock_shell_out(0, "katie.local", ""))
- allow(@plugin).to receive(:resolve_fqdn).and_return("katie.bethell")
+ allow(plugin).to receive(:collect_os).and_return(:darwin)
+ allow(plugin).to receive(:shell_out).with("hostname -s").and_return(mock_shell_out(0, "katie", ""))
+ allow(plugin).to receive(:shell_out).with("hostname").and_return(mock_shell_out(0, "katie.local", ""))
+ allow(plugin).to receive(:resolve_fqdn).and_return("katie.bethell")
end
it_should_check_from("darwin::hostname", "hostname", "hostname -s", "katie")
@@ -32,12 +33,12 @@ describe Ohai::System, "Darwin hostname plugin" do
it_should_check_from("linux::hostname", "machinename", "hostname", "katie.local")
it "uses #resolve_fqdn to find the fqdn" do
- @plugin.run
- expect(@plugin[:fqdn]).to eq("katie.bethell")
+ plugin.run
+ expect(plugin[:fqdn]).to eq("katie.bethell")
end
it "sets the domain to everything after the first dot of the fqdn" do
- @plugin.run
- expect(@plugin[:domain]).to eq("bethell")
+ plugin.run
+ expect(plugin[:domain]).to eq("bethell")
end
end
diff --git a/spec/unit/plugins/darwin/kernel_spec.rb b/spec/unit/plugins/darwin/kernel_spec.rb
index 2cf727be..ab9034ca 100644
--- a/spec/unit/plugins/darwin/kernel_spec.rb
+++ b/spec/unit/plugins/darwin/kernel_spec.rb
@@ -19,15 +19,16 @@
require "spec_helper"
describe Ohai::System, "Darwin kernel plugin" do
+ let(:plugin) { get_plugin("kernel") }
+
before do
- @plugin = get_plugin("kernel")
- allow(@plugin).to receive(:collect_os).and_return(:darwin)
- allow(@plugin).to receive(:init_kernel).and_return({})
+ allow(plugin).to receive(:collect_os).and_return(:darwin)
+ allow(plugin).to receive(:init_kernel).and_return({})
end
it "populates kernel[:modules] from `kextstat -k -l`" do
- allow(@plugin).to receive(:shell_out).with("sysctl -n hw.optional.x86_64").and_return(mock_shell_out(0, "0", ""))
- allow(@plugin).to receive(:shell_out).with("kextstat -k -l").and_return(mock_shell_out(0, <<EOF, ""))
+ allow(plugin).to receive(:shell_out).with("sysctl -n hw.optional.x86_64").and_return(mock_shell_out(0, "0", ""))
+ allow(plugin).to receive(:shell_out).with("kextstat -k -l").and_return(mock_shell_out(0, <<EOF, ""))
8 0 0xffffff7f81aed000 0x41000 0x41000 com.apple.kec.corecrypto (1.0) <7 6 5 4 3 1>
9 22 0xffffff7f807f3000 0x9000 0x9000 com.apple.iokit.IOACPIFamily (1.4) <7 6 4 3>
10 30 0xffffff7f80875000 0x29000 0x29000 com.apple.iokit.IOPCIFamily (2.8) <7 6 5 4 3>
@@ -38,28 +39,28 @@ EOF
"com.apple.iokit.IOACPIFamily" => { "version" => "1.4", "size" => 36864, "index" => "9", "refcount" => "22" },
"com.apple.iokit.IOPCIFamily" => { "version" => "2.8", "size" => 167936, "index" => "10", "refcount" => "30" } }
- @plugin.run
- expect(@plugin[:kernel][:modules]).to eql(modules)
+ plugin.run
+ expect(plugin[:kernel][:modules]).to eql(modules)
end
it "does not set kernel_machine to x86_64" do
- allow(@plugin).to receive(:shell_out).with("sysctl -n hw.optional.x86_64").and_return(mock_shell_out(0, "0", ""))
- allow(@plugin).to receive(:shell_out).with("kextstat -k -l").and_return(mock_shell_out(0, "", ""))
- @plugin.run
- expect(@plugin[:kernel][:machine]).not_to eq("x86_64")
+ allow(plugin).to receive(:shell_out).with("sysctl -n hw.optional.x86_64").and_return(mock_shell_out(0, "0", ""))
+ allow(plugin).to receive(:shell_out).with("kextstat -k -l").and_return(mock_shell_out(0, "", ""))
+ plugin.run
+ expect(plugin[:kernel][:machine]).not_to eq("x86_64")
end
it "sets kernel_machine to x86_64" do
- allow(@plugin).to receive(:shell_out).with("sysctl -n hw.optional.x86_64").and_return(mock_shell_out(0, "1", ""))
- allow(@plugin).to receive(:shell_out).with("kextstat -k -l").and_return(mock_shell_out(0, "", ""))
- @plugin.run
- expect(@plugin[:kernel][:machine]).to eq("x86_64")
+ allow(plugin).to receive(:shell_out).with("sysctl -n hw.optional.x86_64").and_return(mock_shell_out(0, "1", ""))
+ allow(plugin).to receive(:shell_out).with("kextstat -k -l").and_return(mock_shell_out(0, "", ""))
+ plugin.run
+ expect(plugin[:kernel][:machine]).to eq("x86_64")
end
it "sets the kernel_os to the kernel_name value" do
- allow(@plugin).to receive(:shell_out).with("sysctl -n hw.optional.x86_64").and_return(mock_shell_out(0, "1", ""))
- allow(@plugin).to receive(:shell_out).with("kextstat -k -l").and_return(mock_shell_out(0, "", ""))
- @plugin.run
- expect(@plugin[:kernel][:os]).to eq(@plugin[:kernel][:name])
+ allow(plugin).to receive(:shell_out).with("sysctl -n hw.optional.x86_64").and_return(mock_shell_out(0, "1", ""))
+ allow(plugin).to receive(:shell_out).with("kextstat -k -l").and_return(mock_shell_out(0, "", ""))
+ plugin.run
+ expect(plugin[:kernel][:os]).to eq(plugin[:kernel][:name])
end
end
diff --git a/spec/unit/plugins/darwin/memory_spec.rb b/spec/unit/plugins/darwin/memory_spec.rb
index 1baf96d0..dc476a91 100644
--- a/spec/unit/plugins/darwin/memory_spec.rb
+++ b/spec/unit/plugins/darwin/memory_spec.rb
@@ -19,6 +19,8 @@
require "spec_helper"
describe Ohai::System, "Darwin Memory Plugin" do
+ let(:plugin) { get_plugin("darwin/memory") }
+
before do
darwin_memsize = <<~DARWIN_MEMSIZE
17179869184
@@ -39,26 +41,25 @@ describe Ohai::System, "Darwin Memory Plugin" do
Object cache: 12 hits of 139872 lookups (0% hit rate)
DARWIN_VM_STAT
- @plugin = get_plugin("darwin/memory")
- allow(@plugin).to receive(:collect_os).and_return(:darwin)
- allow(@plugin).to receive(:shell_out).with("sysctl -n hw.memsize").and_return(mock_shell_out(0, darwin_memsize, ""))
- allow(@plugin).to receive(:shell_out).with("vm_stat").and_return(mock_shell_out(0, darwin_vm_stat, ""))
- @plugin.run
+ allow(plugin).to receive(:collect_os).and_return(:darwin)
+ allow(plugin).to receive(:shell_out).with("sysctl -n hw.memsize").and_return(mock_shell_out(0, darwin_memsize, ""))
+ allow(plugin).to receive(:shell_out).with("vm_stat").and_return(mock_shell_out(0, darwin_vm_stat, ""))
+ plugin.run
end
it "sets memory[:total] to 16384MB" do
- expect(@plugin[:memory][:total]).to eq("16384MB")
+ expect(plugin[:memory][:total]).to eq("16384MB")
end
it "sets memory[:active] to 5140MB" do
- expect(@plugin[:memory][:active]).to eq("5140MB")
+ expect(plugin[:memory][:active]).to eq("5140MB")
end
it "sets memory[:inactive] to 738MB" do
- expect(@plugin[:memory][:inactive]).to eq("738MB")
+ expect(plugin[:memory][:inactive]).to eq("738MB")
end
it "sets memory[:free] to 10504MB" do
- expect(@plugin[:memory][:free]).to eq("10504MB")
+ expect(plugin[:memory][:free]).to eq("10504MB")
end
end
diff --git a/spec/unit/plugins/darwin/network_spec.rb b/spec/unit/plugins/darwin/network_spec.rb
index 46e53518..c65bfd70 100644
--- a/spec/unit/plugins/darwin/network_spec.rb
+++ b/spec/unit/plugins/darwin/network_spec.rb
@@ -19,6 +19,8 @@
require "spec_helper"
describe Ohai::System, "Darwin Network Plugin" do
+ let(:plugin) { get_plugin("darwin/network") }
+
before do
@darwin_ifconfig = <<~DARWIN_IFCONFIG
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
@@ -412,8 +414,7 @@ describe Ohai::System, "Darwin Network Plugin" do
net.smb.fs.tcprcvbuf: 261120
DARWIN_SYSCTL
- @plugin = get_plugin("darwin/network")
- allow(@plugin).to receive(:collect_os).and_return(:darwin)
+ allow(plugin).to receive(:collect_os).and_return(:darwin)
# @stdin_ifconfig = StringIO.new
# @stdin_arp = StringIO.new
@@ -425,425 +426,425 @@ describe Ohai::System, "Darwin Network Plugin" do
# @netstat_lines = darwin_netstat.split("\n")
# @sysctl_lines = darwin_sysctl.split("\n")
- allow(@plugin).to receive(:shell_out).with("route -n get default").and_return(mock_shell_out(0, @darwin_route, ""))
- allow(@plugin).to receive(:shell_out).with("netstat -i -d -l -b -n")
+ allow(plugin).to receive(:shell_out).with("route -n get default").and_return(mock_shell_out(0, @darwin_route, ""))
+ allow(plugin).to receive(:shell_out).with("netstat -i -d -l -b -n")
end
describe "gathering IP layer address info" do
before do
- allow(@plugin).to receive(:shell_out).with("arp -an").and_return(mock_shell_out(0, @darwin_arp, ""))
- allow(@plugin).to receive(:shell_out).with("ifconfig -a").and_return(mock_shell_out(0, @darwin_ifconfig, ""))
- allow(@plugin).to receive(:shell_out).with("netstat -i -d -l -b -n").and_return(mock_shell_out(0, @darwin_netstat, ""))
- allow(@plugin).to receive(:shell_out).with("sysctl net").and_return(mock_shell_out(0, @darwin_sysctl, ""))
- @plugin.run
+ allow(plugin).to receive(:shell_out).with("arp -an").and_return(mock_shell_out(0, @darwin_arp, ""))
+ allow(plugin).to receive(:shell_out).with("ifconfig -a").and_return(mock_shell_out(0, @darwin_ifconfig, ""))
+ allow(plugin).to receive(:shell_out).with("netstat -i -d -l -b -n").and_return(mock_shell_out(0, @darwin_netstat, ""))
+ allow(plugin).to receive(:shell_out).with("sysctl net").and_return(mock_shell_out(0, @darwin_sysctl, ""))
+ plugin.run
end
it "completes the run" do
- expect(@plugin["network"]).not_to be_nil
+ expect(plugin["network"]).not_to be_nil
end
it "detects the interfaces" do
- expect(@plugin["network"]["interfaces"].keys.sort).to eq(%w{en0 en1 fw0 gif0 lo0 p2p0 stf0 utun0})
+ expect(plugin["network"]["interfaces"].keys.sort).to eq(%w{en0 en1 fw0 gif0 lo0 p2p0 stf0 utun0})
end
it "detects the ipv4 addresses of the ethernet interface" do
- expect(@plugin["network"]["interfaces"]["en1"]["addresses"].keys).to include("10.20.10.144")
- expect(@plugin["network"]["interfaces"]["en1"]["addresses"]["10.20.10.144"]["netmask"]).to eq("255.255.255.0")
- expect(@plugin["network"]["interfaces"]["en1"]["addresses"]["10.20.10.144"]["broadcast"]).to eq("10.20.10.255")
- expect(@plugin["network"]["interfaces"]["en1"]["addresses"]["10.20.10.144"]["family"]).to eq("inet")
+ expect(plugin["network"]["interfaces"]["en1"]["addresses"].keys).to include("10.20.10.144")
+ expect(plugin["network"]["interfaces"]["en1"]["addresses"]["10.20.10.144"]["netmask"]).to eq("255.255.255.0")
+ expect(plugin["network"]["interfaces"]["en1"]["addresses"]["10.20.10.144"]["broadcast"]).to eq("10.20.10.255")
+ expect(plugin["network"]["interfaces"]["en1"]["addresses"]["10.20.10.144"]["family"]).to eq("inet")
end
it "detects the ipv6 addresses of the ethernet interface" do
- expect(@plugin["network"]["interfaces"]["en1"]["addresses"].keys).to include("fe80::ba8d:12ff:fe3a:32de")
- expect(@plugin["network"]["interfaces"]["en1"]["addresses"]["fe80::ba8d:12ff:fe3a:32de"]["scope"]).to eq("Link")
- expect(@plugin["network"]["interfaces"]["en1"]["addresses"]["fe80::ba8d:12ff:fe3a:32de"]["prefixlen"]).to eq("64")
- expect(@plugin["network"]["interfaces"]["en1"]["addresses"]["fe80::ba8d:12ff:fe3a:32de"]["family"]).to eq("inet6")
-
- expect(@plugin["network"]["interfaces"]["en1"]["addresses"].keys).to include("2001:44b8:4186:1100:ba8d:12ff:fe3a:32de")
- expect(@plugin["network"]["interfaces"]["en1"]["addresses"]["2001:44b8:4186:1100:ba8d:12ff:fe3a:32de"]["scope"]).to eq("Global")
- expect(@plugin["network"]["interfaces"]["en1"]["addresses"]["2001:44b8:4186:1100:ba8d:12ff:fe3a:32de"]["prefixlen"]).to eq("64")
- expect(@plugin["network"]["interfaces"]["en1"]["addresses"]["2001:44b8:4186:1100:ba8d:12ff:fe3a:32de"]["family"]).to eq("inet6")
+ expect(plugin["network"]["interfaces"]["en1"]["addresses"].keys).to include("fe80::ba8d:12ff:fe3a:32de")
+ expect(plugin["network"]["interfaces"]["en1"]["addresses"]["fe80::ba8d:12ff:fe3a:32de"]["scope"]).to eq("Link")
+ expect(plugin["network"]["interfaces"]["en1"]["addresses"]["fe80::ba8d:12ff:fe3a:32de"]["prefixlen"]).to eq("64")
+ expect(plugin["network"]["interfaces"]["en1"]["addresses"]["fe80::ba8d:12ff:fe3a:32de"]["family"]).to eq("inet6")
+
+ expect(plugin["network"]["interfaces"]["en1"]["addresses"].keys).to include("2001:44b8:4186:1100:ba8d:12ff:fe3a:32de")
+ expect(plugin["network"]["interfaces"]["en1"]["addresses"]["2001:44b8:4186:1100:ba8d:12ff:fe3a:32de"]["scope"]).to eq("Global")
+ expect(plugin["network"]["interfaces"]["en1"]["addresses"]["2001:44b8:4186:1100:ba8d:12ff:fe3a:32de"]["prefixlen"]).to eq("64")
+ expect(plugin["network"]["interfaces"]["en1"]["addresses"]["2001:44b8:4186:1100:ba8d:12ff:fe3a:32de"]["family"]).to eq("inet6")
end
it "detects the mac addresses of the ethernet interface" do
- expect(@plugin["network"]["interfaces"]["en1"]["addresses"].keys).to include("b8:8d:12:3a:32:de")
- expect(@plugin["network"]["interfaces"]["en1"]["addresses"]["b8:8d:12:3a:32:de"]["family"]).to eq("lladdr")
+ expect(plugin["network"]["interfaces"]["en1"]["addresses"].keys).to include("b8:8d:12:3a:32:de")
+ expect(plugin["network"]["interfaces"]["en1"]["addresses"]["b8:8d:12:3a:32:de"]["family"]).to eq("lladdr")
end
it "detects the encapsulation type of the ethernet interface" do
- expect(@plugin["network"]["interfaces"]["en1"]["encapsulation"]).to eq("Ethernet")
+ expect(plugin["network"]["interfaces"]["en1"]["encapsulation"]).to eq("Ethernet")
end
it "detects the flags of the ethernet interface" do
- expect(@plugin["network"]["interfaces"]["en1"]["flags"].sort).to eq(%w{BROADCAST MULTICAST RUNNING SIMPLEX SMART UP})
+ expect(plugin["network"]["interfaces"]["en1"]["flags"].sort).to eq(%w{BROADCAST MULTICAST RUNNING SIMPLEX SMART UP})
end
it "detects the mtu of the ethernet interface" do
- expect(@plugin["network"]["interfaces"]["en1"]["mtu"]).to eq("1500")
+ expect(plugin["network"]["interfaces"]["en1"]["mtu"]).to eq("1500")
end
it "detects the ipv4 addresses of the loopback interface" do
- expect(@plugin["network"]["interfaces"]["lo0"]["addresses"].keys).to include("127.0.0.1")
- expect(@plugin["network"]["interfaces"]["lo0"]["addresses"]["127.0.0.1"]["netmask"]).to eq("255.0.0.0")
- expect(@plugin["network"]["interfaces"]["lo0"]["addresses"]["127.0.0.1"]["family"]).to eq("inet")
+ expect(plugin["network"]["interfaces"]["lo0"]["addresses"].keys).to include("127.0.0.1")
+ expect(plugin["network"]["interfaces"]["lo0"]["addresses"]["127.0.0.1"]["netmask"]).to eq("255.0.0.0")
+ expect(plugin["network"]["interfaces"]["lo0"]["addresses"]["127.0.0.1"]["family"]).to eq("inet")
end
it "detects the ipv6 addresses of the loopback interface" do
- expect(@plugin["network"]["interfaces"]["lo0"]["addresses"].keys).to include("::1")
- expect(@plugin["network"]["interfaces"]["lo0"]["addresses"]["::1"]["scope"]).to eq("Node")
- expect(@plugin["network"]["interfaces"]["lo0"]["addresses"]["::1"]["prefixlen"]).to eq("128")
- expect(@plugin["network"]["interfaces"]["lo0"]["addresses"]["::1"]["family"]).to eq("inet6")
+ expect(plugin["network"]["interfaces"]["lo0"]["addresses"].keys).to include("::1")
+ expect(plugin["network"]["interfaces"]["lo0"]["addresses"]["::1"]["scope"]).to eq("Node")
+ expect(plugin["network"]["interfaces"]["lo0"]["addresses"]["::1"]["prefixlen"]).to eq("128")
+ expect(plugin["network"]["interfaces"]["lo0"]["addresses"]["::1"]["family"]).to eq("inet6")
end
it "detects the encapsulation type of the loopback interface" do
- expect(@plugin["network"]["interfaces"]["lo0"]["encapsulation"]).to eq("Loopback")
+ expect(plugin["network"]["interfaces"]["lo0"]["encapsulation"]).to eq("Loopback")
end
it "detects the flags of the ethernet interface" do
- expect(@plugin["network"]["interfaces"]["lo0"]["flags"].sort).to eq(%w{LOOPBACK MULTICAST RUNNING UP})
+ expect(plugin["network"]["interfaces"]["lo0"]["flags"].sort).to eq(%w{LOOPBACK MULTICAST RUNNING UP})
end
it "detects the mtu of the loopback interface" do
- expect(@plugin["network"]["interfaces"]["lo0"]["mtu"]).to eq("16384")
+ expect(plugin["network"]["interfaces"]["lo0"]["mtu"]).to eq("16384")
end
it "detects the arp entries" do
- expect(@plugin["network"]["interfaces"]["en1"]["arp"]["10.20.10.1"]).to eq("0:4:ed:de:41:bf")
+ expect(plugin["network"]["interfaces"]["en1"]["arp"]["10.20.10.1"]).to eq("0:4:ed:de:41:bf")
end
it "detects the ethernet counters" do
- expect(@plugin["counters"]["network"]["interfaces"]["en1"]["tx"]["bytes"]).to eq("18228234970")
- expect(@plugin["counters"]["network"]["interfaces"]["en1"]["tx"]["packets"]).to eq("14314573")
- expect(@plugin["counters"]["network"]["interfaces"]["en1"]["tx"]["collisions"]).to eq("0")
- expect(@plugin["counters"]["network"]["interfaces"]["en1"]["tx"]["errors"]).to eq("0")
- expect(@plugin["counters"]["network"]["interfaces"]["en1"]["tx"]["carrier"]).to eq(0)
- expect(@plugin["counters"]["network"]["interfaces"]["en1"]["tx"]["drop"]).to eq(0)
-
- expect(@plugin["counters"]["network"]["interfaces"]["en1"]["rx"]["bytes"]).to eq("2530556736")
- expect(@plugin["counters"]["network"]["interfaces"]["en1"]["rx"]["packets"]).to eq("5921903")
- expect(@plugin["counters"]["network"]["interfaces"]["en1"]["rx"]["errors"]).to eq("0")
- expect(@plugin["counters"]["network"]["interfaces"]["en1"]["rx"]["overrun"]).to eq(0)
- expect(@plugin["counters"]["network"]["interfaces"]["en1"]["rx"]["drop"]).to eq(0)
+ expect(plugin["counters"]["network"]["interfaces"]["en1"]["tx"]["bytes"]).to eq("18228234970")
+ expect(plugin["counters"]["network"]["interfaces"]["en1"]["tx"]["packets"]).to eq("14314573")
+ expect(plugin["counters"]["network"]["interfaces"]["en1"]["tx"]["collisions"]).to eq("0")
+ expect(plugin["counters"]["network"]["interfaces"]["en1"]["tx"]["errors"]).to eq("0")
+ expect(plugin["counters"]["network"]["interfaces"]["en1"]["tx"]["carrier"]).to eq(0)
+ expect(plugin["counters"]["network"]["interfaces"]["en1"]["tx"]["drop"]).to eq(0)
+
+ expect(plugin["counters"]["network"]["interfaces"]["en1"]["rx"]["bytes"]).to eq("2530556736")
+ expect(plugin["counters"]["network"]["interfaces"]["en1"]["rx"]["packets"]).to eq("5921903")
+ expect(plugin["counters"]["network"]["interfaces"]["en1"]["rx"]["errors"]).to eq("0")
+ expect(plugin["counters"]["network"]["interfaces"]["en1"]["rx"]["overrun"]).to eq(0)
+ expect(plugin["counters"]["network"]["interfaces"]["en1"]["rx"]["drop"]).to eq(0)
end
it "detects the loopback counters" do
- expect(@plugin["counters"]["network"]["interfaces"]["lo0"]["tx"]["bytes"]).to eq("25774844")
- expect(@plugin["counters"]["network"]["interfaces"]["lo0"]["tx"]["packets"]).to eq("174982")
- expect(@plugin["counters"]["network"]["interfaces"]["lo0"]["tx"]["collisions"]).to eq("0")
- expect(@plugin["counters"]["network"]["interfaces"]["lo0"]["tx"]["errors"]).to eq("0")
- expect(@plugin["counters"]["network"]["interfaces"]["lo0"]["tx"]["carrier"]).to eq(0)
- expect(@plugin["counters"]["network"]["interfaces"]["lo0"]["tx"]["drop"]).to eq(0)
-
- expect(@plugin["counters"]["network"]["interfaces"]["lo0"]["rx"]["bytes"]).to eq("25774844")
- expect(@plugin["counters"]["network"]["interfaces"]["lo0"]["rx"]["packets"]).to eq("174982")
- expect(@plugin["counters"]["network"]["interfaces"]["lo0"]["rx"]["errors"]).to eq("0")
- expect(@plugin["counters"]["network"]["interfaces"]["lo0"]["rx"]["overrun"]).to eq(0)
- expect(@plugin["counters"]["network"]["interfaces"]["lo0"]["rx"]["drop"]).to eq(0)
+ expect(plugin["counters"]["network"]["interfaces"]["lo0"]["tx"]["bytes"]).to eq("25774844")
+ expect(plugin["counters"]["network"]["interfaces"]["lo0"]["tx"]["packets"]).to eq("174982")
+ expect(plugin["counters"]["network"]["interfaces"]["lo0"]["tx"]["collisions"]).to eq("0")
+ expect(plugin["counters"]["network"]["interfaces"]["lo0"]["tx"]["errors"]).to eq("0")
+ expect(plugin["counters"]["network"]["interfaces"]["lo0"]["tx"]["carrier"]).to eq(0)
+ expect(plugin["counters"]["network"]["interfaces"]["lo0"]["tx"]["drop"]).to eq(0)
+
+ expect(plugin["counters"]["network"]["interfaces"]["lo0"]["rx"]["bytes"]).to eq("25774844")
+ expect(plugin["counters"]["network"]["interfaces"]["lo0"]["rx"]["packets"]).to eq("174982")
+ expect(plugin["counters"]["network"]["interfaces"]["lo0"]["rx"]["errors"]).to eq("0")
+ expect(plugin["counters"]["network"]["interfaces"]["lo0"]["rx"]["overrun"]).to eq(0)
+ expect(plugin["counters"]["network"]["interfaces"]["lo0"]["rx"]["drop"]).to eq(0)
end
it "finds the default interface by asking which iface has the default route" do
- expect(@plugin["network"][:default_interface]).to eq("en1")
+ expect(plugin["network"][:default_interface]).to eq("en1")
end
it "finds the default interface by asking which iface has the default route" do
- expect(@plugin["network"][:default_gateway]).to eq("10.20.10.1")
+ expect(plugin["network"][:default_gateway]).to eq("10.20.10.1")
end
it "detects network settings" do
- expect(@plugin["network"]["settings"]["net.local.stream.sendspace"]).to eq("8192")
- expect(@plugin["network"]["settings"]["net.local.stream.recvspace"]).to eq("8192")
- expect(@plugin["network"]["settings"]["net.local.stream.tracemdns"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.local.dgram.maxdgram"]).to eq("2048")
- expect(@plugin["network"]["settings"]["net.local.dgram.recvspace"]).to eq("4096")
- expect(@plugin["network"]["settings"]["net.local.inflight"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet.ip.portrange.lowfirst"]).to eq("1023")
- expect(@plugin["network"]["settings"]["net.inet.ip.portrange.lowlast"]).to eq("600")
- expect(@plugin["network"]["settings"]["net.inet.ip.portrange.first"]).to eq("49152")
- expect(@plugin["network"]["settings"]["net.inet.ip.portrange.last"]).to eq("65535")
- expect(@plugin["network"]["settings"]["net.inet.ip.portrange.hifirst"]).to eq("49152")
- expect(@plugin["network"]["settings"]["net.inet.ip.portrange.hilast"]).to eq("65535")
- expect(@plugin["network"]["settings"]["net.inet.ip.forwarding"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet.ip.redirect"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet.ip.ttl"]).to eq("64")
- expect(@plugin["network"]["settings"]["net.inet.ip.rtexpire"]).to eq("12")
- expect(@plugin["network"]["settings"]["net.inet.ip.rtminexpire"]).to eq("10")
- expect(@plugin["network"]["settings"]["net.inet.ip.rtmaxcache"]).to eq("128")
- expect(@plugin["network"]["settings"]["net.inet.ip.sourceroute"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet.ip.intr_queue_maxlen"]).to eq("50")
- expect(@plugin["network"]["settings"]["net.inet.ip.intr_queue_drops"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet.ip.accept_sourceroute"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet.ip.keepfaith"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet.ip.gifttl"]).to eq("30")
- expect(@plugin["network"]["settings"]["net.inet.ip.subnets_are_local"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet.ip.mcast.maxgrpsrc"]).to eq("512")
- expect(@plugin["network"]["settings"]["net.inet.ip.mcast.maxsocksrc"]).to eq("128")
- expect(@plugin["network"]["settings"]["net.inet.ip.mcast.loop"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet.ip.check_route_selfref"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet.ip.use_route_genid"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet.ip.dummynet.hash_size"]).to eq("64")
- expect(@plugin["network"]["settings"]["net.inet.ip.dummynet.curr_time"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet.ip.dummynet.ready_heap"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet.ip.dummynet.extract_heap"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet.ip.dummynet.searches"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet.ip.dummynet.search_steps"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet.ip.dummynet.expire"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet.ip.dummynet.max_chain_len"]).to eq("16")
- expect(@plugin["network"]["settings"]["net.inet.ip.dummynet.red_lookup_depth"]).to eq("256")
- expect(@plugin["network"]["settings"]["net.inet.ip.dummynet.red_avg_pkt_size"]).to eq("512")
- expect(@plugin["network"]["settings"]["net.inet.ip.dummynet.red_max_pkt_size"]).to eq("1500")
- expect(@plugin["network"]["settings"]["net.inet.ip.dummynet.debug"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet.ip.fw.enable"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet.ip.fw.autoinc_step"]).to eq("100")
- expect(@plugin["network"]["settings"]["net.inet.ip.fw.one_pass"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet.ip.fw.debug"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet.ip.fw.verbose"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet.ip.fw.verbose_limit"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet.ip.fw.dyn_buckets"]).to eq("256")
- expect(@plugin["network"]["settings"]["net.inet.ip.fw.curr_dyn_buckets"]).to eq("256")
- expect(@plugin["network"]["settings"]["net.inet.ip.fw.dyn_count"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet.ip.fw.dyn_max"]).to eq("4096")
- expect(@plugin["network"]["settings"]["net.inet.ip.fw.static_count"]).to eq("2")
- expect(@plugin["network"]["settings"]["net.inet.ip.fw.dyn_ack_lifetime"]).to eq("300")
- expect(@plugin["network"]["settings"]["net.inet.ip.fw.dyn_syn_lifetime"]).to eq("20")
- expect(@plugin["network"]["settings"]["net.inet.ip.fw.dyn_fin_lifetime"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet.ip.fw.dyn_rst_lifetime"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet.ip.fw.dyn_udp_lifetime"]).to eq("10")
- expect(@plugin["network"]["settings"]["net.inet.ip.fw.dyn_short_lifetime"]).to eq("5")
- expect(@plugin["network"]["settings"]["net.inet.ip.fw.dyn_keepalive"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet.ip.maxfragpackets"]).to eq("1536")
- expect(@plugin["network"]["settings"]["net.inet.ip.maxfragsperpacket"]).to eq("128")
- expect(@plugin["network"]["settings"]["net.inet.ip.maxfrags"]).to eq("3072")
- expect(@plugin["network"]["settings"]["net.inet.ip.scopedroute"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet.ip.check_interface"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet.ip.linklocal.in.allowbadttl"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet.ip.random_id"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet.ip.maxchainsent"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet.ip.select_srcif_debug"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet.icmp.maskrepl"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet.icmp.icmplim"]).to eq("250")
- expect(@plugin["network"]["settings"]["net.inet.icmp.timestamp"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet.icmp.drop_redirect"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet.icmp.log_redirect"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet.icmp.bmcastecho"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet.igmp.recvifkludge"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet.igmp.sendra"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet.igmp.sendlocal"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet.igmp.v1enable"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet.igmp.v2enable"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet.igmp.legacysupp"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet.igmp.default_version"]).to eq("3")
- expect(@plugin["network"]["settings"]["net.inet.igmp.gsrdelay"]).to eq("10")
- expect(@plugin["network"]["settings"]["net.inet.igmp.debug"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet.tcp.rfc1323"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet.tcp.rfc1644"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet.tcp.mssdflt"]).to eq("512")
- expect(@plugin["network"]["settings"]["net.inet.tcp.keepidle"]).to eq("7200000")
- expect(@plugin["network"]["settings"]["net.inet.tcp.keepintvl"]).to eq("75000")
- expect(@plugin["network"]["settings"]["net.inet.tcp.sendspace"]).to eq("65536")
- expect(@plugin["network"]["settings"]["net.inet.tcp.recvspace"]).to eq("65536")
- expect(@plugin["network"]["settings"]["net.inet.tcp.keepinit"]).to eq("75000")
- expect(@plugin["network"]["settings"]["net.inet.tcp.v6mssdflt"]).to eq("1024")
- expect(@plugin["network"]["settings"]["net.inet.tcp.log_in_vain"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet.tcp.blackhole"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet.tcp.delayed_ack"]).to eq("3")
- expect(@plugin["network"]["settings"]["net.inet.tcp.tcp_lq_overflow"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet.tcp.recvbg"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet.tcp.drop_synfin"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet.tcp.reass.maxsegments"]).to eq("3072")
- expect(@plugin["network"]["settings"]["net.inet.tcp.reass.cursegments"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet.tcp.reass.overflows"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet.tcp.slowlink_wsize"]).to eq("8192")
- expect(@plugin["network"]["settings"]["net.inet.tcp.maxseg_unacked"]).to eq("8")
- expect(@plugin["network"]["settings"]["net.inet.tcp.rfc3465"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet.tcp.rfc3465_lim2"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet.tcp.rtt_samples_per_slot"]).to eq("20")
- expect(@plugin["network"]["settings"]["net.inet.tcp.recv_allowed_iaj"]).to eq("5")
- expect(@plugin["network"]["settings"]["net.inet.tcp.acc_iaj_high_thresh"]).to eq("100")
- expect(@plugin["network"]["settings"]["net.inet.tcp.rexmt_thresh"]).to eq("2")
- expect(@plugin["network"]["settings"]["net.inet.tcp.path_mtu_discovery"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet.tcp.slowstart_flightsize"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet.tcp.local_slowstart_flightsize"]).to eq("8")
- expect(@plugin["network"]["settings"]["net.inet.tcp.tso"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet.tcp.ecn_initiate_out"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet.tcp.ecn_negotiate_in"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet.tcp.packetchain"]).to eq("50")
- expect(@plugin["network"]["settings"]["net.inet.tcp.socket_unlocked_on_output"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet.tcp.rfc3390"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet.tcp.min_iaj_win"]).to eq("4")
- expect(@plugin["network"]["settings"]["net.inet.tcp.acc_iaj_react_limit"]).to eq("200")
- expect(@plugin["network"]["settings"]["net.inet.tcp.sack"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet.tcp.sack_maxholes"]).to eq("128")
- expect(@plugin["network"]["settings"]["net.inet.tcp.sack_globalmaxholes"]).to eq("65536")
- expect(@plugin["network"]["settings"]["net.inet.tcp.sack_globalholes"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet.tcp.minmss"]).to eq("216")
- expect(@plugin["network"]["settings"]["net.inet.tcp.minmssoverload"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet.tcp.do_tcpdrain"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet.tcp.pcbcount"]).to eq("86")
- expect(@plugin["network"]["settings"]["net.inet.tcp.icmp_may_rst"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet.tcp.strict_rfc1948"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet.tcp.isn_reseed_interval"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet.tcp.background_io_enabled"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet.tcp.rtt_min"]).to eq("100")
- expect(@plugin["network"]["settings"]["net.inet.tcp.rexmt_slop"]).to eq("200")
- expect(@plugin["network"]["settings"]["net.inet.tcp.randomize_ports"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet.tcp.newreno_sockets"]).to eq("81")
- expect(@plugin["network"]["settings"]["net.inet.tcp.background_sockets"]).to eq("-1")
- expect(@plugin["network"]["settings"]["net.inet.tcp.tcbhashsize"]).to eq("4096")
- expect(@plugin["network"]["settings"]["net.inet.tcp.background_io_trigger"]).to eq("5")
- expect(@plugin["network"]["settings"]["net.inet.tcp.msl"]).to eq("15000")
- expect(@plugin["network"]["settings"]["net.inet.tcp.max_persist_timeout"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet.tcp.always_keepalive"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet.tcp.timer_fastmode_idlemax"]).to eq("20")
- expect(@plugin["network"]["settings"]["net.inet.tcp.broken_peer_syn_rxmit_thres"]).to eq("7")
- expect(@plugin["network"]["settings"]["net.inet.tcp.tcp_timer_advanced"]).to eq("5")
- expect(@plugin["network"]["settings"]["net.inet.tcp.tcp_resched_timerlist"]).to eq("12209")
- expect(@plugin["network"]["settings"]["net.inet.tcp.pmtud_blackhole_detection"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet.tcp.pmtud_blackhole_mss"]).to eq("1200")
- expect(@plugin["network"]["settings"]["net.inet.tcp.timer_fastquantum"]).to eq("100")
- expect(@plugin["network"]["settings"]["net.inet.tcp.timer_slowquantum"]).to eq("500")
- expect(@plugin["network"]["settings"]["net.inet.tcp.win_scale_factor"]).to eq("3")
- expect(@plugin["network"]["settings"]["net.inet.tcp.sockthreshold"]).to eq("64")
- expect(@plugin["network"]["settings"]["net.inet.tcp.bg_target_qdelay"]).to eq("100")
- expect(@plugin["network"]["settings"]["net.inet.tcp.bg_allowed_increase"]).to eq("2")
- expect(@plugin["network"]["settings"]["net.inet.tcp.bg_tether_shift"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet.tcp.bg_ss_fltsz"]).to eq("2")
- expect(@plugin["network"]["settings"]["net.inet.udp.checksum"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet.udp.maxdgram"]).to eq("9216")
- expect(@plugin["network"]["settings"]["net.inet.udp.recvspace"]).to eq("42080")
- expect(@plugin["network"]["settings"]["net.inet.udp.log_in_vain"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet.udp.blackhole"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet.udp.pcbcount"]).to eq("72")
- expect(@plugin["network"]["settings"]["net.inet.udp.randomize_ports"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet.ipsec.def_policy"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet.ipsec.esp_trans_deflev"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet.ipsec.esp_net_deflev"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet.ipsec.ah_trans_deflev"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet.ipsec.ah_net_deflev"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet.ipsec.ah_cleartos"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet.ipsec.ah_offsetmask"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet.ipsec.dfbit"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet.ipsec.ecn"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet.ipsec.debug"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet.ipsec.esp_randpad"]).to eq("-1")
- expect(@plugin["network"]["settings"]["net.inet.ipsec.bypass"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet.ipsec.esp_port"]).to eq("4500")
- expect(@plugin["network"]["settings"]["net.inet.raw.maxdgram"]).to eq("8192")
- expect(@plugin["network"]["settings"]["net.inet.raw.recvspace"]).to eq("8192")
- expect(@plugin["network"]["settings"]["net.link.generic.system.ifcount"]).to eq("10")
- expect(@plugin["network"]["settings"]["net.link.generic.system.dlil_verbose"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.link.generic.system.multi_threaded_input"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.link.generic.system.dlil_input_sanity_check"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.link.ether.inet.prune_intvl"]).to eq("300")
- expect(@plugin["network"]["settings"]["net.link.ether.inet.max_age"]).to eq("1200")
- expect(@plugin["network"]["settings"]["net.link.ether.inet.host_down_time"]).to eq("20")
- expect(@plugin["network"]["settings"]["net.link.ether.inet.apple_hwcksum_tx"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.link.ether.inet.apple_hwcksum_rx"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.link.ether.inet.arp_llreach_base"]).to eq("30")
- expect(@plugin["network"]["settings"]["net.link.ether.inet.maxtries"]).to eq("5")
- expect(@plugin["network"]["settings"]["net.link.ether.inet.useloopback"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.link.ether.inet.proxyall"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.link.ether.inet.sendllconflict"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.link.ether.inet.log_arp_warnings"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.link.ether.inet.keep_announcements"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.link.ether.inet.send_conflicting_probes"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.link.bridge.log_stp"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.link.bridge.debug"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.key.debug"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.key.spi_trycnt"]).to eq("1000")
- expect(@plugin["network"]["settings"]["net.key.spi_minval"]).to eq("256")
- expect(@plugin["network"]["settings"]["net.key.spi_maxval"]).to eq("268435455")
- expect(@plugin["network"]["settings"]["net.key.int_random"]).to eq("60")
- expect(@plugin["network"]["settings"]["net.key.larval_lifetime"]).to eq("30")
- expect(@plugin["network"]["settings"]["net.key.blockacq_count"]).to eq("10")
- expect(@plugin["network"]["settings"]["net.key.blockacq_lifetime"]).to eq("20")
- expect(@plugin["network"]["settings"]["net.key.esp_keymin"]).to eq("256")
- expect(@plugin["network"]["settings"]["net.key.esp_auth"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.key.ah_keymin"]).to eq("128")
- expect(@plugin["network"]["settings"]["net.key.prefered_oldsa"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.key.natt_keepalive_interval"]).to eq("20")
- expect(@plugin["network"]["settings"]["net.inet6.ip6.forwarding"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet6.ip6.redirect"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet6.ip6.hlim"]).to eq("64")
- expect(@plugin["network"]["settings"]["net.inet6.ip6.maxfragpackets"]).to eq("1536")
- expect(@plugin["network"]["settings"]["net.inet6.ip6.accept_rtadv"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet6.ip6.keepfaith"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet6.ip6.log_interval"]).to eq("5")
- expect(@plugin["network"]["settings"]["net.inet6.ip6.hdrnestlimit"]).to eq("15")
- expect(@plugin["network"]["settings"]["net.inet6.ip6.dad_count"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet6.ip6.auto_flowlabel"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet6.ip6.defmcasthlim"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet6.ip6.gifhlim"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet6.ip6.kame_version"]).to eq("2009/apple-darwin")
- expect(@plugin["network"]["settings"]["net.inet6.ip6.use_deprecated"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet6.ip6.rr_prune"]).to eq("5")
- expect(@plugin["network"]["settings"]["net.inet6.ip6.v6only"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet6.ip6.rtexpire"]).to eq("3600")
- expect(@plugin["network"]["settings"]["net.inet6.ip6.rtminexpire"]).to eq("10")
- expect(@plugin["network"]["settings"]["net.inet6.ip6.rtmaxcache"]).to eq("128")
- expect(@plugin["network"]["settings"]["net.inet6.ip6.use_tempaddr"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet6.ip6.temppltime"]).to eq("86400")
- expect(@plugin["network"]["settings"]["net.inet6.ip6.tempvltime"]).to eq("604800")
- expect(@plugin["network"]["settings"]["net.inet6.ip6.auto_linklocal"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet6.ip6.prefer_tempaddr"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet6.ip6.use_defaultzone"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet6.ip6.maxfrags"]).to eq("12288")
- expect(@plugin["network"]["settings"]["net.inet6.ip6.mcast_pmtu"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet6.ip6.neighborgcthresh"]).to eq("1024")
- expect(@plugin["network"]["settings"]["net.inet6.ip6.maxifprefixes"]).to eq("16")
- expect(@plugin["network"]["settings"]["net.inet6.ip6.maxifdefrouters"]).to eq("16")
- expect(@plugin["network"]["settings"]["net.inet6.ip6.maxdynroutes"]).to eq("1024")
- expect(@plugin["network"]["settings"]["net.inet6.ip6.fw.enable"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet6.ip6.fw.debug"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet6.ip6.fw.verbose"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet6.ip6.fw.verbose_limit"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet6.ip6.scopedroute"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet6.ip6.select_srcif_debug"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet6.ip6.mcast.maxgrpsrc"]).to eq("512")
- expect(@plugin["network"]["settings"]["net.inet6.ip6.mcast.maxsocksrc"]).to eq("128")
- expect(@plugin["network"]["settings"]["net.inet6.ip6.mcast.loop"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet6.ip6.only_allow_rfc4193_prefixes"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet6.ipsec6.def_policy"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet6.ipsec6.esp_trans_deflev"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet6.ipsec6.esp_net_deflev"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet6.ipsec6.ah_trans_deflev"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet6.ipsec6.ah_net_deflev"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet6.ipsec6.ecn"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet6.ipsec6.debug"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet6.ipsec6.esp_randpad"]).to eq("-1")
- expect(@plugin["network"]["settings"]["net.inet6.icmp6.rediraccept"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet6.icmp6.redirtimeout"]).to eq("600")
- expect(@plugin["network"]["settings"]["net.inet6.icmp6.nd6_prune"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet6.icmp6.nd6_delay"]).to eq("5")
- expect(@plugin["network"]["settings"]["net.inet6.icmp6.nd6_umaxtries"]).to eq("3")
- expect(@plugin["network"]["settings"]["net.inet6.icmp6.nd6_mmaxtries"]).to eq("3")
- expect(@plugin["network"]["settings"]["net.inet6.icmp6.nd6_useloopback"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet6.icmp6.nodeinfo"]).to eq("3")
- expect(@plugin["network"]["settings"]["net.inet6.icmp6.errppslimit"]).to eq("500")
- expect(@plugin["network"]["settings"]["net.inet6.icmp6.nd6_maxnudhint"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet6.icmp6.nd6_debug"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet6.icmp6.nd6_accept_6to4"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet6.icmp6.nd6_onlink_ns_rfc4861"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.inet6.icmp6.nd6_llreach_base"]).to eq("30")
- expect(@plugin["network"]["settings"]["net.inet6.mld.gsrdelay"]).to eq("10")
- expect(@plugin["network"]["settings"]["net.inet6.mld.v1enable"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet6.mld.use_allow"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.inet6.mld.debug"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.idle.route.expire_timeout"]).to eq("30")
- expect(@plugin["network"]["settings"]["net.idle.route.drain_interval"]).to eq("10")
- expect(@plugin["network"]["settings"]["net.statistics"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.alf.loglevel"]).to eq("55")
- expect(@plugin["network"]["settings"]["net.alf.perm"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.alf.defaultaction"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.alf.mqcount"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.smb.fs.version"]).to eq("107000")
- expect(@plugin["network"]["settings"]["net.smb.fs.loglevel"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.smb.fs.kern_ntlmssp"]).to eq("0")
- expect(@plugin["network"]["settings"]["net.smb.fs.kern_deprecatePreXPServers"]).to eq("1")
- expect(@plugin["network"]["settings"]["net.smb.fs.kern_deadtimer"]).to eq("60")
- expect(@plugin["network"]["settings"]["net.smb.fs.kern_hard_deadtimer"]).to eq("600")
- expect(@plugin["network"]["settings"]["net.smb.fs.kern_soft_deadtimer"]).to eq("30")
- expect(@plugin["network"]["settings"]["net.smb.fs.tcpsndbuf"]).to eq("261120")
- expect(@plugin["network"]["settings"]["net.smb.fs.tcprcvbuf"]).to eq("261120")
+ expect(plugin["network"]["settings"]["net.local.stream.sendspace"]).to eq("8192")
+ expect(plugin["network"]["settings"]["net.local.stream.recvspace"]).to eq("8192")
+ expect(plugin["network"]["settings"]["net.local.stream.tracemdns"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.local.dgram.maxdgram"]).to eq("2048")
+ expect(plugin["network"]["settings"]["net.local.dgram.recvspace"]).to eq("4096")
+ expect(plugin["network"]["settings"]["net.local.inflight"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet.ip.portrange.lowfirst"]).to eq("1023")
+ expect(plugin["network"]["settings"]["net.inet.ip.portrange.lowlast"]).to eq("600")
+ expect(plugin["network"]["settings"]["net.inet.ip.portrange.first"]).to eq("49152")
+ expect(plugin["network"]["settings"]["net.inet.ip.portrange.last"]).to eq("65535")
+ expect(plugin["network"]["settings"]["net.inet.ip.portrange.hifirst"]).to eq("49152")
+ expect(plugin["network"]["settings"]["net.inet.ip.portrange.hilast"]).to eq("65535")
+ expect(plugin["network"]["settings"]["net.inet.ip.forwarding"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet.ip.redirect"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet.ip.ttl"]).to eq("64")
+ expect(plugin["network"]["settings"]["net.inet.ip.rtexpire"]).to eq("12")
+ expect(plugin["network"]["settings"]["net.inet.ip.rtminexpire"]).to eq("10")
+ expect(plugin["network"]["settings"]["net.inet.ip.rtmaxcache"]).to eq("128")
+ expect(plugin["network"]["settings"]["net.inet.ip.sourceroute"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet.ip.intr_queue_maxlen"]).to eq("50")
+ expect(plugin["network"]["settings"]["net.inet.ip.intr_queue_drops"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet.ip.accept_sourceroute"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet.ip.keepfaith"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet.ip.gifttl"]).to eq("30")
+ expect(plugin["network"]["settings"]["net.inet.ip.subnets_are_local"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet.ip.mcast.maxgrpsrc"]).to eq("512")
+ expect(plugin["network"]["settings"]["net.inet.ip.mcast.maxsocksrc"]).to eq("128")
+ expect(plugin["network"]["settings"]["net.inet.ip.mcast.loop"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet.ip.check_route_selfref"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet.ip.use_route_genid"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet.ip.dummynet.hash_size"]).to eq("64")
+ expect(plugin["network"]["settings"]["net.inet.ip.dummynet.curr_time"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet.ip.dummynet.ready_heap"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet.ip.dummynet.extract_heap"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet.ip.dummynet.searches"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet.ip.dummynet.search_steps"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet.ip.dummynet.expire"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet.ip.dummynet.max_chain_len"]).to eq("16")
+ expect(plugin["network"]["settings"]["net.inet.ip.dummynet.red_lookup_depth"]).to eq("256")
+ expect(plugin["network"]["settings"]["net.inet.ip.dummynet.red_avg_pkt_size"]).to eq("512")
+ expect(plugin["network"]["settings"]["net.inet.ip.dummynet.red_max_pkt_size"]).to eq("1500")
+ expect(plugin["network"]["settings"]["net.inet.ip.dummynet.debug"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet.ip.fw.enable"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet.ip.fw.autoinc_step"]).to eq("100")
+ expect(plugin["network"]["settings"]["net.inet.ip.fw.one_pass"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet.ip.fw.debug"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet.ip.fw.verbose"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet.ip.fw.verbose_limit"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet.ip.fw.dyn_buckets"]).to eq("256")
+ expect(plugin["network"]["settings"]["net.inet.ip.fw.curr_dyn_buckets"]).to eq("256")
+ expect(plugin["network"]["settings"]["net.inet.ip.fw.dyn_count"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet.ip.fw.dyn_max"]).to eq("4096")
+ expect(plugin["network"]["settings"]["net.inet.ip.fw.static_count"]).to eq("2")
+ expect(plugin["network"]["settings"]["net.inet.ip.fw.dyn_ack_lifetime"]).to eq("300")
+ expect(plugin["network"]["settings"]["net.inet.ip.fw.dyn_syn_lifetime"]).to eq("20")
+ expect(plugin["network"]["settings"]["net.inet.ip.fw.dyn_fin_lifetime"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet.ip.fw.dyn_rst_lifetime"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet.ip.fw.dyn_udp_lifetime"]).to eq("10")
+ expect(plugin["network"]["settings"]["net.inet.ip.fw.dyn_short_lifetime"]).to eq("5")
+ expect(plugin["network"]["settings"]["net.inet.ip.fw.dyn_keepalive"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet.ip.maxfragpackets"]).to eq("1536")
+ expect(plugin["network"]["settings"]["net.inet.ip.maxfragsperpacket"]).to eq("128")
+ expect(plugin["network"]["settings"]["net.inet.ip.maxfrags"]).to eq("3072")
+ expect(plugin["network"]["settings"]["net.inet.ip.scopedroute"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet.ip.check_interface"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet.ip.linklocal.in.allowbadttl"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet.ip.random_id"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet.ip.maxchainsent"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet.ip.select_srcif_debug"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet.icmp.maskrepl"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet.icmp.icmplim"]).to eq("250")
+ expect(plugin["network"]["settings"]["net.inet.icmp.timestamp"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet.icmp.drop_redirect"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet.icmp.log_redirect"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet.icmp.bmcastecho"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet.igmp.recvifkludge"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet.igmp.sendra"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet.igmp.sendlocal"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet.igmp.v1enable"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet.igmp.v2enable"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet.igmp.legacysupp"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet.igmp.default_version"]).to eq("3")
+ expect(plugin["network"]["settings"]["net.inet.igmp.gsrdelay"]).to eq("10")
+ expect(plugin["network"]["settings"]["net.inet.igmp.debug"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet.tcp.rfc1323"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet.tcp.rfc1644"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet.tcp.mssdflt"]).to eq("512")
+ expect(plugin["network"]["settings"]["net.inet.tcp.keepidle"]).to eq("7200000")
+ expect(plugin["network"]["settings"]["net.inet.tcp.keepintvl"]).to eq("75000")
+ expect(plugin["network"]["settings"]["net.inet.tcp.sendspace"]).to eq("65536")
+ expect(plugin["network"]["settings"]["net.inet.tcp.recvspace"]).to eq("65536")
+ expect(plugin["network"]["settings"]["net.inet.tcp.keepinit"]).to eq("75000")
+ expect(plugin["network"]["settings"]["net.inet.tcp.v6mssdflt"]).to eq("1024")
+ expect(plugin["network"]["settings"]["net.inet.tcp.log_in_vain"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet.tcp.blackhole"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet.tcp.delayed_ack"]).to eq("3")
+ expect(plugin["network"]["settings"]["net.inet.tcp.tcp_lq_overflow"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet.tcp.recvbg"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet.tcp.drop_synfin"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet.tcp.reass.maxsegments"]).to eq("3072")
+ expect(plugin["network"]["settings"]["net.inet.tcp.reass.cursegments"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet.tcp.reass.overflows"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet.tcp.slowlink_wsize"]).to eq("8192")
+ expect(plugin["network"]["settings"]["net.inet.tcp.maxseg_unacked"]).to eq("8")
+ expect(plugin["network"]["settings"]["net.inet.tcp.rfc3465"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet.tcp.rfc3465_lim2"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet.tcp.rtt_samples_per_slot"]).to eq("20")
+ expect(plugin["network"]["settings"]["net.inet.tcp.recv_allowed_iaj"]).to eq("5")
+ expect(plugin["network"]["settings"]["net.inet.tcp.acc_iaj_high_thresh"]).to eq("100")
+ expect(plugin["network"]["settings"]["net.inet.tcp.rexmt_thresh"]).to eq("2")
+ expect(plugin["network"]["settings"]["net.inet.tcp.path_mtu_discovery"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet.tcp.slowstart_flightsize"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet.tcp.local_slowstart_flightsize"]).to eq("8")
+ expect(plugin["network"]["settings"]["net.inet.tcp.tso"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet.tcp.ecn_initiate_out"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet.tcp.ecn_negotiate_in"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet.tcp.packetchain"]).to eq("50")
+ expect(plugin["network"]["settings"]["net.inet.tcp.socket_unlocked_on_output"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet.tcp.rfc3390"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet.tcp.min_iaj_win"]).to eq("4")
+ expect(plugin["network"]["settings"]["net.inet.tcp.acc_iaj_react_limit"]).to eq("200")
+ expect(plugin["network"]["settings"]["net.inet.tcp.sack"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet.tcp.sack_maxholes"]).to eq("128")
+ expect(plugin["network"]["settings"]["net.inet.tcp.sack_globalmaxholes"]).to eq("65536")
+ expect(plugin["network"]["settings"]["net.inet.tcp.sack_globalholes"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet.tcp.minmss"]).to eq("216")
+ expect(plugin["network"]["settings"]["net.inet.tcp.minmssoverload"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet.tcp.do_tcpdrain"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet.tcp.pcbcount"]).to eq("86")
+ expect(plugin["network"]["settings"]["net.inet.tcp.icmp_may_rst"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet.tcp.strict_rfc1948"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet.tcp.isn_reseed_interval"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet.tcp.background_io_enabled"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet.tcp.rtt_min"]).to eq("100")
+ expect(plugin["network"]["settings"]["net.inet.tcp.rexmt_slop"]).to eq("200")
+ expect(plugin["network"]["settings"]["net.inet.tcp.randomize_ports"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet.tcp.newreno_sockets"]).to eq("81")
+ expect(plugin["network"]["settings"]["net.inet.tcp.background_sockets"]).to eq("-1")
+ expect(plugin["network"]["settings"]["net.inet.tcp.tcbhashsize"]).to eq("4096")
+ expect(plugin["network"]["settings"]["net.inet.tcp.background_io_trigger"]).to eq("5")
+ expect(plugin["network"]["settings"]["net.inet.tcp.msl"]).to eq("15000")
+ expect(plugin["network"]["settings"]["net.inet.tcp.max_persist_timeout"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet.tcp.always_keepalive"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet.tcp.timer_fastmode_idlemax"]).to eq("20")
+ expect(plugin["network"]["settings"]["net.inet.tcp.broken_peer_syn_rxmit_thres"]).to eq("7")
+ expect(plugin["network"]["settings"]["net.inet.tcp.tcp_timer_advanced"]).to eq("5")
+ expect(plugin["network"]["settings"]["net.inet.tcp.tcp_resched_timerlist"]).to eq("12209")
+ expect(plugin["network"]["settings"]["net.inet.tcp.pmtud_blackhole_detection"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet.tcp.pmtud_blackhole_mss"]).to eq("1200")
+ expect(plugin["network"]["settings"]["net.inet.tcp.timer_fastquantum"]).to eq("100")
+ expect(plugin["network"]["settings"]["net.inet.tcp.timer_slowquantum"]).to eq("500")
+ expect(plugin["network"]["settings"]["net.inet.tcp.win_scale_factor"]).to eq("3")
+ expect(plugin["network"]["settings"]["net.inet.tcp.sockthreshold"]).to eq("64")
+ expect(plugin["network"]["settings"]["net.inet.tcp.bg_target_qdelay"]).to eq("100")
+ expect(plugin["network"]["settings"]["net.inet.tcp.bg_allowed_increase"]).to eq("2")
+ expect(plugin["network"]["settings"]["net.inet.tcp.bg_tether_shift"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet.tcp.bg_ss_fltsz"]).to eq("2")
+ expect(plugin["network"]["settings"]["net.inet.udp.checksum"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet.udp.maxdgram"]).to eq("9216")
+ expect(plugin["network"]["settings"]["net.inet.udp.recvspace"]).to eq("42080")
+ expect(plugin["network"]["settings"]["net.inet.udp.log_in_vain"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet.udp.blackhole"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet.udp.pcbcount"]).to eq("72")
+ expect(plugin["network"]["settings"]["net.inet.udp.randomize_ports"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet.ipsec.def_policy"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet.ipsec.esp_trans_deflev"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet.ipsec.esp_net_deflev"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet.ipsec.ah_trans_deflev"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet.ipsec.ah_net_deflev"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet.ipsec.ah_cleartos"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet.ipsec.ah_offsetmask"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet.ipsec.dfbit"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet.ipsec.ecn"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet.ipsec.debug"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet.ipsec.esp_randpad"]).to eq("-1")
+ expect(plugin["network"]["settings"]["net.inet.ipsec.bypass"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet.ipsec.esp_port"]).to eq("4500")
+ expect(plugin["network"]["settings"]["net.inet.raw.maxdgram"]).to eq("8192")
+ expect(plugin["network"]["settings"]["net.inet.raw.recvspace"]).to eq("8192")
+ expect(plugin["network"]["settings"]["net.link.generic.system.ifcount"]).to eq("10")
+ expect(plugin["network"]["settings"]["net.link.generic.system.dlil_verbose"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.link.generic.system.multi_threaded_input"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.link.generic.system.dlil_input_sanity_check"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.link.ether.inet.prune_intvl"]).to eq("300")
+ expect(plugin["network"]["settings"]["net.link.ether.inet.max_age"]).to eq("1200")
+ expect(plugin["network"]["settings"]["net.link.ether.inet.host_down_time"]).to eq("20")
+ expect(plugin["network"]["settings"]["net.link.ether.inet.apple_hwcksum_tx"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.link.ether.inet.apple_hwcksum_rx"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.link.ether.inet.arp_llreach_base"]).to eq("30")
+ expect(plugin["network"]["settings"]["net.link.ether.inet.maxtries"]).to eq("5")
+ expect(plugin["network"]["settings"]["net.link.ether.inet.useloopback"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.link.ether.inet.proxyall"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.link.ether.inet.sendllconflict"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.link.ether.inet.log_arp_warnings"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.link.ether.inet.keep_announcements"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.link.ether.inet.send_conflicting_probes"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.link.bridge.log_stp"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.link.bridge.debug"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.key.debug"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.key.spi_trycnt"]).to eq("1000")
+ expect(plugin["network"]["settings"]["net.key.spi_minval"]).to eq("256")
+ expect(plugin["network"]["settings"]["net.key.spi_maxval"]).to eq("268435455")
+ expect(plugin["network"]["settings"]["net.key.int_random"]).to eq("60")
+ expect(plugin["network"]["settings"]["net.key.larval_lifetime"]).to eq("30")
+ expect(plugin["network"]["settings"]["net.key.blockacq_count"]).to eq("10")
+ expect(plugin["network"]["settings"]["net.key.blockacq_lifetime"]).to eq("20")
+ expect(plugin["network"]["settings"]["net.key.esp_keymin"]).to eq("256")
+ expect(plugin["network"]["settings"]["net.key.esp_auth"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.key.ah_keymin"]).to eq("128")
+ expect(plugin["network"]["settings"]["net.key.prefered_oldsa"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.key.natt_keepalive_interval"]).to eq("20")
+ expect(plugin["network"]["settings"]["net.inet6.ip6.forwarding"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet6.ip6.redirect"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet6.ip6.hlim"]).to eq("64")
+ expect(plugin["network"]["settings"]["net.inet6.ip6.maxfragpackets"]).to eq("1536")
+ expect(plugin["network"]["settings"]["net.inet6.ip6.accept_rtadv"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet6.ip6.keepfaith"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet6.ip6.log_interval"]).to eq("5")
+ expect(plugin["network"]["settings"]["net.inet6.ip6.hdrnestlimit"]).to eq("15")
+ expect(plugin["network"]["settings"]["net.inet6.ip6.dad_count"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet6.ip6.auto_flowlabel"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet6.ip6.defmcasthlim"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet6.ip6.gifhlim"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet6.ip6.kame_version"]).to eq("2009/apple-darwin")
+ expect(plugin["network"]["settings"]["net.inet6.ip6.use_deprecated"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet6.ip6.rr_prune"]).to eq("5")
+ expect(plugin["network"]["settings"]["net.inet6.ip6.v6only"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet6.ip6.rtexpire"]).to eq("3600")
+ expect(plugin["network"]["settings"]["net.inet6.ip6.rtminexpire"]).to eq("10")
+ expect(plugin["network"]["settings"]["net.inet6.ip6.rtmaxcache"]).to eq("128")
+ expect(plugin["network"]["settings"]["net.inet6.ip6.use_tempaddr"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet6.ip6.temppltime"]).to eq("86400")
+ expect(plugin["network"]["settings"]["net.inet6.ip6.tempvltime"]).to eq("604800")
+ expect(plugin["network"]["settings"]["net.inet6.ip6.auto_linklocal"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet6.ip6.prefer_tempaddr"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet6.ip6.use_defaultzone"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet6.ip6.maxfrags"]).to eq("12288")
+ expect(plugin["network"]["settings"]["net.inet6.ip6.mcast_pmtu"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet6.ip6.neighborgcthresh"]).to eq("1024")
+ expect(plugin["network"]["settings"]["net.inet6.ip6.maxifprefixes"]).to eq("16")
+ expect(plugin["network"]["settings"]["net.inet6.ip6.maxifdefrouters"]).to eq("16")
+ expect(plugin["network"]["settings"]["net.inet6.ip6.maxdynroutes"]).to eq("1024")
+ expect(plugin["network"]["settings"]["net.inet6.ip6.fw.enable"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet6.ip6.fw.debug"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet6.ip6.fw.verbose"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet6.ip6.fw.verbose_limit"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet6.ip6.scopedroute"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet6.ip6.select_srcif_debug"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet6.ip6.mcast.maxgrpsrc"]).to eq("512")
+ expect(plugin["network"]["settings"]["net.inet6.ip6.mcast.maxsocksrc"]).to eq("128")
+ expect(plugin["network"]["settings"]["net.inet6.ip6.mcast.loop"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet6.ip6.only_allow_rfc4193_prefixes"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet6.ipsec6.def_policy"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet6.ipsec6.esp_trans_deflev"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet6.ipsec6.esp_net_deflev"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet6.ipsec6.ah_trans_deflev"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet6.ipsec6.ah_net_deflev"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet6.ipsec6.ecn"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet6.ipsec6.debug"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet6.ipsec6.esp_randpad"]).to eq("-1")
+ expect(plugin["network"]["settings"]["net.inet6.icmp6.rediraccept"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet6.icmp6.redirtimeout"]).to eq("600")
+ expect(plugin["network"]["settings"]["net.inet6.icmp6.nd6_prune"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet6.icmp6.nd6_delay"]).to eq("5")
+ expect(plugin["network"]["settings"]["net.inet6.icmp6.nd6_umaxtries"]).to eq("3")
+ expect(plugin["network"]["settings"]["net.inet6.icmp6.nd6_mmaxtries"]).to eq("3")
+ expect(plugin["network"]["settings"]["net.inet6.icmp6.nd6_useloopback"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet6.icmp6.nodeinfo"]).to eq("3")
+ expect(plugin["network"]["settings"]["net.inet6.icmp6.errppslimit"]).to eq("500")
+ expect(plugin["network"]["settings"]["net.inet6.icmp6.nd6_maxnudhint"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet6.icmp6.nd6_debug"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet6.icmp6.nd6_accept_6to4"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet6.icmp6.nd6_onlink_ns_rfc4861"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.inet6.icmp6.nd6_llreach_base"]).to eq("30")
+ expect(plugin["network"]["settings"]["net.inet6.mld.gsrdelay"]).to eq("10")
+ expect(plugin["network"]["settings"]["net.inet6.mld.v1enable"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet6.mld.use_allow"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.inet6.mld.debug"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.idle.route.expire_timeout"]).to eq("30")
+ expect(plugin["network"]["settings"]["net.idle.route.drain_interval"]).to eq("10")
+ expect(plugin["network"]["settings"]["net.statistics"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.alf.loglevel"]).to eq("55")
+ expect(plugin["network"]["settings"]["net.alf.perm"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.alf.defaultaction"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.alf.mqcount"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.smb.fs.version"]).to eq("107000")
+ expect(plugin["network"]["settings"]["net.smb.fs.loglevel"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.smb.fs.kern_ntlmssp"]).to eq("0")
+ expect(plugin["network"]["settings"]["net.smb.fs.kern_deprecatePreXPServers"]).to eq("1")
+ expect(plugin["network"]["settings"]["net.smb.fs.kern_deadtimer"]).to eq("60")
+ expect(plugin["network"]["settings"]["net.smb.fs.kern_hard_deadtimer"]).to eq("600")
+ expect(plugin["network"]["settings"]["net.smb.fs.kern_soft_deadtimer"]).to eq("30")
+ expect(plugin["network"]["settings"]["net.smb.fs.tcpsndbuf"]).to eq("261120")
+ expect(plugin["network"]["settings"]["net.smb.fs.tcprcvbuf"]).to eq("261120")
end
end
end
diff --git a/spec/unit/plugins/darwin/platform_spec.rb b/spec/unit/plugins/darwin/platform_spec.rb
index ecd2c5f0..3130a741 100644
--- a/spec/unit/plugins/darwin/platform_spec.rb
+++ b/spec/unit/plugins/darwin/platform_spec.rb
@@ -19,53 +19,54 @@
require "spec_helper"
describe Ohai::System, "Darwin plugin platform" do
+ let(:plugin) { get_plugin("darwin/platform") }
+
before do
- @plugin = get_plugin("darwin/platform")
- allow(@plugin).to receive(:collect_os).and_return(:darwin)
+ allow(plugin).to receive(:collect_os).and_return(:darwin)
@stdout = "ProductName: Mac OS X\nProductVersion: 10.5.5\nBuildVersion: 9F33"
- allow(@plugin).to receive(:shell_out).with("/usr/bin/sw_vers").and_return(mock_shell_out(0, @stdout, ""))
+ allow(plugin).to receive(:shell_out).with("/usr/bin/sw_vers").and_return(mock_shell_out(0, @stdout, ""))
end
it "runs sw_vers" do
- expect(@plugin).to receive(:shell_out).with("/usr/bin/sw_vers").and_return(mock_shell_out(0, @stdout, ""))
- @plugin.run
+ expect(plugin).to receive(:shell_out).with("/usr/bin/sw_vers").and_return(mock_shell_out(0, @stdout, ""))
+ plugin.run
end
it "sets platform to ProductName, downcased with _ for \\s" do
- @plugin.run
- expect(@plugin[:platform]).to eq("mac_os_x")
+ plugin.run
+ expect(plugin[:platform]).to eq("mac_os_x")
end
it "sets platform_version to ProductVersion" do
- @plugin.run
- expect(@plugin[:platform_version]).to eq("10.5.5")
+ plugin.run
+ expect(plugin[:platform_version]).to eq("10.5.5")
end
it "sets platform_build to BuildVersion" do
- @plugin.run
- expect(@plugin[:platform_build]).to eq("9F33")
+ plugin.run
+ expect(plugin[:platform_build]).to eq("9F33")
end
it "sets platform_family to mac_os_x" do
- @plugin.run
- expect(@plugin[:platform_family]).to eq("mac_os_x")
+ plugin.run
+ expect(plugin[:platform_family]).to eq("mac_os_x")
end
describe "on os x server" do
before do
- @plugin[:os] = "darwin"
+ plugin[:os] = "darwin"
@stdout = "ProductName: Mac OS X Server\nProductVersion: 10.6.8\nBuildVersion: 10K549"
- allow(@plugin).to receive(:shell_out).with("/usr/bin/sw_vers").and_return(mock_shell_out(0, @stdout, ""))
+ allow(plugin).to receive(:shell_out).with("/usr/bin/sw_vers").and_return(mock_shell_out(0, @stdout, ""))
end
it "sets platform to mac_os_x_server" do
- @plugin.run
- expect(@plugin[:platform]).to eq("mac_os_x_server")
+ plugin.run
+ expect(plugin[:platform]).to eq("mac_os_x_server")
end
it "sets platform_family to mac_os_x" do
- @plugin.run
- expect(@plugin[:platform_family]).to eq("mac_os_x")
+ plugin.run
+ expect(plugin[:platform_family]).to eq("mac_os_x")
end
end
end
diff --git a/spec/unit/plugins/freebsd/cpu_spec.rb b/spec/unit/plugins/freebsd/cpu_spec.rb
index b6dd27f1..30ad6ca2 100644
--- a/spec/unit/plugins/freebsd/cpu_spec.rb
+++ b/spec/unit/plugins/freebsd/cpu_spec.rb
@@ -19,9 +19,10 @@
require "spec_helper"
describe Ohai::System, "FreeBSD cpu plugin on FreeBSD >=10.2" do
+ let(:plugin) { get_plugin("cpu") }
+
before do
- @plugin = get_plugin("cpu")
- allow(@plugin).to receive(:collect_os).and_return(:freebsd)
+ allow(plugin).to receive(:collect_os).and_return(:freebsd)
@double_file = double("/var/run/dmesg.boot")
allow(@double_file).to receive(:each)
.and_yield("CPU: Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz (2793.59-MHz K8-class CPU)")
@@ -42,62 +43,63 @@ describe Ohai::System, "FreeBSD cpu plugin on FreeBSD >=10.2" do
end
it "detects all CPU flags" do
- @plugin.run
- expect(@plugin[:cpu][:flags]).to eq(%w{fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 mmx fxsr sse sse2 sse3 pclmulqdq mon ssse3 cx16 sse4.1 sse4.2 movbe popcnt aesni xsave osxsave avx rdrand syscall nx rdtscp lm lahf abm nfpusg})
+ plugin.run
+ expect(plugin[:cpu][:flags]).to eq(%w{fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 mmx fxsr sse sse2 sse3 pclmulqdq mon ssse3 cx16 sse4.1 sse4.2 movbe popcnt aesni xsave osxsave avx rdrand syscall nx rdtscp lm lahf abm nfpusg})
end
it "detects CPU model_name" do
- @plugin.run
- expect(@plugin[:cpu][:model_name]).to eq("Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz")
+ plugin.run
+ expect(plugin[:cpu][:model_name]).to eq("Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz")
end
it "detects CPU mhz" do
- @plugin.run
- expect(@plugin[:cpu][:mhz]).to eq("2793.59")
+ plugin.run
+ expect(plugin[:cpu][:mhz]).to eq("2793.59")
end
it "detects CPU vendor_id" do
- @plugin.run
- expect(@plugin[:cpu][:vendor_id]).to eq("GenuineIntel")
+ plugin.run
+ expect(plugin[:cpu][:vendor_id]).to eq("GenuineIntel")
end
it "detects CPU family" do
- @plugin.run
- expect(@plugin[:cpu][:family]).to eq("6")
+ plugin.run
+ expect(plugin[:cpu][:family]).to eq("6")
end
it "detects CPU model" do
- @plugin.run
- expect(@plugin[:cpu][:model]).to eq("70")
+ plugin.run
+ expect(plugin[:cpu][:model]).to eq("70")
end
it "detects CPU stepping" do
- @plugin.run
- expect(@plugin[:cpu][:stepping]).to eq("1")
+ plugin.run
+ expect(plugin[:cpu][:stepping]).to eq("1")
end
it "detects real CPUs" do
- @plugin.run
- expect(@plugin[:cpu][:real]).to eq(2)
+ plugin.run
+ expect(plugin[:cpu][:real]).to eq(2)
end
it "detects total real CPU cores" do
- @plugin.run
- expect(@plugin[:cpu][:cores]).to eq(8)
+ plugin.run
+ expect(plugin[:cpu][:cores]).to eq(8)
end
it "detects total HT CPU cores" do
- @plugin.run
- expect(@plugin[:cpu][:total]).to eq(16)
+ plugin.run
+ expect(plugin[:cpu][:total]).to eq(16)
end
end
describe Ohai::System, "FreeBSD cpu plugin on FreeBSD <=10.1" do
+ let(:plugin) { get_plugin("cpu") }
+
before do
- @plugin = get_plugin("cpu")
- allow(@plugin).to receive(:collect_os).and_return(:freebsd)
- allow(@plugin).to receive(:shell_out).with("sysctl -n hw.ncpu").and_return(mock_shell_out(0, "2", ""))
+ allow(plugin).to receive(:collect_os).and_return(:freebsd)
+ allow(plugin).to receive(:shell_out).with("sysctl -n hw.ncpu").and_return(mock_shell_out(0, "2", ""))
@double_file = double("/var/run/dmesg.boot")
allow(@double_file).to receive(:each)
.and_yield("CPU: Intel(R) Atom(TM) CPU N270 @ 1.60GHz (1596.03-MHz 686-class CPU)")
@@ -106,24 +108,24 @@ describe Ohai::System, "FreeBSD cpu plugin on FreeBSD <=10.1" do
end
it "detects CPU vendor_id" do
- @plugin.run
- expect(@plugin[:cpu][:vendor_id]).to eq("GenuineIntel")
+ plugin.run
+ expect(plugin[:cpu][:vendor_id]).to eq("GenuineIntel")
end
it "detects CPU family" do
- @plugin.run
- expect(@plugin[:cpu][:family]).to eq("6")
+ plugin.run
+ expect(plugin[:cpu][:family]).to eq("6")
end
it "detects CPU model" do
- @plugin.run
+ plugin.run
- expect(@plugin[:cpu][:model]).to eq("28")
+ expect(plugin[:cpu][:model]).to eq("28")
end
it "detects CPU stepping" do
- @plugin.run
- expect(@plugin[:cpu][:stepping]).to eq("2")
+ plugin.run
+ expect(plugin[:cpu][:stepping]).to eq("2")
end
end
diff --git a/spec/unit/plugins/freebsd/hostname_spec.rb b/spec/unit/plugins/freebsd/hostname_spec.rb
index 3f8a8db4..0ac22ce3 100644
--- a/spec/unit/plugins/freebsd/hostname_spec.rb
+++ b/spec/unit/plugins/freebsd/hostname_spec.rb
@@ -19,12 +19,13 @@
require "spec_helper"
describe Ohai::System, "FreeBSD hostname plugin" do
+ let(:plugin) { get_plugin("hostname") }
+
before do
- @plugin = get_plugin("hostname")
- allow(@plugin).to receive(:collect_os).and_return(:freebsd)
- allow(@plugin).to receive(:shell_out).with("hostname -s").and_return(mock_shell_out(0, "katie", ""))
- allow(@plugin).to receive(:shell_out).with("hostname -f").and_return(mock_shell_out(0, "katie.bethell", ""))
- allow(@plugin).to receive(:shell_out).with("hostname").and_return(mock_shell_out(0, "katie.local", ""))
+ allow(plugin).to receive(:collect_os).and_return(:freebsd)
+ allow(plugin).to receive(:shell_out).with("hostname -s").and_return(mock_shell_out(0, "katie", ""))
+ allow(plugin).to receive(:shell_out).with("hostname -f").and_return(mock_shell_out(0, "katie.bethell", ""))
+ allow(plugin).to receive(:shell_out).with("hostname").and_return(mock_shell_out(0, "katie.local", ""))
end
it_should_check_from("freebsd::hostname", "hostname", "hostname -s", "katie")
diff --git a/spec/unit/plugins/freebsd/kernel_spec.rb b/spec/unit/plugins/freebsd/kernel_spec.rb
index 91291b39..bcc968be 100644
--- a/spec/unit/plugins/freebsd/kernel_spec.rb
+++ b/spec/unit/plugins/freebsd/kernel_spec.rb
@@ -19,18 +19,19 @@
require "spec_helper"
describe Ohai::System, "FreeBSD kernel plugin" do
+ let(:plugin) { get_plugin("kernel") }
+
before do
- @plugin = get_plugin("kernel")
- allow(@plugin).to receive(:collect_os).and_return(:freebsd)
- allow(@plugin).to receive(:init_kernel).and_return({ name: "freebsd" })
- allow(@plugin).to receive(:shell_out).with("uname -i").and_return(mock_shell_out(0, "foo\n", ""))
- allow(@plugin).to receive(:shell_out).with("sysctl kern.securelevel").and_return(mock_shell_out(0, "kern.securelevel: 1", ""))
- allow(@plugin).to receive(:shell_out).with( Ohai.abs_path( "/sbin/kldstat" )).and_return(mock_shell_out(0, " 1 7 0xc0400000 97f830 kernel", ""))
+ allow(plugin).to receive(:collect_os).and_return(:freebsd)
+ allow(plugin).to receive(:init_kernel).and_return({ name: "freebsd" })
+ allow(plugin).to receive(:shell_out).with("uname -i").and_return(mock_shell_out(0, "foo\n", ""))
+ allow(plugin).to receive(:shell_out).with("sysctl kern.securelevel").and_return(mock_shell_out(0, "kern.securelevel: 1", ""))
+ allow(plugin).to receive(:shell_out).with( Ohai.abs_path( "/sbin/kldstat" )).and_return(mock_shell_out(0, " 1 7 0xc0400000 97f830 kernel", ""))
end
it "sets the kernel_os to the kernel_name value" do
- @plugin.run
- expect(@plugin[:kernel][:os]).to eq(@plugin[:kernel][:name])
+ plugin.run
+ expect(plugin[:kernel][:os]).to eq(plugin[:kernel][:name])
end
end
diff --git a/spec/unit/plugins/freebsd/platform_spec.rb b/spec/unit/plugins/freebsd/platform_spec.rb
index 58a0fdfa..b065777e 100644
--- a/spec/unit/plugins/freebsd/platform_spec.rb
+++ b/spec/unit/plugins/freebsd/platform_spec.rb
@@ -19,20 +19,21 @@
require "spec_helper"
describe Ohai::System, "FreeBSD plugin platform" do
+ let(:plugin) { get_plugin("freebsd/platform") }
+
before do
- @plugin = get_plugin("freebsd/platform")
- allow(@plugin).to receive(:shell_out).with("uname -s").and_return(mock_shell_out(0, "FreeBSD\n", ""))
- allow(@plugin).to receive(:shell_out).with("uname -r").and_return(mock_shell_out(0, "7.1\n", ""))
- allow(@plugin).to receive(:collect_os).and_return(:freebsd)
+ allow(plugin).to receive(:shell_out).with("uname -s").and_return(mock_shell_out(0, "FreeBSD\n", ""))
+ allow(plugin).to receive(:shell_out).with("uname -r").and_return(mock_shell_out(0, "7.1\n", ""))
+ allow(plugin).to receive(:collect_os).and_return(:freebsd)
end
it "sets platform to lowercased lsb[:id]" do
- @plugin.run
- expect(@plugin[:platform]).to eq("freebsd")
+ plugin.run
+ expect(plugin[:platform]).to eq("freebsd")
end
it "sets platform_version to lsb[:release]" do
- @plugin.run
- expect(@plugin[:platform_version]).to eq("7.1")
+ plugin.run
+ expect(plugin[:platform_version]).to eq("7.1")
end
end
diff --git a/spec/unit/plugins/hostname_spec.rb b/spec/unit/plugins/hostname_spec.rb
index c7e00f8b..18fcc2ed 100644
--- a/spec/unit/plugins/hostname_spec.rb
+++ b/spec/unit/plugins/hostname_spec.rb
@@ -21,77 +21,78 @@ require "wmi-lite/wmi"
require "socket"
describe Ohai::System, "hostname plugin" do
+ let(:plugin) { get_plugin("hostname") }
+
before do
- @plugin = get_plugin("hostname")
- allow(@plugin).to receive(:collect_os).and_return(:default)
- allow(@plugin).to receive(:shell_out).with("hostname").and_return(mock_shell_out(0, "katie.local", ""))
+ allow(plugin).to receive(:collect_os).and_return(:default)
+ allow(plugin).to receive(:shell_out).with("hostname").and_return(mock_shell_out(0, "katie.local", ""))
end
context "default behavior"
before do
- allow(@plugin).to receive(:resolve_fqdn).and_return("katie.bethell")
+ allow(plugin).to receive(:resolve_fqdn).and_return("katie.bethell")
end
it_should_check_from("linux::hostname", "machinename", "hostname", "katie.local")
it "uses #resolve_fqdn to find the fqdn" do
- @plugin.run
- expect(@plugin[:fqdn]).to eq("katie.bethell")
+ plugin.run
+ expect(plugin[:fqdn]).to eq("katie.bethell")
end
it "sets the domain to everything after the first dot of the fqdn" do
- @plugin.run
- expect(@plugin[:domain]).to eq("bethell")
+ plugin.run
+ expect(plugin[:domain]).to eq("bethell")
end
it "sets the [short] hostname to everything before the first dot of the fqdn" do
- @plugin.run
- expect(@plugin[:hostname]).to eq("katie")
+ plugin.run
+ expect(plugin[:hostname]).to eq("katie")
end
context "when a system has a bare hostname without a FQDN" do
before do
- allow(@plugin).to receive(:collect_os).and_return(:default)
- allow(@plugin).to receive(:shell_out).with("hostname").and_return(mock_shell_out(0, "katie", ""))
+ allow(plugin).to receive(:collect_os).and_return(:default)
+ allow(plugin).to receive(:shell_out).with("hostname").and_return(mock_shell_out(0, "katie", ""))
end
it "correctlies set the [short] hostname" do
- @plugin.run
- expect(@plugin[:hostname]).to eq("katie")
+ plugin.run
+ expect(plugin[:hostname]).to eq("katie")
end
end
context "hostname --fqdn when it returns empty string" do
before do
- allow(@plugin).to receive(:collect_os).and_return(:linux)
- allow(@plugin).to receive(:shell_out).with("hostname -s").and_return(
+ allow(plugin).to receive(:collect_os).and_return(:linux)
+ allow(plugin).to receive(:shell_out).with("hostname -s").and_return(
mock_shell_out(0, "katie", "")
)
- allow(@plugin).to receive(:shell_out).with("hostname --fqdn").and_return(
+ allow(plugin).to receive(:shell_out).with("hostname --fqdn").and_return(
mock_shell_out(0, "", ""), mock_shell_out(0, "katie.local", "")
)
end
it "is called twice" do
- @plugin.run
- expect(@plugin[:fqdn]).to eq("katie.local")
+ plugin.run
+ expect(plugin[:fqdn]).to eq("katie.local")
end
end
context "hostname --fqdn when it works" do
before do
- allow(@plugin).to receive(:collect_os).and_return(:linux)
- allow(@plugin).to receive(:shell_out).with("hostname -s").and_return(
+ allow(plugin).to receive(:collect_os).and_return(:linux)
+ allow(plugin).to receive(:shell_out).with("hostname -s").and_return(
mock_shell_out(0, "katie", "")
)
- allow(@plugin).to receive(:shell_out).with("hostname --fqdn").and_return(
+ allow(plugin).to receive(:shell_out).with("hostname --fqdn").and_return(
mock_shell_out(0, "katie.local", "")
)
end
it "is not be called twice" do
- @plugin.run
- expect(@plugin[:fqdn]).to eq("katie.local")
+ plugin.run
+ expect(plugin[:fqdn]).to eq("katie.local")
end
end
end
@@ -136,8 +137,9 @@ describe Ohai::System, "hostname plugin for windows", :windows_only do
]
end
+ let(:plugin) { get_plugin("hostname") }
+
before do
- @plugin = get_plugin("hostname")
allow(WmiLite::Wmi).to receive(:new).and_return(success)
allow(success).to receive(:first_of).with("Win32_ComputerSystem").and_return(host)
allow(Socket).to receive(:gethostname).and_return("local")
@@ -147,16 +149,16 @@ describe Ohai::System, "hostname plugin for windows", :windows_only do
context "when hostname is not set for the machine" do
it "returns short machine name" do
allow(Socket).to receive(:gethostbyaddr).with(anything).and_return(local_hostent)
- @plugin.run
- expect(@plugin[:fqdn]).to eq("local")
+ plugin.run
+ expect(plugin[:fqdn]).to eq("local")
end
end
context "when hostname is set for the machine" do
it "returns the fqdn of the machine" do
allow(Socket).to receive(:gethostbyaddr).with(anything).and_return(fqdn_hostent)
- @plugin.run
- expect(@plugin[:fqdn]).to eq("local.dx.internal.cloudapp.net")
+ plugin.run
+ expect(plugin[:fqdn]).to eq("local.dx.internal.cloudapp.net")
end
end
end
diff --git a/spec/unit/plugins/kernel_spec.rb b/spec/unit/plugins/kernel_spec.rb
index 1ca765d1..80a968e1 100644
--- a/spec/unit/plugins/kernel_spec.rb
+++ b/spec/unit/plugins/kernel_spec.rb
@@ -19,15 +19,16 @@
require "spec_helper"
describe Ohai::System, "plugin kernel" do
+ let(:plugin) { get_plugin("kernel") }
+
before do
- @plugin = get_plugin("kernel")
- allow(@plugin).to receive(:collect_os).and_return(:default) # for debugging
- allow(@plugin).to receive(:shell_out).with("uname -s").and_return(mock_shell_out(0, "Darwin\n", ""))
- allow(@plugin).to receive(:shell_out).with("uname -r").and_return(mock_shell_out(0, "9.5.0\n", ""))
- allow(@plugin).to receive(:shell_out).with("uname -v").and_return(mock_shell_out(0, "Darwin Kernel Version 9.5.0: Wed Sep 3 11:29:43 PDT 2008; root:xnu-1228.7.58~1\/RELEASE_I386\n", ""))
- allow(@plugin).to receive(:shell_out).with("uname -m").and_return(mock_shell_out(0, "i386\n", ""))
- allow(@plugin).to receive(:shell_out).with("uname -o").and_return(mock_shell_out(0, "Linux\n", ""))
- allow(@plugin).to receive(:shell_out).with("uname -p").and_return(mock_shell_out(0, "i386\n", ""))
+ allow(plugin).to receive(:collect_os).and_return(:default) # for debugging
+ allow(plugin).to receive(:shell_out).with("uname -s").and_return(mock_shell_out(0, "Darwin\n", ""))
+ allow(plugin).to receive(:shell_out).with("uname -r").and_return(mock_shell_out(0, "9.5.0\n", ""))
+ allow(plugin).to receive(:shell_out).with("uname -v").and_return(mock_shell_out(0, "Darwin Kernel Version 9.5.0: Wed Sep 3 11:29:43 PDT 2008; root:xnu-1228.7.58~1\/RELEASE_I386\n", ""))
+ allow(plugin).to receive(:shell_out).with("uname -m").and_return(mock_shell_out(0, "i386\n", ""))
+ allow(plugin).to receive(:shell_out).with("uname -o").and_return(mock_shell_out(0, "Linux\n", ""))
+ allow(plugin).to receive(:shell_out).with("uname -p").and_return(mock_shell_out(0, "i386\n", ""))
end
it_should_check_from_mash("kernel", "name", "uname -s", [0, "Darwin\n", ""])
diff --git a/spec/unit/plugins/linux/block_device_spec.rb b/spec/unit/plugins/linux/block_device_spec.rb
index 9a75c12f..8d2f7a33 100644
--- a/spec/unit/plugins/linux/block_device_spec.rb
+++ b/spec/unit/plugins/linux/block_device_spec.rb
@@ -18,6 +18,8 @@
require "spec_helper"
describe Ohai::System, "Linux Block Device Plugin" do
+ let(:plugin) { get_plugin("linux/block_device") }
+
DISKS = {
"sda" => {
"size" => "7814037168",
@@ -42,8 +44,7 @@ describe Ohai::System, "Linux Block Device Plugin" do
end
before do
- @plugin = get_plugin("linux/block_device")
- allow(@plugin).to receive(:collect_os).and_return(:linux)
+ allow(plugin).to receive(:collect_os).and_return(:linux)
allow(File).to receive(:exist?).with("/sys/block").and_return(true)
allow(Dir).to receive(:[]).with("/sys/block/*") do
@@ -67,9 +68,9 @@ describe Ohai::System, "Linux Block Device Plugin" do
end
it "collects all relevant data from disks" do
- @plugin.run
+ plugin.run
DISKS.each do |disk, checks|
- expect(@plugin[:block_device][disk.to_sym]).to include(checks)
+ expect(plugin[:block_device][disk.to_sym]).to include(checks)
end
end
end
diff --git a/spec/unit/plugins/linux/hostname_spec.rb b/spec/unit/plugins/linux/hostname_spec.rb
index 0fe198ca..e3deeb26 100644
--- a/spec/unit/plugins/linux/hostname_spec.rb
+++ b/spec/unit/plugins/linux/hostname_spec.rb
@@ -19,12 +19,13 @@
require "spec_helper"
describe Ohai::System, "Linux hostname plugin" do
+ let(:plugin) { get_plugin("hostname") }
+
before do
- @plugin = get_plugin("hostname")
- allow(@plugin).to receive(:collect_os).and_return(:linux)
- allow(@plugin).to receive(:shell_out).with("hostname -s").and_return(mock_shell_out(0, "katie", ""))
- allow(@plugin).to receive(:shell_out).with("hostname --fqdn").and_return(mock_shell_out(0, "katie.bethell", ""))
- allow(@plugin).to receive(:shell_out).with("hostname").and_return(mock_shell_out(0, "katie.local", ""))
+ allow(plugin).to receive(:collect_os).and_return(:linux)
+ allow(plugin).to receive(:shell_out).with("hostname -s").and_return(mock_shell_out(0, "katie", ""))
+ allow(plugin).to receive(:shell_out).with("hostname --fqdn").and_return(mock_shell_out(0, "katie.bethell", ""))
+ allow(plugin).to receive(:shell_out).with("hostname").and_return(mock_shell_out(0, "katie.local", ""))
end
it_should_check_from("linux::hostname", "hostname", "hostname -s", "katie")
@@ -35,16 +36,16 @@ describe Ohai::System, "Linux hostname plugin" do
describe "when domain name is unset" do
before do
- expect(@plugin).to receive(:shell_out).with("hostname --fqdn").and_raise("Ohai::Exception::Exec")
+ expect(plugin).to receive(:shell_out).with("hostname --fqdn").and_raise("Ohai::Exception::Exec")
end
it "does not raise an error" do
- expect { @plugin.run }.not_to raise_error
+ expect { plugin.run }.not_to raise_error
end
it "does not set fqdn" do
- @plugin.run
- expect(@plugin.fqdn).to eq(nil)
+ plugin.run
+ expect(plugin.fqdn).to eq(nil)
end
end
diff --git a/spec/unit/plugins/linux/kernel_spec.rb b/spec/unit/plugins/linux/kernel_spec.rb
index 8ddcb1f1..4c689631 100644
--- a/spec/unit/plugins/linux/kernel_spec.rb
+++ b/spec/unit/plugins/linux/kernel_spec.rb
@@ -20,6 +20,8 @@
require "spec_helper"
describe Ohai::System, "Linux kernel plugin" do
+ let(:plugin) { get_plugin("kernel") }
+
before do
@env_lsmod = <<~ENV_LSMOD
Module Size Used by
@@ -50,22 +52,21 @@ describe Ohai::System, "Linux kernel plugin" do
"virtio_balloon" => { "size" => "13168", "refcount" => "0" },
"floppy" => { "size" => "55441", "refcount" => "0" },
}
- @plugin = get_plugin("kernel")
- allow(@plugin).to receive(:collect_os).and_return(:linux)
- allow(@plugin).to receive(:init_kernel).and_return({})
- allow(@plugin).to receive(:shell_out).with("uname -o").and_return(mock_shell_out(0, "Linux", ""))
- allow(@plugin).to receive(:shell_out).with("env lsmod").and_return(mock_shell_out(0, @env_lsmod, ""))
+ allow(plugin).to receive(:collect_os).and_return(:linux)
+ allow(plugin).to receive(:init_kernel).and_return({})
+ allow(plugin).to receive(:shell_out).with("uname -o").and_return(mock_shell_out(0, "Linux", ""))
+ allow(plugin).to receive(:shell_out).with("env lsmod").and_return(mock_shell_out(0, @env_lsmod, ""))
@version_module.each do |mod, vers|
allow(File).to receive(:exist?).with("/sys/module/#{mod}/version").and_return(true)
allow(File).to receive(:read).with("/sys/module/#{mod}/version").and_return(vers)
end
- expect(@plugin).to receive(:shell_out).with("env lsmod").at_least(:once)
- @plugin.run
+ expect(plugin).to receive(:shell_out).with("env lsmod").at_least(:once)
+ plugin.run
end
it_should_check_from_deep_mash("linux::kernel", "kernel", "os", "uname -o", [0, "Linux", ""])
it "collects linux::kernel::modules" do
- expect(@plugin.data["kernel"]["modules"]).to eq(@expected_result)
+ expect(plugin.data["kernel"]["modules"]).to eq(@expected_result)
end
end
diff --git a/spec/unit/plugins/linux/lsb_spec.rb b/spec/unit/plugins/linux/lsb_spec.rb
index 4ce9a113..d3329648 100644
--- a/spec/unit/plugins/linux/lsb_spec.rb
+++ b/spec/unit/plugins/linux/lsb_spec.rb
@@ -21,9 +21,10 @@ require "spec_helper"
# We do not alter case for lsb attributes and consume them as provided
describe Ohai::System, "Linux lsb plugin" do
+ let(:plugin) { get_plugin("linux/lsb") }
+
before do
- @plugin = get_plugin("linux/lsb")
- allow(@plugin).to receive(:collect_os).and_return(:linux)
+ allow(plugin).to receive(:collect_os).and_return(:linux)
end
describe "on systems with /etc/lsb-release" do
@@ -40,23 +41,23 @@ describe Ohai::System, "Linux lsb plugin" do
end
it "sets lsb[:id]" do
- @plugin.run
- expect(@plugin[:lsb][:id]).to eq("Ubuntu")
+ plugin.run
+ expect(plugin[:lsb][:id]).to eq("Ubuntu")
end
it "sets lsb[:release]" do
- @plugin.run
- expect(@plugin[:lsb][:release]).to eq("8.04")
+ plugin.run
+ expect(plugin[:lsb][:release]).to eq("8.04")
end
it "sets lsb[:codename]" do
- @plugin.run
- expect(@plugin[:lsb][:codename]).to eq("hardy")
+ plugin.run
+ expect(plugin[:lsb][:codename]).to eq("hardy")
end
it "sets lsb[:description]" do
- @plugin.run
- expect(@plugin[:lsb][:description]).to eq("Ubuntu 8.04")
+ plugin.run
+ expect(plugin[:lsb][:description]).to eq("Ubuntu 8.04")
end
end
@@ -81,27 +82,27 @@ describe Ohai::System, "Linux lsb plugin" do
Release: 5.4
Codename: Final
LSB_RELEASE
- allow(@plugin).to receive(:shell_out).with("lsb_release -a").and_return(mock_shell_out(0, @stdout, ""))
+ allow(plugin).to receive(:shell_out).with("lsb_release -a").and_return(mock_shell_out(0, @stdout, ""))
end
it "sets lsb[:id]" do
- @plugin.run
- expect(@plugin[:lsb][:id]).to eq("CentOS")
+ plugin.run
+ expect(plugin[:lsb][:id]).to eq("CentOS")
end
it "sets lsb[:release]" do
- @plugin.run
- expect(@plugin[:lsb][:release]).to eq("5.4")
+ plugin.run
+ expect(plugin[:lsb][:release]).to eq("5.4")
end
it "sets lsb[:codename]" do
- @plugin.run
- expect(@plugin[:lsb][:codename]).to eq("Final")
+ plugin.run
+ expect(plugin[:lsb][:codename]).to eq("Final")
end
it "sets lsb[:description]" do
- @plugin.run
- expect(@plugin[:lsb][:description]).to eq("CentOS release 5.4 (Final)")
+ plugin.run
+ expect(plugin[:lsb][:description]).to eq("CentOS release 5.4 (Final)")
end
end
@@ -114,27 +115,27 @@ describe Ohai::System, "Linux lsb plugin" do
Release: 14
Codename: Laughlin
LSB_RELEASE
- allow(@plugin).to receive(:shell_out).with("lsb_release -a").and_return(mock_shell_out(0, @stdout, ""))
+ allow(plugin).to receive(:shell_out).with("lsb_release -a").and_return(mock_shell_out(0, @stdout, ""))
end
it "sets lsb[:id]" do
- @plugin.run
- expect(@plugin[:lsb][:id]).to eq("Fedora")
+ plugin.run
+ expect(plugin[:lsb][:id]).to eq("Fedora")
end
it "sets lsb[:release]" do
- @plugin.run
- expect(@plugin[:lsb][:release]).to eq("14")
+ plugin.run
+ expect(plugin[:lsb][:release]).to eq("14")
end
it "sets lsb[:codename]" do
- @plugin.run
- expect(@plugin[:lsb][:codename]).to eq("Laughlin")
+ plugin.run
+ expect(plugin[:lsb][:codename]).to eq("Laughlin")
end
it "sets lsb[:description]" do
- @plugin.run
- expect(@plugin[:lsb][:description]).to eq("Fedora release 14 (Laughlin)")
+ plugin.run
+ expect(plugin[:lsb][:description]).to eq("Fedora release 14 (Laughlin)")
end
end
end
@@ -142,6 +143,6 @@ describe Ohai::System, "Linux lsb plugin" do
it "does not set any lsb values if /etc/lsb-release or /usr/bin/lsb_release do not exist " do
allow(File).to receive(:exist?).with("/etc/lsb-release").and_return(false)
allow(File).to receive(:exist?).with("/usr/bin/lsb_release").and_return(false)
- expect(@plugin.attribute?(:lsb)).to be(false)
+ expect(plugin.attribute?(:lsb)).to be(false)
end
end
diff --git a/spec/unit/plugins/linux/mdadm_spec.rb b/spec/unit/plugins/linux/mdadm_spec.rb
index b7b67b83..7273bbba 100644
--- a/spec/unit/plugins/linux/mdadm_spec.rb
+++ b/spec/unit/plugins/linux/mdadm_spec.rb
@@ -19,6 +19,8 @@
require "spec_helper"
describe Ohai::System, "Linux Mdadm Plugin" do
+ let(:plugin) { get_plugin("linux/mdadm") }
+
before do
@md0 = <<~MD
/dev/md0:
@@ -53,8 +55,7 @@ describe Ohai::System, "Linux Mdadm Plugin" do
4 8 96 4 active sync /dev/sdg
5 8 112 5 active sync /dev/sdh
MD
- @plugin = get_plugin("linux/mdadm")
- allow(@plugin).to receive(:collect_os).and_return(:linux)
+ allow(plugin).to receive(:collect_os).and_return(:linux)
@double_file = double("/proc/mdstat")
allow(@double_file).to receive(:each)
.and_yield("Personalities : [raid1] [raid6] [raid5] [raid4] [linear] [multipath] [raid0] [raid10]")
@@ -62,46 +63,46 @@ describe Ohai::System, "Linux Mdadm Plugin" do
.and_yield(" 2929893888 blocks super 1.2 256K chunks 2 near-copies [6/6] [UUUUUU]")
allow(File).to receive(:open).with("/proc/mdstat").and_return(@double_file)
allow(File).to receive(:exist?).with("/proc/mdstat").and_return(true)
- allow(@plugin).to receive(:shell_out).with("mdadm --detail /dev/md0").and_return(mock_shell_out(0, @md0, ""))
+ 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 "does not raise an error" do
- expect { @plugin.run }.not_to raise_error
+ expect { plugin.run }.not_to raise_error
end
it "detects raid level" do
- @plugin.run
- expect(@plugin[:mdadm][:md0][:level]).to eq(10)
+ plugin.run
+ expect(plugin[:mdadm][:md0][:level]).to eq(10)
end
it "detects raid state" do
- @plugin.run
- expect(@plugin[:mdadm][:md0][:state]).to eq("clean")
+ plugin.run
+ expect(plugin[:mdadm][:md0][:state]).to eq("clean")
end
it "detects raid size" do
- @plugin.run
- expect(@plugin[:mdadm][:md0][:size]).to eq(2794.16)
+ plugin.run
+ expect(plugin[:mdadm][:md0][:size]).to eq(2794.16)
end
it "detects raid metadata level" do
- @plugin.run
- expect(@plugin[:mdadm][:md0][:version]).to eq(1.2)
+ 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 "detects device count of \"#{item}\"" do
- @plugin.run
- expect(@plugin[:mdadm][:md0][:device_counts][item]).to eq(expected_value)
+ plugin.run
+ expect(plugin[:mdadm][:md0][:device_counts][item]).to eq(expected_value)
end
end
it "detects member devices" do
- @plugin.run
- expect(@plugin[:mdadm][:md0][:members].sort).to eq(
+ plugin.run
+ expect(plugin[:mdadm][:md0][:members].sort).to eq(
%w{sdc sdd sde sdf sdg sdh}
)
end
@@ -114,8 +115,8 @@ describe Ohai::System, "Linux Mdadm Plugin" do
.and_yield(" 2929893888 blocks super 1.2 256K chunks 2 near-copies [6/6] [UUUUUU]")
allow(File).to receive(:open).with("/proc/mdstat").and_return(new_mdstat)
- @plugin.run
- expect(@plugin[:mdadm][:md0][:members].sort).to eq(
+ plugin.run
+ expect(plugin[:mdadm][:md0][:members].sort).to eq(
%w{sdc sdd sde sdf sdg sdh sdi sdj}
)
end
@@ -128,8 +129,8 @@ describe Ohai::System, "Linux Mdadm Plugin" do
.and_yield(" 2929893888 blocks super 1.2 256K chunks 2 near-copies [6/6] [UUUUUU]")
allow(File).to receive(:open).with("/proc/mdstat").and_return(new_mdstat)
- @plugin.run
- expect(@plugin[:mdadm][:md0][:members].sort).to eq(
+ plugin.run
+ expect(plugin[:mdadm][:md0][:members].sort).to eq(
%w{sdc sdd sde sdf sdg sdh}
)
end
@@ -141,8 +142,8 @@ describe Ohai::System, "Linux Mdadm Plugin" do
.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})
+ plugin.run
+ expect(plugin[:mdadm][:md0][:spares]).to eq(%w{nvme2n1p3})
end
it "reports journal devices" do
@@ -152,8 +153,8 @@ describe Ohai::System, "Linux Mdadm Plugin" do
.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")
+ plugin.run
+ expect(plugin[:mdadm][:md0][:journal]).to eq("nvme2n1p3")
end
it "reports spare devices" do
@@ -163,8 +164,8 @@ describe Ohai::System, "Linux Mdadm Plugin" do
.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)
- @plugin.run
- expect(@plugin[:mdadm][:md0][:spares]).to eq(%w{sdh1})
+ plugin.run
+ expect(plugin[:mdadm][:md0][:spares]).to eq(%w{sdh1})
end
end
end
diff --git a/spec/unit/plugins/linux/memory_spec.rb b/spec/unit/plugins/linux/memory_spec.rb
index 49ca6362..6337a1c2 100644
--- a/spec/unit/plugins/linux/memory_spec.rb
+++ b/spec/unit/plugins/linux/memory_spec.rb
@@ -17,9 +17,10 @@
require "spec_helper"
describe Ohai::System, "Linux memory plugin" do
+ let(:plugin) { get_plugin("linux/memory") }
+
before do
- @plugin = get_plugin("linux/memory")
- allow(@plugin).to receive(:collect_os).and_return(:linux)
+ allow(plugin).to receive(:collect_os).and_return(:linux)
@double_file = double("/proc/meminfo")
allow(@double_file).to receive(:each)
.and_yield("MemTotal: 131932120 kB")
@@ -65,192 +66,192 @@ describe Ohai::System, "Linux memory plugin" do
end
it "gets total memory" do
- @plugin.run
- expect(@plugin[:memory][:total]).to eql("131932120kB")
+ plugin.run
+ expect(plugin[:memory][:total]).to eql("131932120kB")
end
it "gets free memory" do
- @plugin.run
- expect(@plugin[:memory][:free]).to eql("2269032kB")
+ plugin.run
+ expect(plugin[:memory][:free]).to eql("2269032kB")
end
it "gets available memory" do
- @plugin.run
- expect(@plugin[:memory][:available]).to eql("9208922kB")
+ plugin.run
+ expect(plugin[:memory][:available]).to eql("9208922kB")
end
it "gets memory used for file buffers" do
- @plugin.run
- expect(@plugin[:memory][:buffers]).to eql("646368kB")
+ plugin.run
+ expect(plugin[:memory][:buffers]).to eql("646368kB")
end
it "gets cache memory" do
- @plugin.run
- expect(@plugin[:memory][:cached]).to eql("32346556kB")
+ plugin.run
+ expect(plugin[:memory][:cached]).to eql("32346556kB")
end
it "gets active memory" do
- @plugin.run
- expect(@plugin[:memory][:active]).to eql("98595796kB")
+ plugin.run
+ expect(plugin[:memory][:active]).to eql("98595796kB")
end
it "gets inactive memory" do
- @plugin.run
- expect(@plugin[:memory][:inactive]).to eql("18477320kB")
+ plugin.run
+ expect(plugin[:memory][:inactive]).to eql("18477320kB")
end
it "gets high_total memory" do
- @plugin.run
- expect(@plugin[:memory][:high_total]).to eql("0kB")
+ plugin.run
+ expect(plugin[:memory][:high_total]).to eql("0kB")
end
it "gets high_free memory" do
- @plugin.run
- expect(@plugin[:memory][:high_free]).to eql("0kB")
+ plugin.run
+ expect(plugin[:memory][:high_free]).to eql("0kB")
end
it "gets low_total memory" do
- @plugin.run
- expect(@plugin[:memory][:low_total]).to eql("131932120kB")
+ plugin.run
+ expect(plugin[:memory][:low_total]).to eql("131932120kB")
end
it "gets low_free memory" do
- @plugin.run
- expect(@plugin[:memory][:low_free]).to eql("2269032kB")
+ plugin.run
+ expect(plugin[:memory][:low_free]).to eql("2269032kB")
end
it "gets dirty memory" do
- @plugin.run
- expect(@plugin[:memory][:dirty]).to eql("3212kB")
+ plugin.run
+ expect(plugin[:memory][:dirty]).to eql("3212kB")
end
it "gets writeback memory" do
- @plugin.run
- expect(@plugin[:memory][:writeback]).to eql("0kB")
+ plugin.run
+ expect(plugin[:memory][:writeback]).to eql("0kB")
end
it "gets anon_pages memory" do
- @plugin.run
- expect(@plugin[:memory][:anon_pages]).to eql("84082132kB")
+ plugin.run
+ expect(plugin[:memory][:anon_pages]).to eql("84082132kB")
end
it "gets mapped memory" do
- @plugin.run
- expect(@plugin[:memory][:mapped]).to eql("3445224kB")
+ plugin.run
+ expect(plugin[:memory][:mapped]).to eql("3445224kB")
end
it "gets slab memory" do
- @plugin.run
- expect(@plugin[:memory][:slab]).to eql("9892096kB")
+ plugin.run
+ expect(plugin[:memory][:slab]).to eql("9892096kB")
end
it "gets slab_reclaimable memory" do
- @plugin.run
- expect(@plugin[:memory][:slab_reclaimable]).to eql("362636kB")
+ plugin.run
+ expect(plugin[:memory][:slab_reclaimable]).to eql("362636kB")
end
it "gets slab_reclaimable memory" do
- @plugin.run
- expect(@plugin[:memory][:slab_unreclaim]).to eql("18860kB")
+ plugin.run
+ expect(plugin[:memory][:slab_unreclaim]).to eql("18860kB")
end
it "gets page_tables memory" do
- @plugin.run
- expect(@plugin[:memory][:page_tables]).to eql("1759332kB")
+ plugin.run
+ expect(plugin[:memory][:page_tables]).to eql("1759332kB")
end
it "gets nfs_unstable memory" do
- @plugin.run
- expect(@plugin[:memory][:nfs_unstable]).to eql("0kB")
+ plugin.run
+ expect(plugin[:memory][:nfs_unstable]).to eql("0kB")
end
it "gets bounce memory" do
- @plugin.run
- expect(@plugin[:memory][:bounce]).to eql("0kB")
+ plugin.run
+ expect(plugin[:memory][:bounce]).to eql("0kB")
end
it "gets commit_limit memory" do
- @plugin.run
- expect(@plugin[:memory][:commit_limit]).to eql("148709328kB")
+ plugin.run
+ expect(plugin[:memory][:commit_limit]).to eql("148709328kB")
end
it "gets committed_as memory" do
- @plugin.run
- expect(@plugin[:memory][:committed_as]).to eql("333717060kB")
+ plugin.run
+ expect(plugin[:memory][:committed_as]).to eql("333717060kB")
end
it "gets vmalloc_total memory" do
- @plugin.run
- expect(@plugin[:memory][:vmalloc_total]).to eql("34359738367kB")
+ plugin.run
+ expect(plugin[:memory][:vmalloc_total]).to eql("34359738367kB")
end
it "gets vmalloc_used memory" do
- @plugin.run
- expect(@plugin[:memory][:vmalloc_used]).to eql("276796kB")
+ plugin.run
+ expect(plugin[:memory][:vmalloc_used]).to eql("276796kB")
end
it "gets vmalloc_chunk memory" do
- @plugin.run
- expect(@plugin[:memory][:vmalloc_chunk]).to eql("34359461515kB")
+ plugin.run
+ expect(plugin[:memory][:vmalloc_chunk]).to eql("34359461515kB")
end
it "gets total swap" do
- @plugin.run
- expect(@plugin[:memory][:swap][:total]).to eql("16777208kB")
+ plugin.run
+ expect(plugin[:memory][:swap][:total]).to eql("16777208kB")
end
it "gets cached swap" do
- @plugin.run
- expect(@plugin[:memory][:swap][:cached]).to eql("312kB")
+ plugin.run
+ expect(plugin[:memory][:swap][:cached]).to eql("312kB")
end
it "gets free swap" do
- @plugin.run
- expect(@plugin[:memory][:swap][:free]).to eql("14127356kB")
+ plugin.run
+ expect(plugin[:memory][:swap][:free]).to eql("14127356kB")
end
it "gets total hugepages" do
- @plugin.run
- expect(@plugin[:memory][:hugepages][:total]).to eql("11542")
+ plugin.run
+ expect(plugin[:memory][:hugepages][:total]).to eql("11542")
end
it "gets free hugepages" do
- @plugin.run
- expect(@plugin[:memory][:hugepages][:free]).to eql("11235")
+ plugin.run
+ expect(plugin[:memory][:hugepages][:free]).to eql("11235")
end
it "gets reserved hugepages" do
- @plugin.run
- expect(@plugin[:memory][:hugepages][:reserved]).to eql("11226")
+ plugin.run
+ expect(plugin[:memory][:hugepages][:reserved]).to eql("11226")
end
it "gets surplus hugepages" do
- @plugin.run
- expect(@plugin[:memory][:hugepages][:surplus]).to eql("0")
+ plugin.run
+ expect(plugin[:memory][:hugepages][:surplus]).to eql("0")
end
it "gets hugepage size" do
- @plugin.run
- expect(@plugin[:memory][:hugepage_size]).to eql("2048kB")
+ plugin.run
+ expect(plugin[:memory][:hugepage_size]).to eql("2048kB")
end
it "gets hugetlb memory" do
- @plugin.run
- expect(@plugin[:memory][:hugetlb]).to eql("0kB")
+ plugin.run
+ expect(plugin[:memory][:hugetlb]).to eql("0kB")
end
it "gets directmap 4k memory" do
- @plugin.run
- expect(@plugin[:memory][:directmap][:'4k']).to eql("3720736kB")
+ plugin.run
+ expect(plugin[:memory][:directmap][:'4k']).to eql("3720736kB")
end
it "gets directmap 2M memory" do
- @plugin.run
- expect(@plugin[:memory][:directmap][:'2M']).to eql("12795904kB")
+ plugin.run
+ expect(plugin[:memory][:directmap][:'2M']).to eql("12795904kB")
end
it "gets directmap 1G memory" do
- @plugin.run
- expect(@plugin[:memory][:directmap][:'1G']).to eql("0kB")
+ plugin.run
+ expect(plugin[:memory][:directmap][:'1G']).to eql("0kB")
end
end
diff --git a/spec/unit/plugins/linux/uptime_spec.rb b/spec/unit/plugins/linux/uptime_spec.rb
index 91132ae5..1c8dddc5 100644
--- a/spec/unit/plugins/linux/uptime_spec.rb
+++ b/spec/unit/plugins/linux/uptime_spec.rb
@@ -19,30 +19,31 @@
require "spec_helper"
describe Ohai::System, "Linux plugin uptime" do
+ let(:plugin) { get_plugin("uptime") }
+
before do
- @plugin = get_plugin("uptime")
- allow(@plugin).to receive(:collect_os).and_return(:linux)
+ allow(plugin).to receive(:collect_os).and_return(:linux)
@double_file = double("/proc/uptime", { gets: "18423 989" })
allow(File).to receive(:open).with("/proc/uptime").and_return(@double_file)
end
it "sets uptime_seconds to uptime" do
- @plugin.run
- expect(@plugin[:uptime_seconds]).to eq(18423)
+ plugin.run
+ expect(plugin[:uptime_seconds]).to eq(18423)
end
it "sets uptime to a human readable date" do
- @plugin.run
- expect(@plugin[:uptime]).to eq("5 hours 07 minutes 03 seconds")
+ plugin.run
+ expect(plugin[:uptime]).to eq("5 hours 07 minutes 03 seconds")
end
it "sets idletime_seconds to uptime" do
- @plugin.run
- expect(@plugin[:idletime_seconds]).to eq(989)
+ plugin.run
+ expect(plugin[:idletime_seconds]).to eq(989)
end
it "sets idletime to a human readable date" do
- @plugin.run
- expect(@plugin[:idletime]).to eq("16 minutes 29 seconds")
+ plugin.run
+ expect(plugin[:idletime]).to eq("16 minutes 29 seconds")
end
end
diff --git a/spec/unit/plugins/netbsd/hostname_spec.rb b/spec/unit/plugins/netbsd/hostname_spec.rb
index 713fddbe..d7998828 100644
--- a/spec/unit/plugins/netbsd/hostname_spec.rb
+++ b/spec/unit/plugins/netbsd/hostname_spec.rb
@@ -20,11 +20,11 @@ require "spec_helper"
describe Ohai::System, "NetBSD hostname plugin" do
before do
- @plugin = get_plugin("hostname")
- allow(@plugin).to receive(:collect_os).and_return(:netbsd)
- allow(@plugin).to receive(:shell_out).with("hostname -s").and_return(mock_shell_out(0, "katie\n", ""))
- allow(@plugin).to receive(:shell_out).with("hostname").and_return(mock_shell_out(0, "katie.local", ""))
- allow(@plugin).to receive(:resolve_fqdn).and_return("katie.bethell")
+ plugin = get_plugin("hostname")
+ allow(plugin).to receive(:collect_os).and_return(:netbsd)
+ allow(plugin).to receive(:shell_out).with("hostname -s").and_return(mock_shell_out(0, "katie\n", ""))
+ allow(plugin).to receive(:shell_out).with("hostname").and_return(mock_shell_out(0, "katie.local", ""))
+ allow(plugin).to receive(:resolve_fqdn).and_return("katie.bethell")
end
it_should_check_from("linux::hostname", "hostname", "hostname -s", "katie")
@@ -32,12 +32,12 @@ describe Ohai::System, "NetBSD hostname plugin" do
it_should_check_from("linux::hostname", "machinename", "hostname", "katie.local")
it "uses #resolve_fqdn to find the fqdn" do
- @plugin.run
- expect(@plugin[:fqdn]).to eq("katie.bethell")
+ plugin.run
+ expect(plugin[:fqdn]).to eq("katie.bethell")
end
it "sets the domain to everything after the first dot of the fqdn" do
- @plugin.run
- expect(@plugin[:domain]).to eq("bethell")
+ plugin.run
+ expect(plugin[:domain]).to eq("bethell")
end
end
diff --git a/spec/unit/plugins/netbsd/kernel_spec.rb b/spec/unit/plugins/netbsd/kernel_spec.rb
index d6029d6d..498adb50 100644
--- a/spec/unit/plugins/netbsd/kernel_spec.rb
+++ b/spec/unit/plugins/netbsd/kernel_spec.rb
@@ -20,16 +20,16 @@ require "spec_helper"
describe Ohai::System, "NetBSD kernel plugin" do
before do
- @plugin = get_plugin("kernel")
- allow(@plugin).to receive(:collect_os).and_return(:netbsd)
- allow(@plugin).to receive(:init_kernel).and_return({})
- allow(@plugin).to receive(:shell_out).with("uname -i").and_return(mock_shell_out(0, "foo", ""))
- allow(@plugin).to receive(:shell_out).with("sysctl kern.securelevel").and_return(mock_shell_out(0, "kern.securelevel: 1\n", ""))
- allow(@plugin).to receive(:shell_out).with((Ohai.abs_path( "/usr/bin/modstat" )).to_s).and_return(mock_shell_out(0, " 1 7 0xc0400000 97f830 kernel", ""))
+ plugin = get_plugin("kernel")
+ allow(plugin).to receive(:collect_os).and_return(:netbsd)
+ allow(plugin).to receive(:init_kernel).and_return({})
+ allow(plugin).to receive(:shell_out).with("uname -i").and_return(mock_shell_out(0, "foo", ""))
+ allow(plugin).to receive(:shell_out).with("sysctl kern.securelevel").and_return(mock_shell_out(0, "kern.securelevel: 1\n", ""))
+ allow(plugin).to receive(:shell_out).with((Ohai.abs_path( "/usr/bin/modstat" )).to_s).and_return(mock_shell_out(0, " 1 7 0xc0400000 97f830 kernel", ""))
end
it "sets the kernel_os to the kernel_name value" do
- @plugin.run
- expect(@plugin[:kernel][:os]).to eq(@plugin[:kernel][:name])
+ plugin.run
+ expect(plugin[:kernel][:os]).to eq(plugin[:kernel][:name])
end
end
diff --git a/spec/unit/plugins/netbsd/platform_spec.rb b/spec/unit/plugins/netbsd/platform_spec.rb
index 77524287..283816d3 100644
--- a/spec/unit/plugins/netbsd/platform_spec.rb
+++ b/spec/unit/plugins/netbsd/platform_spec.rb
@@ -19,20 +19,21 @@
require "spec_helper"
describe Ohai::System, "NetBSD plugin platform" do
+ let(:plugin) { get_plugin("netbsd/platform") }
+
before do
- @plugin = get_plugin("netbsd/platform")
- allow(@plugin).to receive(:shell_out).with("uname -s").and_return(mock_shell_out(0, "NetBSD\n", ""))
- allow(@plugin).to receive(:shell_out).with("uname -r").and_return(mock_shell_out(0, "4.5\n", ""))
- allow(@plugin).to receive(:collect_os).and_return(:netbsd)
+ allow(plugin).to receive(:shell_out).with("uname -s").and_return(mock_shell_out(0, "NetBSD\n", ""))
+ allow(plugin).to receive(:shell_out).with("uname -r").and_return(mock_shell_out(0, "4.5\n", ""))
+ allow(plugin).to receive(:collect_os).and_return(:netbsd)
end
it "sets platform to lowercased lsb[:id]" do
- @plugin.run
- expect(@plugin[:platform]).to eq("netbsd")
+ plugin.run
+ expect(plugin[:platform]).to eq("netbsd")
end
it "sets platform_version to lsb[:release]" do
- @plugin.run
- expect(@plugin[:platform_version]).to eq("4.5")
+ plugin.run
+ expect(plugin[:platform_version]).to eq("4.5")
end
end
diff --git a/spec/unit/plugins/network_spec.rb b/spec/unit/plugins/network_spec.rb
index 9ab12a90..a26f4c09 100644
--- a/spec/unit/plugins/network_spec.rb
+++ b/spec/unit/plugins/network_spec.rb
@@ -20,9 +20,9 @@ require "spec_helper"
def it_doesnt_fail
it "doesnt fail" do
- allow(@plugin.logger).to receive(:warn)
- expect(@plugin.logger).not_to receive(:trace).with(/^Plugin network threw exception/)
- @plugin.run
+ allow(plugin.logger).to receive(:warn)
+ expect(plugin.logger).not_to receive(:trace).with(/^Plugin network threw exception/)
+ plugin.run
end
end
@@ -32,11 +32,11 @@ def it_populates_ipaddress_attributes
it "populates ipaddress, macaddress and ip6address" do
- allow(@plugin.logger).to receive(:warn)
- expect(@plugin.logger).not_to receive(:trace).with(/^Plugin network threw exception/)
- @plugin.run
+ allow(plugin.logger).to receive(:warn)
+ expect(plugin.logger).not_to receive(:trace).with(/^Plugin network threw exception/)
+ plugin.run
%w{ ipaddress macaddress ip6address }.each do |attribute|
- expect(@plugin).to have_key(attribute)
+ expect(plugin).to have_key(attribute)
end
rescue Exception
puts "RSpec context: #{source}"
@@ -46,7 +46,6 @@ def it_populates_ipaddress_attributes
end
describe Ohai::System, "Network Plugin" do
-
# output of network plugins on particular platforms to mock plugin runs
basic_data = {
"freebsd" => {
@@ -329,9 +328,10 @@ describe Ohai::System, "Network Plugin" do
}
describe "on linux" do
+ let(:plugin) { get_plugin("network") }
+
before do
- @plugin = get_plugin("network")
- @plugin["network"] = basic_data["linux"]["network"]
+ plugin["network"] = basic_data["linux"]["network"]
end
describe "when the linux::network plugin hasn't set any of {ip,ip6,mac}address attributes" do
@@ -339,66 +339,66 @@ describe Ohai::System, "Network Plugin" do
it_populates_ipaddress_attributes
it "detects {ip,ip6,mac}address" do
- @plugin.run
- expect(@plugin["ipaddress"]).to eq("192.168.66.33")
- expect(@plugin["macaddress"]).to eq("00:16:3E:2F:36:79")
- expect(@plugin["ip6address"]).to eq("3ffe:1111:2222::33")
+ plugin.run
+ expect(plugin["ipaddress"]).to eq("192.168.66.33")
+ expect(plugin["macaddress"]).to eq("00:16:3E:2F:36:79")
+ expect(plugin["ip6address"]).to eq("3ffe:1111:2222::33")
end
end
describe "default ipv4 and ipv6 gateway on different interfaces" do
describe "both interfaces have an ARP" do
before do
- @plugin["network"]["default_inet6_gateway"] = "3ffe:1111:3333::"
- @plugin["network"]["default_inet6_interface"] = "eth1"
+ plugin["network"]["default_inet6_gateway"] = "3ffe:1111:3333::"
+ plugin["network"]["default_inet6_interface"] = "eth1"
end
it_populates_ipaddress_attributes
it "detects {ip,ip6}address" do
- @plugin.run
- expect(@plugin["ipaddress"]).to eq("192.168.66.33")
- expect(@plugin["ip6address"]).to eq("3ffe:1111:3333::1")
+ plugin.run
+ expect(plugin["ipaddress"]).to eq("192.168.66.33")
+ expect(plugin["ip6address"]).to eq("3ffe:1111:3333::1")
end
it "set macaddress from the ipv4 setup" do
- @plugin.run
- expect(@plugin["macaddress"]).to eq("00:16:3E:2F:36:79")
+ plugin.run
+ expect(plugin["macaddress"]).to eq("00:16:3E:2F:36:79")
end
it "informs about this setup" do
- expect(@plugin.logger).to receive(:trace).with(/ipaddress and ip6address are set from different interfaces/)
- allow(@plugin.logger).to receive(:trace)
- @plugin.run
+ expect(plugin.logger).to receive(:trace).with(/ipaddress and ip6address are set from different interfaces/)
+ allow(plugin.logger).to receive(:trace)
+ plugin.run
end
end
describe "ipv4 interface has no ARP" do
before do
- @plugin["network"]["interfaces"]["eth0"]["addresses"].delete_if { |k, kv| kv["family"] == "lladdr" }
+ plugin["network"]["interfaces"]["eth0"]["addresses"].delete_if { |k, kv| kv["family"] == "lladdr" }
# not really checked by this pluging
- @plugin["network"]["interfaces"]["eth0"]["flags"] << "NOARP"
- @plugin["network"]["default_inet6_gateway"] = "3ffe:1111:3333::"
- @plugin["network"]["default_inet6_interface"] = "eth1"
+ plugin["network"]["interfaces"]["eth0"]["flags"] << "NOARP"
+ plugin["network"]["default_inet6_gateway"] = "3ffe:1111:3333::"
+ plugin["network"]["default_inet6_interface"] = "eth1"
end
it_populates_ipaddress_attributes
it "detects {ip,ip6}address" do
- @plugin.run
- expect(@plugin["ipaddress"]).to eq("192.168.66.33")
- expect(@plugin["ip6address"]).to eq("3ffe:1111:3333::1")
+ plugin.run
+ expect(plugin["ipaddress"]).to eq("192.168.66.33")
+ expect(plugin["ip6address"]).to eq("3ffe:1111:3333::1")
end
it "sets macaddress to the ipv6 interface because it hadn't set one for ipv4 first" do
- @plugin.run
- expect(@plugin["macaddress"]).to eq("00:16:3E:2F:36:80")
+ plugin.run
+ expect(plugin["macaddress"]).to eq("00:16:3E:2F:36:80")
end
it "informs about this setup" do
- expect(@plugin.logger).to receive(:trace).with(/ipaddress and ip6address are set from different interfaces/)
- allow(@plugin.logger).to receive(:trace)
- @plugin.run
+ expect(plugin.logger).to receive(:trace).with(/ipaddress and ip6address are set from different interfaces/)
+ allow(plugin.logger).to receive(:trace)
+ plugin.run
end
end
end
@@ -406,76 +406,76 @@ describe Ohai::System, "Network Plugin" do
describe "conflicting results from the linux::network plugin" do
describe "default interface doesn't match the default_gateway" do
before do
- @plugin["network"]["default_interface"] = "eth1"
- @plugin["network"]["default_inet6_interface"] = "eth1"
+ plugin["network"]["default_interface"] = "eth1"
+ plugin["network"]["default_inet6_interface"] = "eth1"
end
it_populates_ipaddress_attributes
it "picks {ip,ip6,mac}address" do
- allow(@plugin.logger).to receive(:warn)
- @plugin.run
- expect(@plugin["ipaddress"]).to eq("192.168.99.11")
- expect(@plugin["macaddress"]).to eq("00:16:3E:2F:36:80")
- expect(@plugin["ip6address"]).to eq("3ffe:1111:3333::1")
+ allow(plugin.logger).to receive(:warn)
+ plugin.run
+ expect(plugin["ipaddress"]).to eq("192.168.99.11")
+ expect(plugin["macaddress"]).to eq("00:16:3E:2F:36:80")
+ expect(plugin["ip6address"]).to eq("3ffe:1111:3333::1")
end
it "warns about this conflict" do
- expect(@plugin.logger).to receive(:trace).with(%r{\[inet\] no ipaddress/mask on eth1}).once
- expect(@plugin.logger).to receive(:trace).with(%r{\[inet6\] no ipaddress/mask on eth1}).once
- allow(@plugin.logger).to receive(:trace)
- @plugin.run
+ expect(plugin.logger).to receive(:trace).with(%r{\[inet\] no ipaddress/mask on eth1}).once
+ expect(plugin.logger).to receive(:trace).with(%r{\[inet6\] no ipaddress/mask on eth1}).once
+ allow(plugin.logger).to receive(:trace)
+ plugin.run
end
end
describe "there's a default gateway, none of the configured ip/mask theorically allows to reach it" do
before do
- @plugin["network"]["default_gateway"] = "172.16.12.42"
- @plugin["network"]["default_inet6_gateway"] = "3ffe:12:42::7070"
+ plugin["network"]["default_gateway"] = "172.16.12.42"
+ plugin["network"]["default_inet6_gateway"] = "3ffe:12:42::7070"
end
it "picks {ip,ip6,mac}address" do
- allow(@plugin.logger).to receive(:warn)
- @plugin.run
- expect(@plugin["ipaddress"]).to eq("192.168.66.33")
- expect(@plugin["macaddress"]).to eq("00:16:3E:2F:36:79")
- expect(@plugin["ip6address"]).to eq("3ffe:1111:2222::33")
+ allow(plugin.logger).to receive(:warn)
+ plugin.run
+ expect(plugin["ipaddress"]).to eq("192.168.66.33")
+ expect(plugin["macaddress"]).to eq("00:16:3E:2F:36:79")
+ expect(plugin["ip6address"]).to eq("3ffe:1111:2222::33")
end
end
describe "no ip address for the given default interface/gateway" do
before do
- @plugin["network"]["interfaces"]["eth0"]["addresses"].delete_if { |k, v| %w{inet inet6}.include? v["family"] }
+ plugin["network"]["interfaces"]["eth0"]["addresses"].delete_if { |k, v| %w{inet inet6}.include? v["family"] }
end
it_doesnt_fail
it "doesn't detect {ip,ip6,mac}address" do
- allow(@plugin.logger).to receive(:warn)
- @plugin.run
- expect(@plugin["ipaddress"]).to be_nil
- expect(@plugin["macaddress"]).to be_nil
- expect(@plugin["ip6address"]).to be_nil
+ allow(plugin.logger).to receive(:warn)
+ plugin.run
+ expect(plugin["ipaddress"]).to be_nil
+ expect(plugin["macaddress"]).to be_nil
+ expect(plugin["ip6address"]).to be_nil
end
it "warns about this conflict" do
- expect(@plugin.logger).to receive(:warn).with(/unable to detect ipaddress/).once
- expect(@plugin.logger).to receive(:warn).with(/\[inet\] no ip address on eth0/).once
- expect(@plugin.logger).to receive(:trace).with(/unable to detect ip6address/).once
- expect(@plugin.logger).to receive(:trace).with(/unable to detect macaddress/).twice # for each family
- expect(@plugin.logger).to receive(:warn).with(/\[inet6\] no ip address on eth0/).once
- @plugin.run
+ expect(plugin.logger).to receive(:warn).with(/unable to detect ipaddress/).once
+ expect(plugin.logger).to receive(:warn).with(/\[inet\] no ip address on eth0/).once
+ expect(plugin.logger).to receive(:trace).with(/unable to detect ip6address/).once
+ expect(plugin.logger).to receive(:trace).with(/unable to detect macaddress/).twice # for each family
+ expect(plugin.logger).to receive(:warn).with(/\[inet6\] no ip address on eth0/).once
+ plugin.run
end
end
describe "no ip at all" do
before do
- @plugin["network"]["default_gateway"] = nil
- @plugin["network"]["default_interface"] = nil
- @plugin["network"]["default_inet6_gateway"] = nil
- @plugin["network"]["default_inet6_interface"] = nil
- @plugin["network"]["interfaces"].each_value do |val|
+ plugin["network"]["default_gateway"] = nil
+ plugin["network"]["default_interface"] = nil
+ plugin["network"]["default_inet6_gateway"] = nil
+ plugin["network"]["default_inet6_interface"] = nil
+ plugin["network"]["interfaces"].each_value do |val|
val["addresses"].delete_if { |k, kv| %w{inet inet6}.include? kv["family"] }
end
end
@@ -483,18 +483,18 @@ describe Ohai::System, "Network Plugin" do
it_doesnt_fail
it "doesn't detect {ip,ip6,mac}address" do
- allow(@plugin.logger).to receive(:warn)
- @plugin.run
- expect(@plugin["ipaddress"]).to be_nil
- expect(@plugin["macaddress"]).to be_nil
- expect(@plugin["ip6address"]).to be_nil
+ allow(plugin.logger).to receive(:warn)
+ plugin.run
+ expect(plugin["ipaddress"]).to be_nil
+ expect(plugin["macaddress"]).to be_nil
+ expect(plugin["ip6address"]).to be_nil
end
it "warns about it" do
- expect(@plugin.logger).to receive(:warn).with(/unable to detect ipaddress/).once
- expect(@plugin.logger).to receive(:trace).with(/unable to detect macaddress/).twice # for each family
- expect(@plugin.logger).to receive(:trace).with(/unable to detect ip6address/).once
- @plugin.run
+ expect(plugin.logger).to receive(:warn).with(/unable to detect ipaddress/).once
+ expect(plugin.logger).to receive(:trace).with(/unable to detect macaddress/).twice # for each family
+ expect(plugin.logger).to receive(:trace).with(/unable to detect ip6address/).once
+ plugin.run
end
end
end
@@ -502,7 +502,7 @@ describe Ohai::System, "Network Plugin" do
describe "several ipaddresses matching the default route" do
describe "bigger prefix not set on the default interface" do
before do
- @plugin["network"]["interfaces"]["eth2"] = {
+ plugin["network"]["interfaces"]["eth2"] = {
"flags" => %w{BROADCAST MULTICAST UP},
"number" => "2",
"addresses" => {
@@ -531,23 +531,23 @@ describe Ohai::System, "Network Plugin" do
it_populates_ipaddress_attributes
it "sets {ip,ip6,mac}address correctly" do
- @plugin.run
- expect(@plugin["ipaddress"]).to eq("192.168.66.33")
- expect(@plugin["macaddress"]).to eq("00:16:3E:2F:36:79")
- expect(@plugin["ip6address"]).to eq("3ffe:1111:2222::33")
+ plugin.run
+ expect(plugin["ipaddress"]).to eq("192.168.66.33")
+ expect(plugin["macaddress"]).to eq("00:16:3E:2F:36:79")
+ expect(plugin["ip6address"]).to eq("3ffe:1111:2222::33")
end
end
describe "bigger prefix set on the default interface" do
before do
- @plugin["network"]["interfaces"]["eth0"]["addresses"]["192.168.66.99"] = {
+ plugin["network"]["interfaces"]["eth0"]["addresses"]["192.168.66.99"] = {
"scope" => "Global",
"netmask" => "255.255.255.128",
"broadcast" => "192.168.66.127",
"prefixlen" => "25",
"family" => "inet",
}
- @plugin["network"]["interfaces"]["eth0"]["addresses"]["3ffe:1111:2222:0:4444::1"] = {
+ plugin["network"]["interfaces"]["eth0"]["addresses"]["3ffe:1111:2222:0:4444::1"] = {
"prefixlen" => "64",
"family" => "inet6",
"scope" => "Global",
@@ -557,16 +557,16 @@ describe Ohai::System, "Network Plugin" do
it_populates_ipaddress_attributes
it "sets {ip,ip6,mac}address correctly" do
- @plugin.run
- expect(@plugin["ipaddress"]).to eq("192.168.66.99")
- expect(@plugin["macaddress"]).to eq("00:16:3E:2F:36:79")
- expect(@plugin["ip6address"]).to eq("3ffe:1111:2222:0:4444::1")
+ plugin.run
+ expect(plugin["ipaddress"]).to eq("192.168.66.99")
+ expect(plugin["macaddress"]).to eq("00:16:3E:2F:36:79")
+ expect(plugin["ip6address"]).to eq("3ffe:1111:2222:0:4444::1")
end
end
describe "smallest ip not set on the default_interface" do
before do
- @plugin["network"]["interfaces"]["eth2"] = {
+ plugin["network"]["interfaces"]["eth2"] = {
"flags" => %w{BROADCAST MULTICAST UP},
"number" => "2",
"addresses" => {
@@ -595,23 +595,23 @@ describe Ohai::System, "Network Plugin" do
it_populates_ipaddress_attributes
it "sets {ip,ip6,mac}address correctly" do
- @plugin.run
- expect(@plugin["ipaddress"]).to eq("192.168.66.33")
- expect(@plugin["macaddress"]).to eq("00:16:3E:2F:36:79")
- expect(@plugin["ip6address"]).to eq("3ffe:1111:2222::33")
+ plugin.run
+ expect(plugin["ipaddress"]).to eq("192.168.66.33")
+ expect(plugin["macaddress"]).to eq("00:16:3E:2F:36:79")
+ expect(plugin["ip6address"]).to eq("3ffe:1111:2222::33")
end
end
describe "smallest ip set on the default_interface" do
before do
- @plugin["network"]["interfaces"]["eth0"]["addresses"]["192.168.66.32"] = {
+ plugin["network"]["interfaces"]["eth0"]["addresses"]["192.168.66.32"] = {
"scope" => "Global",
"netmask" => "255.255.255.0",
"broadcast" => "192.168.66.255",
"prefixlen" => "24",
"family" => "inet",
}
- @plugin["network"]["interfaces"]["eth0"]["addresses"]["3ffe:1111:2222::32"] = {
+ plugin["network"]["interfaces"]["eth0"]["addresses"]["3ffe:1111:2222::32"] = {
"prefixlen" => "48",
"family" => "inet6",
"scope" => "Global",
@@ -621,10 +621,10 @@ describe Ohai::System, "Network Plugin" do
it_populates_ipaddress_attributes
it "sets {ip,ip6,mac}address correctly" do
- @plugin.run
- expect(@plugin["ipaddress"]).to eq("192.168.66.32")
- expect(@plugin["macaddress"]).to eq("00:16:3E:2F:36:79")
- expect(@plugin["ip6address"]).to eq("3ffe:1111:2222::32")
+ plugin.run
+ expect(plugin["ipaddress"]).to eq("192.168.66.32")
+ expect(plugin["macaddress"]).to eq("00:16:3E:2F:36:79")
+ expect(plugin["ip6address"]).to eq("3ffe:1111:2222::32")
end
end
end
@@ -632,47 +632,47 @@ describe Ohai::System, "Network Plugin" do
describe "no default route" do
describe "first interface is not the best choice" do
before do
- @plugin["network"]["default_gateway"] = nil
- @plugin["network"]["default_interface"] = nil
- @plugin["network"]["default_inet6_gateway"] = nil
- @plugin["network"]["default_inet6_interface"] = nil
+ plugin["network"]["default_gateway"] = nil
+ plugin["network"]["default_interface"] = nil
+ plugin["network"]["default_inet6_gateway"] = nil
+ plugin["network"]["default_inet6_interface"] = nil
# removing inet* addresses from eth0, to complicate things a bit
- @plugin["network"]["interfaces"]["eth0"]["addresses"].delete_if { |k, v| %w{inet inet6}.include? v["family"] }
+ plugin["network"]["interfaces"]["eth0"]["addresses"].delete_if { |k, v| %w{inet inet6}.include? v["family"] }
end
it_populates_ipaddress_attributes
it "picks {ip,mac,ip6}address from the first interface" do
- expect(@plugin.logger).to receive(:trace).with(/\[inet\] no default interface/).once
- expect(@plugin.logger).to receive(:trace).with(/\[inet6\] no default interface/).once
- allow(@plugin.logger).to receive(:trace)
- @plugin.run
- expect(@plugin["ipaddress"]).to eq("192.168.99.11")
- expect(@plugin["macaddress"]).to eq("00:16:3E:2F:36:80")
- expect(@plugin["ip6address"]).to eq("3ffe:1111:3333::1")
+ expect(plugin.logger).to receive(:trace).with(/\[inet\] no default interface/).once
+ expect(plugin.logger).to receive(:trace).with(/\[inet6\] no default interface/).once
+ allow(plugin.logger).to receive(:trace)
+ plugin.run
+ expect(plugin["ipaddress"]).to eq("192.168.99.11")
+ expect(plugin["macaddress"]).to eq("00:16:3E:2F:36:80")
+ expect(plugin["ip6address"]).to eq("3ffe:1111:3333::1")
end
end
describe "can choose from addresses with different scopes" do
before do
- @plugin["network"]["default_gateway"] = nil
- @plugin["network"]["default_interface"] = nil
- @plugin["network"]["default_inet6_gateway"] = nil
- @plugin["network"]["default_inet6_interface"] = nil
+ plugin["network"]["default_gateway"] = nil
+ plugin["network"]["default_interface"] = nil
+ plugin["network"]["default_inet6_gateway"] = nil
+ plugin["network"]["default_inet6_interface"] = nil
# just changing scopes to lInK for eth0 addresses
- @plugin["network"]["interfaces"]["eth0"]["addresses"].each_value { |v| v[:scope] = "lInK" if %w{inet inet6}.include? v["family"] }
+ plugin["network"]["interfaces"]["eth0"]["addresses"].each_value { |v| v[:scope] = "lInK" if %w{inet inet6}.include? v["family"] }
end
it_populates_ipaddress_attributes
it "prefers global scope addressses to set {ip,mac,ip6}address" do
- expect(@plugin.logger).to receive(:trace).with(/\[inet\] no default interface/).once
- expect(@plugin.logger).to receive(:trace).with(/\[inet6\] no default interface/).once
- allow(@plugin.logger).to receive(:trace)
- @plugin.run
- expect(@plugin["ipaddress"]).to eq("192.168.99.11")
- expect(@plugin["macaddress"]).to eq("00:16:3E:2F:36:80")
- expect(@plugin["ip6address"]).to eq("3ffe:1111:3333::1")
+ expect(plugin.logger).to receive(:trace).with(/\[inet\] no default interface/).once
+ expect(plugin.logger).to receive(:trace).with(/\[inet6\] no default interface/).once
+ allow(plugin.logger).to receive(:trace)
+ plugin.run
+ expect(plugin["ipaddress"]).to eq("192.168.99.11")
+ expect(plugin["macaddress"]).to eq("00:16:3E:2F:36:80")
+ expect(plugin["ip6address"]).to eq("3ffe:1111:3333::1")
end
end
end
@@ -680,42 +680,42 @@ describe Ohai::System, "Network Plugin" do
describe "link level default route" do
describe "simple setup" do
before do
- @plugin["network"]["default_gateway"] = "0.0.0.0"
- @plugin["network"]["default_interface"] = "eth1"
- @plugin["network"]["default_inet6_gateway"] = "::"
- @plugin["network"]["default_inet6_interface"] = "eth1"
+ plugin["network"]["default_gateway"] = "0.0.0.0"
+ plugin["network"]["default_interface"] = "eth1"
+ plugin["network"]["default_inet6_gateway"] = "::"
+ plugin["network"]["default_inet6_interface"] = "eth1"
end
it_populates_ipaddress_attributes
it "picks {ip,mac,ip6}address from the default interface" do
- @plugin.run
- expect(@plugin["ipaddress"]).to eq("192.168.99.11")
- expect(@plugin["macaddress"]).to eq("00:16:3E:2F:36:80")
- expect(@plugin["ip6address"]).to eq("3ffe:1111:3333::1")
+ plugin.run
+ expect(plugin["ipaddress"]).to eq("192.168.99.11")
+ expect(plugin["macaddress"]).to eq("00:16:3E:2F:36:80")
+ expect(plugin["ip6address"]).to eq("3ffe:1111:3333::1")
end
end
describe "fe80::1 as a default gateway" do
before do
- @plugin["network"]["default_inet6_gateway"] = "fe80::1"
+ plugin["network"]["default_inet6_gateway"] = "fe80::1"
end
it_populates_ipaddress_attributes
it "picks {ip,mac,ip6}address from the default interface" do
- @plugin.run
- expect(@plugin["ip6address"]).to eq("3ffe:1111:2222::33")
+ plugin.run
+ expect(plugin["ip6address"]).to eq("3ffe:1111:2222::33")
end
end
describe "can choose from addresses with different scopes" do
before do
- @plugin["network"]["default_gateway"] = "0.0.0.0"
- @plugin["network"]["default_interface"] = "eth1"
- @plugin["network"]["default_inet6_gateway"] = "::"
- @plugin["network"]["default_inet6_interface"] = "eth1"
- @plugin["network"]["interfaces"]["eth1"]["addresses"]["127.0.0.2"] = {
+ plugin["network"]["default_gateway"] = "0.0.0.0"
+ plugin["network"]["default_interface"] = "eth1"
+ plugin["network"]["default_inet6_gateway"] = "::"
+ plugin["network"]["default_inet6_interface"] = "eth1"
+ plugin["network"]["interfaces"]["eth1"]["addresses"]["127.0.0.2"] = {
"scope" => "host",
"netmask" => "255.255.255.255",
"prefixlen" => "32",
@@ -726,17 +726,17 @@ describe Ohai::System, "Network Plugin" do
it_populates_ipaddress_attributes
it "picks {ip,mac,ip6}address from the default interface" do
- @plugin.run
- expect(@plugin["ipaddress"]).to eq("192.168.99.11")
- expect(@plugin["macaddress"]).to eq("00:16:3E:2F:36:80")
- expect(@plugin["ip6address"]).to eq("3ffe:1111:3333::1")
+ plugin.run
+ expect(plugin["ipaddress"]).to eq("192.168.99.11")
+ expect(plugin["macaddress"]).to eq("00:16:3E:2F:36:80")
+ expect(plugin["ip6address"]).to eq("3ffe:1111:3333::1")
end
end
end
describe "point to point address" do
before do
- @plugin["network"]["interfaces"]["eth2"] = {
+ plugin["network"]["interfaces"]["eth2"] = {
"flags" => %w{POINTOPOINT BROADCAST MULTICAST UP},
"number" => "2",
"addresses" => {
@@ -761,27 +761,27 @@ describe Ohai::System, "Network Plugin" do
},
},
}
- @plugin["network"]["default_gateway"] = "192.168.99.126"
- @plugin["network"]["default_interface"] = "eth2"
- @plugin["network"]["default_inet6_gateway"] = "3ffe:1111:2222:0:4444::2"
- @plugin["network"]["default_inet6_interface"] = "eth2"
+ plugin["network"]["default_gateway"] = "192.168.99.126"
+ plugin["network"]["default_interface"] = "eth2"
+ plugin["network"]["default_inet6_gateway"] = "3ffe:1111:2222:0:4444::2"
+ plugin["network"]["default_inet6_interface"] = "eth2"
end
it_populates_ipaddress_attributes
it "picks {ip,mac,ip6}address from the default interface" do
- @plugin.run
- expect(@plugin["ipaddress"]).to eq("192.168.66.99")
- expect(@plugin["macaddress"]).to eq("00:16:3E:2F:36:81")
- expect(@plugin["ip6address"]).to eq("3ffe:1111:2222:0:4444::1")
+ plugin.run
+ expect(plugin["ipaddress"]).to eq("192.168.66.99")
+ expect(plugin["macaddress"]).to eq("00:16:3E:2F:36:81")
+ expect(plugin["ip6address"]).to eq("3ffe:1111:2222:0:4444::1")
end
end
describe "ipv6 only node" do
before do
- @plugin["network"]["default_gateway"] = nil
- @plugin["network"]["default_interface"] = nil
- @plugin["network"]["interfaces"].each_value do |val|
+ plugin["network"]["default_gateway"] = nil
+ plugin["network"]["default_interface"] = nil
+ plugin["network"]["interfaces"].each_value do |val|
val["addresses"].delete_if { |k, kv| kv["family"] == "inet" }
end
end
@@ -789,38 +789,38 @@ describe Ohai::System, "Network Plugin" do
it_doesnt_fail
it "can't detect ipaddress" do
- allow(@plugin.logger).to receive(:warn)
- @plugin.run
- expect(@plugin["ipaddress"]).to be_nil
+ allow(plugin.logger).to receive(:warn)
+ plugin.run
+ expect(plugin["ipaddress"]).to be_nil
end
it "warns about not being able to set {ip,mac}address (ipv4)" do
- expect(@plugin.logger).to receive(:warn).with(/unable to detect ipaddress/).once
- expect(@plugin.logger).to receive(:trace).with(/unable to detect macaddress/) # for ipv4
- expect(@plugin.logger).to receive(:trace).with(/setting macaddress to/) # for ipv6
- expect(@plugin.logger).to receive(:trace).with(/\[inet6\] Using default interface eth0 and default gateway/) # for ipv6
- @plugin.run
+ expect(plugin.logger).to receive(:warn).with(/unable to detect ipaddress/).once
+ expect(plugin.logger).to receive(:trace).with(/unable to detect macaddress/) # for ipv4
+ expect(plugin.logger).to receive(:trace).with(/setting macaddress to/) # for ipv6
+ expect(plugin.logger).to receive(:trace).with(/\[inet6\] Using default interface eth0 and default gateway/) # for ipv6
+ plugin.run
end
it "sets {ip6,mac}address" do
- allow(@plugin.logger).to receive(:warn)
- @plugin.run
- expect(@plugin["ip6address"]).to eq("3ffe:1111:2222::33")
- expect(@plugin["macaddress"]).to eq("00:16:3E:2F:36:79")
+ allow(plugin.logger).to receive(:warn)
+ plugin.run
+ expect(plugin["ip6address"]).to eq("3ffe:1111:2222::33")
+ expect(plugin["macaddress"]).to eq("00:16:3E:2F:36:79")
end
it "informs about macaddress being set using the ipv6 setup" do
- expect(@plugin.logger).to receive(:trace).with(/setting macaddress to '00:16:3E:2F:36:79'/)
- allow(@plugin.logger).to receive(:trace)
- @plugin.run
+ expect(plugin.logger).to receive(:trace).with(/setting macaddress to '00:16:3E:2F:36:79'/)
+ allow(plugin.logger).to receive(:trace)
+ plugin.run
end
end
describe "ipv6 only with ipv4 loopback" do
before do
- @plugin["network"]["default_gateway"] = nil
- @plugin["network"]["default_interface"] = nil
- @plugin["network"]["interfaces"].each do |i, iv|
+ plugin["network"]["default_gateway"] = nil
+ plugin["network"]["default_interface"] = nil
+ plugin["network"]["interfaces"].each do |i, iv|
next if i == "lo"
iv["addresses"].delete_if { |k, kv| kv["family"] == "inet" }
@@ -830,22 +830,22 @@ describe Ohai::System, "Network Plugin" do
it_doesnt_fail
it "can't detect ipaddress" do
- allow(@plugin.logger).to receive(:warn)
- @plugin.run
- expect(@plugin["ipaddress"]).to eq("127.0.0.1")
+ allow(plugin.logger).to receive(:warn)
+ plugin.run
+ expect(plugin["ipaddress"]).to eq("127.0.0.1")
end
it "sets {ip6,mac}address" do
- allow(@plugin.logger).to receive(:warn)
- @plugin.run
- expect(@plugin["ip6address"]).to eq("3ffe:1111:2222::33")
- expect(@plugin["macaddress"]).to eq("00:16:3E:2F:36:79")
+ allow(plugin.logger).to receive(:warn)
+ plugin.run
+ expect(plugin["ip6address"]).to eq("3ffe:1111:2222::33")
+ expect(plugin["macaddress"]).to eq("00:16:3E:2F:36:79")
end
it "informs about macaddress being set using the ipv6 setup" do
- expect(@plugin.logger).to receive(:trace).with(/setting macaddress to '00:16:3E:2F:36:79'/)
- allow(@plugin.logger).to receive(:trace)
- @plugin.run
+ expect(plugin.logger).to receive(:trace).with(/setting macaddress to '00:16:3E:2F:36:79'/)
+ allow(plugin.logger).to receive(:trace)
+ plugin.run
end
end
end
@@ -854,13 +854,13 @@ describe Ohai::System, "Network Plugin" do
basic_data.keys.sort.each do |os|
describe "the #{os}::network has already set some of the {ip,mac,ip6}address attributes" do
before do
- @plugin["network"] = basic_data[os]["network"]
+ plugin["network"] = basic_data[os]["network"]
end
describe "{ip,mac}address are already set" do
before do
- @plugin["ipaddress"] = "10.11.12.13"
- @plugin["macaddress"] = "00:AA:BB:CC:DD:EE"
+ plugin["ipaddress"] = "10.11.12.13"
+ plugin["macaddress"] = "00:AA:BB:CC:DD:EE"
@expected_results = {
"freebsd" => {
"ip6address" => "2001:470:d:cb4::1",
@@ -880,21 +880,21 @@ describe Ohai::System, "Network Plugin" do
it_populates_ipaddress_attributes
it "detects ip6address" do
- @plugin.run
- expect(@plugin["ip6address"]).to eq(@expected_results[os]["ip6address"])
+ plugin.run
+ expect(plugin["ip6address"]).to eq(@expected_results[os]["ip6address"])
end
it "doesn't overwrite {ip,mac}address" do
- @plugin.run
- expect(@plugin["ipaddress"]).to eq("10.11.12.13")
- expect(@plugin["macaddress"]).to eq("00:AA:BB:CC:DD:EE")
+ plugin.run
+ expect(plugin["ipaddress"]).to eq("10.11.12.13")
+ expect(plugin["macaddress"]).to eq("00:AA:BB:CC:DD:EE")
end
end
describe "ip6address is already set" do
describe "node has ipv4 and ipv6" do
before do
- @plugin["ip6address"] = "3ffe:8888:9999::1"
+ plugin["ip6address"] = "3ffe:8888:9999::1"
@expected_results = {
"freebsd" => {
"ipaddress" => "76.91.1.255",
@@ -914,27 +914,27 @@ describe Ohai::System, "Network Plugin" do
it_populates_ipaddress_attributes
it "detects {ip,mac}address" do
- @plugin.run
- expect(@plugin["ipaddress"]).to eq(@expected_results[os]["ipaddress"])
- expect(@plugin["macaddress"]).to eq(@expected_results[os]["macaddress"])
+ plugin.run
+ expect(plugin["ipaddress"]).to eq(@expected_results[os]["ipaddress"])
+ expect(plugin["macaddress"]).to eq(@expected_results[os]["macaddress"])
end
it "doesn't overwrite ip6address" do
- @plugin.run
- expect(@plugin["ip6address"]).to eq("3ffe:8888:9999::1")
+ plugin.run
+ expect(plugin["ip6address"]).to eq("3ffe:8888:9999::1")
end
end
describe "ipv6 only node" do
before do
- @plugin["network"]["default_gateway"] = nil
- @plugin["network"]["default_interface"] = nil
- @plugin["network"]["interfaces"].each_value do |val|
+ plugin["network"]["default_gateway"] = nil
+ plugin["network"]["default_interface"] = nil
+ plugin["network"]["interfaces"].each_value do |val|
if val.key? "addresses"
val["addresses"].delete_if { |k, kv| kv["family"] == "inet" }
end
end
- @plugin["ip6address"] = "3ffe:8888:9999::1"
+ plugin["ip6address"] = "3ffe:8888:9999::1"
@expected_results = {
"freebsd" => {
"macaddress" => "02:20:6f:d2:c4:00",
@@ -951,26 +951,26 @@ describe Ohai::System, "Network Plugin" do
it_doesnt_fail
it "can't detect ipaddress (ipv4)" do
- allow(@plugin.logger).to receive(:warn)
- @plugin.run
- expect(@plugin["ipaddress"]).to be_nil
+ allow(plugin.logger).to receive(:warn)
+ plugin.run
+ expect(plugin["ipaddress"]).to be_nil
end
it "takes the macaddress from ipv6" do
- allow(@plugin.logger).to receive(:warn)
- @plugin.run
- expect(@plugin["macaddress"]).to eq(@expected_results[os]["macaddress"])
+ allow(plugin.logger).to receive(:warn)
+ plugin.run
+ expect(plugin["macaddress"]).to eq(@expected_results[os]["macaddress"])
end
it "warns about not being able to set ipaddress" do
- expect(@plugin.logger).to receive(:warn).with(/unable to detect ipaddress/).once
- @plugin.run
+ expect(plugin.logger).to receive(:warn).with(/unable to detect ipaddress/).once
+ plugin.run
end
it "doesn't overwrite ip6address" do
- allow(@plugin.logger).to receive(:warn)
- @plugin.run
- expect(@plugin["ip6address"]).to eq("3ffe:8888:9999::1")
+ allow(plugin.logger).to receive(:warn)
+ plugin.run
+ expect(plugin["ip6address"]).to eq("3ffe:8888:9999::1")
end
end
end
@@ -978,8 +978,8 @@ describe Ohai::System, "Network Plugin" do
describe "{mac,ip6}address are already set" do
describe "valid ipv4 setup" do
before do
- @plugin["macaddress"] = "00:AA:BB:CC:DD:EE"
- @plugin["ip6address"] = "3ffe:8888:9999::1"
+ plugin["macaddress"] = "00:AA:BB:CC:DD:EE"
+ plugin["ip6address"] = "3ffe:8888:9999::1"
@expected_results = {
"freebsd" => {
"ipaddress" => "76.91.1.255",
@@ -999,76 +999,76 @@ describe Ohai::System, "Network Plugin" do
it_populates_ipaddress_attributes
it "detects ipaddress and does not overwrite macaddress" do
- @plugin.run
- expect(@plugin["ipaddress"]).to eq(@expected_results[os]["ipaddress"])
- expect(@plugin["macaddress"]).to eq(@plugin["macaddress"])
+ plugin.run
+ expect(plugin["ipaddress"]).to eq(@expected_results[os]["ipaddress"])
+ expect(plugin["macaddress"]).to eq(plugin["macaddress"])
end
it "doesn't overwrite ip6address" do
- @plugin.run
- expect(@plugin["ip6address"]).to eq("3ffe:8888:9999::1")
+ plugin.run
+ expect(plugin["ip6address"]).to eq("3ffe:8888:9999::1")
end
end
describe "ipv6 only node" do
before do
- @plugin["network"]["default_gateway"] = nil
- @plugin["network"]["default_interface"] = nil
- @plugin["network"]["interfaces"].each_value do |val|
+ plugin["network"]["default_gateway"] = nil
+ plugin["network"]["default_interface"] = nil
+ plugin["network"]["interfaces"].each_value do |val|
if val.key? "addresses"
val["addresses"].delete_if { |k, kv| kv["family"] == "inet" }
end
end
- @plugin["macaddress"] = "00:AA:BB:CC:DD:EE"
- @plugin["ip6address"] = "3ffe:8888:9999::1"
+ plugin["macaddress"] = "00:AA:BB:CC:DD:EE"
+ plugin["ip6address"] = "3ffe:8888:9999::1"
end
it_doesnt_fail
it "can't set ipaddress" do
- allow(@plugin.logger).to receive(:warn)
- @plugin.run
- expect(@plugin["ipaddress"]).to be_nil
+ allow(plugin.logger).to receive(:warn)
+ plugin.run
+ expect(plugin["ipaddress"]).to be_nil
end
it "doesn't overwrite {ip6,mac}address" do
- allow(@plugin.logger).to receive(:warn)
- @plugin.run
- expect(@plugin["ip6address"]).to eq("3ffe:8888:9999::1")
- expect(@plugin["macaddress"]).to eq("00:AA:BB:CC:DD:EE")
+ allow(plugin.logger).to receive(:warn)
+ plugin.run
+ expect(plugin["ip6address"]).to eq("3ffe:8888:9999::1")
+ expect(plugin["macaddress"]).to eq("00:AA:BB:CC:DD:EE")
end
end
end
describe "{ip,mac,ip6}address are already set" do
before do
- @plugin["ipaddress"] = "10.11.12.13"
- @plugin["macaddress"] = "00:AA:BB:CC:DD:EE"
- @plugin["ip6address"] = "3ffe:8888:9999::1"
+ plugin["ipaddress"] = "10.11.12.13"
+ plugin["macaddress"] = "00:AA:BB:CC:DD:EE"
+ plugin["ip6address"] = "3ffe:8888:9999::1"
end
it_populates_ipaddress_attributes
it "doesn't overwrite {ip,mac,ip6}address" do
- @plugin.run
- expect(@plugin["ipaddress"]).to eq("10.11.12.13")
- expect(@plugin["macaddress"]).to eq("00:AA:BB:CC:DD:EE")
- expect(@plugin["ip6address"]).to eq("3ffe:8888:9999::1")
+ plugin.run
+ expect(plugin["ipaddress"]).to eq("10.11.12.13")
+ expect(plugin["macaddress"]).to eq("00:AA:BB:CC:DD:EE")
+ expect(plugin["ip6address"]).to eq("3ffe:8888:9999::1")
end
end
describe "{ip,ip6}address are already set" do
before do
- @plugin["ipaddress"] = "10.11.12.13"
- @plugin["ip6address"] = "3ffe:8888:9999::1"
+ plugin["ipaddress"] = "10.11.12.13"
+ plugin["ip6address"] = "3ffe:8888:9999::1"
end
it_doesnt_fail
it "doesn't overwrite {ip,ip6}address" do
- @plugin.run
- expect(@plugin["ipaddress"]).to eq("10.11.12.13")
- expect(@plugin["ip6address"]).to eq("3ffe:8888:9999::1")
+ plugin.run
+ expect(plugin["ipaddress"]).to eq("10.11.12.13")
+ expect(plugin["ip6address"]).to eq("3ffe:8888:9999::1")
end
end
diff --git a/spec/unit/plugins/ohai_spec.rb b/spec/unit/plugins/ohai_spec.rb
index e95d1ac1..17f90051 100644
--- a/spec/unit/plugins/ohai_spec.rb
+++ b/spec/unit/plugins/ohai_spec.rb
@@ -21,12 +21,10 @@
require "spec_helper"
describe Ohai::System, "plugin ohai" do
- before do
- @plugin = get_plugin("ohai")
- end
+ let(:plugin) { get_plugin("ohai") }
it "sets [:chef_packages][:ohai][:version] to the current version" do
- @plugin.run
- expect(@plugin[:chef_packages][:ohai][:version]).to eq(Ohai::VERSION)
+ plugin.run
+ expect(plugin[:chef_packages][:ohai][:version]).to eq(Ohai::VERSION)
end
end
diff --git a/spec/unit/plugins/ohai_time_spec.rb b/spec/unit/plugins/ohai_time_spec.rb
index ea5f2d66..6098291a 100644
--- a/spec/unit/plugins/ohai_time_spec.rb
+++ b/spec/unit/plugins/ohai_time_spec.rb
@@ -19,26 +19,24 @@
require "spec_helper"
describe Ohai::System, "plugin ohai_time" do
- before do
- @plugin = get_plugin("ohai_time")
- end
+ let(:plugin) { get_plugin("ohai_time") }
it "gets the current time" do
expect(Time).to receive(:now)
- @plugin.run
+ plugin.run
end
it "turns the time into a floating point number" do
time = Time.now
expect(time).to receive(:to_f)
allow(Time).to receive(:now).and_return(time)
- @plugin.run
+ plugin.run
end
it "sets ohai_time to the current time" do
time = Time.now
allow(Time).to receive(:now).and_return(time)
- @plugin.run
- expect(@plugin[:ohai_time]).to eq(time.to_f)
+ plugin.run
+ expect(plugin[:ohai_time]).to eq(time.to_f)
end
end
diff --git a/spec/unit/plugins/openbsd/hostname_spec.rb b/spec/unit/plugins/openbsd/hostname_spec.rb
index 495e116a..cffa3547 100644
--- a/spec/unit/plugins/openbsd/hostname_spec.rb
+++ b/spec/unit/plugins/openbsd/hostname_spec.rb
@@ -19,12 +19,13 @@
require "spec_helper"
describe Ohai::System, "OpenBSD hostname plugin" do
+ let(:plugin) { get_plugin("hostname") }
+
before do
- @plugin = get_plugin("hostname")
- allow(@plugin).to receive(:collect_os).and_return(:openbsd)
- allow(@plugin).to receive(:shell_out).with("hostname -s").and_return(mock_shell_out(0, "katie\n", ""))
- allow(@plugin).to receive(:shell_out).with("hostname").and_return(mock_shell_out(0, "katie.local", ""))
- allow(@plugin).to receive(:resolve_fqdn).and_return("katie.bethell")
+ allow(plugin).to receive(:collect_os).and_return(:openbsd)
+ allow(plugin).to receive(:shell_out).with("hostname -s").and_return(mock_shell_out(0, "katie\n", ""))
+ allow(plugin).to receive(:shell_out).with("hostname").and_return(mock_shell_out(0, "katie.local", ""))
+ allow(plugin).to receive(:resolve_fqdn).and_return("katie.bethell")
end
it_should_check_from("linux::hostname", "hostname", "hostname -s", "katie")
@@ -32,12 +33,12 @@ describe Ohai::System, "OpenBSD hostname plugin" do
it_should_check_from("linux::hostname", "machinename", "hostname", "katie.local")
it "uses #resolve_fqdn to find the fqdn" do
- @plugin.run
- expect(@plugin[:fqdn]).to eq("katie.bethell")
+ plugin.run
+ expect(plugin[:fqdn]).to eq("katie.bethell")
end
it "sets the domain to everything after the first dot of the fqdn" do
- @plugin.run
- expect(@plugin[:domain]).to eq("bethell")
+ plugin.run
+ expect(plugin[:domain]).to eq("bethell")
end
end
diff --git a/spec/unit/plugins/openbsd/kernel_spec.rb b/spec/unit/plugins/openbsd/kernel_spec.rb
index 89252563..5ed784df 100644
--- a/spec/unit/plugins/openbsd/kernel_spec.rb
+++ b/spec/unit/plugins/openbsd/kernel_spec.rb
@@ -19,18 +19,19 @@
require "spec_helper"
describe Ohai::System, "OpenBSD kernel plugin" do
+ let(:plugin) { get_plugin("kernel") }
+
before do
- @plugin = get_plugin("kernel")
- allow(@plugin).to receive(:collect_os).and_return(:openbsd)
- allow(@plugin).to receive(:init_kernel).and_return({})
- allow(@plugin).to receive(:shell_out).with("uname -i").and_return(mock_shell_out(0, "foo", ""))
- allow(@plugin).to receive(:shell_out).with("sysctl kern.securelevel").and_return(mock_shell_out(0, "kern.securelevel: 1\n", ""))
- allow(@plugin).to receive(:shell_out).with( Ohai.abs_path( "/usr/bin/modstat" )).and_return(mock_shell_out(0, " 1 7 0xc0400000 97f830 kernel", ""))
+ allow(plugin).to receive(:collect_os).and_return(:openbsd)
+ allow(plugin).to receive(:init_kernel).and_return({})
+ allow(plugin).to receive(:shell_out).with("uname -i").and_return(mock_shell_out(0, "foo", ""))
+ allow(plugin).to receive(:shell_out).with("sysctl kern.securelevel").and_return(mock_shell_out(0, "kern.securelevel: 1\n", ""))
+ allow(plugin).to receive(:shell_out).with( Ohai.abs_path( "/usr/bin/modstat" )).and_return(mock_shell_out(0, " 1 7 0xc0400000 97f830 kernel", ""))
end
it "sets the kernel_os to the kernel_name value" do
- @plugin.run
- expect(@plugin[:kernel][:os]).to eq(@plugin[:kernel][:name])
+ plugin.run
+ expect(plugin[:kernel][:os]).to eq(plugin[:kernel][:name])
end
end
diff --git a/spec/unit/plugins/openbsd/platform_spec.rb b/spec/unit/plugins/openbsd/platform_spec.rb
index 9a626f1f..0fa2a26e 100644
--- a/spec/unit/plugins/openbsd/platform_spec.rb
+++ b/spec/unit/plugins/openbsd/platform_spec.rb
@@ -19,15 +19,16 @@
require "spec_helper"
describe Ohai::System, "OpenBSD plugin platform" do
+ let(:plugin) { get_plugin("openbsd/platform") }
+
before do
- @plugin = get_plugin("openbsd/platform")
- allow(@plugin).to receive(:shell_out).with("uname -s").and_return(mock_shell_out(0, "OpenBSD\n", ""))
- allow(@plugin).to receive(:shell_out).with("uname -r").and_return(mock_shell_out(0, "4.5\n", ""))
- allow(@plugin).to receive(:collect_os).and_return(:openbsd)
+ allow(plugin).to receive(:shell_out).with("uname -s").and_return(mock_shell_out(0, "OpenBSD\n", ""))
+ allow(plugin).to receive(:shell_out).with("uname -r").and_return(mock_shell_out(0, "4.5\n", ""))
+ allow(plugin).to receive(:collect_os).and_return(:openbsd)
end
it "sets platform_version to lsb[:release]" do
- @plugin.run
- expect(@plugin[:platform_version]).to eq("4.5")
+ plugin.run
+ expect(plugin[:platform_version]).to eq("4.5")
end
end
diff --git a/spec/unit/plugins/os_spec.rb b/spec/unit/plugins/os_spec.rb
index 69882b64..0fdd1a79 100644
--- a/spec/unit/plugins/os_spec.rb
+++ b/spec/unit/plugins/os_spec.rb
@@ -24,10 +24,11 @@ require "spec_helper"
ORIGINAL_CONFIG_HOST_OS = ::RbConfig::CONFIG["host_os"]
describe Ohai::System, "plugin os" do
+ let(:plugin) { get_plugin("os") }
+
before do
- @plugin = get_plugin("os")
- @plugin[:kernel] = Mash.new
- @plugin[:kernel][:release] = "kings of leon"
+ plugin[:kernel] = Mash.new
+ plugin[:kernel][:release] = "kings of leon"
end
after do
@@ -35,8 +36,8 @@ describe Ohai::System, "plugin os" do
end
it "sets os_version to kernel_release" do
- @plugin.run
- expect(@plugin[:os_version]).to eq(@plugin[:kernel][:release])
+ plugin.run
+ expect(plugin[:os_version]).to eq(plugin[:kernel][:release])
end
describe "on linux" do
@@ -45,8 +46,8 @@ describe Ohai::System, "plugin os" do
end
it "sets the os to linux" do
- @plugin.run
- expect(@plugin[:os]).to eq("linux")
+ plugin.run
+ expect(plugin[:os]).to eq("linux")
end
end
@@ -56,8 +57,8 @@ describe Ohai::System, "plugin os" do
end
it "sets the os to darwin" do
- @plugin.run
- expect(@plugin[:os]).to eq("darwin")
+ plugin.run
+ expect(plugin[:os]).to eq("darwin")
end
end
@@ -67,38 +68,36 @@ describe Ohai::System, "plugin os" do
end
it "sets the os to solaris2" do
- @plugin.run
- expect(@plugin[:os]).to eq("solaris2")
+ plugin.run
+ expect(plugin[:os]).to eq("solaris2")
end
end
describe "on AIX" do
before do
- @plugin = get_plugin("os")
- allow(@plugin).to receive(:collect_os).and_return(:aix)
- allow(@plugin).to receive(:shell_out).with("oslevel -s").and_return(mock_shell_out(0, "7200-00-01-1543\n", nil))
- @plugin.run
+ allow(plugin).to receive(:collect_os).and_return(:aix)
+ allow(plugin).to receive(:shell_out).with("oslevel -s").and_return(mock_shell_out(0, "7200-00-01-1543\n", nil))
+ plugin.run
end
it "sets the top-level os attribute" do
- expect(@plugin[:os]).to be(:aix)
+ expect(plugin[:os]).to be(:aix)
end
it "sets the top-level os_level attribute" do
- expect(@plugin[:os_version]).to eql("7200-00-01-1543")
+ expect(plugin[:os_version]).to eql("7200-00-01-1543")
end
end
describe "on FreeBSD" do
before do
- @plugin = get_plugin("os")
- allow(@plugin).to receive(:shell_out).with("sysctl -n kern.osreldate").and_return(mock_shell_out(0, "902001\n", ""))
- allow(@plugin).to receive(:collect_os).and_return(:freebsd)
+ allow(plugin).to receive(:shell_out).with("sysctl -n kern.osreldate").and_return(mock_shell_out(0, "902001\n", ""))
+ allow(plugin).to receive(:collect_os).and_return(:freebsd)
end
it "sets os_version to __FreeBSD_version" do
- @plugin.run
- expect(@plugin[:os_version]).to eq("902001")
+ plugin.run
+ expect(plugin[:os_version]).to eq("902001")
end
end
@@ -108,8 +107,8 @@ describe Ohai::System, "plugin os" do
end
it "sets the os to the ruby 'host_os'" do
- @plugin.run
- expect(@plugin[:os]).to eq("tron")
+ plugin.run
+ expect(plugin[:os]).to eq("tron")
end
end
end
diff --git a/spec/unit/plugins/packages_spec.rb b/spec/unit/plugins/packages_spec.rb
index e4ad9015..41ae8d66 100644
--- a/spec/unit/plugins/packages_spec.rb
+++ b/spec/unit/plugins/packages_spec.rb
@@ -29,9 +29,7 @@ describe Ohai::System, "plugin packages" do
let(:format) { '${Package}\t${Version}\t${Architecture}\n' }
- let(:stdout) do
- File.read(File.join(SPEC_PLUGIN_PATH, "dpkg-query.output"))
- end
+ let(:stdout) { File.read(File.join(SPEC_PLUGIN_PATH, "dpkg-query.output")) }
before do
allow(plugin).to receive(:collect_os).and_return(:linux)
diff --git a/spec/unit/plugins/platform_spec.rb b/spec/unit/plugins/platform_spec.rb
index 6c30a1bf..a348ba58 100644
--- a/spec/unit/plugins/platform_spec.rb
+++ b/spec/unit/plugins/platform_spec.rb
@@ -19,47 +19,48 @@
require "spec_helper"
describe Ohai::System, "plugin platform" do
+ let(:plugin) { get_plugin("platform") }
+
before do
- @plugin = get_plugin("platform")
- allow(@plugin).to receive(:collect_os).and_return(:default)
- @plugin[:os] = "monkey"
- @plugin[:os_version] = "poop"
+ allow(plugin).to receive(:collect_os).and_return(:default)
+ plugin[:os] = "monkey"
+ plugin[:os_version] = "poop"
end
it "sets the platform and platform family to the os if it was not set earlier" do
- @plugin.run
- expect(@plugin[:platform]).to eql("monkey")
- expect(@plugin[:platform_family]).to eql("monkey")
+ plugin.run
+ expect(plugin[:platform]).to eql("monkey")
+ expect(plugin[:platform_family]).to eql("monkey")
end
it "does not set the platform to the os if it was set earlier" do
- @plugin[:platform] = "lars"
- @plugin.run
- expect(@plugin[:platform]).to eql("lars")
+ plugin[:platform] = "lars"
+ plugin.run
+ expect(plugin[:platform]).to eql("lars")
end
it "sets the platform_family to the platform if platform was set earlier but not platform_family" do
- @plugin[:platform] = "lars"
- @plugin[:platform_family] = "jack"
- @plugin.run
- expect(@plugin[:platform_family]).to eql("jack")
+ plugin[:platform] = "lars"
+ plugin[:platform_family] = "jack"
+ plugin.run
+ expect(plugin[:platform_family]).to eql("jack")
end
it "does not set the platform_family if the platform_family was set earlier." do
- @plugin[:platform] = "lars"
- @plugin.run
- expect(@plugin[:platform]).to eql("lars")
- expect(@plugin[:platform_family]).to eql("lars")
+ plugin[:platform] = "lars"
+ plugin.run
+ expect(plugin[:platform]).to eql("lars")
+ expect(plugin[:platform_family]).to eql("lars")
end
it "sets the platform_version to the os_version if it was not set earlier" do
- @plugin.run
- expect(@plugin[:os_version]).to eql("poop")
+ plugin.run
+ expect(plugin[:os_version]).to eql("poop")
end
it "does not set the platform to the os if it was set earlier" do
- @plugin[:platform_version] = "ulrich"
- @plugin.run
- expect(@plugin[:platform_version]).to eql("ulrich")
+ plugin[:platform_version] = "ulrich"
+ plugin.run
+ expect(plugin[:platform_version]).to eql("ulrich")
end
end
diff --git a/spec/unit/plugins/root_group_spec.rb b/spec/unit/plugins/root_group_spec.rb
index 910c6ca2..2baa0ee5 100644
--- a/spec/unit/plugins/root_group_spec.rb
+++ b/spec/unit/plugins/root_group_spec.rb
@@ -19,9 +19,7 @@
require "spec_helper"
describe Ohai::System, "root_group" do
- before do
- @plugin = get_plugin("root_group")
- end
+ let(:plugin) { get_plugin("root_group") }
describe "unix platform", :unix_only do
before do
@@ -41,8 +39,8 @@ describe Ohai::System, "root_group" do
end
it "has a root_group of wheel" do
- @plugin.run
- expect(@plugin[:root_group]).to eq("wheel")
+ plugin.run
+ expect(plugin[:root_group]).to eq("wheel")
end
end
@@ -52,8 +50,8 @@ describe Ohai::System, "root_group" do
end
it "has a root_group of root" do
- @plugin.run
- expect(@plugin[:root_group]).to eq("root")
+ plugin.run
+ expect(plugin[:root_group]).to eq("root")
end
end
@@ -63,8 +61,8 @@ describe Ohai::System, "root_group" do
end
it "has a root_group of system" do
- @plugin.run
- expect(@plugin[:root_group]).to eq("system")
+ plugin.run
+ expect(plugin[:root_group]).to eq("system")
end
end
end
@@ -75,7 +73,7 @@ describe Ohai::System, "root_group" do
before do
allow(WmiLite::Wmi).to receive(:new).and_return(wmi)
- allow(@plugin).to receive(:collect_os).and_return(:windows)
+ allow(plugin).to receive(:collect_os).and_return(:windows)
end
it "returns the group Administrators" do
@@ -84,7 +82,7 @@ describe Ohai::System, "root_group" do
.with("select * from Win32_Group where sid like 'S-1-5-32-544' and LocalAccount=True")
.and_return("Administrators")
- @plugin.run
+ plugin.run
end
end
end
diff --git a/spec/unit/plugins/ruby_spec.rb b/spec/unit/plugins/ruby_spec.rb
index b634f124..7d84376c 100644
--- a/spec/unit/plugins/ruby_spec.rb
+++ b/spec/unit/plugins/ruby_spec.rb
@@ -21,13 +21,16 @@ require "spec_helper"
ruby_bin = File.join(::RbConfig::CONFIG["bindir"], ::RbConfig::CONFIG["ruby_install_name"])
describe Ohai::System, "plugin ruby" do
+ let(:plugin) do
+ plugin_data = get_plugin("ruby")
+ plugin_data[:languages] = Mash.new
+ plugin_data
+ end
before(:all) do
- @plugin = get_plugin("ruby")
- @plugin[:languages] = Mash.new
- @plugin.run
+ plugin.run
- @ruby_ohai_data_pristine = @plugin[:languages][:ruby]
+ @ruby_ohai_data_pristine = plugin[:languages][:ruby]
end
before do
diff --git a/spec/unit/plugins/rust_spec.rb b/spec/unit/plugins/rust_spec.rb
index 542423b9..724710ef 100644
--- a/spec/unit/plugins/rust_spec.rb
+++ b/spec/unit/plugins/rust_spec.rb
@@ -18,8 +18,9 @@ require "spec_helper"
describe Ohai::System, "plugin rust" do
let(:stdout) { "rustc 1.0.0-nightly (29bd9a06e 2015-01-20 23:03:09 +0000)" }
+ let(:plugin) { get_plugin("rust") }
+
let(:plugin) do
- plugin = get_plugin("rust")
plugin[:languages] = Mash.new
allow(plugin).to receive(:shell_out).with("rustc --version").and_return(mock_shell_out(0, stdout, ""))
plugin
diff --git a/spec/unit/plugins/shells_spec.rb b/spec/unit/plugins/shells_spec.rb
index f70218e6..f4554189 100644
--- a/spec/unit/plugins/shells_spec.rb
+++ b/spec/unit/plugins/shells_spec.rb
@@ -19,8 +19,9 @@ require "spec_helper"
describe Ohai::System, "plugin shells" do
let(:plugin) { get_plugin("shells") }
+ let(:shell_file_content) { shell_file }
- # content from OS X 10.11
+ # content from macOS 10.15
shell_file = ["# List of acceptable shells for chpass(1).\n",
"# Ftpd will not allow users to connect who are not using\n",
"# one of these shells.\n",
@@ -32,8 +33,6 @@ describe Ohai::System, "plugin shells" do
"/bin/tcsh\n",
"/bin/zsh\n"]
- let(:shell_file_content) { shell_file }
-
it "does not set shells attribute if /etc/shells does not exist" do
allow(::File).to receive(:exist?).with("/etc/shells").and_return(false)
plugin.run
diff --git a/spec/unit/plugins/solaris2/cpu_spec.rb b/spec/unit/plugins/solaris2/cpu_spec.rb
index 6bc6ff62..54257094 100644
--- a/spec/unit/plugins/solaris2/cpu_spec.rb
+++ b/spec/unit/plugins/solaris2/cpu_spec.rb
@@ -16,10 +16,11 @@
require "spec_helper"
-describe Ohai::System, "Solaris2.X cpu plugin" do
+describe Ohai::System, "Solaris2 cpu plugin" do
+ let(:plugin) { get_plugin("cpu") }
+
before do
- @plugin = get_plugin("cpu")
- allow(@plugin).to receive(:collect_os).and_return("solaris2")
+ allow(plugin).to receive(:collect_os).and_return("solaris2")
end
describe "on x86 processors" do
@@ -442,188 +443,188 @@ describe Ohai::System, "Solaris2.X cpu plugin" do
cpu_info:15:cpu_info15:supported_max_cstates 1
cpu_info:15:cpu_info15:vendor_id GenuineIntel
END
- allow(@plugin).to receive(:shell_out).with("kstat -p cpu_info").and_return(mock_shell_out(0, kstatinfo_output, ""))
- @plugin.run
+ allow(plugin).to receive(:shell_out).with("kstat -p cpu_info").and_return(mock_shell_out(0, kstatinfo_output, ""))
+ plugin.run
end
it "gets the total virtual processor count" do
- expect(@plugin["cpu"]["total"]).to be(16)
+ expect(plugin["cpu"]["total"]).to be(16)
end
it "gets the total processor count" do
- expect(@plugin["cpu"]["real"]).to be(2)
+ expect(plugin["cpu"]["real"]).to be(2)
end
it "gets the number of threads per core" do
- expect(@plugin["cpu"]["corethreads"]).to be(2)
+ expect(plugin["cpu"]["corethreads"]).to be(2)
end
it "gets the total number of online cores" do
- expect(@plugin["cpu"]["cpustates"]["on-line"]).to be(8)
+ expect(plugin["cpu"]["cpustates"]["on-line"]).to be(8)
end
it "gets the total number of offline cores" do
- expect(@plugin["cpu"]["cpustates"]["off-line"]).to be(8)
+ expect(plugin["cpu"]["cpustates"]["off-line"]).to be(8)
end
describe "per-cpu information" do
it "includes processor vendor_ids" do
# CPU Socket 0
- expect(@plugin["cpu"]["15"]["vendor_id"]).to eql("GenuineIntel")
- expect(@plugin["cpu"]["13"]["vendor_id"]).to eql("GenuineIntel")
- expect(@plugin["cpu"]["11"]["vendor_id"]).to eql("GenuineIntel")
- expect(@plugin["cpu"]["9"]["vendor_id"]).to eql("GenuineIntel")
- expect(@plugin["cpu"]["7"]["vendor_id"]).to eql("GenuineIntel")
- expect(@plugin["cpu"]["5"]["vendor_id"]).to eql("GenuineIntel")
- expect(@plugin["cpu"]["3"]["vendor_id"]).to eql("GenuineIntel")
- expect(@plugin["cpu"]["1"]["vendor_id"]).to eql("GenuineIntel")
+ expect(plugin["cpu"]["15"]["vendor_id"]).to eql("GenuineIntel")
+ expect(plugin["cpu"]["13"]["vendor_id"]).to eql("GenuineIntel")
+ expect(plugin["cpu"]["11"]["vendor_id"]).to eql("GenuineIntel")
+ expect(plugin["cpu"]["9"]["vendor_id"]).to eql("GenuineIntel")
+ expect(plugin["cpu"]["7"]["vendor_id"]).to eql("GenuineIntel")
+ expect(plugin["cpu"]["5"]["vendor_id"]).to eql("GenuineIntel")
+ expect(plugin["cpu"]["3"]["vendor_id"]).to eql("GenuineIntel")
+ expect(plugin["cpu"]["1"]["vendor_id"]).to eql("GenuineIntel")
# CPU Socket 1
- expect(@plugin["cpu"]["14"]["vendor_id"]).to eql("CrazyTown")
- expect(@plugin["cpu"]["12"]["vendor_id"]).to eql("CrazyTown")
- expect(@plugin["cpu"]["10"]["vendor_id"]).to eql("CrazyTown")
- expect(@plugin["cpu"]["8"]["vendor_id"]).to eql("CrazyTown")
- expect(@plugin["cpu"]["6"]["vendor_id"]).to eql("CrazyTown")
- expect(@plugin["cpu"]["4"]["vendor_id"]).to eql("CrazyTown")
- expect(@plugin["cpu"]["2"]["vendor_id"]).to eql("CrazyTown")
- expect(@plugin["cpu"]["0"]["vendor_id"]).to eql("CrazyTown")
+ expect(plugin["cpu"]["14"]["vendor_id"]).to eql("CrazyTown")
+ expect(plugin["cpu"]["12"]["vendor_id"]).to eql("CrazyTown")
+ expect(plugin["cpu"]["10"]["vendor_id"]).to eql("CrazyTown")
+ expect(plugin["cpu"]["8"]["vendor_id"]).to eql("CrazyTown")
+ expect(plugin["cpu"]["6"]["vendor_id"]).to eql("CrazyTown")
+ expect(plugin["cpu"]["4"]["vendor_id"]).to eql("CrazyTown")
+ expect(plugin["cpu"]["2"]["vendor_id"]).to eql("CrazyTown")
+ expect(plugin["cpu"]["0"]["vendor_id"]).to eql("CrazyTown")
end
it "includes processor families" do
- expect(@plugin["cpu"]["15"]["family"]).to eql("6")
- expect(@plugin["cpu"]["13"]["family"]).to eql("6")
- expect(@plugin["cpu"]["11"]["family"]).to eql("6")
- expect(@plugin["cpu"]["9"]["family"]).to eql("6")
- expect(@plugin["cpu"]["7"]["family"]).to eql("6")
- expect(@plugin["cpu"]["5"]["family"]).to eql("6")
- expect(@plugin["cpu"]["3"]["family"]).to eql("6")
- expect(@plugin["cpu"]["1"]["family"]).to eql("6")
+ expect(plugin["cpu"]["15"]["family"]).to eql("6")
+ expect(plugin["cpu"]["13"]["family"]).to eql("6")
+ expect(plugin["cpu"]["11"]["family"]).to eql("6")
+ expect(plugin["cpu"]["9"]["family"]).to eql("6")
+ expect(plugin["cpu"]["7"]["family"]).to eql("6")
+ expect(plugin["cpu"]["5"]["family"]).to eql("6")
+ expect(plugin["cpu"]["3"]["family"]).to eql("6")
+ expect(plugin["cpu"]["1"]["family"]).to eql("6")
- expect(@plugin["cpu"]["14"]["family"]).to eql("12")
- expect(@plugin["cpu"]["12"]["family"]).to eql("12")
- expect(@plugin["cpu"]["10"]["family"]).to eql("12")
- expect(@plugin["cpu"]["8"]["family"]).to eql("12")
- expect(@plugin["cpu"]["6"]["family"]).to eql("12")
- expect(@plugin["cpu"]["4"]["family"]).to eql("12")
- expect(@plugin["cpu"]["2"]["family"]).to eql("12")
- expect(@plugin["cpu"]["0"]["family"]).to eql("12")
+ expect(plugin["cpu"]["14"]["family"]).to eql("12")
+ expect(plugin["cpu"]["12"]["family"]).to eql("12")
+ expect(plugin["cpu"]["10"]["family"]).to eql("12")
+ expect(plugin["cpu"]["8"]["family"]).to eql("12")
+ expect(plugin["cpu"]["6"]["family"]).to eql("12")
+ expect(plugin["cpu"]["4"]["family"]).to eql("12")
+ expect(plugin["cpu"]["2"]["family"]).to eql("12")
+ expect(plugin["cpu"]["0"]["family"]).to eql("12")
end
it "includes processor models" do
- expect(@plugin["cpu"]["15"]["model"]).to eql("26")
- expect(@plugin["cpu"]["13"]["model"]).to eql("26")
- expect(@plugin["cpu"]["11"]["model"]).to eql("26")
- expect(@plugin["cpu"]["9"]["model"]).to eql("26")
- expect(@plugin["cpu"]["7"]["model"]).to eql("26")
- expect(@plugin["cpu"]["5"]["model"]).to eql("26")
- expect(@plugin["cpu"]["3"]["model"]).to eql("26")
- expect(@plugin["cpu"]["1"]["model"]).to eql("26")
+ expect(plugin["cpu"]["15"]["model"]).to eql("26")
+ expect(plugin["cpu"]["13"]["model"]).to eql("26")
+ expect(plugin["cpu"]["11"]["model"]).to eql("26")
+ expect(plugin["cpu"]["9"]["model"]).to eql("26")
+ expect(plugin["cpu"]["7"]["model"]).to eql("26")
+ expect(plugin["cpu"]["5"]["model"]).to eql("26")
+ expect(plugin["cpu"]["3"]["model"]).to eql("26")
+ expect(plugin["cpu"]["1"]["model"]).to eql("26")
- expect(@plugin["cpu"]["14"]["model"]).to eql("93")
- expect(@plugin["cpu"]["12"]["model"]).to eql("93")
- expect(@plugin["cpu"]["10"]["model"]).to eql("93")
- expect(@plugin["cpu"]["8"]["model"]).to eql("93")
- expect(@plugin["cpu"]["6"]["model"]).to eql("93")
- expect(@plugin["cpu"]["4"]["model"]).to eql("93")
- expect(@plugin["cpu"]["2"]["model"]).to eql("93")
- expect(@plugin["cpu"]["0"]["model"]).to eql("93")
+ expect(plugin["cpu"]["14"]["model"]).to eql("93")
+ expect(plugin["cpu"]["12"]["model"]).to eql("93")
+ expect(plugin["cpu"]["10"]["model"]).to eql("93")
+ expect(plugin["cpu"]["8"]["model"]).to eql("93")
+ expect(plugin["cpu"]["6"]["model"]).to eql("93")
+ expect(plugin["cpu"]["4"]["model"]).to eql("93")
+ expect(plugin["cpu"]["2"]["model"]).to eql("93")
+ expect(plugin["cpu"]["0"]["model"]).to eql("93")
end
it "includs processor architecture" do
- expect(@plugin["cpu"]["15"]["arch"]).to eql("i386")
- expect(@plugin["cpu"]["13"]["arch"]).to eql("i386")
- expect(@plugin["cpu"]["11"]["arch"]).to eql("i386")
- expect(@plugin["cpu"]["9"]["arch"]).to eql("i386")
- expect(@plugin["cpu"]["7"]["arch"]).to eql("i386")
- expect(@plugin["cpu"]["5"]["arch"]).to eql("i386")
- expect(@plugin["cpu"]["3"]["arch"]).to eql("i386")
- expect(@plugin["cpu"]["1"]["arch"]).to eql("i386")
+ expect(plugin["cpu"]["15"]["arch"]).to eql("i386")
+ expect(plugin["cpu"]["13"]["arch"]).to eql("i386")
+ expect(plugin["cpu"]["11"]["arch"]).to eql("i386")
+ expect(plugin["cpu"]["9"]["arch"]).to eql("i386")
+ expect(plugin["cpu"]["7"]["arch"]).to eql("i386")
+ expect(plugin["cpu"]["5"]["arch"]).to eql("i386")
+ expect(plugin["cpu"]["3"]["arch"]).to eql("i386")
+ expect(plugin["cpu"]["1"]["arch"]).to eql("i386")
- expect(@plugin["cpu"]["14"]["arch"]).to eql("i386")
- expect(@plugin["cpu"]["12"]["arch"]).to eql("i386")
- expect(@plugin["cpu"]["10"]["arch"]).to eql("i386")
- expect(@plugin["cpu"]["8"]["arch"]).to eql("i386")
- expect(@plugin["cpu"]["6"]["arch"]).to eql("i386")
- expect(@plugin["cpu"]["4"]["arch"]).to eql("i386")
- expect(@plugin["cpu"]["2"]["arch"]).to eql("i386")
- expect(@plugin["cpu"]["0"]["arch"]).to eql("i386")
+ expect(plugin["cpu"]["14"]["arch"]).to eql("i386")
+ expect(plugin["cpu"]["12"]["arch"]).to eql("i386")
+ expect(plugin["cpu"]["10"]["arch"]).to eql("i386")
+ expect(plugin["cpu"]["8"]["arch"]).to eql("i386")
+ expect(plugin["cpu"]["6"]["arch"]).to eql("i386")
+ expect(plugin["cpu"]["4"]["arch"]).to eql("i386")
+ expect(plugin["cpu"]["2"]["arch"]).to eql("i386")
+ expect(plugin["cpu"]["0"]["arch"]).to eql("i386")
end
it "includes processor stepping" do
- expect(@plugin["cpu"]["15"]["stepping"]).to eql("5")
- expect(@plugin["cpu"]["13"]["stepping"]).to eql("5")
- expect(@plugin["cpu"]["11"]["stepping"]).to eql("5")
- expect(@plugin["cpu"]["9"]["stepping"]).to eql("5")
- expect(@plugin["cpu"]["7"]["stepping"]).to eql("5")
- expect(@plugin["cpu"]["5"]["stepping"]).to eql("5")
- expect(@plugin["cpu"]["3"]["stepping"]).to eql("5")
- expect(@plugin["cpu"]["1"]["stepping"]).to eql("5")
+ expect(plugin["cpu"]["15"]["stepping"]).to eql("5")
+ expect(plugin["cpu"]["13"]["stepping"]).to eql("5")
+ expect(plugin["cpu"]["11"]["stepping"]).to eql("5")
+ expect(plugin["cpu"]["9"]["stepping"]).to eql("5")
+ expect(plugin["cpu"]["7"]["stepping"]).to eql("5")
+ expect(plugin["cpu"]["5"]["stepping"]).to eql("5")
+ expect(plugin["cpu"]["3"]["stepping"]).to eql("5")
+ expect(plugin["cpu"]["1"]["stepping"]).to eql("5")
- expect(@plugin["cpu"]["14"]["stepping"]).to eql("9")
- expect(@plugin["cpu"]["12"]["stepping"]).to eql("9")
- expect(@plugin["cpu"]["10"]["stepping"]).to eql("9")
- expect(@plugin["cpu"]["8"]["stepping"]).to eql("9")
- expect(@plugin["cpu"]["6"]["stepping"]).to eql("9")
- expect(@plugin["cpu"]["4"]["stepping"]).to eql("9")
- expect(@plugin["cpu"]["2"]["stepping"]).to eql("9")
- expect(@plugin["cpu"]["0"]["stepping"]).to eql("9")
+ expect(plugin["cpu"]["14"]["stepping"]).to eql("9")
+ expect(plugin["cpu"]["12"]["stepping"]).to eql("9")
+ expect(plugin["cpu"]["10"]["stepping"]).to eql("9")
+ expect(plugin["cpu"]["8"]["stepping"]).to eql("9")
+ expect(plugin["cpu"]["6"]["stepping"]).to eql("9")
+ expect(plugin["cpu"]["4"]["stepping"]).to eql("9")
+ expect(plugin["cpu"]["2"]["stepping"]).to eql("9")
+ expect(plugin["cpu"]["0"]["stepping"]).to eql("9")
end
it "includes processor model names" do
- expect(@plugin["cpu"]["15"]["model_name"]).to eql("Intel(r) Xeon(r) CPU X5570 @ 2.93GHz")
- expect(@plugin["cpu"]["13"]["model_name"]).to eql("Intel(r) Xeon(r) CPU X5570 @ 2.93GHz")
- expect(@plugin["cpu"]["11"]["model_name"]).to eql("Intel(r) Xeon(r) CPU X5570 @ 2.93GHz")
- expect(@plugin["cpu"]["9"]["model_name"]).to eql("Intel(r) Xeon(r) CPU X5570 @ 2.93GHz")
- expect(@plugin["cpu"]["7"]["model_name"]).to eql("Intel(r) Xeon(r) CPU X5570 @ 2.93GHz")
- expect(@plugin["cpu"]["5"]["model_name"]).to eql("Intel(r) Xeon(r) CPU X5570 @ 2.93GHz")
- expect(@plugin["cpu"]["3"]["model_name"]).to eql("Intel(r) Xeon(r) CPU X5570 @ 2.93GHz")
- expect(@plugin["cpu"]["1"]["model_name"]).to eql("Intel(r) Xeon(r) CPU X5570 @ 2.93GHz")
- expect(@plugin["cpu"]["14"]["model_name"]).to eql("Crazy(r) Argon(r) CPU Y5570 @ 1.93GHz")
- expect(@plugin["cpu"]["12"]["model_name"]).to eql("Crazy(r) Argon(r) CPU Y5570 @ 1.93GHz")
- expect(@plugin["cpu"]["10"]["model_name"]).to eql("Crazy(r) Argon(r) CPU Y5570 @ 1.93GHz")
- expect(@plugin["cpu"]["8"]["model_name"]).to eql("Crazy(r) Argon(r) CPU Y5570 @ 1.93GHz")
- expect(@plugin["cpu"]["6"]["model_name"]).to eql("Crazy(r) Argon(r) CPU Y5570 @ 1.93GHz")
- expect(@plugin["cpu"]["4"]["model_name"]).to eql("Crazy(r) Argon(r) CPU Y5570 @ 1.93GHz")
- expect(@plugin["cpu"]["2"]["model_name"]).to eql("Crazy(r) Argon(r) CPU Y5570 @ 1.93GHz")
- expect(@plugin["cpu"]["0"]["model_name"]).to eql("Crazy(r) Argon(r) CPU Y5570 @ 1.93GHz")
+ expect(plugin["cpu"]["15"]["model_name"]).to eql("Intel(r) Xeon(r) CPU X5570 @ 2.93GHz")
+ expect(plugin["cpu"]["13"]["model_name"]).to eql("Intel(r) Xeon(r) CPU X5570 @ 2.93GHz")
+ expect(plugin["cpu"]["11"]["model_name"]).to eql("Intel(r) Xeon(r) CPU X5570 @ 2.93GHz")
+ expect(plugin["cpu"]["9"]["model_name"]).to eql("Intel(r) Xeon(r) CPU X5570 @ 2.93GHz")
+ expect(plugin["cpu"]["7"]["model_name"]).to eql("Intel(r) Xeon(r) CPU X5570 @ 2.93GHz")
+ expect(plugin["cpu"]["5"]["model_name"]).to eql("Intel(r) Xeon(r) CPU X5570 @ 2.93GHz")
+ expect(plugin["cpu"]["3"]["model_name"]).to eql("Intel(r) Xeon(r) CPU X5570 @ 2.93GHz")
+ expect(plugin["cpu"]["1"]["model_name"]).to eql("Intel(r) Xeon(r) CPU X5570 @ 2.93GHz")
+ expect(plugin["cpu"]["14"]["model_name"]).to eql("Crazy(r) Argon(r) CPU Y5570 @ 1.93GHz")
+ expect(plugin["cpu"]["12"]["model_name"]).to eql("Crazy(r) Argon(r) CPU Y5570 @ 1.93GHz")
+ expect(plugin["cpu"]["10"]["model_name"]).to eql("Crazy(r) Argon(r) CPU Y5570 @ 1.93GHz")
+ expect(plugin["cpu"]["8"]["model_name"]).to eql("Crazy(r) Argon(r) CPU Y5570 @ 1.93GHz")
+ expect(plugin["cpu"]["6"]["model_name"]).to eql("Crazy(r) Argon(r) CPU Y5570 @ 1.93GHz")
+ expect(plugin["cpu"]["4"]["model_name"]).to eql("Crazy(r) Argon(r) CPU Y5570 @ 1.93GHz")
+ expect(plugin["cpu"]["2"]["model_name"]).to eql("Crazy(r) Argon(r) CPU Y5570 @ 1.93GHz")
+ expect(plugin["cpu"]["0"]["model_name"]).to eql("Crazy(r) Argon(r) CPU Y5570 @ 1.93GHz")
end
it "includes processor speed in MHz" do
- expect(@plugin["cpu"]["15"]["mhz"]).to eql("2926")
- expect(@plugin["cpu"]["13"]["mhz"]).to eql("2926")
- expect(@plugin["cpu"]["11"]["mhz"]).to eql("2926")
- expect(@plugin["cpu"]["9"]["mhz"]).to eql("2926")
- expect(@plugin["cpu"]["7"]["mhz"]).to eql("2926")
- expect(@plugin["cpu"]["5"]["mhz"]).to eql("2926")
- expect(@plugin["cpu"]["3"]["mhz"]).to eql("2926")
- expect(@plugin["cpu"]["1"]["mhz"]).to eql("2926")
- expect(@plugin["cpu"]["14"]["mhz"]).to eql("1933")
- expect(@plugin["cpu"]["12"]["mhz"]).to eql("1933")
- expect(@plugin["cpu"]["10"]["mhz"]).to eql("1933")
- expect(@plugin["cpu"]["8"]["mhz"]).to eql("1933")
- expect(@plugin["cpu"]["6"]["mhz"]).to eql("1933")
- expect(@plugin["cpu"]["4"]["mhz"]).to eql("1933")
- expect(@plugin["cpu"]["2"]["mhz"]).to eql("1933")
- expect(@plugin["cpu"]["0"]["mhz"]).to eql("1933")
+ expect(plugin["cpu"]["15"]["mhz"]).to eql("2926")
+ expect(plugin["cpu"]["13"]["mhz"]).to eql("2926")
+ expect(plugin["cpu"]["11"]["mhz"]).to eql("2926")
+ expect(plugin["cpu"]["9"]["mhz"]).to eql("2926")
+ expect(plugin["cpu"]["7"]["mhz"]).to eql("2926")
+ expect(plugin["cpu"]["5"]["mhz"]).to eql("2926")
+ expect(plugin["cpu"]["3"]["mhz"]).to eql("2926")
+ expect(plugin["cpu"]["1"]["mhz"]).to eql("2926")
+ expect(plugin["cpu"]["14"]["mhz"]).to eql("1933")
+ expect(plugin["cpu"]["12"]["mhz"]).to eql("1933")
+ expect(plugin["cpu"]["10"]["mhz"]).to eql("1933")
+ expect(plugin["cpu"]["8"]["mhz"]).to eql("1933")
+ expect(plugin["cpu"]["6"]["mhz"]).to eql("1933")
+ expect(plugin["cpu"]["4"]["mhz"]).to eql("1933")
+ expect(plugin["cpu"]["2"]["mhz"]).to eql("1933")
+ expect(plugin["cpu"]["0"]["mhz"]).to eql("1933")
end
it "includes processor state" do
- expect(@plugin["cpu"]["15"]["state"]).to eql("on-line")
- expect(@plugin["cpu"]["13"]["state"]).to eql("on-line")
- expect(@plugin["cpu"]["11"]["state"]).to eql("on-line")
- expect(@plugin["cpu"]["9"]["state"]).to eql("on-line")
- expect(@plugin["cpu"]["7"]["state"]).to eql("on-line")
- expect(@plugin["cpu"]["5"]["state"]).to eql("on-line")
- expect(@plugin["cpu"]["3"]["state"]).to eql("on-line")
- expect(@plugin["cpu"]["1"]["state"]).to eql("on-line")
- expect(@plugin["cpu"]["14"]["state"]).to eql("off-line")
- expect(@plugin["cpu"]["12"]["state"]).to eql("off-line")
- expect(@plugin["cpu"]["10"]["state"]).to eql("off-line")
- expect(@plugin["cpu"]["8"]["state"]).to eql("off-line")
- expect(@plugin["cpu"]["6"]["state"]).to eql("off-line")
- expect(@plugin["cpu"]["4"]["state"]).to eql("off-line")
- expect(@plugin["cpu"]["2"]["state"]).to eql("off-line")
- expect(@plugin["cpu"]["0"]["state"]).to eql("off-line")
+ expect(plugin["cpu"]["15"]["state"]).to eql("on-line")
+ expect(plugin["cpu"]["13"]["state"]).to eql("on-line")
+ expect(plugin["cpu"]["11"]["state"]).to eql("on-line")
+ expect(plugin["cpu"]["9"]["state"]).to eql("on-line")
+ expect(plugin["cpu"]["7"]["state"]).to eql("on-line")
+ expect(plugin["cpu"]["5"]["state"]).to eql("on-line")
+ expect(plugin["cpu"]["3"]["state"]).to eql("on-line")
+ expect(plugin["cpu"]["1"]["state"]).to eql("on-line")
+ expect(plugin["cpu"]["14"]["state"]).to eql("off-line")
+ expect(plugin["cpu"]["12"]["state"]).to eql("off-line")
+ expect(plugin["cpu"]["10"]["state"]).to eql("off-line")
+ expect(plugin["cpu"]["8"]["state"]).to eql("off-line")
+ expect(plugin["cpu"]["6"]["state"]).to eql("off-line")
+ expect(plugin["cpu"]["4"]["state"]).to eql("off-line")
+ expect(plugin["cpu"]["2"]["state"]).to eql("off-line")
+ expect(plugin["cpu"]["0"]["state"]).to eql("off-line")
end
end
end
@@ -2808,118 +2809,118 @@ describe Ohai::System, "Solaris2.X cpu plugin" do
cpu_info:127:cpu_info127:state_begin 1430258903
cpu_info:127:cpu_info127:supported_frequencies_Hz 1648762500
END
- allow(@plugin).to receive(:shell_out).with("kstat -p cpu_info").and_return(mock_shell_out(0, kstatinfo_output, ""))
- @plugin.run
+ allow(plugin).to receive(:shell_out).with("kstat -p cpu_info").and_return(mock_shell_out(0, kstatinfo_output, ""))
+ plugin.run
end
it "gets the total virtual processor count" do
- expect(@plugin["cpu"]["total"]).to be(128)
+ expect(plugin["cpu"]["total"]).to be(128)
end
it "gets the total processor count" do
- expect(@plugin["cpu"]["real"]).to be(1)
+ expect(plugin["cpu"]["real"]).to be(1)
end
it "gets the total core count" do
- expect(@plugin["cpu"]["cores"]).to be(16)
+ expect(plugin["cpu"]["cores"]).to be(16)
end
it "gets the number of threads per core" do
- expect(@plugin["cpu"]["corethreads"]).to be(8)
+ expect(plugin["cpu"]["corethreads"]).to be(8)
end
it "gets the total number of online cores" do
- expect(@plugin["cpu"]["cpustates"]["on-line"]).to be(124)
+ expect(plugin["cpu"]["cpustates"]["on-line"]).to be(124)
end
it "gets the total number of offline cores" do
- expect(@plugin["cpu"]["cpustates"]["off-line"]).to be(4)
+ expect(plugin["cpu"]["cpustates"]["off-line"]).to be(4)
end
describe "per-cpu information" do
it "includes processor model names" do
- expect(@plugin["cpu"]["0"]["model_name"]).to eql("SPARC-T3")
- expect(@plugin["cpu"]["1"]["model_name"]).to eql("SPARC-T3")
- expect(@plugin["cpu"]["2"]["model_name"]).to eql("SPARC-T3")
- expect(@plugin["cpu"]["3"]["model_name"]).to eql("SPARC-T3")
- expect(@plugin["cpu"]["124"]["model_name"]).to eql("SPARC-T4")
- expect(@plugin["cpu"]["125"]["model_name"]).to eql("SPARC-T4")
- expect(@plugin["cpu"]["126"]["model_name"]).to eql("SPARC-T4")
- expect(@plugin["cpu"]["127"]["model_name"]).to eql("SPARC-T4")
+ expect(plugin["cpu"]["0"]["model_name"]).to eql("SPARC-T3")
+ expect(plugin["cpu"]["1"]["model_name"]).to eql("SPARC-T3")
+ expect(plugin["cpu"]["2"]["model_name"]).to eql("SPARC-T3")
+ expect(plugin["cpu"]["3"]["model_name"]).to eql("SPARC-T3")
+ expect(plugin["cpu"]["124"]["model_name"]).to eql("SPARC-T4")
+ expect(plugin["cpu"]["125"]["model_name"]).to eql("SPARC-T4")
+ expect(plugin["cpu"]["126"]["model_name"]).to eql("SPARC-T4")
+ expect(plugin["cpu"]["127"]["model_name"]).to eql("SPARC-T4")
end
it "includes processor sockets" do
- expect(@plugin["cpu"]["0"]["socket"]).to eql("0")
- expect(@plugin["cpu"]["1"]["socket"]).to eql("0")
- expect(@plugin["cpu"]["2"]["socket"]).to eql("0")
- expect(@plugin["cpu"]["3"]["socket"]).to eql("0")
- expect(@plugin["cpu"]["124"]["socket"]).to eql("0")
- expect(@plugin["cpu"]["125"]["socket"]).to eql("0")
- expect(@plugin["cpu"]["126"]["socket"]).to eql("0")
- expect(@plugin["cpu"]["127"]["socket"]).to eql("0")
+ expect(plugin["cpu"]["0"]["socket"]).to eql("0")
+ expect(plugin["cpu"]["1"]["socket"]).to eql("0")
+ expect(plugin["cpu"]["2"]["socket"]).to eql("0")
+ expect(plugin["cpu"]["3"]["socket"]).to eql("0")
+ expect(plugin["cpu"]["124"]["socket"]).to eql("0")
+ expect(plugin["cpu"]["125"]["socket"]).to eql("0")
+ expect(plugin["cpu"]["126"]["socket"]).to eql("0")
+ expect(plugin["cpu"]["127"]["socket"]).to eql("0")
end
it "includes processor MHz" do
- expect(@plugin["cpu"]["0"]["mhz"]).to eql("1649")
- expect(@plugin["cpu"]["1"]["mhz"]).to eql("1649")
- expect(@plugin["cpu"]["2"]["mhz"]).to eql("1649")
- expect(@plugin["cpu"]["3"]["mhz"]).to eql("1649")
- expect(@plugin["cpu"]["124"]["mhz"]).to eql("1649")
- expect(@plugin["cpu"]["125"]["mhz"]).to eql("1649")
- expect(@plugin["cpu"]["126"]["mhz"]).to eql("1649")
- expect(@plugin["cpu"]["127"]["mhz"]).to eql("1649")
+ expect(plugin["cpu"]["0"]["mhz"]).to eql("1649")
+ expect(plugin["cpu"]["1"]["mhz"]).to eql("1649")
+ expect(plugin["cpu"]["2"]["mhz"]).to eql("1649")
+ expect(plugin["cpu"]["3"]["mhz"]).to eql("1649")
+ expect(plugin["cpu"]["124"]["mhz"]).to eql("1649")
+ expect(plugin["cpu"]["125"]["mhz"]).to eql("1649")
+ expect(plugin["cpu"]["126"]["mhz"]).to eql("1649")
+ expect(plugin["cpu"]["127"]["mhz"]).to eql("1649")
end
it "includes processor core IDs" do
- expect(@plugin["cpu"]["0"]["core_id"]).to eql("1026")
- expect(@plugin["cpu"]["8"]["core_id"]).to eql("1033")
- expect(@plugin["cpu"]["16"]["core_id"]).to eql("1040")
- expect(@plugin["cpu"]["24"]["core_id"]).to eql("1047")
- expect(@plugin["cpu"]["32"]["core_id"]).to eql("1054")
- expect(@plugin["cpu"]["40"]["core_id"]).to eql("1061")
- expect(@plugin["cpu"]["48"]["core_id"]).to eql("1068")
- expect(@plugin["cpu"]["56"]["core_id"]).to eql("1075")
- expect(@plugin["cpu"]["64"]["core_id"]).to eql("1082")
- expect(@plugin["cpu"]["72"]["core_id"]).to eql("1089")
- expect(@plugin["cpu"]["80"]["core_id"]).to eql("1096")
- expect(@plugin["cpu"]["88"]["core_id"]).to eql("1103")
- expect(@plugin["cpu"]["96"]["core_id"]).to eql("1110")
- expect(@plugin["cpu"]["104"]["core_id"]).to eql("1117")
- expect(@plugin["cpu"]["112"]["core_id"]).to eql("1124")
- expect(@plugin["cpu"]["120"]["core_id"]).to eql("1131")
+ expect(plugin["cpu"]["0"]["core_id"]).to eql("1026")
+ expect(plugin["cpu"]["8"]["core_id"]).to eql("1033")
+ expect(plugin["cpu"]["16"]["core_id"]).to eql("1040")
+ expect(plugin["cpu"]["24"]["core_id"]).to eql("1047")
+ expect(plugin["cpu"]["32"]["core_id"]).to eql("1054")
+ expect(plugin["cpu"]["40"]["core_id"]).to eql("1061")
+ expect(plugin["cpu"]["48"]["core_id"]).to eql("1068")
+ expect(plugin["cpu"]["56"]["core_id"]).to eql("1075")
+ expect(plugin["cpu"]["64"]["core_id"]).to eql("1082")
+ expect(plugin["cpu"]["72"]["core_id"]).to eql("1089")
+ expect(plugin["cpu"]["80"]["core_id"]).to eql("1096")
+ expect(plugin["cpu"]["88"]["core_id"]).to eql("1103")
+ expect(plugin["cpu"]["96"]["core_id"]).to eql("1110")
+ expect(plugin["cpu"]["104"]["core_id"]).to eql("1117")
+ expect(plugin["cpu"]["112"]["core_id"]).to eql("1124")
+ expect(plugin["cpu"]["120"]["core_id"]).to eql("1131")
end
it "includes processor architecture" do
- expect(@plugin["cpu"]["0"]["arch"]).to eql("sparcv9")
- expect(@plugin["cpu"]["1"]["arch"]).to eql("sparcv9")
- expect(@plugin["cpu"]["2"]["arch"]).to eql("sparcv9")
- expect(@plugin["cpu"]["3"]["arch"]).to eql("sparcv9")
- expect(@plugin["cpu"]["124"]["arch"]).to eql("sparcv9")
- expect(@plugin["cpu"]["125"]["arch"]).to eql("sparcv9")
- expect(@plugin["cpu"]["126"]["arch"]).to eql("sparcv9")
- expect(@plugin["cpu"]["127"]["arch"]).to eql("sparcv9")
+ expect(plugin["cpu"]["0"]["arch"]).to eql("sparcv9")
+ expect(plugin["cpu"]["1"]["arch"]).to eql("sparcv9")
+ expect(plugin["cpu"]["2"]["arch"]).to eql("sparcv9")
+ expect(plugin["cpu"]["3"]["arch"]).to eql("sparcv9")
+ expect(plugin["cpu"]["124"]["arch"]).to eql("sparcv9")
+ expect(plugin["cpu"]["125"]["arch"]).to eql("sparcv9")
+ expect(plugin["cpu"]["126"]["arch"]).to eql("sparcv9")
+ expect(plugin["cpu"]["127"]["arch"]).to eql("sparcv9")
end
it "includes processor FPU type" do
- expect(@plugin["cpu"]["0"]["fpu_type"]).to eql("sparcv9")
- expect(@plugin["cpu"]["1"]["fpu_type"]).to eql("sparcv9")
- expect(@plugin["cpu"]["2"]["fpu_type"]).to eql("sparcv9")
- expect(@plugin["cpu"]["3"]["fpu_type"]).to eql("sparcv9")
- expect(@plugin["cpu"]["124"]["fpu_type"]).to eql("sparcv9")
- expect(@plugin["cpu"]["125"]["fpu_type"]).to eql("sparcv9")
- expect(@plugin["cpu"]["126"]["fpu_type"]).to eql("sparcv9")
- expect(@plugin["cpu"]["127"]["fpu_type"]).to eql("sparcv9")
+ expect(plugin["cpu"]["0"]["fpu_type"]).to eql("sparcv9")
+ expect(plugin["cpu"]["1"]["fpu_type"]).to eql("sparcv9")
+ expect(plugin["cpu"]["2"]["fpu_type"]).to eql("sparcv9")
+ expect(plugin["cpu"]["3"]["fpu_type"]).to eql("sparcv9")
+ expect(plugin["cpu"]["124"]["fpu_type"]).to eql("sparcv9")
+ expect(plugin["cpu"]["125"]["fpu_type"]).to eql("sparcv9")
+ expect(plugin["cpu"]["126"]["fpu_type"]).to eql("sparcv9")
+ expect(plugin["cpu"]["127"]["fpu_type"]).to eql("sparcv9")
end
it "includes processor state" do
- expect(@plugin["cpu"]["0"]["state"]).to eql("on-line")
- expect(@plugin["cpu"]["1"]["state"]).to eql("on-line")
- expect(@plugin["cpu"]["2"]["state"]).to eql("on-line")
- expect(@plugin["cpu"]["3"]["state"]).to eql("on-line")
- expect(@plugin["cpu"]["124"]["state"]).to eql("off-line")
- expect(@plugin["cpu"]["125"]["state"]).to eql("off-line")
- expect(@plugin["cpu"]["126"]["state"]).to eql("off-line")
- expect(@plugin["cpu"]["127"]["state"]).to eql("off-line")
+ expect(plugin["cpu"]["0"]["state"]).to eql("on-line")
+ expect(plugin["cpu"]["1"]["state"]).to eql("on-line")
+ expect(plugin["cpu"]["2"]["state"]).to eql("on-line")
+ expect(plugin["cpu"]["3"]["state"]).to eql("on-line")
+ expect(plugin["cpu"]["124"]["state"]).to eql("off-line")
+ expect(plugin["cpu"]["125"]["state"]).to eql("off-line")
+ expect(plugin["cpu"]["126"]["state"]).to eql("off-line")
+ expect(plugin["cpu"]["127"]["state"]).to eql("off-line")
end
end
end
diff --git a/spec/unit/plugins/solaris2/dmi_spec.rb b/spec/unit/plugins/solaris2/dmi_spec.rb
index fcc2225e..97bc1fbf 100644
--- a/spec/unit/plugins/solaris2/dmi_spec.rb
+++ b/spec/unit/plugins/solaris2/dmi_spec.rb
@@ -112,16 +112,17 @@ SOLARIS_DMI_OUT = <<~EOS.freeze
EOS
describe Ohai::System, "Solaris2.X DMI plugin" do
+ let(:plugin) { get_plugin("solaris2/dmi") }
+
before do
- @plugin = get_plugin("solaris2/dmi")
- allow(@plugin).to receive(:collect_os).and_return("solaris2")
+ allow(plugin).to receive(:collect_os).and_return("solaris2")
@stdout = SOLARIS_DMI_OUT
- allow(@plugin).to receive(:shell_out).with("smbios").and_return(mock_shell_out(0, @stdout, ""))
+ allow(plugin).to receive(:shell_out).with("smbios").and_return(mock_shell_out(0, @stdout, ""))
end
it "runs smbios" do
- expect(@plugin).to receive(:shell_out).with("smbios").and_return(mock_shell_out(0, @stdout, ""))
- @plugin.run
+ expect(plugin).to receive(:shell_out).with("smbios").and_return(mock_shell_out(0, @stdout, ""))
+ plugin.run
end
{
@@ -140,14 +141,14 @@ describe Ohai::System, "Solaris2.X DMI plugin" do
}.each do |id, data|
data.each do |attribute, value|
it "has [:dmi][:#{id}][:#{attribute}] set" do
- @plugin.run
- expect(@plugin[:dmi][id][attribute]).to eql(value)
+ plugin.run
+ expect(plugin[:dmi][id][attribute]).to eql(value)
end
end
end
it "ignores unwanted types" do
- @plugin.run
- expect(@plugin[:dmi]).not_to have_key(:on_board_devices)
+ plugin.run
+ expect(plugin[:dmi]).not_to have_key(:on_board_devices)
end
end
diff --git a/spec/unit/plugins/solaris2/hostname_spec.rb b/spec/unit/plugins/solaris2/hostname_spec.rb
index 390b5e45..a455bd2c 100644
--- a/spec/unit/plugins/solaris2/hostname_spec.rb
+++ b/spec/unit/plugins/solaris2/hostname_spec.rb
@@ -19,19 +19,20 @@
require "spec_helper"
describe Ohai::System, "Solaris2.X hostname plugin" do
+ let(:plugin) { get_plugin("hostname") }
+
before do
- @plugin = get_plugin("hostname")
- allow(@plugin).to receive(:collect_os).and_return(:solaris2)
- allow(@plugin).to receive(:resolve_fqdn).and_return("kitteh.inurfridge.eatinurfoodz")
- allow(@plugin).to receive(:shell_out).with("hostname").and_return(mock_shell_out(0, "kitteh\n", ""))
- # Socket.stub(:getaddrinfo).and_return( [["AF_INET", 0, "kitteh.inurfridge.eatinurfoodz", "10.1.2.3", 2, 0, 0]] );
+ allow(plugin).to receive(:collect_os).and_return(:solaris2)
+ allow(plugin).to receive(:resolve_fqdn).and_return("kitteh.inurfridge.eatinurfoodz")
+ allow(plugin).to receive(:shell_out).with("hostname").and_return(mock_shell_out(0, "kitteh\n", ""))
+ # Socket.stub(:getaddrinfo).and_return( [["AF_INET", 0, "kitteh.inurfridge.eatinurfoodz", "10.1.2.3", 2, 0, 0]] );
end
it_should_check_from("solaris2::hostname", "hostname", "hostname", "kitteh")
it "gets the fqdn value from #resolve_fqdn" do
- @plugin.run
- expect(@plugin["fqdn"]).to eq("kitteh.inurfridge.eatinurfoodz")
+ plugin.run
+ expect(plugin["fqdn"]).to eq("kitteh.inurfridge.eatinurfoodz")
end
end
diff --git a/spec/unit/plugins/solaris2/kernel_spec.rb b/spec/unit/plugins/solaris2/kernel_spec.rb
index e2f7971d..95797438 100644
--- a/spec/unit/plugins/solaris2/kernel_spec.rb
+++ b/spec/unit/plugins/solaris2/kernel_spec.rb
@@ -19,6 +19,8 @@
require "spec_helper"
describe Ohai::System, "Solaris2.X kernel plugin" do
+ let(:plugin) { get_plugin("kernel") }
+
# NOTE: Solaris will report the same module loaded multiple times
# with the same ID, Loadaddr, etc. and only the info column different
# ignoring it, and removing the data from this fixture.
@@ -134,11 +136,10 @@ describe Ohai::System, "Solaris2.X kernel plugin" do
TOOMUCH
before do
- @plugin = get_plugin("kernel")
- allow(@plugin).to receive(:collect_os).and_return(:solaris2)
- allow(@plugin).to receive(:init_kernel).and_return({})
- allow(@plugin).to receive(:shell_out).with("uname -s").and_return(mock_shell_out(0, "SunOS\n", ""))
- allow(@plugin).to receive(:shell_out).with("modinfo").and_return(mock_shell_out(0, MODINFO, ""))
+ allow(plugin).to receive(:collect_os).and_return(:solaris2)
+ allow(plugin).to receive(:init_kernel).and_return({})
+ allow(plugin).to receive(:shell_out).with("uname -s").and_return(mock_shell_out(0, "SunOS\n", ""))
+ allow(plugin).to receive(:shell_out).with("modinfo").and_return(mock_shell_out(0, MODINFO, ""))
@release = StringIO.new(" Oracle Solaris 10 1/13 s10s_u11wos_24a SPARC\n Assembled 17 January 2013")
allow(File).to receive(:open).with("/etc/release").and_yield(@release)
end
@@ -146,38 +147,38 @@ describe Ohai::System, "Solaris2.X kernel plugin" do
it "gives the Solaris update version information" do
@release = StringIO.new(" Solaris 10 10/08 s10s_u6wos_07b SPARC\n Use is subject to license terms.\n Assembled 27 October 2008")
allow(File).to receive(:open).with("/etc/release").and_yield(@release)
- @plugin.run
- expect(@plugin[:kernel][:update]).to eq("10 10/08 s10s_u6wos_07")
+ plugin.run
+ expect(plugin[:kernel][:update]).to eq("10 10/08 s10s_u6wos_07")
end
it "gives the Oracle Solaris update version information" do
@release = StringIO.new(" Oracle Solaris 10 1/13 s10s_u11wos_24a SPARC\n Assembled 17 January 2013")
allow(File).to receive(:open).with("/etc/release").and_yield(@release)
- @plugin.run
- expect(@plugin[:kernel][:update]).to eq("10 1/13 s10s_u11wos_24")
+ plugin.run
+ expect(plugin[:kernel][:update]).to eq("10 1/13 s10s_u11wos_24")
end
it "gives the Solaris 11 update version information" do
@release = StringIO.new(" Oracle Solaris 11.3 SPARC\n Assembled 25 July 2016")
allow(File).to receive(:open).with("/etc/release").and_yield(@release)
- @plugin.run
- expect(@plugin[:kernel][:update]).to eq("11.3")
+ plugin.run
+ expect(plugin[:kernel][:update]).to eq("11.3")
end
it_should_check_from_deep_mash("solaris2::kernel", "kernel", "os", "uname -s", [0, "SunOS\n", ""])
it "gives excruciating detail about kernel modules" do
- @plugin.run
+ plugin.run
- expect(@plugin[:kernel][:modules]).to have(107).modules
+ expect(plugin[:kernel][:modules]).to have(107).modules
# Teh daterz
# Id Loadaddr Size Info Rev Module Name
# 6 1180000 4623 1 1 specfs (filesystem for specfs)
teh_daterz = { "id" => 6, "loadaddr" => "1180000", "size" => 17955, "description" => "filesystem for specfs" }
- expect(@plugin[:kernel][:modules].keys).to include("specfs")
- expect(@plugin[:kernel][:modules].keys).not_to include("Module")
- expect(@plugin[:kernel][:modules]["specfs"]).to eq(teh_daterz)
+ expect(plugin[:kernel][:modules].keys).to include("specfs")
+ expect(plugin[:kernel][:modules].keys).not_to include("Module")
+ expect(plugin[:kernel][:modules]["specfs"]).to eq(teh_daterz)
end
end
diff --git a/spec/unit/plugins/solaris2/memory_spec.rb b/spec/unit/plugins/solaris2/memory_spec.rb
index 11fc88b9..9c9b3697 100644
--- a/spec/unit/plugins/solaris2/memory_spec.rb
+++ b/spec/unit/plugins/solaris2/memory_spec.rb
@@ -17,27 +17,28 @@
require "spec_helper"
describe Ohai::System, "Solaris2.X memory plugin" do
+ let(:plugin) { get_plugin("solaris2/memory") }
+
before do
- @plugin = get_plugin("solaris2/memory")
- allow(@plugin).to receive(:collect_os).and_return("solaris2")
- allow(@plugin).to receive(:shell_out).with("prtconf | grep Memory").and_return(mock_shell_out(0, "Memory size: 8194 Megabytes\n", ""))
+ allow(plugin).to receive(:collect_os).and_return("solaris2")
+ allow(plugin).to receive(:shell_out).with("prtconf | grep Memory").and_return(mock_shell_out(0, "Memory size: 8194 Megabytes\n", ""))
@swap_s = "total: 112230656k bytes allocated + 357865576k reserved = 470096232k used, 47057688k available\n"
- allow(@plugin).to receive(:shell_out).with("swap -s").and_return(mock_shell_out(0, @swap_s, ""))
+ allow(plugin).to receive(:shell_out).with("swap -s").and_return(mock_shell_out(0, @swap_s, ""))
end
it "gets the total memory" do
- @plugin.run
- expect(@plugin[:memory][:total]).to eql("#{8194 * 1024}kB")
+ plugin.run
+ expect(plugin[:memory][:total]).to eql("#{8194 * 1024}kB")
end
it "gets total swap" do
- @plugin.run
- expect(@plugin[:memory][:swap][:total]).to eql("#{(470096232 + 47057688)}kB" )
+ plugin.run
+ expect(plugin[:memory][:swap][:total]).to eql("#{(470096232 + 47057688)}kB" )
end
it "gets free swap" do
- @plugin.run
- expect(@plugin[:memory][:swap][:free]).to eql("47057688kB")
+ plugin.run
+ expect(plugin[:memory][:swap][:free]).to eql("47057688kB")
end
end
diff --git a/spec/unit/plugins/solaris2/network_spec.rb b/spec/unit/plugins/solaris2/network_spec.rb
index 07151ce7..ca451f2e 100644
--- a/spec/unit/plugins/solaris2/network_spec.rb
+++ b/spec/unit/plugins/solaris2/network_spec.rb
@@ -19,6 +19,7 @@
require "spec_helper"
describe Ohai::System, "Solaris2.X network plugin" do
+ let(:plugin) { get_plugin("solaris2/network") }
before do
@solaris_arp_rn = <<~ARP_RN
@@ -124,46 +125,45 @@ describe Ohai::System, "Solaris2.X network plugin" do
@ifconfig_lines = @solaris_ifconfig.split("\n")
- @plugin = get_plugin("solaris2/network")
- allow(@plugin).to receive(:collect_os).and_return(:solaris2)
- @plugin[:network] = Mash.new
+ allow(plugin).to receive(:collect_os).and_return(:solaris2)
+ plugin[:network] = Mash.new
- allow(@plugin).to receive(:shell_out).with("ifconfig -a").and_return(mock_shell_out(0, @solaris_route_get, ""))
- allow(@plugin).to receive(:shell_out).with("arp -an").and_return(mock_shell_out(0, @solaris_arp_rn, ""))
- allow(@plugin).to receive(:shell_out).with("route -v -n get default").and_return(mock_shell_out(0, @solaris_route_get, ""))
+ allow(plugin).to receive(:shell_out).with("ifconfig -a").and_return(mock_shell_out(0, @solaris_route_get, ""))
+ allow(plugin).to receive(:shell_out).with("arp -an").and_return(mock_shell_out(0, @solaris_arp_rn, ""))
+ allow(plugin).to receive(:shell_out).with("route -v -n get default").and_return(mock_shell_out(0, @solaris_route_get, ""))
end
describe "gathering IP layer address info" do
before do
@stdout = double("Pipe, stdout, cmd=`route get default`", read: @solaris_route_get)
- allow(@plugin).to receive(:shell_out).with("route -v -n get default").and_return(mock_shell_out(0, @solaris_route_get, ""))
- allow(@plugin).to receive(:shell_out).with("ifconfig -a").and_return(mock_shell_out(0, @solaris_ifconfig, ""))
- @plugin.run
+ allow(plugin).to receive(:shell_out).with("route -v -n get default").and_return(mock_shell_out(0, @solaris_route_get, ""))
+ allow(plugin).to receive(:shell_out).with("ifconfig -a").and_return(mock_shell_out(0, @solaris_ifconfig, ""))
+ plugin.run
end
it "completes the run" do
- expect(@plugin["network"]).not_to be_nil
+ expect(plugin["network"]).not_to be_nil
end
it "detects the interfaces" do
- expect(@plugin["network"]["interfaces"].keys.sort).to eq(["e1000g0:3", "e1000g2:1", "eri0", "ip.tun0", "ip.tun0:1", "ip6.tun0", "ipmp0", "lo0", "lo0:3", "net0", "net1:1", "qfe1", "vni0"])
+ expect(plugin["network"]["interfaces"].keys.sort).to eq(["e1000g0:3", "e1000g2:1", "eri0", "ip.tun0", "ip.tun0:1", "ip6.tun0", "ipmp0", "lo0", "lo0:3", "net0", "net1:1", "qfe1", "vni0"])
end
it "detects the ip addresses of the interfaces" do
- expect(@plugin["network"]["interfaces"]["e1000g0:3"]["addresses"].keys).to include("72.2.115.28")
+ expect(plugin["network"]["interfaces"]["e1000g0:3"]["addresses"].keys).to include("72.2.115.28")
end
it "detects the encapsulation type of the interfaces" do
- expect(@plugin["network"]["interfaces"]["e1000g0:3"]["encapsulation"]).to eq("Ethernet")
+ expect(plugin["network"]["interfaces"]["e1000g0:3"]["encapsulation"]).to eq("Ethernet")
end
it "detects the L3PROTECT network flag" do
- expect(@plugin["network"]["interfaces"]["net0"]["flags"]).to include("L3PROTECT")
+ expect(plugin["network"]["interfaces"]["net0"]["flags"]).to include("L3PROTECT")
end
it "detects an interface with no index number" do
- expect(@plugin["network"]["interfaces"]["ipmp0"]["index"]).to eq(nil)
- expect(@plugin["network"]["interfaces"]["ipmp0"]["mtu"]).to eq("1500")
+ expect(plugin["network"]["interfaces"]["ipmp0"]["index"]).to eq(nil)
+ expect(plugin["network"]["interfaces"]["ipmp0"]["mtu"]).to eq("1500")
end
end
@@ -171,17 +171,17 @@ describe Ohai::System, "Solaris2.X network plugin" do
describe "gathering solaris 11 zone IP layer address info" do
before do
@stdout = double("Pipe, stdout, cmd=`route get default`", read: @solaris11_route_get)
- allow(@plugin).to receive(:shell_out).with("route -v -n get default").and_return(mock_shell_out(0, @solaris11_route_get, ""))
- allow(@plugin).to receive(:shell_out).with("ifconfig -a").and_return(mock_shell_out(0, @solaris_ifconfig, ""))
- @plugin.run
+ allow(plugin).to receive(:shell_out).with("route -v -n get default").and_return(mock_shell_out(0, @solaris11_route_get, ""))
+ allow(plugin).to receive(:shell_out).with("ifconfig -a").and_return(mock_shell_out(0, @solaris_ifconfig, ""))
+ plugin.run
end
it "finds the flags for a PHYSRUNNING interface" do
- expect(@plugin[:network][:interfaces]["net1:1"][:flags]).to eq(%w{ UP BROADCAST RUNNING MULTICAST IPv4 PHYSRUNNING })
+ expect(plugin[:network][:interfaces]["net1:1"][:flags]).to eq(%w{ UP BROADCAST RUNNING MULTICAST IPv4 PHYSRUNNING })
end
it "finds the default interface for a solaris 11 zone" do
- expect(@plugin[:network][:default_interface]).to eq("net1:1")
+ expect(plugin[:network][:default_interface]).to eq("net1:1")
end
end
@@ -190,12 +190,12 @@ describe Ohai::System, "Solaris2.X network plugin" do
describe "setting the node's default IP address attribute" do
before do
@stdout = double("Pipe, stdout, cmd=`route get default`", read: @solaris_route_get)
- allow(@plugin).to receive(:shell_out).with("route -v -n get default").and_return(mock_shell_out(0, @solaris_route_get, ""))
- @plugin.run
+ allow(plugin).to receive(:shell_out).with("route -v -n get default").and_return(mock_shell_out(0, @solaris_route_get, ""))
+ plugin.run
end
it "finds the default interface by asking which iface has the default route" do
- expect(@plugin[:network][:default_interface]).to eq("e1000g0")
+ expect(plugin[:network][:default_interface]).to eq("e1000g0")
end
end
end
diff --git a/spec/unit/plugins/solaris2/platform_spec.rb b/spec/unit/plugins/solaris2/platform_spec.rb
index 3a1560a3..68a3715f 100644
--- a/spec/unit/plugins/solaris2/platform_spec.rb
+++ b/spec/unit/plugins/solaris2/platform_spec.rb
@@ -19,10 +19,11 @@
require "spec_helper"
describe Ohai::System, "Solaris plugin platform" do
+ let(:plugin) { get_plugin("solaris2/platform") }
+
before do
- @plugin = get_plugin("solaris2/platform")
- allow(@plugin).to receive(:collect_os).and_return(:solaris2)
- allow(@plugin).to receive(:shell_out).with("/sbin/uname -X")
+ allow(plugin).to receive(:collect_os).and_return(:solaris2)
+ allow(plugin).to receive(:shell_out).with("/sbin/uname -X")
end
describe "on SmartOS" do
@@ -42,25 +43,25 @@ describe Ohai::System, "Solaris plugin platform" do
UNAME_X
allow(File).to receive(:exist?).with("/sbin/uname").and_return(true)
- allow(@plugin).to receive(:shell_out).with("/sbin/uname -X").and_return(mock_shell_out(0, @uname_x, ""))
+ allow(plugin).to receive(:shell_out).with("/sbin/uname -X").and_return(mock_shell_out(0, @uname_x, ""))
@release = StringIO.new(" SmartOS 20120130T201844Z x86_64\n")
allow(File).to receive(:open).with("/etc/release").and_yield(@release)
end
it "runs uname and set platform and build" do
- @plugin.run
- expect(@plugin[:platform_build]).to eq("joyent_20120130T201844Z")
+ plugin.run
+ expect(plugin[:platform_build]).to eq("joyent_20120130T201844Z")
end
it "sets the platform" do
- @plugin.run
- expect(@plugin[:platform]).to eq("smartos")
+ plugin.run
+ expect(plugin[:platform]).to eq("smartos")
end
it "sets the platform_version" do
- @plugin.run
- expect(@plugin[:platform_version]).to eq("5.11")
+ plugin.run
+ expect(plugin[:platform_version]).to eq("5.11")
end
end
@@ -82,25 +83,25 @@ describe Ohai::System, "Solaris plugin platform" do
UNAME_X
allow(File).to receive(:exist?).with("/sbin/uname").and_return(true)
- allow(@plugin).to receive(:shell_out).with("/sbin/uname -X").and_return(mock_shell_out(0, @uname_x, ""))
+ allow(plugin).to receive(:shell_out).with("/sbin/uname -X").and_return(mock_shell_out(0, @uname_x, ""))
@release = StringIO.new(" Oracle Solaris 11.1 X86\n")
allow(File).to receive(:open).with("/etc/release").and_yield(@release)
end
it "runs uname and set platform and build" do
- @plugin.run
- expect(@plugin[:platform_build]).to eq("11.1")
+ plugin.run
+ expect(plugin[:platform_build]).to eq("11.1")
end
it "sets the platform" do
- @plugin.run
- expect(@plugin[:platform]).to eq("solaris2")
+ plugin.run
+ expect(plugin[:platform]).to eq("solaris2")
end
it "sets the platform_version" do
- @plugin.run
- expect(@plugin[:platform_version]).to eq("5.11")
+ plugin.run
+ expect(plugin[:platform_version]).to eq("5.11")
end
end
diff --git a/spec/unit/plugins/ssh_host_keys_spec.rb b/spec/unit/plugins/ssh_host_keys_spec.rb
index 8eea800e..8d3e10e6 100644
--- a/spec/unit/plugins/ssh_host_keys_spec.rb
+++ b/spec/unit/plugins/ssh_host_keys_spec.rb
@@ -19,10 +19,10 @@
require "spec_helper"
describe Ohai::System, "ssh_host_key plugin" do
+ let(:plugin) { get_plugin("ssh_host_key") }
before do
- @plugin = get_plugin("ssh_host_key")
- @plugin[:keys] = Mash.new
+ plugin[:keys] = Mash.new
allow(File).to receive(:exist?).with("/etc/ssh/sshd_config").and_return(true)
allow(File).to receive(:open).with("/etc/ssh/sshd_config").and_yield(sshd_config_file)
@@ -49,27 +49,27 @@ describe Ohai::System, "ssh_host_key plugin" do
shared_examples "loads keys" do
it "reads the key and sets the dsa attribute correctly" do
- @plugin.run
- expect(@plugin[:keys][:ssh][:host_dsa_public]).to eql(@dsa_key.split[1])
- expect(@plugin[:keys][:ssh][:host_dsa_type]).to be_nil
+ plugin.run
+ expect(plugin[:keys][:ssh][:host_dsa_public]).to eql(@dsa_key.split[1])
+ expect(plugin[:keys][:ssh][:host_dsa_type]).to be_nil
end
it "reads the key and sets the rsa attribute correctly" do
- @plugin.run
- expect(@plugin[:keys][:ssh][:host_rsa_public]).to eql(@rsa_key.split[1])
- expect(@plugin[:keys][:ssh][:host_rsa_type]).to be_nil
+ plugin.run
+ expect(plugin[:keys][:ssh][:host_rsa_public]).to eql(@rsa_key.split[1])
+ expect(plugin[:keys][:ssh][:host_rsa_type]).to be_nil
end
it "reads the key and sets the ecdsa attribute correctly" do
- @plugin.run
- expect(@plugin[:keys][:ssh][:host_ecdsa_public]).to eql(@ecdsa_key.split[1])
- expect(@plugin[:keys][:ssh][:host_ecdsa_type]).to eql(@ecdsa_key.split[0])
+ plugin.run
+ expect(plugin[:keys][:ssh][:host_ecdsa_public]).to eql(@ecdsa_key.split[1])
+ expect(plugin[:keys][:ssh][:host_ecdsa_type]).to eql(@ecdsa_key.split[0])
end
it "reads the key and sets the ed25519 attribute correctly" do
- @plugin.run
- expect(@plugin[:keys][:ssh][:host_ed25519_public]).to eql(@ed25519_key.split[1])
- expect(@plugin[:keys][:ssh][:host_ed25519_type]).to be_nil
+ plugin.run
+ expect(plugin[:keys][:ssh][:host_ed25519_public]).to eql(@ed25519_key.split[1])
+ expect(plugin[:keys][:ssh][:host_ed25519_type]).to be_nil
end
end
diff --git a/spec/unit/plugins/timezone_spec.rb b/spec/unit/plugins/timezone_spec.rb
index 154ccfd3..72964e8f 100644
--- a/spec/unit/plugins/timezone_spec.rb
+++ b/spec/unit/plugins/timezone_spec.rb
@@ -18,13 +18,14 @@
require "spec_helper"
describe Ohai::System, "timezone plugin" do
+ let(:plugin) { get_plugin("timezone") }
+
before do
- @plugin = get_plugin("timezone")
allow(Time).to receive_message_chain(:now, :getlocal, :zone) { "ZZZ" }
end
it "gets the local timezone" do
- @plugin.run
- expect(@plugin["time"]["timezone"]).to eq("ZZZ")
+ plugin.run
+ expect(plugin["time"]["timezone"]).to eq("ZZZ")
end
end
diff --git a/spec/unit/plugins/windows/cpu_spec.rb b/spec/unit/plugins/windows/cpu_spec.rb
index 551f030d..082243ec 100644
--- a/spec/unit/plugins/windows/cpu_spec.rb
+++ b/spec/unit/plugins/windows/cpu_spec.rb
@@ -21,49 +21,50 @@ require "spec_helper"
shared_examples "a cpu" do |cpu_no|
describe "cpu #{cpu_no}" do
it "sets physical_id to CPU#{cpu_no}" do
- expect(@plugin[:cpu][cpu_no.to_s][:physical_id]).to eq("CPU#{cpu_no}")
+ expect(plugin[:cpu][cpu_no.to_s][:physical_id]).to eq("CPU#{cpu_no}")
end
it "sets mhz to 2793" do
- expect(@plugin[:cpu][cpu_no.to_s][:mhz]).to eq("2793")
+ expect(plugin[:cpu][cpu_no.to_s][:mhz]).to eq("2793")
end
it "sets vendor_id to GenuineIntel" do
- expect(@plugin[:cpu][cpu_no.to_s][:vendor_id]).to eq("GenuineIntel")
+ expect(plugin[:cpu][cpu_no.to_s][:vendor_id]).to eq("GenuineIntel")
end
it "sets model_name to Intel(R) Core(TM) i7-4500U CPU @ 1.80GHz" do
- expect(@plugin[:cpu][cpu_no.to_s][:model_name])
+ expect(plugin[:cpu][cpu_no.to_s][:model_name])
.to eq("Intel(R) Core(TM) i7-4500U CPU @ 1.80GHz")
end
it "sets description to Intel64 Family 6 Model 70 Stepping 1" do
- expect(@plugin[:cpu][cpu_no.to_s][:description])
+ expect(plugin[:cpu][cpu_no.to_s][:description])
.to eq("Intel64 Family 6 Model 70 Stepping 1")
end
it "sets model to 17921" do
- expect(@plugin[:cpu][cpu_no.to_s][:model]).to eq("17921")
+ expect(plugin[:cpu][cpu_no.to_s][:model]).to eq("17921")
end
it "sets family to 2" do
- expect(@plugin[:cpu][cpu_no.to_s][:family]).to eq("2")
+ expect(plugin[:cpu][cpu_no.to_s][:family]).to eq("2")
end
it "sets stepping to 9" do
- expect(@plugin[:cpu][cpu_no.to_s][:stepping]).to eq(9)
+ expect(plugin[:cpu][cpu_no.to_s][:stepping]).to eq(9)
end
it "sets cache_size to 64 KB" do
- expect(@plugin[:cpu][cpu_no.to_s][:cache_size]).to eq("64 KB")
+ expect(plugin[:cpu][cpu_no.to_s][:cache_size]).to eq("64 KB")
end
end
end
describe Ohai::System, "Windows cpu plugin" do
+ let(:plugin) { get_plugin("cpu") }
+
before do
- @plugin = get_plugin("cpu")
- allow(@plugin).to receive(:collect_os).and_return(:windows)
+ allow(plugin).to receive(:collect_os).and_return(:windows)
@double_wmi_instance = instance_double(WmiLite::Wmi)
@@ -97,20 +98,20 @@ describe Ohai::System, "Windows cpu plugin" do
.with("Win32_Processor")
.and_return(@processors)
- @plugin.run
+ plugin.run
end
it "sets total cpu to 2" do
- expect(@plugin[:cpu][:total]).to eq(4)
+ expect(plugin[:cpu][:total]).to eq(4)
end
it "sets real cpu to 2" do
- expect(@plugin[:cpu][:real]).to eq(2)
+ expect(plugin[:cpu][:real]).to eq(2)
end
it "sets 2 distinct cpus numbered 0 and 1" do
- expect(@plugin[:cpu]).to have_key("0")
- expect(@plugin[:cpu]).to have_key("1")
+ expect(plugin[:cpu]).to have_key("0")
+ expect(plugin[:cpu]).to have_key("1")
end
it_behaves_like "a cpu", 0
diff --git a/spec/unit/plugins/windows/memory_spec.rb b/spec/unit/plugins/windows/memory_spec.rb
index 38e88eda..2095d416 100644
--- a/spec/unit/plugins/windows/memory_spec.rb
+++ b/spec/unit/plugins/windows/memory_spec.rb
@@ -17,9 +17,10 @@
require "spec_helper"
describe Ohai::System, "Windows memory plugin", :windows_only do
+ let(:plugin) { get_plugin("windows/memory") }
+
before do
require "wmi-lite/wmi"
- @plugin = get_plugin("windows/memory")
mock_os = {
"TotalVisibleMemorySize" => "10485760",
"FreePhysicalMemory" => "5242880",
@@ -30,23 +31,23 @@ describe Ohai::System, "Windows memory plugin", :windows_only do
end
it "gets total memory" do
- @plugin.run
- expect(@plugin["memory"]["total"]).to eql("10485760kB")
+ plugin.run
+ expect(plugin["memory"]["total"]).to eql("10485760kB")
end
it "gets free memory" do
- @plugin.run
- expect(@plugin["memory"]["free"]).to eql("5242880kB")
+ plugin.run
+ expect(plugin["memory"]["free"]).to eql("5242880kB")
end
it "gets total swap" do
- @plugin.run
- expect(@plugin["memory"]["swap"]["total"]).to eql("20971520kB")
+ plugin.run
+ expect(plugin["memory"]["swap"]["total"]).to eql("20971520kB")
end
it "gets free memory" do
- @plugin.run
- expect(@plugin["memory"]["swap"]["free"]).to eql("15728640kB")
+ plugin.run
+ expect(plugin["memory"]["swap"]["free"]).to eql("15728640kB")
end
end