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

Function TestSameRTCMessagesWithOneDifferrence

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

Source from the content-addressed store, hash-verified

2490}
2491
2492func TestSameRTCMessagesWithOneDifferrence(t *testing.T) {
2493 ctx := context.Background()
2494
2495 s1 := runNewServer(t, 1, "1.1.1.1", 10179)
2496 defer s1.StopBgp(context.Background(), &api.StopBgpRequest{})
2497 err := s1.SetLogLevel(context.Background(), &api.SetLogLevelRequest{Level: api.SetLogLevelRequest_LEVEL_DEBUG})
2498 assert.NoError(t, err)
2499 s2 := runNewServer(t, 1, "2.2.2.2", 20179)
2500 defer s2.StopBgp(context.Background(), &api.StopBgpRequest{})
2501 err = s2.SetLogLevel(context.Background(), &api.SetLogLevelRequest{Level: api.SetLogLevelRequest_LEVEL_DEBUG})
2502 assert.NoError(t, err)
2503
2504 if err := peerServers(t, ctx, []*BgpServer{s1, s2}, []oc.AfiSafiType{oc.AFI_SAFI_TYPE_L3VPN_IPV4_UNICAST, oc.AFI_SAFI_TYPE_RTC}); err != nil {
2505 t.Fatal(err)
2506 }
2507 watcher1 := s1.watch(WatchUpdate(true, "", ""))
2508 watcher2 := s2.watch(WatchUpdate(true, "", ""))
2509
2510 rt := bgp.NewTwoOctetAsSpecificExtended(bgp.EC_SUBTYPE_ROUTE_TARGET, 100, 100, true)
2511
2512 panh, _ := bgp.NewPathAttributeNextHop(netip.MustParseAddr("3.3.3.3"))
2513 // VPN Path:
2514 attrs := []bgp.PathAttributeInterface{
2515 bgp.NewPathAttributeOrigin(0),
2516 panh,
2517 bgp.NewPathAttributeExtendedCommunities([]bgp.ExtendedCommunityInterface{rt}),
2518 }
2519 rd, _ := bgp.ParseRouteDistinguisher("100:100")
2520 labels := bgp.NewMPLSLabelStack(100, 200)
2521 prefix, _ := bgp.NewLabeledVPNIPAddrPrefix(netip.MustParsePrefix("10.30.2.0/24"), *labels, rd)
2522 path, _ := apiutil.NewPath(bgp.RF_IPv4_VPN, prefix, false, attrs, time.Now())
2523
2524 if _, err := s2.AddPath(apiutil.AddPathRequest{Paths: []*apiutil.Path{mustApi2apiutilPath(path)}}); err != nil {
2525 t.Fatal(err)
2526 }
2527
2528 panh, _ = bgp.NewPathAttributeNextHop(netip.IPv4Unspecified())
2529 attrsNH0 := []bgp.PathAttributeInterface{
2530 bgp.NewPathAttributeOrigin(0),
2531 panh,
2532 }
2533 pathRtc0, _ := apiutil.NewPath(bgp.RF_RTC_UC, bgp.NewRouteTargetMembershipNLRI(1, rt), false, attrsNH0, time.Now())
2534 if _, err := s1.AddPath(apiutil.AddPathRequest{Paths: []*apiutil.Path{mustApi2apiutilPath(pathRtc0)}}); err != nil {
2535 t.Fatal(err)
2536 }
2537
2538 // s1 should receive this route from s2
2539 t1 := time.NewTimer(30 * time.Second)
2540 for found := false; !found; {
2541 select {
2542 case ev := <-watcher1.Event():
2543 switch msg := ev.(type) {
2544 case *watchEventUpdate:
2545 for _, path := range msg.PathList {
2546 t.Logf("tester received path: %s", path.String())
2547 if vpnPath, ok := path.GetNlri().(*bgp.LabeledVPNIPAddrPrefix); ok {
2548 if vpnPath.Prefix == prefix.Prefix {
2549 t.Logf("tester found expected prefix: %s", vpnPath.Prefix)

Callers

nothing calls this directly

Calls 15

StringMethod · 0.95
GetNlriMethod · 0.95
NewPathAttributeNextHopFunction · 0.92
NewPathAttributeOriginFunction · 0.92
ParseRouteDistinguisherFunction · 0.92
NewMPLSLabelStackFunction · 0.92
NewPathFunction · 0.92
runNewServerFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…