diff options
author | Tim Smith <tsmith84@gmail.com> | 2020-11-17 16:36:50 -0800 |
---|---|---|
committer | Tim Smith <tsmith84@gmail.com> | 2020-11-17 17:07:10 -0800 |
commit | 7ab7562271acbd4c6b310fbcaf001ae99f4c0272 (patch) | |
tree | 5707dde12deb73db2b1392aa5c5025a6c89f64f2 | |
parent | 6e7d7eb4d3202f785be013d8bf67afa6eb0161ab (diff) | |
download | ohai-7ab7562271acbd4c6b310fbcaf001ae99f4c0272.tar.gz |
Fixes for test failures
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r-- | lib/ohai/plugins/aix/network.rb | 5 | ||||
-rw-r--r-- | spec/unit/plugins/aix/network_spec.rb | 8 |
2 files changed, 7 insertions, 6 deletions
diff --git a/lib/ohai/plugins/aix/network.rb b/lib/ohai/plugins/aix/network.rb index 01647bf2..52e419e3 100644 --- a/lib/ohai/plugins/aix/network.rb +++ b/lib/ohai/plugins/aix/network.rb @@ -49,11 +49,12 @@ Ohai.plugin(:Network) do # :default_interface, :default_gateway - route -n get 0 netstat_so = shell_out("netstat -rn").stdout netstat_so.each_line do |line| - next unless line.start_with?('default') + next unless line.start_with?("default") + items = line.split(" ") network[:default_gateway] = items[1] network[:default_interface] = items[5] - return + break end end diff --git a/spec/unit/plugins/aix/network_spec.rb b/spec/unit/plugins/aix/network_spec.rb index 1bedbdc8..47e14ae2 100644 --- a/spec/unit/plugins/aix/network_spec.rb +++ b/spec/unit/plugins/aix/network_spec.rb @@ -20,7 +20,7 @@ require "spec_helper" describe Ohai::System, "AIX network plugin" do before do - @netstat_rn_grep_default = <<~NETSTAT_RN_GREP_DEFAULT + @netstat_rn = <<~NETSTAT_RN Destination Gateway Flags Refcnt Use Interface Destination Gateway Flags Refs Use If Exp Groups Only the root user can specify the Z flag @@ -34,7 +34,7 @@ describe Ohai::System, "AIX network plugin" do Only the root user can specify the Z flag (Internet v6): ::1%1 ::1%1 UH 1 677032 lo0 - - => - NETSTAT_RN_GREP_DEFAULT + NETSTAT_RN @ifconfig = <<~IFCONFIG en0: flags=1e080863,480<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST,GROUPRT,64BIT,CHECKSUM_OFFLOAD(ACTIVE),CHAIN> metric 1 @@ -89,7 +89,7 @@ describe Ohai::System, "AIX network plugin" do 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("netstat -rn").and_return(mock_shell_out(0, @netstat_rn, 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)) @@ -134,7 +134,7 @@ describe Ohai::System, "AIX network plugin" do 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.0.1") end it "returns the default interface of the system's network" do |