From 96c9a73e98dbe431adb2c2774a1df10b61a48efb Mon Sep 17 00:00:00 2001 From: Phil Dibowitz Date: Tue, 22 Oct 2024 14:05:34 -0700 Subject: [PATCH] Unit tests for freebsd network plugin; plus fixes This adds unittests for the FreeBSD network plugin. It also fixes various issues: * It now running on modern freebsd which has extra columns in netstat output. * It now properly reports encapuslation, MTU, and metric It also includes a test case with `::1` on `lo1` to start building out support for sorting out #1838 Signed-off-by: Phil Dibowitz --- lib/ohai/plugins/freebsd/network.rb | 43 ++- spec/unit/plugins/freebsd/network_spec.rb | 337 ++++++++++++++++++++++ 2 files changed, 371 insertions(+), 9 deletions(-) create mode 100644 spec/unit/plugins/freebsd/network_spec.rb diff --git a/lib/ohai/plugins/freebsd/network.rb b/lib/ohai/plugins/freebsd/network.rb index 4c84a9848..f99faa1a5 100644 --- a/lib/ohai/plugins/freebsd/network.rb +++ b/lib/ohai/plugins/freebsd/network.rb @@ -80,10 +80,13 @@ flags = $1.split(",") iface[cint][:flags] = flags if flags.length > 0 end - if line =~ /metric: (\d+) mtu: (\d+)/ + if line =~ /metric (\d+) mtu (\d+)/ iface[cint][:metric] = $1 iface[cint][:mtu] = $2 end + if line =~ /media: (\w+)/ + iface[cint][:encapsulation] = $1 + end end so = shell_out("arp -an") @@ -104,22 +107,44 @@ # which have been auto-configured (interfaces statically configured # into a system, but not located at boot time are not shown). so = shell_out("netstat -ibdn") - so.stdout.lines do |line| + head = so.stdout.lines[0] + have_drop = false + if head =~ /Idrop/ + have_drop = true + # Name Mtu Network Address Ipkts Ierrs Idrop Ibytes Opkts Oerrs Obytes Coll Drop + # vtnet0 1500 fa:16:3e:ba:3e:25 579 0 0 46746 210 0 26242 0 0 + # $1 $2 $3 $4 $5 $6 $7 $8 $9 $10 $11 + regex = /^([\w\.\*]+)\s+\d+\s+\s+([\w\d:]*)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/ + else # Name Mtu Network Address Ipkts Ierrs Ibytes Opkts Oerrs Obytes Coll Drop # ed0 1500 54:52:00:68:92:85 333604 26 151905886 175472 0 24897542 0 905 # $1 $2 $3 $4 $5 $6 $7 $8 $9 $10 - if line =~ /^([\w\.\*]+)\s+\d+\s+\s+([\w:]*)\s*(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/ + regex = /^([\w\.\*]+)\s+\d+\s+\s+([\w\d:]*)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/ + end + so.stdout.lines do |line| + if line =~ regex net_counters[$1] ||= Mash.new net_counters[$1]["rx"] ||= Mash.new net_counters[$1]["tx"] ||= Mash.new net_counters[$1]["rx"]["packets"] = $3 net_counters[$1]["rx"]["errors"] = $4 - net_counters[$1]["rx"]["bytes"] = $5 - net_counters[$1]["tx"]["packets"] = $6 - net_counters[$1]["tx"]["errors"] = $7 - net_counters[$1]["tx"]["bytes"] = $8 - net_counters[$1]["tx"]["collisions"] = $9 - net_counters[$1]["tx"]["dropped"] = $10 + if have_drop + net_counters[$1]["rx"]["dropped"] = $5 + net_counters[$1]["rx"]["bytes"] = $6 + net_counters[$1]["tx"]["packets"] = $7 + net_counters[$1]["tx"]["errors"] = $8 + net_counters[$1]["tx"]["bytes"] = $9 + net_counters[$1]["tx"]["collisions"] = $10 + net_counters[$1]["tx"]["dropped"] = $11 + else + net_counters[$1]["rx"]["bytes"] = $5 + net_counters[$1]["tx"]["packets"] = $6 + net_counters[$1]["tx"]["errors"] = $7 + net_counters[$1]["tx"]["bytes"] = $8 + net_counters[$1]["tx"]["collisions"] = $9 + net_counters[$1]["tx"]["dropped"] = $10 + end + end end diff --git a/spec/unit/plugins/freebsd/network_spec.rb b/spec/unit/plugins/freebsd/network_spec.rb new file mode 100644 index 000000000..5cd54cf4d --- /dev/null +++ b/spec/unit/plugins/freebsd/network_spec.rb @@ -0,0 +1,337 @@ +require "spec_helper" + +describe Ohai::System, "FreeBSD Network Plugin" do + before do + @freebsd_ifconfig = <<~FREEBSD_IFCONFIG + vtnet0: flags=1008843 metric 0 mtu 1500 + options=4c079b + ether fa:16:3e:ba:3e:25 + inet 140.211.10.91 netmask 0xffffffc0 broadcast 140.211.10.127 + inet6 fe80::f816:3eff:feba:3e25%vtnet0 prefixlen 64 scopeid 0x1 + inet6 2605:bc80:3010:506:f816:3eff:feba:3e25 prefixlen 64 autoconf pltime 604800 vltime 2592000 + media: Ethernet autoselect (10Gbase-T ) + status: active + nd6 options=23 + lo0: flags=1008049 metric 0 mtu 16384 + options=680003 + inet 127.0.0.1 netmask 0xff000000 + inet6 ::1 prefixlen 128 + inet6 fe80::1%lo0 prefixlen 64 scopeid 0x2 + groups: lo + nd6 options=21 + FREEBSD_IFCONFIG + + @freebsd_arp = <<~FREEBSD_ARP + ? (140.211.10.91) at fa:16:3e:ba:3e:25 on vtnet0 permanent [ethernet] + ? (140.211.10.65) at c0:d6:82:36:03:2b on vtnet0 expires in 1200 seconds [ethernet] + ? (140.211.10.66) at fa:16:3e:7f:19:ef on vtnet0 expires in 1193 seconds [ethernet] + FREEBSD_ARP + + @freebsd_route = <<~FREEBSD_ROUTE + route to: 0.0.0.0 + destination: 0.0.0.0 + mask: 0.0.0.0 + gateway: 140.211.10.65 + fib: 0 + interface: vtnet0 + flags: + recvpipe sendpipe ssthresh rtt,msec mtu weight expire + 0 0 0 0 1500 1 0 + FREEBSD_ROUTE + + @freebsd_netstat = <<~FREEBSD_NETSTAT + Name Mtu Network Address Ipkts Ierrs Idrop Ibytes Opkts Oerrs Obytes Coll Drop + vtnet0 1500 fa:16:3e:ba:3e:25 579 0 0 46746 210 0 26242 0 0 + vtnet0 - fe80::%vtnet0/64 fe80::f816:3eff:feba:3e25%vtnet0 3 - - 272 5 - 328 - - + vtnet0 - 2605:bc80:3010:506::/64 2605:bc80:3010:506:f816:3eff:feba:3e25 38 - - 3648 38 - 3648 - - + vtnet0 - 140.211.10.64/26 140.211.10.91 189 - - 18998 159 - 18594 - - + lo0 16384 lo0 0 0 0 0 0 0 0 0 0 + lo0 - ::1/128 ::1 0 - - 0 0 - 0 - - + lo0 - fe80::%lo0/64 fe80::1%lo0 0 - - 0 0 - 0 - - + lo0 - 127.0.0.0/8 127.0.0.1 0 - - 0 0 - 0 - - + FREEBSD_NETSTAT + + @freebsd_ifconfig2 = <<~FREEBSD_IFCONFIG + vtnet0: flags=1008843 metric 0 mtu 1500 + options=4c079b + ether fa:16:3e:ba:3e:25 + inet 140.211.10.91 netmask 0xffffffc0 broadcast 140.211.10.127 + inet6 fe80::f816:3eff:feba:3e25%vtnet0 prefixlen 64 scopeid 0x1 + inet6 2605:bc80:3010:506:f816:3eff:feba:3e25 prefixlen 64 autoconf pltime 604800 vltime 2592000 + media: Ethernet autoselect (10Gbase-T ) + status: active + nd6 options=23 + lo0: flags=1008049 metric 0 mtu 16384 + options=680003 + inet 127.0.0.1 netmask 0xff000000 + inet6 fe80::1%lo0 prefixlen 64 scopeid 0x2 + groups: lo + nd6 options=21 + lo1: flags=1008049 metric 0 mtu 16384 + options=680003 + inet6 fe80::1%lo1 prefixlen 64 scopeid 0x3 + inet6 ::1 prefixlen 128 + groups: lo + nd6 options=21 + FREEBSD_IFCONFIG + + @freebsd_arp2 = <<~FREEBSD_ARP + ? (140.211.10.91) at fa:16:3e:ba:3e:25 on vtnet0 permanent [ethernet] + ? (140.211.10.65) at c0:d6:82:36:03:2b on vtnet0 expires in 1200 seconds [ethernet] + ? (140.211.10.66) at fa:16:3e:7f:19:ef on vtnet0 expires in 1193 seconds [ethernet] + FREEBSD_ARP + + @freebsd_route2 = <<~FREEBSD_ROUTE + route to: 0.0.0.0 + destination: 0.0.0.0 + mask: 0.0.0.0 + gateway: 140.211.10.65 + fib: 0 + interface: vtnet0 + flags: + recvpipe sendpipe ssthresh rtt,msec mtu weight expire + 0 0 0 0 1500 1 0 + FREEBSD_ROUTE + + @freebsd_netstat2 = <<~FREEBSD_NETSTAT + Name Mtu Network Address Ipkts Ierrs Idrop Ibytes Opkts Oerrs Obytes Coll Drop + vtnet0 1500 fa:16:3e:ba:3e:25 3734 0 0 15901987 1740 0 175778 0 0 + vtnet0 - fe80::%vtnet0/64 fe80::f816:3eff:feba:3e25%vtnet0 1 - - 104 2 - 128 - - + vtnet0 - 2605:bc80:3010:506::/64 2605:bc80:3010:506:f816:3eff:feba:3e25 0 - - 0 0 - 0 - - + vtnet0 - 140.211.10.64/26 140.211.10.91 103 - - 7093 80 - 7824 - - + lo0 16384 lo0 0 0 0 0 0 0 0 0 0 + lo0 - fe80::%lo0/64 fe80::1%lo0 0 - - 0 0 - 0 - - + lo0 - 127.0.0.0/8 127.0.0.1 0 - - 0 0 - 0 - - + lo1 16384 lo1 0 0 0 0 0 0 0 0 0 + lo1 - fe80::%lo1/64 fe80::1%lo1 0 - - 0 0 - 0 - - + FREEBSD_NETSTAT + # If this line is in the HEREDOC above, it messes up vim's ability to syntax highlight. wtf. + @freebsd_netstat2 << "lo1 - ::/64 ::1 0 - - 0 0 - 0 - -\n" + + + @plugin = get_plugin("freebsd/network") + allow(@plugin).to receive(:collect_os).and_return(:freebsd) + end + + describe "gathering IP layer address info" do + before do + allow(@plugin).to receive(:shell_out).with(/ifconfig -a$/).and_return(mock_shell_out(0, @freebsd_ifconfig, "")) + allow(@plugin).to receive(:shell_out).with('route -n get default').and_return(mock_shell_out(0, @freebsd_route, "")) + allow(@plugin).to receive(:shell_out).with('arp -an').and_return(mock_shell_out(0, @freebsd_arp, "")) + allow(@plugin).to receive(:shell_out).with('netstat -ibdn').and_return(mock_shell_out(0, @freebsd_netstat, "")) + @plugin.run + end + + it "completes the run" do + expect(@plugin["network"]).not_to be_nil + end + + it "detects the interfaces" do + expect(@plugin["network"]["interfaces"].keys.sort).to eq(%w{lo0 vtnet0}) + end + + it "detects the ipv4 addresses of the ethernet interface" do + expect(@plugin["network"]["interfaces"]["vtnet0"]["addresses"].keys).to include("140.211.10.91") + expect(@plugin["network"]["interfaces"]["vtnet0"]["addresses"]["140.211.10.91"]["netmask"]).to eq("255.255.255.192") + expect(@plugin["network"]["interfaces"]["vtnet0"]["addresses"]["140.211.10.91"]["broadcast"]).to eq("140.211.10.127") + expect(@plugin["network"]["interfaces"]["vtnet0"]["addresses"]["140.211.10.91"]["family"]).to eq("inet") + end + + it "detects the ipv6 addresses of the ethernet interface" do + expect(@plugin["network"]["interfaces"]["vtnet0"]["addresses"].keys).to include("2605:bc80:3010:506:f816:3eff:feba:3e25") + expect(@plugin["network"]["interfaces"]["vtnet0"]["addresses"]["2605:bc80:3010:506:f816:3eff:feba:3e25"]["prefixlen"]).to eq("64") + expect(@plugin["network"]["interfaces"]["vtnet0"]["addresses"]["2605:bc80:3010:506:f816:3eff:feba:3e25"]["family"]).to eq("inet6") + + expect(@plugin["network"]["interfaces"]["vtnet0"]["addresses"].keys).to include("fe80::f816:3eff:feba:3e25") + expect(@plugin["network"]["interfaces"]["vtnet0"]["addresses"]["fe80::f816:3eff:feba:3e25"]["prefixlen"]).to eq("64") + expect(@plugin["network"]["interfaces"]["vtnet0"]["addresses"]["fe80::f816:3eff:feba:3e25"]["family"]).to eq("inet6") + end + + it "detects the mac addresses of the ethernet interface" do + expect(@plugin["network"]["interfaces"]["vtnet0"]["addresses"].keys).to include("fa:16:3e:ba:3e:25") + expect(@plugin["network"]["interfaces"]["vtnet0"]["addresses"]["fa:16:3e:ba:3e:25"]["family"]).to eq("lladdr") + end + + it "detects the encapsulation type of the ethernet interface" do + expect(@plugin["network"]["interfaces"]["vtnet0"]["encapsulation"]).to eq("Ethernet") + end + + it "detects the flags of the ethernet interface" do + expect(@plugin["network"]["interfaces"]["vtnet0"]["flags"].sort).to eq(%w{BROADCAST LOWER_UP MULTICAST RUNNING SIMPLEX UP}) + end + + it "detects the mtu of the ethernet interface" do + expect(@plugin["network"]["interfaces"]["vtnet0"]["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") + 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"]["prefixlen"]).to eq("128") + expect(@plugin["network"]["interfaces"]["lo0"]["addresses"]["::1"]["family"]).to eq("inet6") + end + + # on FreeBSD, no encapsulation is reported for loopback + it "detects the flags of the loopback interface" do + expect(@plugin["network"]["interfaces"]["lo0"]["flags"].sort).to eq(%w{LOOPBACK LOWER_UP MULTICAST RUNNING UP}) + end + + it "detects the mtu of the loopback interface" do + expect(@plugin["network"]["interfaces"]["lo0"]["mtu"]).to eq("16384") + end + + it "detects the arp entries" do + expect(@plugin["network"]["interfaces"]["vtnet0"]["arp"]["140.211.10.91"]).to eq("fa:16:3e:ba:3e:25") + end + + it "detects the ethernet counters" do + expect(@plugin["counters"]["network"]["interfaces"]["vtnet0"]["tx"]["bytes"]).to eq("26242") + expect(@plugin["counters"]["network"]["interfaces"]["vtnet0"]["tx"]["packets"]).to eq("210") + expect(@plugin["counters"]["network"]["interfaces"]["vtnet0"]["tx"]["collisions"]).to eq("0") + expect(@plugin["counters"]["network"]["interfaces"]["vtnet0"]["tx"]["errors"]).to eq("0") + expect(@plugin["counters"]["network"]["interfaces"]["vtnet0"]["tx"]["dropped"]).to eq("0") + + expect(@plugin["counters"]["network"]["interfaces"]["vtnet0"]["rx"]["bytes"]).to eq("46746") + expect(@plugin["counters"]["network"]["interfaces"]["vtnet0"]["rx"]["packets"]).to eq("579") + expect(@plugin["counters"]["network"]["interfaces"]["vtnet0"]["rx"]["errors"]).to eq("0") + expect(@plugin["counters"]["network"]["interfaces"]["vtnet0"]["rx"]["dropped"]).to eq("0") + end + + it "detects the loopback counters" do + expect(@plugin["counters"]["network"]["interfaces"]["lo0"]["tx"]["bytes"]).to eq("0") + expect(@plugin["counters"]["network"]["interfaces"]["lo0"]["tx"]["packets"]).to eq("0") + 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"]["dropped"]).to eq("0") + + expect(@plugin["counters"]["network"]["interfaces"]["lo0"]["rx"]["bytes"]).to eq("0") + expect(@plugin["counters"]["network"]["interfaces"]["lo0"]["rx"]["packets"]).to eq("0") + expect(@plugin["counters"]["network"]["interfaces"]["lo0"]["rx"]["errors"]).to eq("0") + expect(@plugin["counters"]["network"]["interfaces"]["lo0"]["rx"]["dropped"]).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("vtnet0") + end + + it "finds the default interface by asking which iface has the default route" do + expect(@plugin["network"][:default_gateway]).to eq("140.211.10.65") + end + end + + describe "gathering IP layer address info with lo1" do + before do + allow(@plugin).to receive(:shell_out).with(/ifconfig -a$/).and_return(mock_shell_out(0, @freebsd_ifconfig2, "")) + allow(@plugin).to receive(:shell_out).with('route -n get default').and_return(mock_shell_out(0, @freebsd_route2, "")) + allow(@plugin).to receive(:shell_out).with('arp -an').and_return(mock_shell_out(0, @freebsd_arp2, "")) + allow(@plugin).to receive(:shell_out).with('netstat -ibdn').and_return(mock_shell_out(0, @freebsd_netstat2, "")) + @plugin.run + end + + it "completes the run" do + expect(@plugin["network"]).not_to be_nil + end + + it "detects the interfaces" do + expect(@plugin["network"]["interfaces"].keys.sort).to eq(%w{lo0 lo1 vtnet0}) + end + + it "detects the ipv4 addresses of the ethernet interface" do + expect(@plugin["network"]["interfaces"]["vtnet0"]["addresses"].keys).to include("140.211.10.91") + expect(@plugin["network"]["interfaces"]["vtnet0"]["addresses"]["140.211.10.91"]["netmask"]).to eq("255.255.255.192") + expect(@plugin["network"]["interfaces"]["vtnet0"]["addresses"]["140.211.10.91"]["broadcast"]).to eq("140.211.10.127") + expect(@plugin["network"]["interfaces"]["vtnet0"]["addresses"]["140.211.10.91"]["family"]).to eq("inet") + end + + it "detects the ipv6 addresses of the ethernet interface" do + expect(@plugin["network"]["interfaces"]["vtnet0"]["addresses"].keys).to include("2605:bc80:3010:506:f816:3eff:feba:3e25") + expect(@plugin["network"]["interfaces"]["vtnet0"]["addresses"]["2605:bc80:3010:506:f816:3eff:feba:3e25"]["prefixlen"]).to eq("64") + expect(@plugin["network"]["interfaces"]["vtnet0"]["addresses"]["2605:bc80:3010:506:f816:3eff:feba:3e25"]["family"]).to eq("inet6") + + expect(@plugin["network"]["interfaces"]["vtnet0"]["addresses"].keys).to include("fe80::f816:3eff:feba:3e25") + expect(@plugin["network"]["interfaces"]["vtnet0"]["addresses"]["fe80::f816:3eff:feba:3e25"]["prefixlen"]).to eq("64") + expect(@plugin["network"]["interfaces"]["vtnet0"]["addresses"]["fe80::f816:3eff:feba:3e25"]["family"]).to eq("inet6") + end + + it "detects the mac addresses of the ethernet interface" do + expect(@plugin["network"]["interfaces"]["vtnet0"]["addresses"].keys).to include("fa:16:3e:ba:3e:25") + expect(@plugin["network"]["interfaces"]["vtnet0"]["addresses"]["fa:16:3e:ba:3e:25"]["family"]).to eq("lladdr") + end + + it "detects the encapsulation type of the ethernet interface" do + expect(@plugin["network"]["interfaces"]["vtnet0"]["encapsulation"]).to eq("Ethernet") + end + + it "detects the flags of the ethernet interface" do + expect(@plugin["network"]["interfaces"]["vtnet0"]["flags"].sort).to eq(%w{BROADCAST LOWER_UP MULTICAST RUNNING SIMPLEX UP}) + end + + it "detects the mtu of the ethernet interface" do + expect(@plugin["network"]["interfaces"]["vtnet0"]["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") + end + + it "detects the ipv6 addresses of the loopback interface" do + expect(@plugin["network"]["interfaces"]["lo1"]["addresses"].keys).to include("::1") + expect(@plugin["network"]["interfaces"]["lo1"]["addresses"]["::1"]["prefixlen"]).to eq("128") + expect(@plugin["network"]["interfaces"]["lo1"]["addresses"]["::1"]["family"]).to eq("inet6") + end + + # on FreeBSD, no encapsulation is reported for loopback + it "detects the flags of the loopback interface" do + expect(@plugin["network"]["interfaces"]["lo0"]["flags"].sort).to eq(%w{LOOPBACK LOWER_UP MULTICAST RUNNING UP}) + end + + it "detects the mtu of the loopback interface" do + expect(@plugin["network"]["interfaces"]["lo0"]["mtu"]).to eq("16384") + end + + it "detects the arp entries" do + expect(@plugin["network"]["interfaces"]["vtnet0"]["arp"]["140.211.10.91"]).to eq("fa:16:3e:ba:3e:25") + end + + it "detects the ethernet counters" do + expect(@plugin["counters"]["network"]["interfaces"]["vtnet0"]["tx"]["bytes"]).to eq("175778") + expect(@plugin["counters"]["network"]["interfaces"]["vtnet0"]["tx"]["packets"]).to eq("1740") + expect(@plugin["counters"]["network"]["interfaces"]["vtnet0"]["tx"]["collisions"]).to eq("0") + expect(@plugin["counters"]["network"]["interfaces"]["vtnet0"]["tx"]["errors"]).to eq("0") + expect(@plugin["counters"]["network"]["interfaces"]["vtnet0"]["tx"]["dropped"]).to eq("0") + + expect(@plugin["counters"]["network"]["interfaces"]["vtnet0"]["rx"]["bytes"]).to eq("15901987") + expect(@plugin["counters"]["network"]["interfaces"]["vtnet0"]["rx"]["packets"]).to eq("3734") + expect(@plugin["counters"]["network"]["interfaces"]["vtnet0"]["rx"]["errors"]).to eq("0") + expect(@plugin["counters"]["network"]["interfaces"]["vtnet0"]["rx"]["dropped"]).to eq("0") + end + + it "detects the loopback counters" do + expect(@plugin["counters"]["network"]["interfaces"]["lo0"]["tx"]["bytes"]).to eq("0") + expect(@plugin["counters"]["network"]["interfaces"]["lo0"]["tx"]["packets"]).to eq("0") + 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"]["dropped"]).to eq("0") + + expect(@plugin["counters"]["network"]["interfaces"]["lo0"]["rx"]["bytes"]).to eq("0") + expect(@plugin["counters"]["network"]["interfaces"]["lo0"]["rx"]["packets"]).to eq("0") + expect(@plugin["counters"]["network"]["interfaces"]["lo0"]["rx"]["errors"]).to eq("0") + expect(@plugin["counters"]["network"]["interfaces"]["lo0"]["rx"]["dropped"]).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("vtnet0") + end + + it "finds the default interface by asking which iface has the default route" do + expect(@plugin["network"][:default_gateway]).to eq("140.211.10.65") + end + end +end