diff --git a/feature/bgp/policybase/otg_tests/multipath_bgp_ecmp_protocol_nexthop/multipath_bgp_ecmp_protocol_nexthop_test.go b/feature/bgp/policybase/otg_tests/multipath_bgp_ecmp_protocol_nexthop/multipath_bgp_ecmp_protocol_nexthop_test.go index 80801b24c17..f8ba43a1226 100644 --- a/feature/bgp/policybase/otg_tests/multipath_bgp_ecmp_protocol_nexthop/multipath_bgp_ecmp_protocol_nexthop_test.go +++ b/feature/bgp/policybase/otg_tests/multipath_bgp_ecmp_protocol_nexthop/multipath_bgp_ecmp_protocol_nexthop_test.go @@ -15,6 +15,7 @@ package multipath_bgp_ecmp_protocol_nexthop_test import ( "fmt" + "math/rand" "strconv" "testing" "time" @@ -139,8 +140,8 @@ const ( trafficPps = 10000 packetSize = 1500 peerGrpName1 = "BGP-PEER-GROUP1" - lossTolerancePct = 0 // Packet loss tolerance in percentage - lbToleranceFms = 20 // Load Balance Tolerance in percentage + lossTolerancePct = 0.5 // Packet loss tolerance in percentage + lbToleranceFms = 20 // Load Balance Tolerance in percentage rplType = oc.RoutingPolicy_PolicyResultType_ACCEPT_ROUTE rplName = "ALLOW" ) @@ -660,16 +661,16 @@ func configureOTG(t *testing.T, otg *otg.OTG) gosnappi.Config { ipHeader.Src().SetValue(tc.srcIP) ipHeader.Dst().Increment().SetStart(tc.dstIP).SetCount(100) udpHeader := flow.Packet().Add().Udp() - udpHeader.SrcPort().SetValue(14) - udpHeader.DstPort().Increment().SetStart(1024).SetCount(10000) + udpHeader.SrcPort().SetValues(randRange(1024, 65535, 1000)) + udpHeader.DstPort().SetValues(randRange(1024, 65535, 1000)) case "ipv6": flow.TxRx().Device().SetTxNames([]string{iDut1Ipv6.Name()}).SetRxNames(rxIpv6IntfNames) ipHeader := flow.Packet().Add().Ipv6() ipHeader.Src().SetValue(tc.srcIP) ipHeader.Dst().Increment().SetStart(tc.dstIP).SetCount(100) udpHeader := flow.Packet().Add().Udp() - udpHeader.SrcPort().SetValue(14) - udpHeader.DstPort().Increment().SetStart(1024).SetCount(10000) + udpHeader.SrcPort().SetValues(randRange(1024, 65535, 1000)) + udpHeader.DstPort().SetValues(randRange(1024, 65535, 1000)) } flow.Size().SetFixed(uint32(packetSize)) flow.Rate().SetPps(trafficPps) @@ -799,3 +800,13 @@ func verifyECMPLoadBalance(t *testing.T, ate *ondatra.ATEDevice, pc int, expecte } } } + +func randRange(start, end uint32, count int) []uint32 { + var result []uint32 + diff := int32(end - start) + for len(result) < count { + randomValue := rand.Int31n(diff) + int32(start) + result = append(result, uint32(randomValue)) + } + return result +}