Skip to content
Snippets Groups Projects
Unverified Commit e2be5936 authored by Christoph Petrausch's avatar Christoph Petrausch Committed by GitHub
Browse files

Merge branch 'master' into test/add-fuzzing

parents 451c9527 6a15247f
No related branches found
No related tags found
No related merge requests found
......@@ -16,6 +16,7 @@ type PeerInfo struct {
PeerAddr bnet.IP
PeerASN uint32
LocalASN uint32
States []string
}
type peer struct {
......@@ -50,10 +51,19 @@ type familyParameters struct {
}
func (p *peer) snapshot() PeerInfo {
p.fsmsMu.Lock()
defer p.fsmsMu.Unlock()
states := make([]string, 0, len(p.fsms))
for _, fsm := range p.fsms {
fsm.stateMu.RLock()
states = append(states, stateName(fsm.state))
fsm.stateMu.RUnlock()
}
return PeerInfo{
PeerAddr: p.addr,
PeerASN: p.peerASN,
LocalASN: p.localASN,
States: states,
}
}
......
......@@ -10,6 +10,7 @@ import (
"github.com/bio-routing/bio-rd/routingtable/locRIB"
bnet "github.com/bio-routing/bio-rd/net"
"github.com/stretchr/testify/assert"
)
func TestBgpServerPeerSnapshot(t *testing.T) {
......@@ -60,13 +61,12 @@ func TestBgpServerPeerSnapshot(t *testing.T) {
break
}
if want, got := bnet.IPv4FromOctets(169, 254, 200, 1), peer.PeerAddr; !want.Equal(got) {
t.Errorf("PeerAddr: got %v, want %v", got, want)
}
if want, got := uint32(65300), peer.PeerASN; want != got {
t.Errorf("PeerASN: got %v, want %v", got, want)
}
if want, got := uint32(204880), peer.LocalASN; want != got {
t.Errorf("PeerASN: got %v, want %v", got, want)
want := PeerInfo{
PeerAddr: bnet.IPv4FromOctets(169, 254, 200, 1),
PeerASN: uint32(65300),
LocalASN: uint32(204880),
States: []string{"idle"},
}
assert.Equal(t, want, peer)
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment