Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RT-1.27: fixed failed tests #3613

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

singh-prem
Copy link
Contributor

This PR contains following:

  1. Changed bgp protocol instance name to default as table connection does not have a mechanism to pick a particular bgp instance.
  2. added sortDevicesByName function to sort emulated devices such that correct bgp neighbor gets emulated on correct otg port.
  3. Changed GetAll to LookupAll for prefixes learnt on OTG such that test does not fail fatally for cases where prefixes are not meant to be sent to otg.
  4. Added deviations and methods to configure default-reject route-policy, metric, attribute and skip subscription for table connection.

@singh-prem singh-prem requested review from dplore and a team as code owners November 29, 2024 11:30
@OpenConfigBot
Copy link

OpenConfigBot commented Nov 29, 2024

Pull Request Functional Test Report for #3613 / 9f18c0d

Virtual Devices

Device Test Test Documentation Job Raw Log
Arista cEOS status
RT-1.27: Static route to BGP redistribution
Cisco 8000E status
RT-1.27: Static route to BGP redistribution
Cisco XRd status
RT-1.27: Static route to BGP redistribution
Juniper ncPTX status
RT-1.27: Static route to BGP redistribution
Nokia SR Linux status
RT-1.27: Static route to BGP redistribution
Openconfig Lemming status
RT-1.27: Static route to BGP redistribution

Hardware Devices

Device Test Test Documentation Raw Log
Arista 7808 status
RT-1.27: Static route to BGP redistribution
Cisco 8808 status
RT-1.27: Static route to BGP redistribution
Juniper PTX10008 status
RT-1.27: Static route to BGP redistribution
Nokia 7250 IXR-10e status
RT-1.27: Static route to BGP redistribution

Help

@@ -221,7 +224,7 @@ func configureDUTBGP(t *testing.T, dut *ondatra.DUTDevice) {
t.Helper()

dutOcRoot := &oc.Root{}
bgpPath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut)).Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "BGP")
bgpPath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut)).Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "default")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imo this should be a map[string]string variable lookup to enable per-vendor naming schema.

or a deviation-based lookup, similar to how the "static" protocol is currently defined (static_protocol_name).

cc @dplore

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This reference to default network instance should be implemented using deviations.DefaultNetworkInstance()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @dplore , just to be sure, are you suggesting the code to change like this :
bgpPath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut)).Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, deviations.DefaultNetworkInstance(dut))

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dplore

This reference to default network instance should be implemented using deviations.DefaultNetworkInstance()

I think this change is about the BGP protocol instance naming (seems that some implementations use BGP, while other require the name default)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see, the current code is already using deviations.DefaultNetworkInstance(dut) for the network instance name. This change is about the bgp instance name. (thanks for pointing that out @LimeHat)

The OC default for this leaf is DEFAULT. Since this test does not require using a non-default name, the device is expected to use DEFAULT.

The need to use a name which is not DEFAULT should be via a deviation.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, still waiting to see a deviation specifically for cisco added to use this non-standard bgp protocol instance name of default

@coveralls
Copy link

coveralls commented Dec 7, 2024

Pull Request Test Coverage Report for Build 12431277691

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 55.268%

Totals Coverage Status
Change from base Build 12422942759: 0.0%
Covered Lines: 1983
Relevant Lines: 3588

💛 - Coveralls

@ram-mac
Copy link
Contributor

ram-mac commented Dec 16, 2024

@singh-prem can you resolve the conflicts and also rebase the checks

@ram-mac ram-mac assigned singh-prem and unassigned dplore Dec 16, 2024
@@ -235,7 +238,7 @@ func configureDUTBGP(t *testing.T, dut *ondatra.DUTDevice) {

// setup BGP
networkInstance := dutOcRoot.GetOrCreateNetworkInstance(deviations.DefaultNetworkInstance(dut))
networkInstanceProtocolBgp := networkInstance.GetOrCreateProtocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "BGP")
networkInstanceProtocolBgp := networkInstance.GetOrCreateProtocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "default")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, introduce a deviation for the BGP instance name. The standard should be "DEFAULT" and the deviation can be whatever you supply, specific for your NOS requirement.

@@ -320,13 +323,19 @@ func configureDUT(t *testing.T, dut *ondatra.DUTDevice) {
func awaitBGPEstablished(t *testing.T, dut *ondatra.DUTDevice, neighbors []string) {
for _, neighbor := range neighbors {
gnmi.Await(t, dut, gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut)).
Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "BGP").
Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "default").
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, introduce a deviation for the BGP instance name

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also suggest to use utility method to configure default network instance
fptest.ConfigureDefaultNetworkInstance from the cfgplugin utility

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ram-mac , FYI: as noted above, this is the bgp protocol instance name, not the network-instance name. But yes, a new deviation for Cisco is needed to set the bgp protocol instance name

@@ -479,6 +489,17 @@ func configureTableConnection(t *testing.T, dut *ondatra.DUTDevice, isV4, mPropa
}

batchSet.Set(t, dut)
if deviations.TcMetricPropagationUnsupported(dut) {
med := medZero
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to use switch dut.Vendor() format. See the requirements for deviations at:

if deviations.RequiredOCNotSupported(t, dut) {
switch dut.Vendor() {
case ondatra.VENDOR_X:
configureDeviceUsingCli(t, dut, vendorXConfig)
}
}

(This is because the CLI you are adding is specific to Cisco. Other vendors may also use this deviation, but with their own CLI)

med = medIPv6
}
}
setMetricViaCLI(t, dut, isV4, med, importPolicy)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
setMetricViaCLI(t, dut, isV4, med, importPolicy)
setMetricViaCiscoCLI(t, dut, isV4, med, importPolicy)

