Skip to content

Commit

Permalink
RT-1.27: fixed failed tests (openconfig#3613)
Browse files Browse the repository at this point in the history
* intial code

* defined deviations

* updated deviation usage

* taken care of comments, also changed static route replace to update to preserve base routes

* added default bgp instance name in metadata file

* Update internal/cfgplugins/bgp_policy.go

function description change

Co-authored-by: Darren Loher <[email protected]>

* Update internal/cfgplugins/bgp_policy.go

function description change 2

Co-authored-by: Darren Loher <[email protected]>

* added bug info to the deviations

---------

Co-authored-by: Darren Loher <[email protected]>
Co-authored-by: Ram <[email protected]>
  • Loading branch information
3 people authored Jan 11, 2025
1 parent 407cbaf commit a92713a
Show file tree
Hide file tree
Showing 7 changed files with 1,463 additions and 1,132 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,18 @@ platform_exceptions: {
set_metric_as_preference: true
}
}
platform_exceptions: {
platform: {
vendor: CISCO
}
deviations: {
set_metric_as_preference: true
skip_bgp_send_community_type: true
bgp_community_set_refs_unsupported: true
tc_default_import_policy_unsupported: true
tc_metric_propagation_unsupported: true
tc_attribute_propagation_unsupported: true
tc_subscription_unsupported: true
default_bgp_instance_name: "default"
}
}

Large diffs are not rendered by default.

63 changes: 63 additions & 0 deletions internal/cfgplugins/bgp_policy.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package cfgplugins

import (
"fmt"
"testing"

"github.com/openconfig/featureprofiles/internal/helpers"
"github.com/openconfig/ondatra"
)

// DeviationCiscoRoutingPolicyBGPActionSetCommunity is used as an alternative to

Check failure on line 25 in internal/cfgplugins/bgp_policy.go

View workflow job for this annotation

GitHub Actions / Static Analysis

comment on exported function DeviationCiscoRoutingPolicyBGPActionSetMed should be of the form "DeviationCiscoRoutingPolicyBGPActionSetMed ..."

Check failure on line 25 in internal/cfgplugins/bgp_policy.go

View workflow job for this annotation

GitHub Actions / Static Analysis

comment on exported function DeviationCiscoRoutingPolicyBGPActionSetMed should be of the form "DeviationCiscoRoutingPolicyBGPActionSetMed ..."

Check failure on line 25 in internal/cfgplugins/bgp_policy.go

View workflow job for this annotation

GitHub Actions / Static Analysis

comment on exported function DeviationCiscoRoutingPolicyBGPActionSetMed should be of the form "DeviationCiscoRoutingPolicyBGPActionSetMed ..."

Check failure on line 25 in internal/cfgplugins/bgp_policy.go

View workflow job for this annotation

GitHub Actions / Static Analysis

comment on exported function DeviationCiscoRoutingPolicyBGPActionSetMed should be of the form "DeviationCiscoRoutingPolicyBGPActionSetMed ..."

Check failure on line 25 in internal/cfgplugins/bgp_policy.go

View workflow job for this annotation

GitHub Actions / Static Analysis

comment on exported function DeviationCiscoRoutingPolicyBGPActionSetMed should be of the form "DeviationCiscoRoutingPolicyBGPActionSetMed ..."

Check failure on line 25 in internal/cfgplugins/bgp_policy.go

View workflow job for this annotation

GitHub Actions / Static Analysis

comment on exported function DeviationCiscoRoutingPolicyBGPActionSetMed should be of the form "DeviationCiscoRoutingPolicyBGPActionSetMed ..."

Check failure on line 25 in internal/cfgplugins/bgp_policy.go

View workflow job for this annotation

GitHub Actions / Static Analysis

comment on exported function DeviationCiscoRoutingPolicyBGPActionSetMed should be of the form "DeviationCiscoRoutingPolicyBGPActionSetMed ..."

Check failure on line 25 in internal/cfgplugins/bgp_policy.go

View workflow job for this annotation

GitHub Actions / Static Analysis

comment on exported function DeviationCiscoRoutingPolicyBGPActionSetMed should be of the form "DeviationCiscoRoutingPolicyBGPActionSetMed ..."
// /routing-policy/policy-definitions/policy-definition/statements/statement/actions/bgp-actions/config/set-med.
// This deviation implements CLI to perform the equivalent function.
func DeviationCiscoRoutingPolicyBGPActionSetMed(t *testing.T, dut *ondatra.DUTDevice, policyName string, statement string, prefixSetName string, setMed int, origin string) {
//route-policy route-policy-v4
// #statement-name statement-v4
// if destination in prefix-set-v4 then
// set med 104
// set origin igp
// endif
// end-policy
cliConfig := fmt.Sprintf("route-policy %s\n #statement-name %v\n if destination in %v then\n", policyName, statement, prefixSetName)

if setMed != 0 {
cliConfig += fmt.Sprintf(" set med %d\n", setMed)
}
if origin != "" {
cliConfig += fmt.Sprintf(" set origin %v\n", origin)
}
cliConfig += " done\n endif\nend-policy\n"
helpers.GnmiCLIConfig(t, dut, cliConfig)
}

