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

Function Test_BgpAddDeletePeer

pkg/server/bfd_server_test.go:253–376  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

251}
252
253func Test_BgpAddDeletePeer(t *testing.T) {
254 assert := assert.New(t)
255
256 s := NewBgpServer()
257 go s.Serve()
258 err := s.StartBgp(context.Background(), &api.StartBgpRequest{
259 Global: &api.Global{
260 Asn: 1,
261 RouterId: "1.1.1.1",
262 ListenPort: 10179,
263 },
264 })
265 assert.NoError(err)
266 defer s.Stop()
267
268 nConf1 := &oc.Neighbor{
269 Config: oc.NeighborConfig{
270 NeighborAddress: netip.MustParseAddr("127.0.0.1"),
271 PeerGroup: "group_on",
272 },
273 }
274 nConf2 := &oc.Neighbor{
275 Config: oc.NeighborConfig{
276 NeighborAddress: netip.MustParseAddr("127.0.0.2"),
277 PeerGroup: "group_on",
278 },
279 }
280 pgConf := &oc.PeerGroup{
281 Config: oc.PeerGroupConfig{
282 PeerGroupName: "group_on",
283 },
284 Bfd: oc.Bfd{
285 Config: oc.BfdConfig{
286 Enabled: true,
287 DetectionMultiplier: 7,
288 RequiredMinimumReceive: 123000,
289 DesiredMinimumTxInterval: 456000,
290 },
291 },
292 }
293 gConf := &oc.Global{}
294
295 err = oc.SetDefaultNeighborConfigValues(nConf1, pgConf, gConf)
296 assert.NoError(err)
297 err = oc.SetDefaultNeighborConfigValues(nConf2, pgConf, gConf)
298 assert.NoError(err)
299
300 // Add 'group_on' with enabled BFD
301 err = s.AddPeerGroup(context.Background(), &api.AddPeerGroupRequest{
302 PeerGroup: oc.NewPeerGroupFromConfigStruct(pgConf),
303 })
304 assert.NoError(err)
305
306 var count int
307
308 // Add 1 peer
309 err = s.AddPeer(context.Background(), &api.AddPeerRequest{
310 Peer: oc.NewPeerFromConfigStruct(nConf1),

Callers

nothing calls this directly

Calls 12

ServeMethod · 0.95
StartBgpMethod · 0.95
StopMethod · 0.95
AddPeerGroupMethod · 0.95
AddPeerMethod · 0.95
ListBfdPeerMethod · 0.95
DeletePeerMethod · 0.95
NewPeerFromConfigStructFunction · 0.92
NewBgpServerFunction · 0.85
EqualMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…