More features (#9)
* added config file implementation, refactoring * add gitignore * improved test * preperations for more metrics * added resource metrics * added first bgp metrics * added asn as label for bgp metrics * added prefix and message counts to bgp metrics * simplified * Update README.md * added yaml dependency * fixed go routine call * added timeout * clean up * added TLS support * set default api port for TLS * added routes metric * added missing log information * added type collectorContext to reduce the count of parameters for better readability * added DHCP and DHCPv6 metrics * filter for active dhcp leases only * added pool metrics * enable/disable feature in config file * refactoring * clean up * comment fix
This commit is contained in:
committed by
Steve Brunton
parent
f2866a3a2f
commit
d170b0a4d2
@@ -17,8 +17,13 @@ func TestShouldParse(t *testing.T) {
|
||||
t.Fatalf("expected 2 devices, got %v", len(c.Devices))
|
||||
}
|
||||
|
||||
assertConfig("test1", "192.168.1.1", "foo", "bar", c.Devices[0], t)
|
||||
assertConfig("test2", "192.168.2.1", "test", "123", c.Devices[1], t)
|
||||
assertDevice("test1", "192.168.1.1", "foo", "bar", c.Devices[0], t)
|
||||
assertDevice("test2", "192.168.2.1", "test", "123", c.Devices[1], t)
|
||||
assertFeature("BGP", c.Features.BGP, t)
|
||||
assertFeature("DHCP", c.Features.DHCP, t)
|
||||
assertFeature("DHCPv6", c.Features.DHCPv6, t)
|
||||
assertFeature("Pools", c.Features.Pools, t)
|
||||
assertFeature("Routes", c.Features.Routes, t)
|
||||
}
|
||||
|
||||
func loadTestFile(t *testing.T) []byte {
|
||||
@@ -30,7 +35,7 @@ func loadTestFile(t *testing.T) []byte {
|
||||
return b
|
||||
}
|
||||
|
||||
func assertConfig(name, address, user, password string, c Device, t *testing.T) {
|
||||
func assertDevice(name, address, user, password string, c Device, t *testing.T) {
|
||||
if c.Name != name {
|
||||
t.Fatalf("expected name %s, got %s", name, c.Name)
|
||||
}
|
||||
@@ -47,3 +52,9 @@ func assertConfig(name, address, user, password string, c Device, t *testing.T)
|
||||
t.Fatalf("expected password %s, got %s", password, c.Password)
|
||||
}
|
||||
}
|
||||
|
||||
func assertFeature(name string, v bool, t *testing.T) {
|
||||
if !v {
|
||||
t.Fatalf("exprected feature %s to be enabled", name)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user