Skip to content

Commit

Permalink
resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
arvbaska1 committed May 24, 2024
2 parents d751301 + 49a2979 commit d5c6921
Show file tree
Hide file tree
Showing 74 changed files with 2,160 additions and 1,308 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,12 @@ func TestRouteSummaryWithISIS(t *testing.T) {
}).Await(t)

dni := deviations.DefaultNetworkInstance(ts.DUT)
ipv4Entry := gnmi.Get(t, ts.DUT, gnmi.OC().NetworkInstance(dni).Afts().AftSummaries().Ipv4Unicast().Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_ISIS).Counters().AftEntries().State())
if ipv4Entry == 0 {
t.Errorf("ipv4 BGP entries, got: %d, want: %d", ipv4Entry, prefixesCount)
if got, ok := gnmi.Await(t, ts.DUT, gnmi.OC().NetworkInstance(dni).Afts().AftSummaries().Ipv4Unicast().Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_ISIS).Counters().AftEntries().State(), 1*time.Minute, uint64(prefixesCount)).Val(); !ok {
t.Errorf("ipv4 isis entries, got: %d, want: %d", got, prefixesCount)
}

ipv6Entry := gnmi.Get(t, ts.DUT, gnmi.OC().NetworkInstance(dni).Afts().AftSummaries().Ipv6Unicast().Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_ISIS).Counters().AftEntries().State())
if ipv6Entry == 0 {
t.Errorf("ipv6 BGP entries, got: %d, want: %d", ipv6Entry, prefixesCount)
if got, ok := gnmi.Await(t, ts.DUT, gnmi.OC().NetworkInstance(dni).Afts().AftSummaries().Ipv6Unicast().Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_ISIS).Counters().AftEntries().State(), 1*time.Minute, uint64(prefixesCount)).Val(); !ok {
t.Errorf("ipv6 isis entries, got: %d, want: %d", got, prefixesCount)
}
}

Expand Down Expand Up @@ -218,14 +216,12 @@ func TestRouteSummaryWithBGP(t *testing.T) {

dni := deviations.DefaultNetworkInstance(dut)
if tc.dut.ipv4 {
ipv4Entry := gnmi.Get(t, dut, gnmi.OC().NetworkInstance(dni).Afts().AftSummaries().Ipv4Unicast().Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP).Counters().AftEntries().State())
if ipv4Entry == 0 {
t.Errorf("ipv4 BGP entries, got: %d, want: %d", ipv4Entry, prefixesCount)
if got, ok := gnmi.Await(t, dut, gnmi.OC().NetworkInstance(dni).Afts().AftSummaries().Ipv4Unicast().Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP).Counters().AftEntries().State(), 1*time.Minute, uint64(prefixesCount)).Val(); !ok {
t.Errorf("ipv4 BGP entries, got: %d, want: %d", got, prefixesCount)
}
} else {
ipv6Entry := gnmi.Get(t, dut, gnmi.OC().NetworkInstance(dni).Afts().AftSummaries().Ipv6Unicast().Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP).Counters().AftEntries().State())
if ipv6Entry == 0 {
t.Errorf("ipv4 BGP entries, got: %d, want: %d", ipv6Entry, prefixesCount)
if got, ok := gnmi.Await(t, dut, gnmi.OC().NetworkInstance(dni).Afts().AftSummaries().Ipv6Unicast().Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP).Counters().AftEntries().State(), 1*time.Minute, uint64(prefixesCount)).Val(); !ok {
t.Errorf("ipv4 BGP entries, got: %d, want: %d", got, prefixesCount)
}
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,16 @@ Validate BGP in multipath scenario
* /network-instances/network-instance/afts/next-hop-groups/next-hop-group[id=<id>]/state
* /network-instances/network-instance/afts/next-hop-groups/next-hop-group/next-hops

## Protocol/RPC Parameter Coverage
## OpenConfig Path and RPC Coverage

* gNMI
* Set
* Subscribe

```yaml
rpcs:
gnmi:
gNMI.Get:
gNMI.Subscribe:

```

## Required DUT platform

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

"math/rand"

