Skip to content

Commit

Permalink
Merge pull request #115 from lucacome/slog
Browse files Browse the repository at this point in the history
Add linters and fix errors
  • Loading branch information
tynany authored Oct 8, 2024
2 parents c91dddd + 2b3945c commit 8ca646b
Show file tree
Hide file tree
Showing 17 changed files with 105 additions and 135 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ executors:
golang:
docker:
# Whenever the Go version is updated here, .promu.yml, Dockerfile and line 6 of this file should also be updated.
- image: cimg/go:1.22
- image: cimg/go:1.23
jobs:
test:
executor: golang
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ jobs:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
- uses: actions/setup-go@v5
with:
go-version: 1.22
- uses: actions/checkout@v3
go-version: stable
- uses: actions/checkout@v4
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v6
with:
version: v1.60.3
version: v1.61.0
10 changes: 9 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
linters-settings:
errcheck:
exclude-functions:
- (github.com/go-kit/log.Logger).Log
- (net/http.ResponseWriter).Write

linters:
enable:
- gofmt
- gofumpt
- goimports
- misspell
- revive
- sloglint
4 changes: 2 additions & 2 deletions .promu.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
go:
# Whenever the Go version is updated here, .circle/config.yml and Dockerfile should also be updated.
version: 1.22
version: 1.23
repository:
path: github.com/tynany/frr_exporter
build:
Expand All @@ -26,4 +26,4 @@ crossbuild:
- freebsd/amd64
- freebsd/386
- freebsd/arm
- freebsd/arm64
- freebsd/arm64
4 changes: 1 addition & 3 deletions collector/bfd.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ import (
"github.com/prometheus/client_golang/prometheus"
)

var (
bfdSubsystem = "bfd"
)
var bfdSubsystem = "bfd"

func init() {
registerCollector(bfdSubsystem, enabledByDefault, NewBFDCollector)
Expand Down
21 changes: 9 additions & 12 deletions collector/bfd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,15 @@ import (
dto "github.com/prometheus/client_model/go"
)

var (
expectedBFDMetrics = map[string]float64{
"frr_bfd_peer_count{}": 3,
"frr_bfd_peer_uptime{local=10.10.141.81,peer=10.10.141.61}": 847716,
"frr_bfd_peer_state{local=10.10.141.81,peer=10.10.141.61}": 1,
"frr_bfd_peer_uptime{local=10.10.141.81,peer=10.10.141.62}": 847595,
"frr_bfd_peer_state{local=10.10.141.81,peer=10.10.141.62}": 1,
"frr_bfd_peer_uptime{local=10.10.141.81,peer=10.10.141.63}": 847888,
"frr_bfd_peer_state{local=10.10.141.81,peer=10.10.141.63}": 0,
}
)
var expectedBFDMetrics = map[string]float64{
"frr_bfd_peer_count{}": 3,
"frr_bfd_peer_uptime{local=10.10.141.81,peer=10.10.141.61}": 847716,
"frr_bfd_peer_state{local=10.10.141.81,peer=10.10.141.61}": 1,
"frr_bfd_peer_uptime{local=10.10.141.81,peer=10.10.141.62}": 847595,
"frr_bfd_peer_state{local=10.10.141.81,peer=10.10.141.62}": 1,
"frr_bfd_peer_uptime{local=10.10.141.81,peer=10.10.141.63}": 847888,
"frr_bfd_peer_state{local=10.10.141.81,peer=10.10.141.63}": 0,
}

func TestProcessBFDPeers(t *testing.T) {
ch := make(chan prometheus.Metric, 1024)
Expand Down Expand Up @@ -70,7 +68,6 @@ func TestProcessBFDPeers(t *testing.T) {
if expectedMetricVal != metricVal {
t.Errorf("metric %s expected value %v got %v", metricName, expectedMetricVal, metricVal)
}

} else {
t.Errorf("unexpected metric: %s : %v", metricName, metricVal)
}
Expand Down
11 changes: 4 additions & 7 deletions collector/bgp.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ func NewBGPCollector(logger *slog.Logger) (Collector, error) {
}

func getBGPDesc() map[string]*prometheus.Desc {

bgpLabels := []string{"vrf", "afi", "safi", "local_as"}
bgpPeerTypeLabels := []string{"type", "afi", "safi"}
bgpPeerLabels := append(bgpLabels, "peer", "peer_as")
Expand Down Expand Up @@ -157,7 +156,6 @@ func collectBGP(ch chan<- prometheus.Metric, AFI string, logger *slog.Logger, de

if (AFI == "ipv4") || (AFI == "ipv6") {
SAFI = ""

} else if AFI == "l2vpn" {
SAFI = "evpn"
}
Expand All @@ -179,12 +177,12 @@ func processBGPSummary(ch chan<- prometheus.Metric, jsonBGPSum []byte, AFI strin
// so we simulate it here, rather than using a conditional and writing almost the same code twice
if AFI == "l2vpn" && SAFI == "evpn" {
// since we need to massage the format a bit, unmarshall into a temp variable
var tempJsonMap map[string]bgpProcess
if err := json.Unmarshal(jsonBGPSum, &tempJsonMap); err != nil {
var tempJSONMap map[string]bgpProcess
if err := json.Unmarshal(jsonBGPSum, &tempJSONMap); err != nil {
return err
}
jsonMap = map[string]map[string]bgpProcess{}
for vrfName, vrfData := range tempJsonMap {
for vrfName, vrfData := range tempJSONMap {
jsonMap[vrfName] = map[string]bgpProcess{"xxxxevpn": vrfData}
}
} else {
Expand Down Expand Up @@ -256,7 +254,7 @@ func processBGPSummary(ch chan<- prometheus.Metric, jsonBGPSum []byte, AFI strin
newCounter(ch, bgpDesc["msgSent"], float64(peerData.MsgSent), peerLabels...)
newGauge(ch, bgpDesc["UptimeSec"], float64(peerData.PeerUptimeMsec)*0.001, peerLabels...)

// In earlier versions of FRR, the prefixReceivedCount JSON element is used for the number of recieved prefixes, but in later versions it was changed to PfxRcd.
// In earlier versions of FRR, the prefixReceivedCount JSON element is used for the number of received prefixes, but in later versions it was changed to PfxRcd.
prefixReceived := 0.0
if peerData.PrefixReceivedCount != 0 {
prefixReceived = float64(peerData.PrefixReceivedCount)
Expand Down Expand Up @@ -370,7 +368,6 @@ type bgpAdvertisedRoutes struct {
}

func getBGPPeerDesc() (map[string]bgpVRF, error) {

output, err := executeBGPCommand("show bgp vrf all neighbors json")
if err != nil {
return nil, err
Expand Down
1 change: 0 additions & 1 deletion collector/bgp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ func compareMetrics(t *testing.T, gotMetrics map[string]float64, expectedMetrics
if expectedMetricVal != metricVal {
t.Errorf("metric %s expected value %v got %v", metricName, expectedMetricVal, metricVal)
}

} else {
t.Errorf("unexpected metric: %s : %v", metricName, metricVal)
}
Expand Down
8 changes: 4 additions & 4 deletions collector/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ import (
)

const (
metric_namespace = "frr"
metricNamespace = "frr"
enabledByDefault = true
disabledByDefault = false
)

var (
socketConn *frrsockets.Connection
frrTotalScrapeCount = prometheus.NewCounter(prometheus.CounterOpts{
Namespace: metric_namespace,
Namespace: metricNamespace,
Name: "scrapes_total",
Help: "Total number of times FRR has been scraped.",
})
Expand Down Expand Up @@ -137,11 +137,11 @@ func (e *Exporter) Describe(ch chan<- *prometheus.Desc) {
}

func promDesc(metricName string, metricDescription string, labels []string) *prometheus.Desc {
return prometheus.NewDesc(metric_namespace+"_"+metricName, metricDescription, labels, nil)
return prometheus.NewDesc(metricNamespace+"_"+metricName, metricDescription, labels, nil)
}

func colPromDesc(subsystem string, metricName string, metricDescription string, labels []string) *prometheus.Desc {
return prometheus.NewDesc(prometheus.BuildFQName(metric_namespace, subsystem, metricName), metricDescription, labels, nil)
return prometheus.NewDesc(prometheus.BuildFQName(metricNamespace, subsystem, metricName), metricDescription, labels, nil)
}

func newGauge(ch chan<- prometheus.Metric, descName *prometheus.Desc, metric float64, labels ...string) {
Expand Down
1 change: 0 additions & 1 deletion collector/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ func executeVRRPCommand(cmd string) ([]byte, error) {
return execVtyshCommand(cmd)
}
return socketConn.ExecVRRPCmd(cmd)

}

func execVtyshCommand(vtyshCmd string) ([]byte, error) {
Expand Down
55 changes: 26 additions & 29 deletions collector/ospf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,32 @@ import (
dto "github.com/prometheus/client_model/go"
)

var (
expectedOSPFMetrics = map[string]float64{
"frr_ospf_neighbors{area=0.0.0.0,iface=swp1,vrf=default}": 0,
"frr_ospf_neighbors{area=0.0.0.0,iface=swp2,vrf=default}": 1,
"frr_ospf_neighbors{area=0.0.0.0,iface=swp3,vrf=red}": 0,
"frr_ospf_neighbors{area=0.0.0.0,iface=swp4,vrf=red}": 1,
"frr_ospf_neighbor_adjacencies{area=0.0.0.0,iface=swp1,vrf=default}": 0,
"frr_ospf_neighbor_adjacencies{area=0.0.0.0,iface=swp2,vrf=default}": 1,
"frr_ospf_neighbor_adjacencies{area=0.0.0.0,iface=swp3,vrf=red}": 0,
"frr_ospf_neighbor_adjacencies{area=0.0.0.0,iface=swp4,vrf=red}": 1,
"frr_ospf_neighbors{area=0.0.0.0,iface=swp1,instance=1,vrf=default}": 0,
"frr_ospf_neighbors{area=0.0.0.0,iface=swp2,instance=1,vrf=default}": 1,
"frr_ospf_neighbors{area=0.0.0.0,iface=swp3,instance=1,vrf=red}": 0,
"frr_ospf_neighbors{area=0.0.0.0,iface=swp4,instance=1,vrf=red}": 1,
"frr_ospf_neighbors{area=0.0.0.0,iface=swp1,instance=2,vrf=default}": 0,
"frr_ospf_neighbors{area=0.0.0.0,iface=swp2,instance=2,vrf=default}": 1,
"frr_ospf_neighbors{area=0.0.0.0,iface=swp3,instance=2,vrf=red}": 0,
"frr_ospf_neighbors{area=0.0.0.0,iface=swp4,instance=2,vrf=red}": 1,
"frr_ospf_neighbor_adjacencies{area=0.0.0.0,iface=swp1,instance=1,vrf=default}": 0,
"frr_ospf_neighbor_adjacencies{area=0.0.0.0,iface=swp2,instance=1,vrf=default}": 1,
"frr_ospf_neighbor_adjacencies{area=0.0.0.0,iface=swp3,instance=1,vrf=red}": 0,
"frr_ospf_neighbor_adjacencies{area=0.0.0.0,iface=swp4,instance=1,vrf=red}": 1,
"frr_ospf_neighbor_adjacencies{area=0.0.0.0,iface=swp1,instance=2,vrf=default}": 0,
"frr_ospf_neighbor_adjacencies{area=0.0.0.0,iface=swp2,instance=2,vrf=default}": 1,
"frr_ospf_neighbor_adjacencies{area=0.0.0.0,iface=swp3,instance=2,vrf=red}": 0,
"frr_ospf_neighbor_adjacencies{area=0.0.0.0,iface=swp4,instance=2,vrf=red}": 1,
}
)
var expectedOSPFMetrics = map[string]float64{
"frr_ospf_neighbors{area=0.0.0.0,iface=swp1,vrf=default}": 0,
"frr_ospf_neighbors{area=0.0.0.0,iface=swp2,vrf=default}": 1,
"frr_ospf_neighbors{area=0.0.0.0,iface=swp3,vrf=red}": 0,
"frr_ospf_neighbors{area=0.0.0.0,iface=swp4,vrf=red}": 1,
"frr_ospf_neighbor_adjacencies{area=0.0.0.0,iface=swp1,vrf=default}": 0,
"frr_ospf_neighbor_adjacencies{area=0.0.0.0,iface=swp2,vrf=default}": 1,
"frr_ospf_neighbor_adjacencies{area=0.0.0.0,iface=swp3,vrf=red}": 0,
"frr_ospf_neighbor_adjacencies{area=0.0.0.0,iface=swp4,vrf=red}": 1,
"frr_ospf_neighbors{area=0.0.0.0,iface=swp1,instance=1,vrf=default}": 0,
"frr_ospf_neighbors{area=0.0.0.0,iface=swp2,instance=1,vrf=default}": 1,
"frr_ospf_neighbors{area=0.0.0.0,iface=swp3,instance=1,vrf=red}": 0,
"frr_ospf_neighbors{area=0.0.0.0,iface=swp4,instance=1,vrf=red}": 1,
"frr_ospf_neighbors{area=0.0.0.0,iface=swp1,instance=2,vrf=default}": 0,
"frr_ospf_neighbors{area=0.0.0.0,iface=swp2,instance=2,vrf=default}": 1,
"frr_ospf_neighbors{area=0.0.0.0,iface=swp3,instance=2,vrf=red}": 0,
"frr_ospf_neighbors{area=0.0.0.0,iface=swp4,instance=2,vrf=red}": 1,
"frr_ospf_neighbor_adjacencies{area=0.0.0.0,iface=swp1,instance=1,vrf=default}": 0,
"frr_ospf_neighbor_adjacencies{area=0.0.0.0,iface=swp2,instance=1,vrf=default}": 1,
"frr_ospf_neighbor_adjacencies{area=0.0.0.0,iface=swp3,instance=1,vrf=red}": 0,
"frr_ospf_neighbor_adjacencies{area=0.0.0.0,iface=swp4,instance=1,vrf=red}": 1,
"frr_ospf_neighbor_adjacencies{area=0.0.0.0,iface=swp1,instance=2,vrf=default}": 0,
"frr_ospf_neighbor_adjacencies{area=0.0.0.0,iface=swp2,instance=2,vrf=default}": 1,
"frr_ospf_neighbor_adjacencies{area=0.0.0.0,iface=swp3,instance=2,vrf=red}": 0,
"frr_ospf_neighbor_adjacencies{area=0.0.0.0,iface=swp4,instance=2,vrf=red}": 1,
}

func TestProcessOSPFInterface(t *testing.T) {
ospfInterfaceSum := readTestFixture(t, "show_ip_ospf_vrf_all_interface.json")
Expand Down Expand Up @@ -97,7 +95,6 @@ func TestProcessOSPFInterface(t *testing.T) {
if expectedMetricVal != metricVal {
t.Errorf("metric %s expected value %v got %v", metricName, expectedMetricVal, metricVal)
}

} else {
t.Errorf("unexpected metric: %s : %v", metricName, metricVal)
}
Expand Down
8 changes: 3 additions & 5 deletions collector/pim.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ import (
"github.com/prometheus/client_golang/prometheus"
)

var (
pimSubsystem = "pim"
)
const pimSubsystem = "pim"

func init() {
registerCollector(pimSubsystem, disabledByDefault, NewPIMCollector)
Expand Down Expand Up @@ -66,13 +64,13 @@ func processPIMNeighbors(ch chan<- prometheus.Metric, jsonPIMNeighbors []byte, l
if err := json.Unmarshal(ifaceData, &neighbors); err != nil {
return fmt.Errorf("cannot unmarshal neighbor json: %s", err)
}
for neighborIp, neighborData := range neighbors {
for neighborIP, neighborData := range neighbors {
neighborCount++
if uptimeSec, err := parseHMS(neighborData.UpTime); err != nil {
logger.Error("cannot parse neighbor uptime", "uptime", neighborData.UpTime, "err", err)
} else {
// The labels are "vrf", "iface", "neighbor"
neighborLabels := []string{strings.ToLower(vrfName), strings.ToLower(ifaceName), neighborIp}
neighborLabels := []string{strings.ToLower(vrfName), strings.ToLower(ifaceName), neighborIP}
newGauge(ch, pimDesc["upTime"], float64(uptimeSec), neighborLabels...)
}

Expand Down
1 change: 0 additions & 1 deletion collector/pim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ func TestProcessPIMNeighbors(t *testing.T) {
if expectedMetricVal != metricVal {
t.Errorf("metric %s expected value %v got %v", metricName, expectedMetricVal, metricVal)
}

} else {
t.Errorf("unexpected metric: %s : %v", metricName, metricVal)
}
Expand Down
63 changes: 30 additions & 33 deletions collector/vrrp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,36 @@ import (
dto "github.com/prometheus/client_model/go"
)

var (
expectedVRRPMetrics = map[string]float64{
"frr_vrrp_advertisements_received_total{interface=gw_extnet,proto=v4,subinterface=extnet_v4_1,vrid=1}": 1548196,
"frr_vrrp_advertisements_received_total{interface=gw_extnet,proto=v4,subinterface=extnet_v4_2,vrid=2}": 4.0,
"frr_vrrp_advertisements_received_total{interface=gw_extnet,proto=v6,subinterface=,vrid=2}": 0.0,
"frr_vrrp_advertisements_received_total{interface=gw_extnet,proto=v6,subinterface=extnet_v6_1,vrid=1}": 1548195,
"frr_vrrp_advertisements_sent_total{interface=gw_extnet,proto=v4,subinterface=extnet_v4_1,vrid=1}": 6,
"frr_vrrp_advertisements_sent_total{interface=gw_extnet,proto=v4,subinterface=extnet_v4_2,vrid=2}": 1548210,
"frr_vrrp_advertisements_sent_total{interface=gw_extnet,proto=v6,subinterface=,vrid=2}": 0,
"frr_vrrp_advertisements_sent_total{interface=gw_extnet,proto=v6,subinterface=extnet_v6_1,vrid=1}": 2,
"frr_vrrp_gratuitous_arp_sent_total{interface=gw_extnet,proto=v4,subinterface=extnet_v4_1,vrid=1}": 4,
"frr_vrrp_gratuitous_arp_sent_total{interface=gw_extnet,proto=v4,subinterface=extnet_v4_2,vrid=2}": 1,
"frr_vrrp_neighbor_advertisements_sent_total{interface=gw_extnet,proto=v6,subinterface=,vrid=2}": 0,
"frr_vrrp_neighbor_advertisements_sent_total{interface=gw_extnet,proto=v6,subinterface=extnet_v6_1,vrid=1}": 5,
"frr_vrrp_state_transitions_total{interface=gw_extnet,proto=v4,subinterface=extnet_v4_1,vrid=1}": 9,
"frr_vrrp_state_transitions_total{interface=gw_extnet,proto=v4,subinterface=extnet_v4_2,vrid=2}": 2,
"frr_vrrp_state_transitions_total{interface=gw_extnet,proto=v6,subinterface=,vrid=2}": 0,
"frr_vrrp_state_transitions_total{interface=gw_extnet,proto=v6,subinterface=extnet_v6_1,vrid=1}": 11,
"frr_vrrp_state{interface=gw_extnet,proto=v4,state=Backup,subinterface=extnet_v4_1,vrid=1}": 1,
"frr_vrrp_state{interface=gw_extnet,proto=v4,state=Backup,subinterface=extnet_v4_2,vrid=2}": 0,
"frr_vrrp_state{interface=gw_extnet,proto=v4,state=Initialize,subinterface=extnet_v4_1,vrid=1}": 0,
"frr_vrrp_state{interface=gw_extnet,proto=v4,state=Initialize,subinterface=extnet_v4_2,vrid=2}": 0,
"frr_vrrp_state{interface=gw_extnet,proto=v4,state=Master,subinterface=extnet_v4_1,vrid=1}": 0,
"frr_vrrp_state{interface=gw_extnet,proto=v4,state=Master,subinterface=extnet_v4_2,vrid=2}": 1,
"frr_vrrp_state{interface=gw_extnet,proto=v6,state=Backup,subinterface=,vrid=2}": 0,
"frr_vrrp_state{interface=gw_extnet,proto=v6,state=Backup,subinterface=extnet_v6_1,vrid=1}": 1,
"frr_vrrp_state{interface=gw_extnet,proto=v6,state=Initialize,subinterface=,vrid=2}": 1,
"frr_vrrp_state{interface=gw_extnet,proto=v6,state=Initialize,subinterface=extnet_v6_1,vrid=1}": 0,
"frr_vrrp_state{interface=gw_extnet,proto=v6,state=Master,subinterface=,vrid=2}": 0,
"frr_vrrp_state{interface=gw_extnet,proto=v6,state=Master,subinterface=extnet_v6_1,vrid=1}": 0,
}
)
var expectedVRRPMetrics = map[string]float64{
"frr_vrrp_advertisements_received_total{interface=gw_extnet,proto=v4,subinterface=extnet_v4_1,vrid=1}": 1548196,
"frr_vrrp_advertisements_received_total{interface=gw_extnet,proto=v4,subinterface=extnet_v4_2,vrid=2}": 4.0,
"frr_vrrp_advertisements_received_total{interface=gw_extnet,proto=v6,subinterface=,vrid=2}": 0.0,
"frr_vrrp_advertisements_received_total{interface=gw_extnet,proto=v6,subinterface=extnet_v6_1,vrid=1}": 1548195,
"frr_vrrp_advertisements_sent_total{interface=gw_extnet,proto=v4,subinterface=extnet_v4_1,vrid=1}": 6,
"frr_vrrp_advertisements_sent_total{interface=gw_extnet,proto=v4,subinterface=extnet_v4_2,vrid=2}": 1548210,
"frr_vrrp_advertisements_sent_total{interface=gw_extnet,proto=v6,subinterface=,vrid=2}": 0,
"frr_vrrp_advertisements_sent_total{interface=gw_extnet,proto=v6,subinterface=extnet_v6_1,vrid=1}": 2,
"frr_vrrp_gratuitous_arp_sent_total{interface=gw_extnet,proto=v4,subinterface=extnet_v4_1,vrid=1}": 4,
"frr_vrrp_gratuitous_arp_sent_total{interface=gw_extnet,proto=v4,subinterface=extnet_v4_2,vrid=2}": 1,
"frr_vrrp_neighbor_advertisements_sent_total{interface=gw_extnet,proto=v6,subinterface=,vrid=2}": 0,
"frr_vrrp_neighbor_advertisements_sent_total{interface=gw_extnet,proto=v6,subinterface=extnet_v6_1,vrid=1}": 5,
"frr_vrrp_state_transitions_total{interface=gw_extnet,proto=v4,subinterface=extnet_v4_1,vrid=1}": 9,
"frr_vrrp_state_transitions_total{interface=gw_extnet,proto=v4,subinterface=extnet_v4_2,vrid=2}": 2,
"frr_vrrp_state_transitions_total{interface=gw_extnet,proto=v6,subinterface=,vrid=2}": 0,
"frr_vrrp_state_transitions_total{interface=gw_extnet,proto=v6,subinterface=extnet_v6_1,vrid=1}": 11,
"frr_vrrp_state{interface=gw_extnet,proto=v4,state=Backup,subinterface=extnet_v4_1,vrid=1}": 1,
"frr_vrrp_state{interface=gw_extnet,proto=v4,state=Backup,subinterface=extnet_v4_2,vrid=2}": 0,
"frr_vrrp_state{interface=gw_extnet,proto=v4,state=Initialize,subinterface=extnet_v4_1,vrid=1}": 0,
"frr_vrrp_state{interface=gw_extnet,proto=v4,state=Initialize,subinterface=extnet_v4_2,vrid=2}": 0,
"frr_vrrp_state{interface=gw_extnet,proto=v4,state=Master,subinterface=extnet_v4_1,vrid=1}": 0,
"frr_vrrp_state{interface=gw_extnet,proto=v4,state=Master,subinterface=extnet_v4_2,vrid=2}": 1,
"frr_vrrp_state{interface=gw_extnet,proto=v6,state=Backup,subinterface=,vrid=2}": 0,
"frr_vrrp_state{interface=gw_extnet,proto=v6,state=Backup,subinterface=extnet_v6_1,vrid=1}": 1,
"frr_vrrp_state{interface=gw_extnet,proto=v6,state=Initialize,subinterface=,vrid=2}": 1,
"frr_vrrp_state{interface=gw_extnet,proto=v6,state=Initialize,subinterface=extnet_v6_1,vrid=1}": 0,
"frr_vrrp_state{interface=gw_extnet,proto=v6,state=Master,subinterface=,vrid=2}": 0,
"frr_vrrp_state{interface=gw_extnet,proto=v6,state=Master,subinterface=extnet_v6_1,vrid=1}": 0,
}

func TestProcessVRRPInfo(t *testing.T) {
ch := make(chan prometheus.Metric, 1024)
Expand Down Expand Up @@ -91,7 +89,6 @@ func TestProcessVRRPInfo(t *testing.T) {
if expectedMetricVal != metricVal {
t.Errorf("metric %s expected value %v got %v", metricName, expectedMetricVal, metricVal)
}

} else {
t.Errorf("unexpected metric: %s : %v", metricName, metricVal)
}
Expand Down
Loading

0 comments on commit 8ca646b

Please sign in to comment.