Skip to content

Commit

Permalink
updated bgp util to take input ports to configure bgp (openconfig#2787)
Browse files Browse the repository at this point in the history
  • Loading branch information
self-maurya authored Mar 12, 2024
1 parent 12fba01 commit 0705541
Show file tree
Hide file tree
Showing 8 changed files with 153 additions and 134 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ func (d *dutData) Configure(t *testing.T, dut *ondatra.DUTDevice) {
if !d.ipv4 {
aftType = oc.BgpTypes_AFI_SAFI_TYPE_IPV6_UNICAST
}
bgpOC := cfgplugins.BuildBGPOCConfig(t, dut, d.routerID, aftType, d.neighborConfig)
bgpOC := cfgplugins.BuildBGPOCConfig(t, dut, d.routerID, []oc.E_BgpTypes_AFI_SAFI_TYPE{aftType}, d.neighborConfig)

for _, a := range []attrs.Attributes{dutPort1, dutPort2} {
ocName := dut.Port(t, a.Name).Name()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ const (
bgpName = "BGP"
maskLenExact = "exact"
dummyAS = uint32(64655)
dutAS = uint32(65656)
ateAS = uint32(65657)
dutAS = uint32(64656)
ateAS = uint32(64657)
v4Route = "203.10.113.0"
v4TrafficStart = "203.10.113.1"
v4DummyRoute = "192.51.100.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ func TestBGPSetup(t *testing.T) {

for _, tc := range testCases {
t.Run(tc.desc, func(t *testing.T) {
bs := cfgplugins.NewBGPSession(t, cfgplugins.PortCount4)
bs.WithEBGP(t, oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST, true, !tc.enableMultiAS)
bs := cfgplugins.NewBGPSession(t, cfgplugins.PortCount4, nil)
bs.WithEBGP(t, []oc.E_BgpTypes_AFI_SAFI_TYPE{oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST}, []string{"port2", "port3", "port4"}, true, !tc.enableMultiAS)
dni := deviations.DefaultNetworkInstance(bs.DUT)
bgp := bs.DUTConf.GetOrCreateNetworkInstance(dni).GetOrCreateProtocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "BGP").GetOrCreateBgp()
gEBGP := bgp.GetOrCreateGlobal().GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST).GetOrCreateUseMultiplePaths().GetOrCreateEbgp()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ func verifyECMPLoadBalance(t *testing.T, ate *ondatra.ATEDevice, pc int, expecte
}

func TestBGPSetup(t *testing.T) {
bs := cfgplugins.NewBGPSession(t, cfgplugins.PortCount4)
bs.WithEBGP(t, oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST, true, false)
bs := cfgplugins.NewBGPSession(t, cfgplugins.PortCount4, nil)
bs.WithEBGP(t, []oc.E_BgpTypes_AFI_SAFI_TYPE{oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST}, []string{"port3", "port4"}, true, false)
dni := deviations.DefaultNetworkInstance(bs.DUT)
bgp := bs.DUTConf.GetOrCreateNetworkInstance(dni).GetOrCreateProtocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "BGP").GetOrCreateBgp()
gEBGP := bgp.GetOrCreateGlobal().GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST).GetOrCreateUseMultiplePaths().GetOrCreateEbgp()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package aspath_and_community_test

import (
"sort"
"testing"
"time"

Expand Down Expand Up @@ -139,8 +138,6 @@ func configureOTG(t *testing.T, bs *cfgplugins.BGPSession, prefixesV4 [][]string
}

devices := bs.ATETop.Devices().Items()
byName := func(i, j int) bool { return devices[i].Name() < devices[j].Name() }
sort.Slice(devices, byName)

ipv4 := devices[1].Ethernets().Items()[0].Ipv4Addresses().Items()[0]
bgp4Peer := devices[1].Bgp().Ipv4Interfaces().Items()[0].Peers().Items()[0]
Expand Down Expand Up @@ -243,9 +240,8 @@ func verifyTraffic(t *testing.T, ate *ondatra.ATEDevice, ports int, testResults
func TestCommunitySet(t *testing.T) {
testResults := [5]bool{true, true, true, false, false}

bs := cfgplugins.NewBGPSession(t, cfgplugins.PortCount2)
bs.WithEBGP(t, oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST, true, true)
bs.WithEBGP(t, oc.BgpTypes_AFI_SAFI_TYPE_IPV6_UNICAST, true, true)
bs := cfgplugins.NewBGPSession(t, cfgplugins.PortCount2, nil)
bs.WithEBGP(t, []oc.E_BgpTypes_AFI_SAFI_TYPE{oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST, oc.BgpTypes_AFI_SAFI_TYPE_IPV6_UNICAST}, []string{"port2"}, true, true)

configureOTG(t, bs, prefixesV4, prefixesV6)
bs.PushAndStart(t)
Expand Down
8 changes: 2 additions & 6 deletions feature/bgp/policybase/otg_tests/aspath_test/aspath_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package aspath_test

import (
"sort"
"testing"
"time"

Expand Down Expand Up @@ -91,8 +90,6 @@ func configureImportBGPPolicy(t *testing.T, dut *ondatra.DUTDevice, ipv4 string,

func configureOTG(t *testing.T, bs *cfgplugins.BGPSession, prefixesV4 [][]string, prefixesV6 [][]string, aspathMembers [][]uint32) {
devices := bs.ATETop.Devices().Items()
byName := func(i, j int) bool { return devices[i].Name() < devices[j].Name() }
sort.Slice(devices, byName)

ipv4 := devices[1].Ethernets().Items()[0].Ipv4Addresses().Items()[0]
bgp4Peer := devices[1].Bgp().Ipv4Interfaces().Items()[0].Peers().Items()[0]
Expand Down Expand Up @@ -187,9 +184,8 @@ type testCase struct {
}

func TestCommunitySet(t *testing.T) {
bs := cfgplugins.NewBGPSession(t, cfgplugins.PortCount2)
bs.WithEBGP(t, oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST, true, true)
bs.WithEBGP(t, oc.BgpTypes_AFI_SAFI_TYPE_IPV6_UNICAST, true, true)
bs := cfgplugins.NewBGPSession(t, cfgplugins.PortCount2, nil)
bs.WithEBGP(t, []oc.E_BgpTypes_AFI_SAFI_TYPE{oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST, oc.BgpTypes_AFI_SAFI_TYPE_IPV6_UNICAST}, []string{"port2"}, true, true)

var aspathMembers = [][]uint32{
{100, 200, 300},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package community_test

import (
"sort"
"testing"
"time"

Expand Down Expand Up @@ -97,8 +96,6 @@ func configureImportBGPPolicy(t *testing.T, dut *ondatra.DUTDevice, ipv4 string,

func configureOTG(t *testing.T, bs *cfgplugins.BGPSession, prefixesV4 [][]string, prefixesV6 [][]string, communityMembers [][][]int) {
devices := bs.ATETop.Devices().Items()
byName := func(i, j int) bool { return devices[i].Name() < devices[j].Name() }
sort.Slice(devices, byName)

ipv4 := devices[1].Ethernets().Items()[0].Ipv4Addresses().Items()[0]
bgp4Peer := devices[1].Bgp().Ipv4Interfaces().Items()[0].Peers().Items()[0]
Expand Down Expand Up @@ -201,9 +198,8 @@ type testCase struct {
}

func TestCommunitySet(t *testing.T) {
bs := cfgplugins.NewBGPSession(t, cfgplugins.PortCount2)
bs.WithEBGP(t, oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST, true, true)
bs.WithEBGP(t, oc.BgpTypes_AFI_SAFI_TYPE_IPV6_UNICAST, true, true)
bs := cfgplugins.NewBGPSession(t, cfgplugins.PortCount2, nil)
bs.WithEBGP(t, []oc.E_BgpTypes_AFI_SAFI_TYPE{oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST, oc.BgpTypes_AFI_SAFI_TYPE_IPV6_UNICAST}, []string{"port2"}, true, true)

var communityMembers = [][][]int{
{
Expand Down
Loading

0 comments on commit 0705541

Please sign in to comment.