"github.com/open-traffic-generator/snappi/gosnappi"
"github.com/openconfig/featureprofiles/internal/cfgplugins"
"github.com/openconfig/featureprofiles/internal/deviations"
Expand All @@ -37,8 +39,8 @@ const (
prefixesCount = 4
pathID = 1
maxPaths = 2
trafficPps = 1000
totalPackets = 120000
trafficPps = 100000
totalPackets = 12000000
lossTolerancePct = 0
lbToleranceFms = 20
)
Expand Down Expand Up @@ -69,10 +71,24 @@ func configureOTG(t *testing.T, bs *cfgplugins.BGPSession) {
bgp4PeerRoute.AddPath().SetPathId(pathID)
}

configureFlow(bs)
configureFlow(t, bs)
}

func randRange(t *testing.T, start, end uint32, count int) []uint32 {
if count > int(end-start) {
t.Fatal("randRange: count greater than end-start.")
}
rand.New(rand.NewSource(time.Now().UnixNano()))
var result []uint32
for len(result) < count {
diff := end - start
randomValue := rand.Int31n(int32(diff)) + int32(start)
result = append(result, uint32(randomValue))
}
return result
}

func configureFlow(bs *cfgplugins.BGPSession) {
func configureFlow(t *testing.T, bs *cfgplugins.BGPSession) {
bs.ATETop.Flows().Clear()

var rxNames []string
Expand All @@ -91,6 +107,11 @@ func configureFlow(bs *cfgplugins.BGPSession) {
e := flow.Packet().Add().Ethernet()
e.Src().SetValue(bs.ATEPorts[0].MAC)
v4 := flow.Packet().Add().Ipv4()
v4.Src().Increment().SetStart(bs.ATEPorts[0].IPv4).SetCount(prefixesCount)
v4.Dst().Increment().SetStart(prefixesStart).SetCount(prefixesCount)
udp := flow.Packet().Add().Udp()
udp.SrcPort().SetValues(randRange(t, 34525, 65535, 500))
udp.DstPort().SetValues(randRange(t, 49152, 65535, 500))
v4.Src().SetValue(bs.ATEPorts[0].IPv4)
v4.Dst().SetValue(prefixesStart)
}
Expand Down Expand Up @@ -174,15 +195,22 @@ func TestBGPSetup(t *testing.T) {
gEBGP := bgp.GetOrCreateGlobal().GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST).GetOrCreateUseMultiplePaths().GetOrCreateEbgp()
pgUseMulitplePaths := bgp.GetOrCreatePeerGroup(cfgplugins.BGPPeerGroup1).GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST).GetOrCreateUseMultiplePaths()
if tc.enableMultipath {
t.Logf("Enable Multipath")
pgUseMulitplePaths.Enabled = ygot.Bool(true)
t.Logf("Enable Maximum Paths")
gEBGP.MaximumPaths = ygot.Uint32(maxPaths)
}
if tc.enableMultiAS && !deviations.SkipSettingAllowMultipleAS(bs.DUT) {
if tc.enableMultiAS && !deviations.SkipSettingAllowMultipleAS(bs.DUT) && deviations.SkipAfiSafiPathForBgpMultipleAs(bs.DUT) {
t.Logf("Enable MultiAS ")
gEBGP := bgp.GetOrCreateGlobal().GetOrCreateUseMultiplePaths().GetOrCreateEbgp()
gEBGP.AllowMultipleAs = ygot.Bool(true)
}
if tc.enableMultiAS && !deviations.SkipSettingAllowMultipleAS(bs.DUT) && !deviations.SkipAfiSafiPathForBgpMultipleAs(bs.DUT) {
t.Logf("Enable MultiAS ")
gEBGP.AllowMultipleAs = ygot.Bool(true)
}

configureOTG(t, bs)

bs.PushAndStart(t)

t.Logf("Verify DUT BGP sessions up")
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
skip_afi_safi_path_for_bgp_multiple_as: true
}
}
platform_exceptions: {
Expand All @@ -37,3 +38,4 @@ platform_exceptions: {
}
}
tags: TAGS_DATACENTER_EDGE

50 changes: 50 additions & 0 deletions feature/bgp/policybase/otg_tests/community_test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,53 @@ import-policy
* /network-instances/network-instance/protocols/protocol/bgp/neighbors/neighbor/afi-safis/afi-safi/state/prefixes/received-pre-policy
* /network-instances/network-instance/protocols/protocol/bgp/neighbors/neighbor/afi-safis/afi-safi/state/prefixes/received
* /network-instances/network-instance/protocols/protocol/bgp/neighbors/neighbor/afi-safis/afi-safi/state/prefixes/installed

