Skip to content

Commit

Permalink
Fix BGP policy config to only configure each policy once. (openconfig…
Browse files Browse the repository at this point in the history
…#1909)

* Fix BGP policy config to only configure each policy once.

* Update drained_configuration_convergence_time_bgp_test.go

typo fix
  • Loading branch information
wenovus authored Jul 19, 2023
1 parent 71774d5 commit 0830217
Showing 1 changed file with 18 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,21 @@ const (
bgpMED = 25
)

// setAllow is used to configure ALLOW routing policy on DUT.
func setAllow(t *testing.T, dut *ondatra.DUTDevice, d *oc.Root) {

// Configure Allow Policy on DUT.
rp := d.GetOrCreateRoutingPolicy()
pd := rp.GetOrCreatePolicyDefinition(setALLOWPolicy)
st, err := pd.AppendNewStatement("id-1")
if err != nil {
t.Fatal(err)
}
st.GetOrCreateActions().PolicyResult = oc.RoutingPolicy_PolicyResultType_ACCEPT_ROUTE

gnmi.Replace(t, dut, gnmi.OC().RoutingPolicy().Config(), rp)
}

// setMED is used to configure routing policy to set BGP MED on DUT.
func setMED(t *testing.T, dut *ondatra.DUTDevice, d *oc.Root) {

Expand All @@ -59,14 +74,6 @@ func setMED(t *testing.T, dut *ondatra.DUTDevice, d *oc.Root) {
setMedBGP := actions5.GetOrCreateBgpActions()
setMedBGP.SetMed = oc.UnionUint32(bgpMED)

// Configure Allow policy
pd := rp.GetOrCreatePolicyDefinition(setALLOWPolicy)
st, err := pd.AppendNewStatement("id-1")
if err != nil {
t.Fatal(err)
}
st.GetOrCreateActions().PolicyResult = oc.RoutingPolicy_PolicyResultType_ACCEPT_ROUTE

gnmi.Replace(t, dut, gnmi.OC().RoutingPolicy().Config(), rp)
}

Expand All @@ -86,13 +93,6 @@ func setASPath(t *testing.T, dut *ondatra.DUTDevice, d *oc.Root) {
aspend.Asn = ygot.Uint32(setup.DUTAs)
aspend.RepeatN = ygot.Uint8(asPathRepeatValue)

// Configure Allow policy
pdef := rp.GetOrCreatePolicyDefinition(setALLOWPolicy)
stmt, err = pdef.AppendNewStatement("id-1")
if err != nil {
t.Fatal(err)
}
stmt.GetOrCreateActions().PolicyResult = oc.RoutingPolicy_PolicyResultType_ACCEPT_ROUTE
gnmi.Replace(t, dut, gnmi.OC().RoutingPolicy().Config(), rp)

netInstance := d.GetOrCreateNetworkInstance(deviations.DefaultNetworkInstance(dut))
Expand Down Expand Up @@ -310,6 +310,9 @@ func TestBGPBenchmarking(t *testing.T) {
}
gnmi.Delete(t, dut, gnmi.OC().RoutingPolicy().Config())

t.Logf("Configure Allow policy.")
setAllow(t, dut, d)

t.Logf("Configure MED routing policy.")
setMED(t, dut, d)

Expand Down

0 comments on commit 0830217

Please sign in to comment.