// DeviationCiscoRoutingPolicyBGPActionSetCommunity is used as an alternative to
// /routing-policy/policy-definitions/policy-definition/statements/statement/actions/bgp-actions/set-community
// This deviation implements CLI to perform the equivalent function.
func DeviationCiscoRoutingPolicyBGPActionSetCommunity(t *testing.T, dut *ondatra.DUTDevice, policyName string, statement string, community string) {
// route-policy route-policy-v4
// #statement-name statement-v4
// set community community-set-v4
// done
// end-policy
cliConfig := fmt.Sprintf("route-policy %s\n #statement-name %v\n", policyName, statement)
if community != "" {
cliConfig += fmt.Sprintf(" set community %v\n", community)
}
cliConfig += " done\nend-policy\n"
helpers.GnmiCLIConfig(t, dut, cliConfig)
}
48 changes: 48 additions & 0 deletions internal/cfgplugins/tableconnections.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package cfgplugins

import (
"fmt"
"testing"

"github.com/openconfig/featureprofiles/internal/helpers"
"github.com/openconfig/ondatra"
)

// DeviationCiscoTableConnectionsStatictoBGPMetricPropagation 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.
func DeviationCiscoTableConnectionsStatictoBGPMetricPropagation(t *testing.T, dut *ondatra.DUTDevice, isV4 bool, metric int, routePolicyName string) {
// router bgp 64512
//
// address-family ipv4 unicast
// redistribute static metric 104
// !
// address-family ipv6 unicast
// redistribute static metric 106
var aftype string
if isV4 {
aftype = "ipv4"
} else {
aftype = "ipv6"
}
cliConfig := fmt.Sprintf("router bgp 64512\n address-family %v unicast\n redistribute static metric %d\n !\n!\n", aftype, metric)
if routePolicyName != "" {
cliConfig = fmt.Sprintf("router bgp 64512\n address-family %v unicast\n redistribute static metric %d route-policy %s\n !\n!\n", aftype, metric, routePolicyName)
}
helpers.GnmiCLIConfig(t, dut, cliConfig)
}
28 changes: 28 additions & 0 deletions internal/deviations/deviations.go
Original file line number Diff line number Diff line change
Expand Up @@ -1264,3 +1264,31 @@ func BgpSetMedV7Unsupported(dut *ondatra.DUTDevice) bool {
func EnableTableConnections(dut *ondatra.DUTDevice) bool {
return lookupDUTDeviations(dut).GetEnableTableConnections()
}

// TcDefaultImportPolicyUnsupported returns true if default import policy for table connection is unsupported
func TcDefaultImportPolicyUnsupported(dut *ondatra.DUTDevice) bool {
return lookupDUTDeviations(dut).GetTcDefaultImportPolicyUnsupported()
}

// TcMetricPropagationUnsupported returns true if metric propagation for table connection is unsupported
func TcMetricPropagationUnsupported(dut *ondatra.DUTDevice) bool {
return lookupDUTDeviations(dut).GetTcMetricPropagationUnsupported()
}

// TcAttributePropagationUnsupported returns true if attribute propagation for table connection is unsupported
func TcAttributePropagationUnsupported(dut *ondatra.DUTDevice) bool {
return lookupDUTDeviations(dut).GetTcAttributePropagationUnsupported()
}

// TcSubscriptionUnsupported returns true if subscription for table connection is unsupported
func TcSubscriptionUnsupported(dut *ondatra.DUTDevice) bool {
return lookupDUTDeviations(dut).GetTcSubscriptionUnsupported()
}

// DefaultBgpInstanceName returns bgp instance name as set in deviation to override default value "DEFAULT"
func DefaultBgpInstanceName(dut *ondatra.DUTDevice) string {
if dbin := lookupDUTDeviations(dut).GetDefaultBgpInstanceName(); dbin != "" {
return dbin
}
return "DEFAULT"
}
15 changes: 15 additions & 0 deletions proto/metadata.proto
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,21 @@ message Metadata {
// Juniper: b/358534837
// Devices that do not support setting med value using union type in OC.
bool bgp_set_med_v7_unsupported = 241;
// Cisco: b/388980373
// default import policy for table connection unsupported is set to true for devices that do not support default import policy.
bool tc_default_import_policy_unsupported = 242;
// Cisco: b/388955361
// table connection metric propagation unsupported is set to true for devices that do not support metric propagation.
bool tc_metric_propagation_unsupported = 243;
// Cisco: b/388980376
// table connection attribute propagation unsupported is set to true for devices that do not support attribute propagation.
bool tc_attribute_propagation_unsupported = 244;
// Cisco: b/388955364
// table connection subscription unsupported is set to true for devices that do not support subscription for table connection leaves.
bool tc_subscription_unsupported = 245;
// Cisco: b/388983709
// default bgp instance name is used to set bgp instance name value other than DEFAULT
string default_bgp_instance_name = 246;

// Reserved field numbers and identifiers.
reserved 84, 9, 28, 20, 90, 97, 55, 89, 19, 36, 35, 40, 173;
Expand Down
Loading

0 comments on commit a92713a

Please sign in to comment.