## OpenConfig Path and RPC Coverage

The below yaml defines the OC paths intended to be covered by this test. OC
paths used for test setup are not listed here.

```yaml
paths:
## Config paths
### Policy definition
/routing-policy/policy-definitions/policy-definition/config/name:
/routing-policy/policy-definitions/policy-definition/statements/statement/config/name:
### Policy for community-set match
/routing-policy/defined-sets/bgp-defined-sets/community-sets/community-set/config/community-set-name:
/routing-policy/defined-sets/bgp-defined-sets/community-sets/community-set/config/community-member:
/routing-policy/defined-sets/bgp-defined-sets/community-sets/community-set/config/match-set-options:
/routing-policy/policy-definitions/policy-definition/statements/statement/conditions/bgp-conditions/match-community-set/config/community-set:
/routing-policy/policy-definitions/policy-definition/statements/statement/conditions/bgp-conditions/match-community-set/config/match-set-options:
/routing-policy/policy-definitions/policy-definition/statements/statement/actions/config/policy-result:
/network-instances/network-instance/protocols/protocol/bgp/neighbors/neighbor/afi-safis/afi-safi/apply-policy/config/import-policy:

## State paths
### Policy definition state

/routing-policy/policy-definitions/policy-definition/state/name:
/routing-policy/policy-definitions/policy-definition/statements/statement/state/name:

### Policy for community-set match state

/routing-policy/defined-sets/bgp-defined-sets/community-sets/community-set/state/community-set-name:
/routing-policy/defined-sets/bgp-defined-sets/community-sets/community-set/state/community-member:
/routing-policy/defined-sets/bgp-defined-sets/community-sets/community-set/state/match-set-options:
/routing-policy/policy-definitions/policy-definition/statements/statement/conditions/bgp-conditions/state/community-set:

### Paths to verify policy state

/network-instances/network-instance/protocols/protocol/bgp/neighbors/neighbor/afi-safis/afi-safi/apply-policy/state/export-policy:
/network-instances/network-instance/protocols/protocol/bgp/neighbors/neighbor/afi-safis/afi-safi/apply-policy/state/import-policy:

### Paths to verify prefixes sent and received

/network-instances/network-instance/protocols/protocol/bgp/neighbors/neighbor/afi-safis/afi-safi/state/prefixes/sent:
/network-instances/network-instance/protocols/protocol/bgp/neighbors/neighbor/afi-safis/afi-safi/state/prefixes/received-pre-policy:
/network-instances/network-instance/protocols/protocol/bgp/neighbors/neighbor/afi-safis/afi-safi/state/prefixes/received:
/network-instances/network-instance/protocols/protocol/bgp/neighbors/neighbor/afi-safis/afi-safi/state/prefixes/installed:
rpcs:
gnmi:
gNMI.Set:
gNMI.Subscribe:
```
58 changes: 44 additions & 14 deletions feature/bgp/policybase/otg_tests/community_test/community_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package community_test

