Revamp the netdev collector to use throw-away ConstMetrics.
This commit is contained in:
parent
e180b882d6
commit
13672ced48
3 changed files with 85 additions and 108 deletions
|
|
@ -18,23 +18,23 @@ func TestNetDevStats(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if want, got := "10437182923", netStats["receive"]["wlan0"]["bytes"]; want != got {
|
||||
if want, got := "10437182923", netStats["wlan0"]["receive_bytes"]; want != got {
|
||||
t.Errorf("want netstat wlan0 bytes %s, got %s", want, got)
|
||||
}
|
||||
|
||||
if want, got := "68210035552", netStats["receive"]["eth0"]["bytes"]; want != got {
|
||||
if want, got := "68210035552", netStats["eth0"]["receive_bytes"]; want != got {
|
||||
t.Errorf("want netstat eth0 bytes %s, got %s", want, got)
|
||||
}
|
||||
|
||||
if want, got := "934", netStats["transmit"]["tun0"]["packets"]; want != got {
|
||||
if want, got := "934", netStats["tun0"]["transmit_packets"]; want != got {
|
||||
t.Errorf("want netstat tun0 packets %s, got %s", want, got)
|
||||
}
|
||||
|
||||
if want, got := 6, len(netStats["transmit"]); want != got {
|
||||
if want, got := 6, len(netStats); want != got {
|
||||
t.Errorf("want count of devices to be %d, got %d", want, got)
|
||||
}
|
||||
|
||||
if _, ok := netStats["transmit"]["veth4B09XN"]; ok != false {
|
||||
if _, ok := netStats["veth4B09XN"]["transmit_bytes"]; ok != false {
|
||||
t.Error("want fixture interface veth4B09XN to not exist, but it does")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue