Skip to content

Commit

Permalink
Merge branch 'main' into jianchen-g/OC_github
Browse files Browse the repository at this point in the history
  • Loading branch information
Ankur19 authored Jan 2, 2025
2 parents ae7f698 + 08ad546 commit 8e22162
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func TestBgpSession(t *testing.T) {
configureRegexPolicy(t, dut)

d := &oc.Root{}
rpl := configureBGPPolicy(t, d, tc.nbr.isV4)
rpl := configureBGPPolicy(t, d, tc.nbr.isV4, dut)
gnmi.Replace(t, dut, gnmi.OC().RoutingPolicy().Config(), rpl)

t.Log("Configure BGP on DUT")
Expand Down Expand Up @@ -259,7 +259,7 @@ func configureRegexPolicy(t *testing.T, dut *ondatra.DUTDevice) {

// configureBGPPolicy configures a BGP routing policy to accept or reject routes based on prefix match conditions
// Additonally, it also configures policy to match prefix based on community and regex for as path
func configureBGPPolicy(t *testing.T, d *oc.Root, isV4 bool) *oc.RoutingPolicy {
func configureBGPPolicy(t *testing.T, d *oc.Root, isV4 bool, dut *ondatra.DUTDevice) *oc.RoutingPolicy {
t.Helper()
rp := d.GetOrCreateRoutingPolicy()
pset := rp.GetOrCreateDefinedSets().GetOrCreatePrefixSet(rejectPrefix)
Expand Down Expand Up @@ -299,7 +299,11 @@ func configureBGPPolicy(t *testing.T, d *oc.Root, isV4 bool) *oc.RoutingPolicy {
t.Errorf("Error while creating new statement %v", err)
}
stmt50.GetOrCreateActions().PolicyResult = oc.RoutingPolicy_PolicyResultType_REJECT_ROUTE
stmt50.GetOrCreateConditions().GetOrCreateBgpConditions().CommunitySet = ygot.String(communitySet)
if deviations.BGPConditionsMatchCommunitySetUnsupported(dut) {
stmt50.GetOrCreateConditions().GetOrCreateBgpConditions().SetCommunitySet(communitySet)
} else {
stmt50.GetOrCreateConditions().GetOrCreateBgpConditions().GetOrCreateMatchCommunitySet().SetCommunitySet(communitySet)
}

stmt60, err := pdefComm.AppendNewStatement(aclStatement4)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ platform_exceptions: {
}
deviations: {
ipv4_missing_enabled: true
bgp_conditions_match_community_set_unsupported: true
}
}
platform_exceptions: {
Expand All @@ -21,6 +22,7 @@ platform_exceptions: {
explicit_port_speed: true
explicit_interface_in_default_vrf: true
interface_enabled: true
bgp_conditions_match_community_set_unsupported: true
}
}
platform_exceptions: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,7 @@ func isisImportPolicyConfig(t *testing.T, dut *ondatra.DUTDevice, policyName str
tableConn.SetDisableMetricPropagation(metricPropagation)
}
if deviations.EnableTableConnections(dut) {
state := "enable"
configEnableTbNative(t, dut, state)
fptest.ConfigEnableTbNative(t, dut)
}
gnmi.BatchReplace(batchSet, gnmi.OC().NetworkInstance(dni).TableConnection(srcProto, dstProto, addfmly).Config(), tableConn)

Expand Down Expand Up @@ -375,46 +374,6 @@ func getTagSetName(dut *ondatra.DUTDevice, policyName, stmtName, afStr string) s
return fmt.Sprintf("tag-set-%s", afStr)
}

func configEnableTbNative(t testing.TB, d *ondatra.DUTDevice, state string) {
t.Helper()
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())
}
}

func TestStaticToISISRedistribution(t *testing.T) {
var ts *isissession.TestSession

Expand Down

0 comments on commit 8e22162

Please sign in to comment.