import (
"fmt"
"strconv"
"testing"
"time"
Expand All @@ -23,18 +24,21 @@ import (
"github.com/openconfig/featureprofiles/internal/cfgplugins"
"github.com/openconfig/featureprofiles/internal/deviations"
"github.com/openconfig/featureprofiles/internal/fptest"
"github.com/openconfig/featureprofiles/internal/helpers"
"github.com/openconfig/featureprofiles/internal/otgutils"
"github.com/openconfig/ondatra"
"github.com/openconfig/ondatra/gnmi"
"github.com/openconfig/ondatra/gnmi/oc"
)

const (
prefixV4Len = 30
prefixV6Len = 126
trafficPps = 100
totalPackets = 1200
bgpName = "BGP"
prefixV4Len = 30
prefixV6Len = 126
trafficPps = 100
totalPackets = 1200
bgpName = "BGP"
RPLPermitAll = "PERMIT-ALL"
comunitySetNameRegex = "any_my_regex_comms"
)

var prefixesV4 = [][]string{
Expand Down Expand Up @@ -65,24 +69,47 @@ func configureImportBGPPolicy(t *testing.T, dut *ondatra.DUTDevice, ipv4 string,
}
stmt1.GetOrCreateActions().SetPolicyResult(oc.RoutingPolicy_PolicyResultType_ACCEPT_ROUTE)

communitySet := rp.GetOrCreateDefinedSets().GetOrCreateBgpDefinedSets().GetOrCreateCommunitySet(communitySetName)
if !(deviations.CommunityMemberRegexUnsupported(dut) && communitySetName == comunitySetNameRegex) {
communitySet := rp.GetOrCreateDefinedSets().GetOrCreateBgpDefinedSets().GetOrCreateCommunitySet(communitySetName)

cs := []oc.RoutingPolicy_DefinedSets_BgpDefinedSets_CommunitySet_CommunityMember_Union{}
for _, commMatch := range communityMatch {
if commMatch != "" {
cs = append(cs, oc.UnionString(commMatch))
cs := []oc.RoutingPolicy_DefinedSets_BgpDefinedSets_CommunitySet_CommunityMember_Union{}
for _, commMatch := range communityMatch {
if commMatch != "" {
cs = append(cs, oc.UnionString(commMatch))
}
}
communitySet.SetCommunityMember(cs)
communitySet.SetMatchSetOptions(matchSetOptions)
}
var communitySetCLIConfig string
if deviations.CommunityMemberRegexUnsupported(dut) && communitySetName == comunitySetNameRegex {
switch dut.Vendor() {
case ondatra.CISCO:
communitySetCLIConfig = fmt.Sprintf("community-set %v\n ios-regex '10[0-9]:1'\n end-set", communitySetName)
default:
t.Fatalf("Unsupported vendor %s for deviation 'CommunityMemberRegexUnsupported'", dut.Vendor())
}
helpers.GnmiCLIConfig(t, dut, communitySetCLIConfig)
}
communitySet.SetCommunityMember(cs)
communitySet.SetMatchSetOptions(matchSetOptions)

if deviations.BGPConditionsMatchCommunitySetUnsupported(dut) {
stmt1.GetOrCreateConditions().GetOrCreateBgpConditions().SetCommunitySet(communitySetName)
} else {
stmt1.GetOrCreateConditions().GetOrCreateBgpConditions().GetOrCreateMatchCommunitySet().SetCommunitySet(communitySetName)
}
//Add default Permit-all policy along with new policy config
pdAllow := rp.GetOrCreatePolicyDefinition(RPLPermitAll)
st, err := pdAllow.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)
if deviations.CommunityMemberRegexUnsupported(dut) && communitySetName == comunitySetNameRegex {
gnmi.Update(t, dut, gnmi.OC().RoutingPolicy().Config(), rp)
} else {
gnmi.Replace(t, dut, gnmi.OC().RoutingPolicy().Config(), rp)
}

dni := deviations.DefaultNetworkInstance(dut)
pathV6 := gnmi.OC().NetworkInstance(dni).Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, bgpName).Bgp().Neighbor(ipv6).AfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV6_UNICAST).ApplyPolicy()
Expand Down Expand Up @@ -251,7 +278,7 @@ func TestCommunitySet(t *testing.T) {
},
{
desc: "Testing with any_my_regex_comms",
communitySetName: "any_my_regex_comms",
communitySetName: comunitySetNameRegex,
communityMatch: [3]string{"10[0-9]:1"},
matchSetOptions: oc.BgpPolicy_MatchSetOptionsType_ANY,
testResults: [4]bool{true, true, true, false},
Expand All @@ -270,6 +297,9 @@ func TestCommunitySet(t *testing.T) {
}
bs.PushAndStartATE(t)

//Verify BGP session after its reset with OTG push config & start
cfgplugins.VerifyDUTBGPEstablished(t, bs.DUT)

t.Logf("Starting traffic for IPv4 and v6")
bs.ATE.OTG().StartTraffic(t)
time.Sleep(sleepTime * time.Second)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,12 @@ platform_exceptions: {
bgp_conditions_match_community_set_unsupported: true
}
}
platform_exceptions: {
platform: {
vendor: CISCO
}
deviations: {
bgp_conditions_match_community_set_unsupported: true
community_member_regex_unsupported: true
}
}
Loading

0 comments on commit d5c6921

Please sign in to comment.