(t *testing.T)
| 2622 | } |
| 2623 | |
| 2624 | func TestRTCWithdrawUpdatedPath(t *testing.T) { |
| 2625 | ctx := context.Background() |
| 2626 | |
| 2627 | s1 := runNewServer(t, 1, "1.1.1.1", 10179) |
| 2628 | defer s1.StopBgp(context.Background(), &api.StopBgpRequest{}) |
| 2629 | err := s1.SetLogLevel(context.Background(), &api.SetLogLevelRequest{Level: api.SetLogLevelRequest_LEVEL_DEBUG}) |
| 2630 | assert.NoError(t, err) |
| 2631 | s2 := runNewServer(t, 1, "2.2.2.2", 20179) |
| 2632 | defer s2.StopBgp(context.Background(), &api.StopBgpRequest{}) |
| 2633 | err = s2.SetLogLevel(context.Background(), &api.SetLogLevelRequest{Level: api.SetLogLevelRequest_LEVEL_DEBUG}) |
| 2634 | assert.NoError(t, err) |
| 2635 | |
| 2636 | if err := peerServers(t, ctx, []*BgpServer{s1, s2}, []oc.AfiSafiType{oc.AFI_SAFI_TYPE_L3VPN_IPV4_UNICAST, oc.AFI_SAFI_TYPE_RTC}); err != nil { |
| 2637 | t.Fatal(err) |
| 2638 | } |
| 2639 | watcher1 := s1.watch(WatchUpdate(true, "", "")) |
| 2640 | |
| 2641 | rt1 := bgp.NewTwoOctetAsSpecificExtended(bgp.EC_SUBTYPE_ROUTE_TARGET, 100, 100, true) |
| 2642 | rt2 := bgp.NewTwoOctetAsSpecificExtended(bgp.EC_SUBTYPE_ROUTE_TARGET, 200, 200, true) |
| 2643 | |
| 2644 | panh, _ := bgp.NewPathAttributeNextHop(netip.MustParseAddr("3.3.3.3")) |
| 2645 | // VPN Path: |
| 2646 | attrs12 := []bgp.PathAttributeInterface{ |
| 2647 | bgp.NewPathAttributeOrigin(0), |
| 2648 | panh, |
| 2649 | bgp.NewPathAttributeExtendedCommunities([]bgp.ExtendedCommunityInterface{rt1, rt2}), |
| 2650 | } |
| 2651 | attrs1 := []bgp.PathAttributeInterface{ |
| 2652 | bgp.NewPathAttributeOrigin(0), |
| 2653 | panh, |
| 2654 | bgp.NewPathAttributeExtendedCommunities([]bgp.ExtendedCommunityInterface{rt1}), |
| 2655 | } |
| 2656 | rd, _ := bgp.ParseRouteDistinguisher("100:100") |
| 2657 | labels := bgp.NewMPLSLabelStack(100, 200) |
| 2658 | prefix, _ := bgp.NewLabeledVPNIPAddrPrefix(netip.MustParsePrefix("10.30.2.0/24"), *labels, rd) |
| 2659 | path12, _ := apiutil.NewPath(bgp.RF_IPv4_VPN, prefix, false, attrs12, time.Now()) |
| 2660 | path1, _ := apiutil.NewPath(bgp.RF_IPv4_VPN, prefix, false, attrs1, time.Now()) |
| 2661 | |
| 2662 | if _, err := s2.AddPath(apiutil.AddPathRequest{Paths: []*apiutil.Path{mustApi2apiutilPath(path12)}}); err != nil { |
| 2663 | t.Fatal(err) |
| 2664 | } |
| 2665 | |
| 2666 | panh, _ = bgp.NewPathAttributeNextHop(netip.IPv4Unspecified()) |
| 2667 | attrsNH0 := []bgp.PathAttributeInterface{ |
| 2668 | bgp.NewPathAttributeOrigin(0), |
| 2669 | panh, |
| 2670 | } |
| 2671 | pathRtc0, _ := apiutil.NewPath(bgp.RF_RTC_UC, bgp.NewRouteTargetMembershipNLRI(1, rt2), false, attrsNH0, time.Now()) |
| 2672 | if _, err := s1.AddPath(apiutil.AddPathRequest{Paths: []*apiutil.Path{mustApi2apiutilPath(pathRtc0)}}); err != nil { |
| 2673 | t.Fatal(err) |
| 2674 | } |
| 2675 | |
| 2676 | // s1 should receive this route from s2 |
| 2677 | t1 := time.NewTimer(30 * time.Second) |
| 2678 | for found := false; !found; { |
| 2679 | select { |
| 2680 | case ev := <-watcher1.Event(): |
| 2681 | switch msg := ev.(type) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…