From 3a3d098154cca23fcfca63ee40a3b461dcb206ba Mon Sep 17 00:00:00 2001 From: snaragund <168457653+snaragund@users.noreply.github.com> Date: Fri, 27 Dec 2024 08:55:01 +0530 Subject: [PATCH] RT-1.28: Fixed script with added deviations (#3567) * 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 f41b14ae757fc5367b892b30427150bcb4612744. * -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 Co-authored-by: Tushar Rathod <111466464+trathod1@users.noreply.github.com> --- .../bgp_isis_redistribution_test.go | 46 +++++++++---- .../metadata.textproto | 11 ++++ internal/deviations/deviations.go | 10 +-- internal/fptest/tableconnection.go | 66 +++++++++++++++++++ proto/metadata.proto | 2 +- 5 files changed, 115 insertions(+), 20 deletions(-) create mode 100644 internal/fptest/tableconnection.go diff --git a/feature/bgp/bgp_isis_redistribution/otg_tests/bgp_isis_redistribution_test/bgp_isis_redistribution_test.go b/feature/bgp/bgp_isis_redistribution/otg_tests/bgp_isis_redistribution_test/bgp_isis_redistribution_test.go index c54fe7f044d..b9a95fce876 100644 --- a/feature/bgp/bgp_isis_redistribution/otg_tests/bgp_isis_redistribution_test/bgp_isis_redistribution_test.go +++ b/feature/bgp/bgp_isis_redistribution/otg_tests/bgp_isis_redistribution_test/bgp_isis_redistribution_test.go @@ -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) { @@ -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) { @@ -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) @@ -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) } } @@ -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)) @@ -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) { @@ -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) { @@ -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) @@ -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) } } @@ -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)) @@ -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) { @@ -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) { diff --git a/feature/bgp/bgp_isis_redistribution/otg_tests/bgp_isis_redistribution_test/metadata.textproto b/feature/bgp/bgp_isis_redistribution/otg_tests/bgp_isis_redistribution_test/metadata.textproto index 7c29f99bbfa..a3769f0ac2c 100644 --- a/feature/bgp/bgp_isis_redistribution/otg_tests/bgp_isis_redistribution_test/metadata.textproto +++ b/feature/bgp/bgp_isis_redistribution/otg_tests/bgp_isis_redistribution_test/metadata.textproto @@ -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 + } +} diff --git a/internal/deviations/deviations.go b/internal/deviations/deviations.go index fb8797c656d..2d34420d438 100644 --- a/internal/deviations/deviations.go +++ b/internal/deviations/deviations.go @@ -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() @@ -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() +} diff --git a/internal/fptest/tableconnection.go b/internal/fptest/tableconnection.go new file mode 100644 index 00000000000..258f48a5acc --- /dev/null +++ b/internal/fptest/tableconnection.go @@ -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()) + } +} diff --git a/proto/metadata.proto b/proto/metadata.proto index 29957c9d35d..7b6318bc66b 100644 --- a/proto/metadata.proto +++ b/proto/metadata.proto @@ -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;