(t *testing.T)
| 973 | } |
| 974 | |
| 975 | func 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() |
nothing calls this directly
no test coverage detected
searching dependent graphs…