Skip to content

Commit

Permalink
adding loop to in MED verification to give sufficient time for MED ch…
Browse files Browse the repository at this point in the history
…ange after config modification

Also made OTG tests inline ATE tests

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.
  • Loading branch information
bkreddy143 committed Nov 16, 2023
1 parent af94fcf commit ab49a87
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -411,9 +411,20 @@ func verifySetMed(t *testing.T, dut *ondatra.DUTDevice, ate *ondatra.ATEDevice,
wantMED = append(wantMED, uint32(wantMEDValue))
}

gotMED := gnmi.GetAll(t, ate, rib.AttrSetAny().Med().State())
if diff := cmp.Diff(wantMED, gotMED); diff != "" {
t.Errorf("Obtained MED on ATE is not as expected, got %v, want %v", gotMED, wantMED)
checkMEDLoop:
for repeat := 10; repeat > 0; repeat-- {
gotMED := gnmi.GetAll(t, ate, rib.AttrSetAny().Med().State())
diff := cmp.Diff(wantMED, gotMED)
switch {
case diff == "":
t.Logf("MED values are as expected")
break checkMEDLoop
case diff != "" && repeat > 0:
t.Logf("MED values not as expected , wait for 10 sec before retry. want %v , got %v", wantMED, gotMED)
time.Sleep(10 * time.Second)
case diff != "" && repeat == 0:
t.Errorf("MED values are not as expected. want %v, got %v", gotMED, wantMED)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"testing"
"time"

"github.com/google/go-cmp/cmp"
"github.com/open-traffic-generator/snappi/gosnappi"
"github.com/openconfig/featureprofiles/internal/attrs"
"github.com/openconfig/featureprofiles/internal/deviations"
Expand Down Expand Up @@ -487,12 +488,27 @@ func verifySetMed(t *testing.T, otg *otg.OTG, config gosnappi.Config, wantMEDVal
}

// compare Med val with expected for each of the recieved routes.
for _, prefix := range bgpPrefixes {
if prefix.GetMultiExitDiscriminator() != wantMEDValue {
t.Errorf("Received Prefix Med %d Expected Med %d for Prefix %v", prefix.GetMultiExitDiscriminator(), wantMEDValue, prefix.GetAddress())
wantMED := []uint32{}
for i := 0; i < routeCount; i++ {
wantMED = append(wantMED, uint32(wantMEDValue))
}

checkMEDLoop:
for repeat := 10; repeat > 0; repeat-- {
gotMED := gnmi.GetAll(t, otg, gnmi.OTG().BgpPeer(ateSrc.Name+".BGP4.peer").UnicastIpv4PrefixAny().MultiExitDiscriminator().State())
diff := cmp.Diff(wantMED, gotMED)
switch {
case diff == "":
t.Logf("MED values are as expected")
break checkMEDLoop
case diff != "" && repeat > 0:
t.Logf("MED values not as expected , wait for 10 sec before retry. want %v , got %v", wantMED, gotMED)
time.Sleep(10 * time.Second)
case diff != "" && repeat == 0:
t.Errorf("MED values are not as expected. want %v, got %v", gotMED, wantMED)
}
}
t.Logf("Received Prefixes are verified for Proper MED value %d", wantMEDValue)

}

// verifyBGPCapabilities is used to Verify BGP capabilities like route refresh as32 and mpbgp.
Expand Down Expand Up @@ -629,7 +645,6 @@ func TestAlwaysCompareMED(t *testing.T) {
}

})

t.Run("Verify MED on received routes at ATE Port1 after removing MED settings", func(t *testing.T) {
t.Log("Verify BGP prefix telemetry.")
verifyPrefixesTelemetry(t, dut, 0, routeCount)
Expand Down

0 comments on commit ab49a87

Please sign in to comment.