Skip to content

Commit

Permalink
RT-1.28: Fixed script with added deviations (#3567)
Browse files Browse the repository at this point in the history
* RT-1.28: Fixed script with additional deviations
- Added new deviation EnableTableConnections & other required deviation.
- Used `bgp_community_member_is_a_string: true` with ref to https://partnerissuetracker.corp.google.com/issues/376799780#comment2
- Match-Community-Set under bgp-conditions configuration moved under policy-defitions as its configuration is deprecated under bgp-defined-sets.
- Under nonMatchingCommunityRoutePolicy(both v4 & v6) changed gnmi.Replace to gnmi.Update to avoid precondition error of failing to delete AllowAll route-policy.

"This code is a Contribution to the OpenConfig Feature Profiles project ("Work") made under the Google Software Grant and Corporate Contributor License Agreement ("CLA") and governed by the Apache License 2.0. No other rights or licenses in or to any of Nokia's intellectual property are granted for any other purpose. This code is provided on an "as is" basis without any warranties of any kind."

* -Removed comment

"This code is a Contribution to the OpenConfig Feature Profiles project ("Work") made under the Google Software Grant and Corporate Contributor License Agreement ("CLA") and governed by the Apache License 2.0. No other rights or licenses in or to any of Nokia's intellectual property are granted for any other purpose. This code is provided on an "as is" basis without any warranties of any kind."

* -Adding changes to deviations.go, metadata.proto & metadata.pb.go for EnableTableConnections.

"This code is a Contribution to the OpenConfig Feature Profiles project ("Work") made under the Google Software Grant and Corporate Contributor License Agreement ("CLA") and governed by the Apache License 2.0. No other rights or licenses in or to any of Nokia's intellectual property are granted for any other purpose. This code is provided on an "as is" basis without any warranties of any kind."

* -Resolving conflicts

"This code is a Contribution to the OpenConfig Feature Profiles project ("Work") made under the Google Software Grant and Corporate Contributor License Agreement ("CLA") and governed by the Apache License 2.0. No other rights or licenses in or to any of Nokia's intellectual property are granted for any other purpose. This code is provided on an "as is" basis without any warranties of any kind."

* Revert "-Resolving conflicts"

This reverts commit f41b14a.

* -Defined & calling  `ConfigEnableTbNative` function from fptest.

"This code is a Contribution to the OpenConfig Feature Profiles project ("Work") made under the Google Software Grant and Corporate Contributor License Agreement ("CLA") and governed by the Apache License 2.0. No other rights or licenses in or to any of Nokia's intellectual property are granted for any other purpose. This code is provided on an "as is" basis without any warranties of any kind."

* -updated deviation comment

"This code is a Contribution to the OpenConfig Feature Profiles project ("Work") made under the Google Software Grant and Corporate Contributor License Agreement ("CLA") and governed by the Apache License 2.0. No other rights or licenses in or to any of Nokia's intellectual property are granted for any other purpose. This code is provided on an "as is" basis without any warranties of any kind."

* Fixed tableconnection with comment

* -Removing extra space in deviations.go

"This code is a Contribution to the OpenConfig Feature Profiles project ("Work") made under the Google Software Grant and Corporate Contributor License Agreement ("CLA") and governed by the Apache License 2.0. No other rights or licenses in or to any of Nokia's intellectual property are granted for any other purpose. This code is provided on an "as is" basis without any warranties of any kind."

---------

Co-authored-by: trathod <[email protected]>
Co-authored-by: Tushar Rathod <[email protected]>
  • Loading branch information
3 people authored Dec 27, 2024
1 parent d63d627 commit 3a3d098
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,9 @@ func nonMatchingPrefixRoutePolicy(t *testing.T, dut *ondatra.DUTDevice) {
}

prefixSet := rp.GetOrCreateDefinedSets().GetOrCreatePrefixSet(v4PrefixSet)
prefixSet.SetMode(oc.PrefixSet_Mode_IPV4)
if !deviations.SkipPrefixSetMode(dut) {
prefixSet.SetMode(oc.PrefixSet_Mode_IPV4)
}
prefixSet.GetOrCreatePrefix(nonAdvertisedIPv4.cidr(t), maskLenExact)

if !deviations.SkipSetRpMatchSetOptions(dut) {
Expand All @@ -330,7 +332,7 @@ func matchingPrefixRoutePolicy(t *testing.T, dut *ondatra.DUTDevice) {
rp := root.GetOrCreateRoutingPolicy()
prefixSet := rp.GetOrCreateDefinedSets().GetOrCreatePrefixSet(v4PrefixSet)
prefixSet.GetOrCreatePrefix(advertisedIPv4.cidr(t), maskLenExact)
gnmi.Update(t, dut, gnmi.OC().RoutingPolicy().DefinedSets().PrefixSet(v4PrefixSet).Config(), prefixSet)
gnmi.Replace(t, dut, gnmi.OC().RoutingPolicy().DefinedSets().PrefixSet(v4PrefixSet).Config(), prefixSet)
}

func nonMatchingCommunityRoutePolicy(t *testing.T, dut *ondatra.DUTDevice) {
Expand All @@ -355,12 +357,14 @@ func nonMatchingCommunityRoutePolicy(t *testing.T, dut *ondatra.DUTDevice) {

communitySet := rp.GetOrCreateDefinedSets().GetOrCreateBgpDefinedSets().GetOrCreateCommunitySet(v4CommunitySet)
communitySet.SetCommunityMember([]oc.RoutingPolicy_DefinedSets_BgpDefinedSets_CommunitySet_CommunityMember_Union{oc.UnionString(fmt.Sprintf("%d:%d", dummyAS, 200))})
communitySet.SetMatchSetOptions(oc.BgpPolicy_MatchSetOptionsType_ANY)

if deviations.BGPConditionsMatchCommunitySetUnsupported(dut) {
communitySet.SetMatchSetOptions(oc.BgpPolicy_MatchSetOptionsType_ANY)
stmt.GetOrCreateConditions().GetOrCreateBgpConditions().SetCommunitySet(v4CommunitySet)
} else {
stmt.GetOrCreateConditions().GetOrCreateBgpConditions().GetOrCreateMatchCommunitySet().SetCommunitySet(v4CommunitySet)
ref1 := stmt.GetOrCreateConditions().GetOrCreateBgpConditions().GetOrCreateMatchCommunitySet()
ref1.SetCommunitySet(v4CommunitySet)
ref1.SetMatchSetOptions(oc.RoutingPolicy_MatchSetOptionsType_ANY)
}
// Configure ALLOWAll policy
pdef = rp.GetOrCreatePolicyDefinition(allowAllPolicy)
Expand All @@ -383,7 +387,7 @@ func matchingCommunityRoutePolicy(t *testing.T, dut *ondatra.DUTDevice) {
rp := root.GetOrCreateRoutingPolicy()
communitySet := rp.GetOrCreateDefinedSets().GetOrCreateBgpDefinedSets().GetOrCreateCommunitySet(v4CommunitySet)
communitySet.SetCommunityMember([]oc.RoutingPolicy_DefinedSets_BgpDefinedSets_CommunitySet_CommunityMember_Union{oc.UnionString(fmt.Sprintf("%d:%d", ateAS, 100))})
gnmi.Update(t, dut, gnmi.OC().RoutingPolicy().DefinedSets().BgpDefinedSets().CommunitySet(v4CommunitySet).Config(), communitySet)
gnmi.Replace(t, dut, gnmi.OC().RoutingPolicy().DefinedSets().BgpDefinedSets().CommunitySet(v4CommunitySet).Config(), communitySet)
}
}

Expand All @@ -410,8 +414,10 @@ func verifyNonMatchingPrefixTelemetry(t *testing.T, dut *ondatra.DUTDevice, ate
if pName := prefixSet.GetName(); pName != v4PrefixSet {
t.Errorf("Prefix set name: %s, want: %s", pName, v4PrefixSet)
}
if pMode := prefixSet.GetMode(); pMode != oc.PrefixSet_Mode_IPV4 {
t.Errorf("Prefix set mode: %s, want: %s", pMode, oc.PrefixSet_Mode_IPV4)
if !deviations.SkipPrefixSetMode(dut) {
if pMode := prefixSet.GetMode(); pMode != oc.PrefixSet_Mode_IPV4 {
t.Errorf("Prefix set mode: %s, want: %s", pMode, oc.PrefixSet_Mode_IPV4)
}
}
if prefix := prefixSet.GetPrefix(nonAdvertisedIPv4.cidr(t), maskLenExact); prefix == nil {
t.Errorf("Prefix is nil, want: %s", nonAdvertisedIPv4.cidr(t))
Expand Down Expand Up @@ -525,7 +531,9 @@ func nonMatchingPrefixRoutePolicyV6(t *testing.T, dut *ondatra.DUTDevice) {
}

prefixSet := rp.GetOrCreateDefinedSets().GetOrCreatePrefixSet(v6PrefixSet)
prefixSet.SetMode(oc.PrefixSet_Mode_IPV6)
if !deviations.SkipPrefixSetMode(dut) {
prefixSet.SetMode(oc.PrefixSet_Mode_IPV6)
}
prefixSet.GetOrCreatePrefix(nonAdvertisedIPv6.cidr(t), maskLenExact)

if !deviations.SkipSetRpMatchSetOptions(dut) {
Expand All @@ -540,7 +548,7 @@ func matchingPrefixRoutePolicyV6(t *testing.T, dut *ondatra.DUTDevice) {
rp := root.GetOrCreateRoutingPolicy()
prefixSet := rp.GetOrCreateDefinedSets().GetOrCreatePrefixSet(v6PrefixSet)
prefixSet.GetOrCreatePrefix(advertisedIPv6.cidr(t), maskLenExact)
gnmi.Update(t, dut, gnmi.OC().RoutingPolicy().DefinedSets().PrefixSet(v6PrefixSet).Config(), prefixSet)
gnmi.Replace(t, dut, gnmi.OC().RoutingPolicy().DefinedSets().PrefixSet(v6PrefixSet).Config(), prefixSet)
}

func nonMatchingCommunityRoutePolicyV6(t *testing.T, dut *ondatra.DUTDevice) {
Expand All @@ -565,12 +573,14 @@ func nonMatchingCommunityRoutePolicyV6(t *testing.T, dut *ondatra.DUTDevice) {

communitySet := rp.GetOrCreateDefinedSets().GetOrCreateBgpDefinedSets().GetOrCreateCommunitySet(v6CommunitySet)
communitySet.SetCommunityMember([]oc.RoutingPolicy_DefinedSets_BgpDefinedSets_CommunitySet_CommunityMember_Union{oc.UnionString(fmt.Sprintf("%d:%d", dummyAS, 200))})
communitySet.SetMatchSetOptions(oc.BgpPolicy_MatchSetOptionsType_ANY)

if deviations.BGPConditionsMatchCommunitySetUnsupported(dut) {
stmt.GetOrCreateConditions().GetOrCreateBgpConditions().SetCommunitySet(v6CommunitySet)
communitySet.SetMatchSetOptions(oc.BgpPolicy_MatchSetOptionsType_ANY)
} else {
stmt.GetOrCreateConditions().GetOrCreateBgpConditions().GetOrCreateMatchCommunitySet().SetCommunitySet(v6CommunitySet)
ref1 := stmt.GetOrCreateConditions().GetOrCreateBgpConditions().GetOrCreateMatchCommunitySet()
ref1.SetCommunitySet(v6CommunitySet)
ref1.SetMatchSetOptions(oc.RoutingPolicy_MatchSetOptionsType_ANY)
}
// Configure ALLOWAll policy
pdef = rp.GetOrCreatePolicyDefinition(allowAllPolicy)
Expand All @@ -592,7 +602,7 @@ func matchingCommunityRoutePolicyV6(t *testing.T, dut *ondatra.DUTDevice) {
rp := root.GetOrCreateRoutingPolicy()
communitySet := rp.GetOrCreateDefinedSets().GetOrCreateBgpDefinedSets().GetOrCreateCommunitySet(v6CommunitySet)
communitySet.SetCommunityMember([]oc.RoutingPolicy_DefinedSets_BgpDefinedSets_CommunitySet_CommunityMember_Union{oc.UnionString(fmt.Sprintf("%d:%d", ateAS, 100))})
gnmi.Update(t, dut, gnmi.OC().RoutingPolicy().DefinedSets().BgpDefinedSets().CommunitySet(v6CommunitySet).Config(), communitySet)
gnmi.Replace(t, dut, gnmi.OC().RoutingPolicy().DefinedSets().BgpDefinedSets().CommunitySet(v6CommunitySet).Config(), communitySet)
}
}

Expand All @@ -619,8 +629,10 @@ func verifyNonMatchingPrefixTelemetryV6(t *testing.T, dut *ondatra.DUTDevice, at
if pName := prefixSet.GetName(); pName != v6PrefixSet {
t.Errorf("Prefix set name: %s, want: %s", pName, v6PrefixSet)
}
if pMode := prefixSet.GetMode(); pMode != oc.PrefixSet_Mode_IPV6 {
t.Errorf("Prefix set mode: %s, want: %s", pMode, oc.PrefixSet_Mode_IPV6)
if !deviations.SkipPrefixSetMode(dut) {
if pMode := prefixSet.GetMode(); pMode != oc.PrefixSet_Mode_IPV6 {
t.Errorf("Prefix set mode: %s, want: %s", pMode, oc.PrefixSet_Mode_IPV6)
}
}
if prefix := prefixSet.GetPrefix(nonAdvertisedIPv6.cidr(t), maskLenExact); prefix == nil {
t.Errorf("Prefix is nil, want: %s", nonAdvertisedIPv6.cidr(t))
Expand Down Expand Up @@ -718,6 +730,9 @@ func verifyMatchingCommunityTelemetryV6(t *testing.T, dut *ondatra.DUTDevice, at
func bgpISISRedistribution(t *testing.T, dut *ondatra.DUTDevice, operation string) {
dni := deviations.DefaultNetworkInstance(dut)
root := &oc.Root{}
if deviations.EnableTableConnections(dut) {
fptest.ConfigEnableTbNative(t, dut)
}
tableConn := root.GetOrCreateNetworkInstance(dni).GetOrCreateTableConnection(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_ISIS, oc.Types_ADDRESS_FAMILY_IPV4)
if operation == "set" {
if !deviations.SkipSettingDisableMetricPropagation(dut) {
Expand All @@ -736,6 +751,9 @@ func bgpISISRedistribution(t *testing.T, dut *ondatra.DUTDevice, operation strin
func bgpISISRedistributionV6(t *testing.T, dut *ondatra.DUTDevice, operation string) {
dni := deviations.DefaultNetworkInstance(dut)
root := &oc.Root{}
if deviations.EnableTableConnections(dut) {
fptest.ConfigEnableTbNative(t, dut)
}
tableConn := root.GetOrCreateNetworkInstance(dni).GetOrCreateTableConnection(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_ISIS, oc.Types_ADDRESS_FAMILY_IPV6)
if operation == "set" {
if !deviations.SkipSettingDisableMetricPropagation(dut) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,14 @@ platform_exceptions: {
default_route_policy_unsupported: true
}
}
platform_exceptions: {
platform: {
vendor: NOKIA
}
deviations: {
explicit_interface_in_default_vrf: true
interface_enabled: true
skip_prefix_set_mode: true
enable_table_connections: true
}
}
10 changes: 5 additions & 5 deletions internal/deviations/deviations.go
Original file line number Diff line number Diff line change
Expand Up @@ -1234,11 +1234,6 @@ func BgpAfiSafiWildcardNotSupported(dut *ondatra.DUTDevice) bool {
return lookupDUTDeviations(dut).GetBgpAfiSafiWildcardNotSupported()
}

// EnableTableConnections Admin Enable Table Connections in SRL native
func EnableTableConnections(dut *ondatra.DUTDevice) bool {
return lookupDUTDeviations(dut).GetEnableTableConnections()
}

// NoZeroSuppression returns true if device wants to remove zero suppression
func NoZeroSuppression(dut *ondatra.DUTDevice) bool {
return lookupDUTDeviations(dut).GetNoZeroSuppression()
Expand All @@ -1264,3 +1259,8 @@ func IsisDatabaseOverloadsUnsupported(dut *ondatra.DUTDevice) bool {
func BgpSetMedV7Unsupported(dut *ondatra.DUTDevice) bool {
return lookupDUTDeviations(dut).GetBgpSetMedV7Unsupported()
}

// EnableTableConnections returns true if admin state of tableconnections needs to be enabled in SRL native model
func EnableTableConnections(dut *ondatra.DUTDevice) bool {
return lookupDUTDeviations(dut).GetEnableTableConnections()
}
66 changes: 66 additions & 0 deletions internal/fptest/tableconnection.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// Copyright 2022 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 fptest

import (
"context"
"encoding/json"
"testing"

gpb "github.com/openconfig/gnmi/proto/gnmi"
"github.com/openconfig/ondatra"
)

// ConfigEnableTbNative enables admin-state of table-connections in native mode.
func ConfigEnableTbNative(t testing.TB, d *ondatra.DUTDevice) {
t.Helper()
state := "enable"
switch d.Vendor() {
case ondatra.NOKIA:
adminEnable, err := json.Marshal(state)
if err != nil {
t.Fatalf("Error with json Marshal: %v", err)
}

gpbSetRequest := &gpb.SetRequest{
Prefix: &gpb.Path{
Origin: "native",
},
Update: []*gpb.Update{
{
Path: &gpb.Path{
Elem: []*gpb.PathElem{
{Name: "network-instance", Key: map[string]string{"name": "DEFAULT"}},
{Name: "table-connections"},
{Name: "admin-state"},
},
},
Val: &gpb.TypedValue{
Value: &gpb.TypedValue_JsonIetfVal{
JsonIetfVal: adminEnable,
},
},
},
},
}

gnmiClient := d.RawAPIs().GNMI(t)
if _, err := gnmiClient.Set(context.Background(), gpbSetRequest); err != nil {
t.Fatalf("Unexpected error updating SRL static-route tag-set: %v", err)
}
default:
t.Fatalf("Unsupported vendor %s for deviation 'EnableTableConnections'", d.Vendor())
}
}
2 changes: 1 addition & 1 deletion proto/metadata.proto
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ message Metadata {
// EnableMultipathUnderAfiSafi returns true for devices that do not support multipath under /global path and instead support under global/afi/safi path
// CISCO: b/376241033
// CISCO: b/340859662
bool enable_multipath_under_afi_safi = 230;
bool enable_multipath_under_afi_safi = 230;
// Device have different default value for allow own as.
// Juniper : b/373559004
bool bgp_allowownas_diff_default_value = 231;
Expand Down

0 comments on commit 3a3d098

Please sign in to comment.