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

Function TestApplyToPathList_UnreachableNoMED

pkg/server/zclient_test.go:145–170  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

143var testNextHop = netip.MustParseAddr("10.3.1.1")
144
145func TestApplyToPathList_UnreachableNoMED(t *testing.T) {
146 // Simulates the zebra-nht scenario: a path with no MED and an
147 // unreachable nexthop should get IsNexthopInvalid=true.
148 assert := assert.New(t)
149
150 nlri, _ := bgp.NewIPAddrPrefix(netip.MustParsePrefix("10.3.2.0/24"))
151 nh, _ := bgp.NewPathAttributeNextHop(testNextHop)
152 attrs := []bgp.PathAttributeInterface{
153 bgp.NewPathAttributeOrigin(bgp.BGP_ORIGIN_ATTR_TYPE_INCOMPLETE),
154 nh,
155 }
156 path := table.NewPath(bgp.RF_IPv4_UC, nil, bgp.PathNLRI{NLRI: nlri}, false, attrs, time.Now(), false)
157
158 cache := nexthopStateCache{
159 testNextHop: math.MaxUint32, // unreachable
160 }
161
162 updated := cache.applyToPathList([]*table.Path{path})
163 assert.Len(updated, 1)
164 assert.True(updated[0].IsNexthopInvalid)
165 assert.False(updated[0].IsWithdraw)
166
167 // Applying again should produce no updates (idempotent)
168 updated2 := cache.applyToPathList(updated)
169 assert.Len(updated2, 0, "applying to already-invalid path should be a no-op")
170}
171
172func TestApplyToPathList_ReachableSetsMED(t *testing.T) {
173 assert := assert.New(t)

Callers

nothing calls this directly

Calls 6

applyToPathListMethod · 0.95
NewIPAddrPrefixFunction · 0.92
NewPathAttributeNextHopFunction · 0.92
NewPathAttributeOriginFunction · 0.92
NewPathFunction · 0.92
LenMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…