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

Function TestMonitor

pkg/server/server_test.go:1183–1386  ·  view source on GitHub ↗
(test *testing.T)

Source from the content-addressed store, hash-verified

1181}
1182
1183func TestMonitor(test *testing.T) {
1184 assert := assert.New(test)
1185 s := NewBgpServer()
1186 go s.Serve()
1187 err := s.StartBgp(context.Background(), &api.StartBgpRequest{
1188 Global: &api.Global{
1189 Asn: 1,
1190 RouterId: "1.1.1.1",
1191 ListenPort: 10179,
1192 },
1193 })
1194 assert.NoError(err)
1195 defer s.StopBgp(context.Background(), &api.StopBgpRequest{})
1196
1197 // Vrf1 111:111 and vrf2 import 111:111 and 222:222
1198 addVrf(test, s, "vrf1", "111:111", []string{"111:111"}, []string{"111:111"}, 1)
1199 addVrf(test, s, "vrf2", "222:222", []string{"111:111", "222:222"}, []string{"222:222"}, 2)
1200
1201 p1 := &api.Peer{
1202 Conf: &api.PeerConf{
1203 NeighborAddress: "127.0.0.1",
1204 PeerAsn: 2,
1205 },
1206 Transport: &api.Transport{
1207 PassiveMode: true,
1208 },
1209 }
1210 err = s.AddPeer(context.Background(), &api.AddPeerRequest{Peer: p1})
1211 assert.NoError(err)
1212
1213 t := NewBgpServer()
1214 go t.Serve()
1215 err = t.StartBgp(context.Background(), &api.StartBgpRequest{
1216 Global: &api.Global{
1217 Asn: 2,
1218 RouterId: "2.2.2.2",
1219 ListenPort: -1,
1220 },
1221 })
1222 assert.NoError(err)
1223 defer t.StopBgp(context.Background(), &api.StopBgpRequest{})
1224
1225 p2 := &api.Peer{
1226 Conf: &api.PeerConf{
1227 NeighborAddress: "127.0.0.1",
1228 PeerAsn: 1,
1229 },
1230 Transport: &api.Transport{
1231 RemotePort: 10179,
1232 },
1233 Timers: &api.Timers{
1234 Config: &api.TimersConfig{
1235 ConnectRetry: 1,
1236 IdleHoldTimeAfterReset: 1,
1237 },
1238 },
1239 }
1240 // go t.MonitorPeer(context.Background(), &api.MonitorPeerRequest{}, func(peer *api.Peer) {

Callers

nothing calls this directly

Calls 15

ServeMethod · 0.95
StartBgpMethod · 0.95
StopBgpMethod · 0.95
AddPeerMethod · 0.95
watchMethod · 0.95
AddPathMethod · 0.95
addPathListMethod · 0.95
getRibMethod · 0.95
NewPathAttributeNextHopFunction · 0.92
NewPathAttributeOriginFunction · 0.92
NewIPAddrPrefixFunction · 0.92
NewPathFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…