Allows netdev devices to be ignored
This commit is contained in:
parent
2824530d16
commit
64affe205b
2 changed files with 27 additions and 7 deletions
|
|
@ -2,6 +2,7 @@ package collector
|
|||
|
||||
import (
|
||||
"os"
|
||||
"regexp"
|
||||
"testing"
|
||||
)
|
||||
|
||||
|
|
@ -12,7 +13,7 @@ func TestNetDevStats(t *testing.T) {
|
|||
}
|
||||
defer file.Close()
|
||||
|
||||
netStats, err := parseNetDevStats(file)
|
||||
netStats, err := parseNetDevStats(file, regexp.MustCompile("^veth"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -28,4 +29,12 @@ func TestNetDevStats(t *testing.T) {
|
|||
if want, got := "934", netStats["transmit"]["tun0"]["packets"]; want != got {
|
||||
t.Errorf("want netstat tun0 packets %s, got %s", want, got)
|
||||
}
|
||||
|
||||
if want, got := 6, len(netStats["transmit"]); want != got {
|
||||
t.Errorf("want count of devices to be %d, got %d", want, got)
|
||||
}
|
||||
|
||||
if _, ok := netStats["transmit"]["veth4B09XN"]; 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