Skip to content

Commit

Permalink
Fix test for Arista using CLI to configure max-prefixes (openconfig#2450
Browse files Browse the repository at this point in the history
)

* Fix test for Arista using CLI to configure max-prefixes

* change deviation name

* fix static analysis error]
  • Loading branch information
Ankur19 authored Dec 6, 2023
1 parent 6532b7d commit c0d53a8
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ const (

var (
vendorSpecRoutecount = map[ondatra.Vendor]uint32{
ondatra.ARISTA: 2500000,
ondatra.JUNIPER: 2500000,
ondatra.NOKIA: 1600000,
}
Expand Down Expand Up @@ -113,12 +114,12 @@ func configureBGP(dut *ondatra.DUTDevice) *oc.NetworkInstance_Protocol {
g := bgp.GetOrCreateGlobal()
g.As = ygot.Uint32(dutAS)
g.RouterId = ygot.String(dutPort1.IPv4)
g.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST).Enabled = ygot.Bool(true)
g.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV6_UNICAST).Enabled = ygot.Bool(true)

pg := bgp.GetOrCreatePeerGroup("BGP-PEER-GROUP-V6")
pg.PeerAs = ygot.Uint32(ateAS)
pg.PeerGroupName = ygot.String("BGP-PEER-GROUP-V6")
pg.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV6_UNICAST).Enabled = ygot.Bool(true)

if deviations.RoutePolicyUnderAFIUnsupported(dut) {
rpl := pg.GetOrCreateApplyPolicy()
Expand All @@ -138,8 +139,6 @@ func configureBGP(dut *ondatra.DUTDevice) *oc.NetworkInstance_Protocol {
bgpNbr.PeerGroup = ygot.String("BGP-PEER-GROUP-V6")
af6 := bgpNbr.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV6_UNICAST)
af6.Enabled = ygot.Bool(true)
af4 := bgpNbr.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST)
af4.Enabled = ygot.Bool(false)
return niProto
}

Expand All @@ -166,7 +165,6 @@ func configureOTG(t *testing.T, otg *otg.OTG) (gosnappi.BgpV6Peer, gosnappi.Devi
iDut1Bgp := iDut1Dev.Bgp().SetRouterId(iDut1Ipv4.Address())
iDut1Bgp6Peer := iDut1Bgp.Ipv6Interfaces().Add().SetIpv6Name(iDut1Ipv6.Name()).Peers().Add().SetName(atePort1.Name + ".BGP6.peer")
iDut1Bgp6Peer.SetPeerAddress(iDut1Ipv6.Gateway()).SetAsNumber(ateAS).SetAsType(gosnappi.BgpV6PeerAsType.EBGP)
iDut1Bgp6Peer.Capability().SetIpv4UnicastAddPath(true).SetIpv6UnicastAddPath(true)
iDut1Bgp6Peer.LearnedInformationFilter().SetUnicastIpv4Prefix(true).SetUnicastIpv6Prefix(true)

t.Logf("Pushing config to ATE and starting protocols...")
Expand Down Expand Up @@ -218,6 +216,25 @@ func TestFibFailDueToHwResExhaust(t *testing.T) {
dutConf := configureBGP(dut)
gnmi.Replace(t, dut, dutConfPath.Config(), dutConf)
fptest.LogQuery(t, "DUT BGP Config", dutConfPath.Config(), gnmi.Get(t, dut, dutConfPath.Config()))
if deviations.BGPMissingOCMaxPrefixesConfiguration(dut) {
switch dut.Vendor() {
case ondatra.ARISTA:
cli := dut.RawAPIs().CLI(t)
_, err := cli.RunCommand(context.Background(), `
configure
router bgp 64500
neighbor BGP-PEER-GROUP-V6 maximum-routes 0
exit
exit
exit
`)
if err != nil {
t.Fatal(err)
}
default:
t.Fatal("Unsupported vendor")
}
}
})

ate := ondatra.ATE(t, "ate")
Expand Down Expand Up @@ -412,6 +429,7 @@ func injectBGPRoutes(t *testing.T, args *testArgs) {
SetAddress(advertisedRoutesv6).
SetPrefix(advertisedRoutesv6MaskLen).
SetCount(vendorSpecRoutecount[args.dut.Vendor()]).SetStep(2)
bgpNeti1Bgp6PeerRoutes.Advanced().SetIncludeLocalPreference(false)

args.otg.PushConfig(t, args.otgConfig)
time.Sleep(30 * time.Second)
Expand Down Expand Up @@ -478,15 +496,16 @@ routeAddLoop:
if err := awaitTimeout(args.ctx, t, args.client, time.Minute); err != nil {
t.Logf("Could not program entries via client, got err, check error codes: %v", err)
}

for _, v := range args.client.Results(t) {
res := args.client.Results(t)
for _, v := range res[len(res)-6:] {
if v.ProgrammingResult == aftspb.AFTResult_FIB_FAILED {
t.Logf("FIB FAILED received %v", v.Details)
fibFailedDstRoute = dstIPList[j]
break routeAddLoop
}
}
j = j + 1
t.Logf("Programmed entries %s --> %s", dstIPList[j]+"/32", vipList[j]+"/32")
j++
// We are filling FIB with BGP routes. After FIB is full, trying to program
// routes through gRIBI client. Since FIB is already full , we should get
// FIB FAILED while programming gRIBI routes. Here we are trying to program
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ platform_exceptions: {
}
deviations: {
omit_l2_mtu: true
interface_config_vrf_before_address: true
interface_enabled: true
default_network_instance: "default"
route_policy_under_afi_unsupported: true
bgp_missing_oc_max_prefixes_configuration: true
}
}
tags: TAGS_TRANSIT
6 changes: 6 additions & 0 deletions internal/deviations/deviations.go
Original file line number Diff line number Diff line change
Expand Up @@ -680,3 +680,9 @@ func SkipPlqInterfaceOperStatusCheck(dut *ondatra.DUTDevice) bool {
func BGPExplicitPrefixLimitReceived(dut *ondatra.DUTDevice) bool {
return lookupDUTDeviations(dut).GetBgpExplicitPrefixLimitReceived()
}

// BGPMissingOCMaxPrefixesConfiguration returns true for devices that does not configure BGP
// maximum routes correctly when max-prefixes OC leaf is configured.
func BGPMissingOCMaxPrefixesConfiguration(dut *ondatra.DUTDevice) bool {
return lookupDUTDeviations(dut).GetBgpMissingOcMaxPrefixesConfiguration()
}
3 changes: 3 additions & 0 deletions proto/metadata.proto
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,9 @@ message Metadata {
// Device set received prefix limits explicitly under prefix-limit-received rather than
// "prefix-limit"
bool bgp_explicit_prefix_limit_received = 127;
// Device does not configure BGP maximum routes correctly when max-prefixes
// leaf is configured
bool bgp_missing_oc_max_prefixes_configuration = 128;

// Reserved field numbers and identifiers.
reserved 84, 9, 28, 20, 90, 97, 55, 89, 19;
Expand Down
92 changes: 54 additions & 38 deletions proto/metadata_go_proto/metadata.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c0d53a8

Please sign in to comment.