MCPcopy
hub / github.com/osrg/gobgp / TestListPathEnableMultipath

Function TestListPathEnableMultipath

pkg/server/server_test.go:975–1077  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

973}
974
975func TestListPathEnableMultipath(t *testing.T) {
976 nlri, err := bgp.NewIPAddrPrefix(netip.MustParsePrefix("10.0.0.0/24"))
977 require.NoError(t, err)
978
979 nh0, err := bgp.NewPathAttributeNextHop(netip.MustParseAddr("192.168.0.1"))
980 require.NoError(t, err)
981
982 nh1, err := bgp.NewPathAttributeNextHop(netip.MustParseAddr("192.168.0.2"))
983 require.NoError(t, err)
984
985 path0 := &apiutil.Path{
986 Family: bgp.RF_IPv4_UC,
987 Nlri: nlri,
988 PeerASN: 65001,
989 Attrs: []bgp.PathAttributeInterface{
990 bgp.NewPathAttributeOrigin(0),
991 bgp.NewPathAttributeAsPath([]bgp.AsPathParamInterface{
992 bgp.NewAsPathParam(2, []uint16{65001}),
993 }),
994 nh0,
995 },
996 }
997 require.NoError(t, err)
998
999 path1 := &apiutil.Path{
1000 Family: bgp.RF_IPv4_UC,
1001 Nlri: nlri,
1002 PeerASN: 65002,
1003 Attrs: []bgp.PathAttributeInterface{
1004 bgp.NewPathAttributeOrigin(0),
1005 bgp.NewPathAttributeAsPath([]bgp.AsPathParamInterface{
1006 bgp.NewAsPathParam(2, []uint16{65002}),
1007 }),
1008 nh1,
1009 },
1010 }
1011 require.NoError(t, err)
1012
1013 tests := []struct {
1014 name string
1015 useMultiPath bool
1016 expectedBest int
1017 }{
1018 {
1019 name: "without multipath",
1020 useMultiPath: false,
1021 expectedBest: 1,
1022 },
1023 {
1024 name: "with multipath",
1025 useMultiPath: true,
1026 expectedBest: 2,
1027 },
1028 }
1029
1030 for _, tt := range tests {
1031 t.Run(tt.name, func(t *testing.T) {
1032 server := NewBgpServer()

Callers

nothing calls this directly

Calls 13

ServeMethod · 0.95
StartBgpMethod · 0.95
StopBgpMethod · 0.95
AddPathMethod · 0.95
ListPathMethod · 0.95
NewIPAddrPrefixFunction · 0.92
NewPathAttributeNextHopFunction · 0.92
NewPathAttributeOriginFunction · 0.92
NewPathAttributeAsPathFunction · 0.92
NewAsPathParamFunction · 0.92
NewBgpServerFunction · 0.85
LenMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…