Skip to content

Commit

Permalink
Addressing review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
s-nandu committed Dec 12, 2024
1 parent 2b5cf72 commit acc2969
Show file tree
Hide file tree
Showing 4 changed files with 142 additions and 177 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package import_export_multi_test

import (
"context"
"fmt"
"strconv"
"strings"
Expand All @@ -28,6 +29,7 @@ import (
"github.com/openconfig/featureprofiles/internal/fptest"
"github.com/openconfig/featureprofiles/internal/helpers"
"github.com/openconfig/featureprofiles/internal/otgutils"
gpb "github.com/openconfig/gnmi/proto/gnmi"
"github.com/openconfig/ondatra"
"github.com/openconfig/ondatra/gnmi"
"github.com/openconfig/ondatra/gnmi/oc"
Expand Down Expand Up @@ -450,7 +452,11 @@ func configureImportExportMultifacetMatchActionsBGPPolicy(t *testing.T, dut *ond
}

// Configure my_aspath: [ "65512" ] to match_aspath_set_med statement
if !deviations.BgpAspathsetUnsupported(dut) {
if deviations.BgpAspathsetUnsupported(dut) {
configureAsPolicy(t, dut)
stmt5.GetOrCreateConditions().SetCallPolicy("multiPolicy-native")

} else {
myAspath := rp.GetOrCreateDefinedSets().GetOrCreateBgpDefinedSets().GetOrCreateAsPathSet(myAsPathName)
myAspath.SetAsPathSetMember([]string{strconv.Itoa(int(cfgplugins.AteAS2))})

Expand All @@ -459,7 +465,6 @@ func configureImportExportMultifacetMatchActionsBGPPolicy(t *testing.T, dut *ond
}
// Configure set-med 100
stmt5.GetOrCreateActions().GetOrCreateBgpActions().SetMed = oc.UnionUint32(medValue)

stmt5.GetOrCreateActions().SetPolicyResult(oc.RoutingPolicy_PolicyResultType_ACCEPT_ROUTE)

if deviations.CommunityMemberRegexUnsupported(dut) {
Expand Down Expand Up @@ -859,6 +864,60 @@ func validateOTGBgpPrefixV4AndASLocalPrefMED(t *testing.T, otg *otg.OTG, dut *on
}
}

// configureAsPolicy is used to configure vendor specific config statement.
func configureAsPolicy(t *testing.T, dut *ondatra.DUTDevice) {
t.Helper()
var config string
gnmiClient := dut.RawAPIs().GNMI(t)

switch dut.Vendor() {
case ondatra.JUNIPER:
config = juniperCLI()
t.Logf("Push the CLI config:%s", dut.Vendor())
}

gpbSetRequest, err := buildCliConfigRequest(config)
if err != nil {
t.Fatalf("Cannot build a gNMI SetRequest: %v", err)
}

if _, err = gnmiClient.Set(context.Background(), gpbSetRequest); err != nil {
t.Fatalf("gnmiClient.Set() with unexpected error: %v", err)
}
}

// Build config with Origin set to cli and Ascii encoded config.
func buildCliConfigRequest(config string) (*gpb.SetRequest, error) {
gpbSetRequest := &gpb.SetRequest{
Update: []*gpb.Update{{
Path: &gpb.Path{
Origin: "cli",
Elem: []*gpb.PathElem{},
},
Val: &gpb.TypedValue{
Value: &gpb.TypedValue_AsciiVal{
AsciiVal: config,
},
},
}},
}
return gpbSetRequest, nil
}

// juniperCLI returns Juniper CLI config statement.
func juniperCLI() string {
return fmt.Sprintf(`
policy-options {
policy-statement %s-native {
term %s {
from as-path test1;
then accept;
}
}
as-path test1 ".*65512.*";
}`, parentPolicy, matchAspathSetMedStatement)
}

// TestImportExportMultifacetMatchActionsBGPPolicy covers RT-7.11
func TestImportExportMultifacetMatchActionsBGPPolicy(t *testing.T) {
dut := ondatra.DUT(t, "dut")
Expand Down
9 changes: 5 additions & 4 deletions internal/deviations/deviations.go
Original file line number Diff line number Diff line change
Expand Up @@ -1218,10 +1218,6 @@ func CiscoPreFECBERInactiveValue(dut *ondatra.DUTDevice) bool {
return lookupDUTDeviations(dut).GetCiscoPreFecBerInactiveValue()
}

// BgpAspathsetUnsupported returns true if as-path-set for bgp-defined-sets is unsupported
func BgpAspathsetUnsupported(dut *ondatra.DUTDevice) bool {
return lookupDUTDeviations(dut).GetBgpAspathsetUnsupported()

// BgpExtendedNextHopEncodingLeafUnsupported return true if bgp extended next hop encoding leaf is unsupported
// Cisco supports the extended nexthop encoding set to true by default that is excercised in the Script where the extended-nexthop-encoding
// a bool value is set to true.
Expand All @@ -1247,3 +1243,8 @@ func EnableTableConnections(dut *ondatra.DUTDevice) bool {
func NoZeroSuppression(dut *ondatra.DUTDevice) bool {
return lookupDUTDeviations(dut).GetNoZeroSuppression()
}

// BgpAspathsetUnsupported returns true if as-path-set for bgp-defined-sets is unsupported
func BgpAspathsetUnsupported(dut *ondatra.DUTDevice) bool {
return lookupDUTDeviations(dut).GetBgpAspathsetUnsupported()
}
8 changes: 4 additions & 4 deletions proto/metadata.proto
Original file line number Diff line number Diff line change
Expand Up @@ -647,10 +647,6 @@ message Metadata {
bool otn_channel_assignment_cisco_numbering = 232;
// Cisco pre-fec-ber inactive value for CISCO-ACACIA vendors
bool cisco_pre_fec_ber_inactive_value = 233;
// bgp_aspathset_unsupported is set to true for devices that do not support as-path-set for bgp-defined-sets.
// Juniper: b/330173167
bool bgp_aspathset_unsupported = 234;

// Device does not support bgp extended next hop encoding leaf.
// Cisco: b/377433951
bool bgp_extended_next_hop_encoding_leaf_unsupported = 234;
Expand All @@ -662,6 +658,10 @@ message Metadata {
// Device has default zero suppression.
// Juniper : b/378646018
bool no_zero_suppression = 237;
// bgp_aspathset_unsupported is set to true for devices that do not support as-path-set for bgp-defined-sets.
// Juniper: b/330173167
bool bgp_aspathset_unsupported = 238;

// 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 acc2969

Please sign in to comment.