CI / changes (push) Successful in 6s
CI / commitlint (push) Skipped
CI / openapi (push) Successful in 28s
CI / web (push) Successful in 52s
CI / go (push) Successful in 2m22s
CI / bird2 (push) Successful in 15s
CI / release (push) Successful in 4m36s
Added functionality for peer discovery, including new API endpoints for listing, approving, and rejecting discovered peers. Updated the network queries and settings to support peer discovery configurations. Enhanced the UI to display discovered peers and integrated related settings in the tenant settings component. Updated OpenAPI documentation to reflect the new endpoints and parameters. This improves the network management capabilities by allowing dynamic peer discovery and management.
50 lines
1.6 KiB
Go
50 lines
1.6 KiB
Go
package birdfmt
|
|
|
|
import "testing"
|
|
|
|
func TestParseBGPSessions_neighborAndState(t *testing.T) {
|
|
sample := `
|
|
BIRD 2.14 ready.
|
|
Name Proto Table State Since Info
|
|
device1 Device --- up 10:00:00
|
|
evobgp_p_abc123 BGP master4 up 10:00:05 Established
|
|
Neighbor address: 198.51.100.2
|
|
Neighbor AS: 65001
|
|
Neighbor ID: 192.0.2.50
|
|
evobgp_p_def456 BGP master4 up 10:00:06 Active
|
|
Neighbor address: 2001:db8::2
|
|
evobgp_dyn_0001 BGP master4 up 10:00:07 Established
|
|
Neighbor address: 203.0.113.10
|
|
Neighbor AS: 65099
|
|
Neighbor ID: 203.0.113.10
|
|
`
|
|
sessions := ParseBGPSessions(sample)
|
|
if len(sessions) != 3 {
|
|
t.Fatalf("got %d sessions want 3", len(sessions))
|
|
}
|
|
if sessions[0].Name != "evobgp_p_abc123" || sessions[0].State != "Established" || sessions[0].Neighbor != "198.51.100.2" {
|
|
t.Fatalf("session0: %+v", sessions[0])
|
|
}
|
|
if sessions[0].NeighborAS != 65001 || sessions[0].NeighborID != "192.0.2.50" {
|
|
t.Fatalf("session0 ids: as=%d id=%q", sessions[0].NeighborAS, sessions[0].NeighborID)
|
|
}
|
|
if sessions[1].Neighbor != "2001:db8::2" || sessions[1].State != "Active" {
|
|
t.Fatalf("session1: %+v", sessions[1])
|
|
}
|
|
if !IsDynamicDiscoverySession(sessions[2].Name) {
|
|
t.Fatalf("session2 should be dynamic: %+v", sessions[2])
|
|
}
|
|
if sessions[2].NeighborAS != 65099 || sessions[2].NeighborID != "203.0.113.10" {
|
|
t.Fatalf("session2 ids: %+v", sessions[2])
|
|
}
|
|
}
|
|
|
|
func TestIsDynamicDiscoverySession(t *testing.T) {
|
|
if !IsDynamicDiscoverySession("evobgp_dyn_0001") {
|
|
t.Fatal("expected true")
|
|
}
|
|
if IsDynamicDiscoverySession("evobgp_p_abc") {
|
|
t.Fatal("expected false")
|
|
}
|
|
}
|