Skip to content

Commit

Permalink
MGT-1 Add vendor changes (openconfig#2898)
Browse files Browse the repository at this point in the history
* Add vendor changes
- Add createInterfaces() to ensure interfaces are created prior to assigning to VRF
- Remove setNoPeerGroup / conditional statement
- Enabled BGP global AFISAFI to BGP configs (REF: openconfig#2420)
- Added 3s sleep for Port2 test to ensure AFTs update
- Add 2 deviations SetRoutePrefNative, TableConnectionsUnsupported
- Changed BatchReplace to BatchUpdate to ensure route redistribution policy remains.

"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."

* Remove Deviation for nativepreference
"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."

* remove dev from metadata.textproto
"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."

* Fixed typo in deviation function
“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
MarcCharlebois authored and ANISH-GOTTAPU committed Jul 10, 2024
1 parent 02b4901 commit 29ef819
Show file tree
Hide file tree
Showing 5 changed files with 131 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ var (
mgmtVRF = "mgmtvrf1"
bgpPorts = []string{"port1", "port2"}

setNoPeerGroup = true
lossTolerance = float64(1)
lossTolerance = float64(1)
)

func TestMain(m *testing.M) {
Expand All @@ -71,7 +70,7 @@ func TestManagementHA1(t *testing.T) {
p3 := dut.Port(t, "port3")
p4 := dut.Port(t, "port4")
loopbackIntfName := netutil.LoopbackInterface(t, dut, 1)

createInterfaces(t, dut, []string{p1.Name(), p2.Name(), p3.Name(), p4.Name(), loopbackIntfName})
addInterfacesToVRF(t, dut, mgmtVRF, []string{p1.Name(), p2.Name(), p3.Name(), p4.Name(), loopbackIntfName})

bs := cfgplugins.NewBGPSession(t, cfgplugins.PortCount4, &mgmtVRF)
Expand All @@ -82,8 +81,7 @@ func TestManagementHA1(t *testing.T) {
true,
true,
)

if setNoPeerGroup {
if deviations.SetNoPeerGroup(dut) {
bs.DUTConf.GetOrCreateNetworkInstance(mgmtVRF).GetOrCreateProtocol(cfgplugins.PTBGP, "BGP").GetOrCreateBgp().PeerGroup = nil
neighbors := bs.DUTConf.GetOrCreateNetworkInstance(mgmtVRF).GetOrCreateProtocol(cfgplugins.PTBGP, "BGP").GetOrCreateBgp().Neighbor
for _, neighbor := range neighbors {
Expand All @@ -93,9 +91,11 @@ func TestManagementHA1(t *testing.T) {

configureEmulatedNetworks(bs)

bs.DUTConf.GetOrCreateNetworkInstance(deviations.DefaultNetworkInstance(dut)).GetOrCreateProtocol(cfgplugins.PTBGP, "BGP").GetOrCreateBgp().GetOrCreateGlobal().SetAs(dutAS)
bs.DUTConf.GetOrCreateNetworkInstance(mgmtVRF).SetRouteDistinguisher(fmt.Sprintf("%d:%d", dutAS, 100))

bs.DUTConf.GetOrCreateNetworkInstance(mgmtVRF).GetOrCreateProtocol(cfgplugins.PTBGP, "BGP").GetOrCreateBgp().GetOrCreateGlobal().SetAs(dutAS)
if dut.Vendor() != ondatra.NOKIA {
bs.DUTConf.GetOrCreateNetworkInstance(mgmtVRF).SetRouteDistinguisher(fmt.Sprintf("%d:%d", dutAS, 100))
}
bs.DUTConf.GetOrCreateNetworkInstance(mgmtVRF).GetOrCreateProtocol(cfgplugins.PTBGP, "BGP").GetOrCreateBgp().GetOrCreateGlobal().GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST).Enabled = ygot.Bool(true)
bs.PushAndStart(t)
if verfied := verifyDUTBGPEstablished(t, bs.DUT, mgmtVRF); verfied {
t.Log("DUT BGP sessions established")
Expand All @@ -105,9 +105,9 @@ func TestManagementHA1(t *testing.T) {
cfgplugins.VerifyOTGBGPEstablished(t, bs.ATE)

configureLoopbackOnDUT(t, bs.DUT)
advertiseDUTLoopbackToATE(t, bs.DUT)
advertiseDUTLoopbackToATE(t, bs.DUT, bs)
configureStaticRoute(t, bs.DUT, bs.ATEPorts[2].IPv6)
configureImportExportBGPPolicy(t, bs)
configureImportExportBGPPolicy(t, bs, dut)

t.Run("traffic received by port1 or port2", func(t *testing.T) {
createFlowV6(t, bs)
Expand All @@ -127,6 +127,7 @@ func TestManagementHA1(t *testing.T) {
createFlowV6(t, bs)
gnmi.Replace(t, dut, gnmi.OC().Interface(p1.Name()).Enabled().Config(), false)
gnmi.Await(t, dut, gnmi.OC().Interface(p1.Name()).AdminStatus().State(), 30*time.Second, oc.Interface_AdminStatus_DOWN)
time.Sleep(3 * time.Second)
bs.ATE.OTG().StartTraffic(t)
time.Sleep(30 * time.Second)
bs.ATE.OTG().StopTraffic(t)
Expand Down Expand Up @@ -242,6 +243,19 @@ func configureLoopbackOnDUT(t *testing.T, dut *ondatra.DUTDevice) {
t.Logf("Got DUT IPv6 loopback address: %v", dutlo0Attrs.IPv6)
}

func createInterfaces(t *testing.T, dut *ondatra.DUTDevice, intfNames []string) {
root := &oc.Root{}
for _, intfName := range intfNames {
i := root.GetOrCreateInterface(intfName)
if intfName == netutil.LoopbackInterface(t, dut, 1) {
i.Type = oc.IETFInterfaces_InterfaceType_softwareLoopback
}
si := i.GetOrCreateSubinterface(0)
si.Enabled = ygot.Bool(true)
gnmi.Update(t, dut, gnmi.OC().Interface(intfName).Config(), i)
}
}

func addInterfacesToVRF(t *testing.T, dut *ondatra.DUTDevice, vrfname string, intfNames []string) {
root := &oc.Root{}
mgmtNI := root.GetOrCreateNetworkInstance(vrfname)
Expand Down Expand Up @@ -270,7 +284,7 @@ func verifyDUTBGPEstablished(t *testing.T, dut *ondatra.DUTDevice, ni string) bo
return true
}

func advertiseDUTLoopbackToATE(t *testing.T, dut *ondatra.DUTDevice) {
func advertiseDUTLoopbackToATE(t *testing.T, dut *ondatra.DUTDevice, bs *cfgplugins.BGPSession) {
t.Helper()

batchSet := &gnmi.SetBatch{}
Expand All @@ -285,31 +299,45 @@ func advertiseDUTLoopbackToATE(t *testing.T, dut *ondatra.DUTDevice) {
stmt.GetOrCreateActions().SetPolicyResult(oc.RoutingPolicy_PolicyResultType_ACCEPT_ROUTE)

prefixSet := rp.GetOrCreateDefinedSets().GetOrCreatePrefixSet("ps")
prefixSet.SetMode(oc.PrefixSet_Mode_IPV6)
if !deviations.SkipPrefixSetMode(dut) {
prefixSet.SetMode(oc.PrefixSet_Mode_IPV6)
}
prefixSet.GetOrCreatePrefix(dutlo0Attrs.IPv6CIDR(), "exact")

if !deviations.SkipSetRpMatchSetOptions(dut) {
stmt.GetOrCreateConditions().GetOrCreateMatchPrefixSet().SetMatchSetOptions(oc.RoutingPolicy_MatchSetOptionsRestrictedType_ANY)
}
stmt.GetOrCreateConditions().GetOrCreateMatchPrefixSet().SetPrefixSet("ps")
gnmi.BatchUpdate(batchSet, gnmi.OC().RoutingPolicy().Config(), rp)

tableConn := root.GetOrCreateNetworkInstance(mgmtVRF).GetOrCreateTableConnection(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_DIRECTLY_CONNECTED, oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, oc.Types_ADDRESS_FAMILY_IPV6)
if !deviations.SkipSettingDisableMetricPropagation(dut) {
tableConn.SetDisableMetricPropagation(false)
}
tableConn.SetDefaultImportPolicy(oc.RoutingPolicy_DefaultPolicyType_REJECT_ROUTE)
tableConn.SetImportPolicy([]string{"rp"})
gnmi.BatchUpdate(batchSet, gnmi.OC().NetworkInstance(mgmtVRF).TableConnection(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_DIRECTLY_CONNECTED, oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, oc.Types_ADDRESS_FAMILY_IPV6).Config(), tableConn)
gnmi.BatchUpdate(batchSet, gnmi.OC().RoutingPolicy().Config(), rp)
batchSet.Set(t, dut)
if deviations.TableConnectionsUnsupported(dut) {
stmt.GetOrCreateConditions().SetInstallProtocolEq(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_DIRECTLY_CONNECTED)
stmt.GetOrCreateActions().PolicyResult = oc.RoutingPolicy_PolicyResultType_ACCEPT_ROUTE
for _, neighbor := range []string{bs.ATEPorts[0].IPv6, bs.ATEPorts[1].IPv6} {
pathV6 := gnmi.OC().NetworkInstance(mgmtVRF).Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "BGP").Bgp().Neighbor(neighbor).AfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV6_UNICAST).ApplyPolicy()
policyV6 := root.GetOrCreateNetworkInstance(mgmtVRF).GetOrCreateProtocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "BGP").GetOrCreateBgp().GetOrCreateNeighbor(neighbor).GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV6_UNICAST).GetOrCreateApplyPolicy()
policyV6.SetExportPolicy([]string{"rp"})
gnmi.BatchUpdate(batchSet, pathV6.Config(), policyV6)
}
} else {
tableConn := root.GetOrCreateNetworkInstance(mgmtVRF).GetOrCreateTableConnection(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_DIRECTLY_CONNECTED, oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, oc.Types_ADDRESS_FAMILY_IPV6)
if !deviations.SkipSettingDisableMetricPropagation(dut) {
tableConn.SetDisableMetricPropagation(false)
}
tableConn.SetDefaultImportPolicy(oc.RoutingPolicy_DefaultPolicyType_REJECT_ROUTE)
tableConn.SetImportPolicy([]string{"rp"})
gnmi.BatchUpdate(batchSet, gnmi.OC().NetworkInstance(mgmtVRF).TableConnection(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_DIRECTLY_CONNECTED, oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, oc.Types_ADDRESS_FAMILY_IPV6).Config(), tableConn)

tableConn1 := root.GetOrCreateNetworkInstance(mgmtVRF).GetOrCreateTableConnection(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_DIRECTLY_CONNECTED, oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, oc.Types_ADDRESS_FAMILY_IPV4)
tableConn1.SetImportPolicy([]string{"rp"})
gnmi.BatchUpdate(batchSet, gnmi.OC().NetworkInstance(mgmtVRF).TableConnection(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_DIRECTLY_CONNECTED, oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, oc.Types_ADDRESS_FAMILY_IPV4).Config(), tableConn1)
tableConn1 := root.GetOrCreateNetworkInstance(mgmtVRF).GetOrCreateTableConnection(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_DIRECTLY_CONNECTED, oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, oc.Types_ADDRESS_FAMILY_IPV4)
tableConn1.SetImportPolicy([]string{"rp"})
gnmi.BatchUpdate(batchSet, gnmi.OC().NetworkInstance(mgmtVRF).TableConnection(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_DIRECTLY_CONNECTED, oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, oc.Types_ADDRESS_FAMILY_IPV4).Config(), tableConn1)

batchSet.Set(t, dut)
batchSet.Set(t, dut)
}
}

func configureImportExportBGPPolicy(t *testing.T, bs *cfgplugins.BGPSession) {
func configureImportExportBGPPolicy(t *testing.T, bs *cfgplugins.BGPSession, dut *ondatra.DUTDevice) {
root := &oc.Root{}
batchSet := &gnmi.SetBatch{}

Expand All @@ -322,7 +350,9 @@ func configureImportExportBGPPolicy(t *testing.T, bs *cfgplugins.BGPSession) {
stmt1.GetOrCreateActions().SetPolicyResult(oc.RoutingPolicy_PolicyResultType_ACCEPT_ROUTE)

prefixSet1 := rp.GetOrCreateDefinedSets().GetOrCreatePrefixSet("ps1")
prefixSet1.SetMode(oc.PrefixSet_Mode_IPV6)
if !deviations.SkipPrefixSetMode(dut) {
prefixSet1.SetMode(oc.PrefixSet_Mode_IPV6)
}
prefixSet1.GetOrCreatePrefix(defaultRoute+"/0", "exact")

if !deviations.SkipSetRpMatchSetOptions(bs.DUT) {
Expand All @@ -338,7 +368,9 @@ func configureImportExportBGPPolicy(t *testing.T, bs *cfgplugins.BGPSession) {
stmt2.GetOrCreateActions().SetPolicyResult(oc.RoutingPolicy_PolicyResultType_ACCEPT_ROUTE)

prefixSet2 := rp.GetOrCreateDefinedSets().GetOrCreatePrefixSet("ps2")
prefixSet2.SetMode(oc.PrefixSet_Mode_IPV6)
if !deviations.SkipPrefixSetMode(dut) {
prefixSet2.SetMode(oc.PrefixSet_Mode_IPV6)
}
prefixSet2.GetOrCreatePrefix(dutlo0Attrs.IPv6CIDR(), "exact")

if !deviations.SkipSetRpMatchSetOptions(bs.DUT) {
Expand All @@ -353,7 +385,7 @@ func configureImportExportBGPPolicy(t *testing.T, bs *cfgplugins.BGPSession) {
policyV6 := root.GetOrCreateNetworkInstance(mgmtVRF).GetOrCreateProtocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "BGP").GetOrCreateBgp().GetOrCreateNeighbor(neighbor).GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV6_UNICAST).GetOrCreateApplyPolicy()
policyV6.SetImportPolicy([]string{"importRoutePolicy"})
policyV6.SetExportPolicy([]string{"exportRoutePolicy"})
gnmi.BatchReplace(batchSet, pathV6.Config(), policyV6)
gnmi.BatchUpdate(batchSet, pathV6.Config(), policyV6)
}

batchSet.Set(t, bs.DUT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@ platform_exceptions: {
skip_set_rp_match_set_options: true
skip_setting_disable_metric_propagation: true
set_metric_as_preference: true
set_no_peer_group: true
}
}
platform_exceptions: {
platform: {
vendor: NOKIA
}
deviations: {
interface_enabled: true
static_protocol_name: "static"
skip_set_rp_match_set_options: true
skip_prefix_set_mode: true
table_connections_unsupported: true
}
}
tags: TAGS_TRANSIT
Expand Down
5 changes: 5 additions & 0 deletions internal/deviations/deviations.go
Original file line number Diff line number Diff line change
Expand Up @@ -936,3 +936,8 @@ func SkipBgpSendCommunityType(dut *ondatra.DUTDevice) bool {
func BgpActionsSetCommunityMethodUnsupported(dut *ondatra.DUTDevice) bool {
return lookupDUTDeviations(dut).GetBgpActionsSetCommunityMethodUnsupported()
}

// Ensure that no BGP configurations exists under PeerGroups.
func SetNoPeerGroup(dut *ondatra.DUTDevice) bool {
return lookupDUTDeviations(dut).GetSetNoPeerGroup()
}
2 changes: 2 additions & 0 deletions proto/metadata.proto
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,8 @@ message Metadata {
bool default_import_export_policy = 173;
// Support for bgp actions set-community method
bool bgp_actions_set_community_method_unsupported = 174;
// Ensure no configurations exist under BGP Peer Groups
bool set_no_peer_group = 175;
// Reserved field numbers and identifiers.
reserved 84, 9, 28, 20, 90, 97, 55, 89, 19;
}
Expand Down
Loading

0 comments on commit 29ef819

Please sign in to comment.