From 420d5d8526425dcccd7a2ebd7b22b5aca7aa8849 Mon Sep 17 00:00:00 2001 From: anksaiki Date: Thu, 9 Nov 2023 15:47:37 -0500 Subject: [PATCH] BGP Afi Safi defaults test fix (#2354) * Fix test to check for the active leaf instead of the name leaf * fix test * revert the extended nh fix --- .../bgp_afi_safi_defaults_test.go | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/feature/experimental/bgp/otg_tests/bgp_afi_safi_defaults/bgp_afi_safi_defaults_test.go b/feature/experimental/bgp/otg_tests/bgp_afi_safi_defaults/bgp_afi_safi_defaults_test.go index 29b44de8809..e6a79872111 100644 --- a/feature/experimental/bgp/otg_tests/bgp_afi_safi_defaults/bgp_afi_safi_defaults_test.go +++ b/feature/experimental/bgp/otg_tests/bgp_afi_safi_defaults/bgp_afi_safi_defaults_test.go @@ -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) @@ -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) @@ -301,10 +302,10 @@ 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, @@ -312,7 +313,7 @@ func verifyBgpCapabilities(t *testing.T, dut *ondatra.DUTDevice, afiSafiLevel st } for _, cap := range gnmi.GetAll(t, dut, nbrPath.State()) { - capabilities[cap] = true + capabilities[cap.GetAfiSafiName()] = cap.GetActive() } switch afiSafiLevel {