helpers.GnmiCLIConfig(t, dut, cliConfig)
}

func setMetricViaCLI(t *testing.T, dut *ondatra.DUTDevice, isV4 bool, metric int, routePolicyName string) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this functon to a new file in internal/cfgplugins such as tableconnections.go

Suggest renaming the function to DeviationCiscoTableConnectionsBGPtoStaticMetricPropagation or similar.

Add a description such as:
This function is used as an alternative to /network-instances/network-instance/table-connections/table-connection/config/disable-metric-propagation. In OC this path is set to 'false' by default, therefore enabling table-connections to propagate metrics from one protocol to another. This deviation implements CLI to perform the equivalent function.

Comment on lines +1100 to +1102
if deviations.BgpCommunitySetRefsUnsupported(dut) {
setCommunityViaCLI(t, dut, redistributeStaticPolicyName, policyStatementName, communitySetName)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to use switch dut.Vendor() format. See the requirements for deviations at:

if deviations.RequiredOCNotSupported(t, dut) {
switch dut.Vendor() {
case ondatra.VENDOR_X:
configureDeviceUsingCli(t, dut, vendorXConfig)
}
}

(This is because the CLI you are adding is specific to Cisco. Other vendors may also use this deviation, but with their own CLI)

Comment on lines +1297 to +1299
if deviations.TcAttributePropagationUnsupported(dut) {
setAttributeViaCLI(t, dut, redistributeStaticPolicyNameV6, "statement-v6", "prefix-set-v6", medIPv6, "igp")
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to use switch dut.Vendor() format. See the requirements for deviations at:

if deviations.RequiredOCNotSupported(t, dut) {
switch dut.Vendor() {
case ondatra.VENDOR_X:
configureDeviceUsingCli(t, dut, vendorXConfig)
}
}

(This is because the CLI you are adding is specific to Cisco. Other vendors may also use this deviation, but with their own CLI)

Comment on lines +1581 to -1491
time.Sleep(15 * time.Second)

_, ok := gnmi.WatchAll(t, ate.OTG(), gnmi.OTG().BgpPeer(bgpPeerName).UnicastIpv4PrefixAny().State(),
time.Minute, func(v *ygnmi.Value[*otgtelemetry.BgpPeer_UnicastIpv4Prefix]) bool {
return v.IsPresent()
}).Await(t)

if !ok {
t.Errorf("No BGP prefixes learnt")
}

bgpPrefixes := gnmi.GetAll(t, ate.OTG(), gnmi.OTG().BgpPeer(bgpPeerName).UnicastIpv4PrefixAny().State())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using sleep instead of gnmi Watch Await is an anti-pattern. Why does gnmi Await not work on Cisco? Please remove this.

Comment on lines -1512 to +1607
time.Sleep(5 * time.Second)
time.Sleep(15 * time.Second)

bgpPrefixes := gnmi.GetAll[*otgtelemetry.BgpPeer_UnicastIpv6Prefix](t, ate.OTG(), gnmi.OTG().BgpPeer(bgpPeerName).UnicastIpv6PrefixAny().State())
bgpPrefixEntries := gnmi.LookupAll[*otgtelemetry.BgpPeer_UnicastIpv6Prefix](t, ate.OTG(), gnmi.OTG().BgpPeer(bgpPeerName).UnicastIpv6PrefixAny().State())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be refactored to use gnmi watch await

@@ -827,6 +866,57 @@ func redistributeIPv4PrefixRoutePolicy(t *testing.T, dut *ondatra.DUTDevice, ate
verifyTraffic(t, ate, otgConfig)
}

func setAttributeViaCLI(t *testing.T, dut *ondatra.DUTDevice, policyName string, statement string, prefixSetName string, setMed int, origin string) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this function to a new file in internal/cfgplugins in bgp_policy.go

Suggest renaming the function to DeviationCiscoRoutingPolicyBGPActionSetMed or similar.

Add a description such as:

This function is used as an alternative to /routing-policy/policy-definitions/policy-definition/statements/statement/actions/bgp-actions/config/set-med. This deviation implements CLI to perform the equivalent function.

@singh-prem singh-prem requested a review from a team December 20, 2024 12:17
@ram-mac
Copy link
Contributor

ram-mac commented Dec 27, 2024

There are some other changes for the same test - #3444
Can we check if the changes suggested in this PR are repeated in this PR?

@@ -221,7 +224,7 @@ func configureDUTBGP(t *testing.T, dut *ondatra.DUTDevice) {
t.Helper()

dutOcRoot := &oc.Root{}
bgpPath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut)).Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "BGP")
bgpPath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut)).Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "default")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, still waiting to see a deviation specifically for cisco added to use this non-standard bgp protocol instance name of default

@@ -320,13 +323,19 @@ func configureDUT(t *testing.T, dut *ondatra.DUTDevice) {
func awaitBGPEstablished(t *testing.T, dut *ondatra.DUTDevice, neighbors []string) {
for _, neighbor := range neighbors {
gnmi.Await(t, dut, gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut)).
Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "BGP").
Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "default").
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ram-mac , FYI: as noted above, this is the bgp protocol instance name, not the network-instance name. But yes, a new deviation for Cisco is needed to set the bgp protocol instance name

@dplore
Copy link
Member

dplore commented Jan 3, 2025

There are some other changes for the same test - #3444 Can we check if the changes suggested in this PR are repeated in this PR?

We'll have to review these PR's one at a time unfortunately. I am giving this PR (#3613) priority for review first. After #3613 is merged, then #3444 will need to merge to mater and resolve and conflicts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants