From ab49a87365ed49a6b70cd250981ffd93e3e8e7ad Mon Sep 17 00:00:00 2001 From: bkreddy143 Date: Thu, 16 Nov 2023 11:18:06 -0800 Subject: [PATCH] adding loop to in MED verification to give sufficient time for MED change after config modification Also made OTG tests inline ATE tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- .../bgp_always_compare_med_test.go | 17 ++++++++++--- .../bgp_always_compare_med_test.go | 25 +++++++++++++++---- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/feature/experimental/bgp/ate_tests/bgp_always_compare_med/bgp_always_compare_med_test.go b/feature/experimental/bgp/ate_tests/bgp_always_compare_med/bgp_always_compare_med_test.go index a47e8dfbed32..7409fee31524 100644 --- a/feature/experimental/bgp/ate_tests/bgp_always_compare_med/bgp_always_compare_med_test.go +++ b/feature/experimental/bgp/ate_tests/bgp_always_compare_med/bgp_always_compare_med_test.go @@ -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) + } } } diff --git a/feature/experimental/bgp/otg_tests/bgp_always_compare_med/bgp_always_compare_med_test.go b/feature/experimental/bgp/otg_tests/bgp_always_compare_med/bgp_always_compare_med_test.go index da00ed71614c..90ef00fa6b14 100644 --- a/feature/experimental/bgp/otg_tests/bgp_always_compare_med/bgp_always_compare_med_test.go +++ b/feature/experimental/bgp/otg_tests/bgp_always_compare_med/bgp_always_compare_med_test.go @@ -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" @@ -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. @@ -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)