Skip to content

Commit

Permalink
BGP Afi Safi defaults test fix (openconfig#2354)
Browse files Browse the repository at this point in the history
* Fix test to check for the active leaf instead of the name leaf

* fix test

* revert the extended nh fix
  • Loading branch information
Ankur19 authored Nov 9, 2023
1 parent cfd1c4c commit 420d5d8
Showing 1 changed file with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,15 @@ func bgpCreateNbr(t *testing.T, localAs, peerAs uint32, dut *ondatra.DUTDevice,
nv4.PeerAs = ygot.Uint32(nbr.as)
nv4.Enabled = ygot.Bool(true)

// Neighbor level config is always applied.
if nbr.isV4 == true {
af4 := nv4.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST)
af4.Enabled = ygot.Bool(true)
} else {
af6 := nv4.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV6_UNICAST)
af6.Enabled = ygot.Bool(true)
}

switch afiSafiLevel {
case globalLevel:
global.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST).Enabled = ygot.Bool(true)
Expand All @@ -155,14 +164,6 @@ func bgpCreateNbr(t *testing.T, localAs, peerAs uint32, dut *ondatra.DUTDevice,
if deviations.BGPGlobalExtendedNextHopEncodingUnsupported(dut) {
global.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST).Ipv4Unicast = nil
}
case nbrLevel:
if nbr.isV4 == true {
af4 := nv4.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST)
af4.Enabled = ygot.Bool(true)
} else {
af6 := nv4.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV6_UNICAST)
af6.Enabled = ygot.Bool(true)
}
case peerGrpLevel:
pg1af4 := pg1.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST)
pg1af4.Enabled = ygot.Bool(true)
Expand Down Expand Up @@ -301,18 +302,18 @@ func verifyBgpCapabilities(t *testing.T, dut *ondatra.DUTDevice, afiSafiLevel st
nbrs := []*bgpNeighbor{nbr1, nbr2, nbr3, nbr4}

statePath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut)).Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "BGP").Bgp()
var nbrPath *netinstbgp.NetworkInstance_Protocol_Bgp_Neighbor_AfiSafi_AfiSafiNamePathAny
var nbrPath *netinstbgp.NetworkInstance_Protocol_Bgp_Neighbor_AfiSafiPathAny

for _, nbr := range nbrs {
nbrPath = statePath.Neighbor(nbr.neighborip).AfiSafiAny().AfiSafiName()
nbrPath = statePath.Neighbor(nbr.neighborip).AfiSafiAny()

capabilities := map[oc.E_BgpTypes_AFI_SAFI_TYPE]bool{
oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST: false,
oc.BgpTypes_AFI_SAFI_TYPE_IPV6_UNICAST: false,
}

for _, cap := range gnmi.GetAll(t, dut, nbrPath.State()) {
capabilities[cap] = true
capabilities[cap.GetAfiSafiName()] = cap.GetActive()
}

switch afiSafiLevel {
Expand Down

0 comments on commit 420d5d8

Please sign in to comment.