Skip to content

Commit

Permalink
Configure NI name whenever configuring type (openconfig#2066)
Browse files Browse the repository at this point in the history
* Use update for ni

* fixed missing otg tests

* added missing pbf config

* sync otg

* Added function for default NI configuration

* removed unrelated changes

---------

Co-authored-by: anksaiki <[email protected]>
Co-authored-by: guoshiuan <[email protected]>
  • Loading branch information
3 people authored Sep 19, 2023
1 parent 0e3336e commit f230879
Show file tree
Hide file tree
Showing 30 changed files with 55 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,7 @@ func (d *dutData) Configure(t *testing.T, dut *ondatra.DUTDevice) {
}

t.Log("Configure Network Instance")
dutConfNIPath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut))
gnmi.Replace(t, dut, dutConfNIPath.Type().Config(), oc.NetworkInstanceTypes_NETWORK_INSTANCE_TYPE_DEFAULT_INSTANCE)
fptest.ConfigureDefaultNetworkInstance(t, dut)

if deviations.ExplicitPortSpeed(dut) {
for _, a := range []attrs.Attributes{dutPort1, dutPort2} {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,7 @@ func (d *dutData) Configure(t *testing.T, dut *ondatra.DUTDevice) {
}

t.Log("Configure Network Instance")
dutConfNIPath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut))
gnmi.Replace(t, dut, dutConfNIPath.Type().Config(), oc.NetworkInstanceTypes_NETWORK_INSTANCE_TYPE_DEFAULT_INSTANCE)
fptest.ConfigureDefaultNetworkInstance(t, dut)

if deviations.ExplicitPortSpeed(dut) {
for _, a := range []attrs.Attributes{dutPort1, dutPort2} {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,7 @@ func configureDUT(t *testing.T, dut *ondatra.DUTDevice) {
gnmi.Replace(t, dut, dc.Interface(i2.GetName()).Config(), i2)

t.Log("Configure/update Network Instance")
dutConfNIPath := dc.NetworkInstance(deviations.DefaultNetworkInstance(dut))
gnmi.Replace(t, dut, dutConfNIPath.Type().Config(), oc.NetworkInstanceTypes_NETWORK_INSTANCE_TYPE_DEFAULT_INSTANCE)
fptest.ConfigureDefaultNetworkInstance(t, dut)

if deviations.ExplicitPortSpeed(dut) {
fptest.SetPortSpeed(t, dut.Port(t, "port1"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -548,8 +548,7 @@ func TestEstablish(t *testing.T) {

// Configure Network instance type on DUT
t.Log("Configure Network Instance type")
dutConfNIPath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut))
gnmi.Replace(t, dut, dutConfNIPath.Type().Config(), oc.NetworkInstanceTypes_NETWORK_INSTANCE_TYPE_DEFAULT_INSTANCE)
fptest.ConfigureDefaultNetworkInstance(t, dut)

// Configure BGP+Neighbors on the DUT
t.Logf("Start DUT BGP Config")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -596,9 +596,7 @@ func TestEstablish(t *testing.T) {

// Configure Network instance type on DUT.
t.Log("Configure Network Instance type")
dutConfNIPath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut))
gnmi.Replace(t, dut, dutConfNIPath.Type().Config(), oc.NetworkInstanceTypes_NETWORK_INSTANCE_TYPE_DEFAULT_INSTANCE)

fptest.ConfigureDefaultNetworkInstance(t, dut)
// Configure BGP+Neighbors on the DUT.
t.Logf("Start DUT BGP Config")
dutConfPath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut)).Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "BGP")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,7 @@ func configureDUT(t *testing.T, dut *ondatra.DUTDevice) {

// Configure Network instance type on DUT
t.Log("Configure/update Network Instance")
dutConfNIPath := dc.NetworkInstance(deviations.DefaultNetworkInstance(dut))
gnmi.Replace(t, dut, dutConfNIPath.Type().Config(), oc.NetworkInstanceTypes_NETWORK_INSTANCE_TYPE_DEFAULT_INSTANCE)
fptest.ConfigureDefaultNetworkInstance(t, dut)

if deviations.ExplicitPortSpeed(dut) {
fptest.SetPortSpeed(t, dut.Port(t, "port1"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ func configureDUT(t *testing.T, dut *ondatra.DUTDevice) {
gnmi.Replace(t, dut, dc.Interface(p2).Config(), i2)
// Configure Network instance type on DUT
t.Log("Configure/update Network Instance")
dutConfNIPath := dc.NetworkInstance(deviations.DefaultNetworkInstance(dut))
gnmi.Replace(t, dut, dutConfNIPath.Type().Config(), oc.NetworkInstanceTypes_NETWORK_INSTANCE_TYPE_DEFAULT_INSTANCE)
fptest.ConfigureDefaultNetworkInstance(t, dut)

if deviations.ExplicitPortSpeed(dut) {
fptest.SetPortSpeed(t, dut.Port(t, "port1"))
Expand Down
9 changes: 4 additions & 5 deletions feature/bgp/tests/local_bgp_test/local_bgp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,11 @@ func bgpWithNbr(as uint32, routerID string, nbr *oc.NetworkInstance_Protocol_Bgp
}

func configureNIType(t *testing.T) {
dut := ondatra.DUT(t, "dut1")
ate := ondatra.DUT(t, "dut2")
dut1 := ondatra.DUT(t, "dut1")
dut2 := ondatra.DUT(t, "dut2")
// Configure Network instance type on DUT
dutConfNIPath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut))
gnmi.Replace(t, dut, dutConfNIPath.Type().Config(), oc.NetworkInstanceTypes_NETWORK_INSTANCE_TYPE_DEFAULT_INSTANCE)
gnmi.Replace(t, ate, dutConfNIPath.Type().Config(), oc.NetworkInstanceTypes_NETWORK_INSTANCE_TYPE_DEFAULT_INSTANCE)
fptest.ConfigureDefaultNetworkInstance(t, dut1)
fptest.ConfigureDefaultNetworkInstance(t, dut2)
}

// configreRoutePolicy adds route-policy config
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,7 @@ func TestEstablishAndDisconnect(t *testing.T) {

// Configure Network instance type on DUT
t.Log("Configure Network Instance")
dutConfNIPath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut))
gnmi.Replace(t, dut, dutConfNIPath.Type().Config(), oc.NetworkInstanceTypes_NETWORK_INSTANCE_TYPE_DEFAULT_INSTANCE)
fptest.ConfigureDefaultNetworkInstance(t, dut)

t.Log("Configure BGP")
dutConfPath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut)).Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "BGP")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -455,8 +455,7 @@ func TestAlwaysCompareMED(t *testing.T) {

t.Run("Configure DEFAULT network instance", func(t *testing.T) {
t.Log("Configure Network Instance type.")
dutConfNIPath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut))
gnmi.Replace(t, dut, dutConfNIPath.Type().Config(), oc.NetworkInstanceTypes_NETWORK_INSTANCE_TYPE_DEFAULT_INSTANCE)
fptest.ConfigureDefaultNetworkInstance(t, dut)
})

dutConfPath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut)).Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "BGP")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -525,8 +525,7 @@ func TestAlwaysCompareMED(t *testing.T) {

t.Run("Configure DEFAULT network instance", func(t *testing.T) {
t.Log("Configure Network Instance type.")
dutConfNIPath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut))
gnmi.Replace(t, dut, dutConfNIPath.Type().Config(), oc.NetworkInstanceTypes_NETWORK_INSTANCE_TYPE_DEFAULT_INSTANCE)
fptest.ConfigureDefaultNetworkInstance(t, dut)
})

dutConfPath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut)).Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "BGP")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,10 @@ func (s *TestSession) PushDUT(ctx context.Context, t testing.TB) error {
}

// Push the ISIS protocol
if _, err := ygnmi.Replace(ctx, s.DUTClient, ocpath.Root().NetworkInstance(deviations.DefaultNetworkInstance(s.DUT)).Type().Config(), oc.NetworkInstanceTypes_NETWORK_INSTANCE_TYPE_DEFAULT_INSTANCE); err != nil {
if _, err := ygnmi.Update(ctx, s.DUTClient, ocpath.Root().NetworkInstance(deviations.DefaultNetworkInstance(s.DUT)).Config(), &oc.NetworkInstance{
Name: ygot.String(deviations.DefaultNetworkInstance(s.DUT)),
Type: oc.NetworkInstanceTypes_NETWORK_INSTANCE_TYPE_DEFAULT_INSTANCE,
}); err != nil {
return fmt.Errorf("configuring network instance: %w", err)
}
dutConf := s.DUTConf.GetOrCreateNetworkInstance(deviations.DefaultNetworkInstance(s.DUT)).GetOrCreateProtocol(PTISIS, ISISName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,10 @@ func (s *TestSession) PushDUT(ctx context.Context, t testing.TB) error {
}

// Push the ISIS protocol
if _, err := ygnmi.Replace(ctx, s.DUTClient, ocpath.Root().NetworkInstance(deviations.DefaultNetworkInstance(s.DUT)).Type().Config(), oc.NetworkInstanceTypes_NETWORK_INSTANCE_TYPE_DEFAULT_INSTANCE); err != nil {
if _, err := ygnmi.Update(ctx, s.DUTClient, ocpath.Root().NetworkInstance(deviations.DefaultNetworkInstance(s.DUT)).Config(), &oc.NetworkInstance{
Name: ygot.String(deviations.DefaultNetworkInstance(s.DUT)),
Type: oc.NetworkInstanceTypes_NETWORK_INSTANCE_TYPE_DEFAULT_INSTANCE,
}); err != nil {
return fmt.Errorf("configuring network instance: %w", err)
}
dutConf := s.DUTConf.GetOrCreateNetworkInstance(deviations.DefaultNetworkInstance(s.DUT)).GetOrCreateProtocol(PTISIS, ISISName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func configureDUT(t *testing.T, dut *ondatra.DUTDevice, p1 *ondatra.Port, p2 *on
// Configure default NI and forwarding policy
t.Logf("*** Configuring default instance forwarding policy on DUT ...")
dutConfPath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut))
gnmi.Replace(t, dut, dutConfPath.Type().Config(), oc.NetworkInstanceTypes_NETWORK_INSTANCE_TYPE_DEFAULT_INSTANCE)
fptest.ConfigureDefaultNetworkInstance(t, dut)

if deviations.ExplicitInterfaceInDefaultVRF(dut) {
fptest.AssignToNetworkInstance(t, dut, i1.GetName(), deviations.DefaultNetworkInstance(dut), 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -508,8 +508,7 @@ func TestPBR(t *testing.T) {
pfpath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut)).PolicyForwarding()

//configure pbr policy-forwarding
dutConfNIPath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut))
gnmi.Replace(t, dut, dutConfNIPath.Type().Config(), oc.NetworkInstanceTypes_NETWORK_INSTANCE_TYPE_DEFAULT_INSTANCE)
fptest.ConfigureDefaultNetworkInstance(t, dut)
errMsg := testt.CaptureFatal(t, func(t testing.TB) {
gnmi.Update(t, dut, gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut)).PolicyForwarding().Config(), tc.policy)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func configureDUT(t *testing.T, dut *ondatra.DUTDevice, p1 *ondatra.Port, p2 *on
// Configure default NI and forwarding policy
t.Logf("*** Configuring default instance forwarding policy on DUT ...")
dutConfPath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut))
gnmi.Replace(t, dut, dutConfPath.Type().Config(), oc.NetworkInstanceTypes_NETWORK_INSTANCE_TYPE_DEFAULT_INSTANCE)
fptest.ConfigureDefaultNetworkInstance(t, dut)

if deviations.ExplicitInterfaceInDefaultVRF(dut) {
fptest.AssignToNetworkInstance(t, dut, i1.GetName(), deviations.DefaultNetworkInstance(dut), 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -525,8 +525,8 @@ func TestPBR(t *testing.T) {
pfpath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut)).PolicyForwarding()

//configure pbr policy-forwarding
dutConfNIPath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut))
gnmi.Replace(t, dut, dutConfNIPath.Type().Config(), oc.NetworkInstanceTypes_NETWORK_INSTANCE_TYPE_DEFAULT_INSTANCE)
fptest.ConfigureDefaultNetworkInstance(t, dut)

errMsg := testt.CaptureFatal(t, func(t testing.TB) {
gnmi.Update(t, dut, gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut)).PolicyForwarding().Config(), tc.policy)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,7 @@ func TestEstablish(t *testing.T) {
dutConfigPath := gnmi.OC()

t.Log("Configure Network Instance type to DEFAULT on DUT.")
dutConfNIPath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut))
gnmi.Replace(t, dut, dutConfNIPath.Type().Config(), oc.NetworkInstanceTypes_NETWORK_INSTANCE_TYPE_DEFAULT_INSTANCE)
fptest.ConfigureDefaultNetworkInstance(t, dut)

t.Log("Build Benchmarking BGP and ISIS test configs.")
dutBenchmarkConfig := setup.BuildBenchmarkingConfig(t)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,7 @@ type testArgs struct {
// Configure network instance
func configureNetworkInstance(t *testing.T) {
dut := ondatra.DUT(t, "dut")

dutConfPath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut))
gnmi.Replace(t, dut, dutConfPath.Type().Config(), oc.NetworkInstanceTypes_NETWORK_INSTANCE_TYPE_DEFAULT_INSTANCE)
fptest.ConfigureDefaultNetworkInstance(t, dut)
}

// configStaticRoute configures a static route.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,10 @@ func configureNetworkInstance(t *testing.T, dut *ondatra.DUTDevice) {
}

dutConfNIPath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut))
gnmi.Replace(t, dut, dutConfNIPath.Type().Config(), oc.NetworkInstanceTypes_NETWORK_INSTANCE_TYPE_DEFAULT_INSTANCE)
fptest.ConfigureDefaultNetworkInstance(t, dut)

// configure PBF in DEFAULT vrf
defNIPath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut))
gnmi.Replace(t, dut, defNIPath.Type().Config(), oc.NetworkInstanceTypes_NETWORK_INSTANCE_TYPE_DEFAULT_INSTANCE)
gnmi.Replace(t, dut, defNIPath.PolicyForwarding().Config(), configurePBF(dut))
gnmi.Replace(t, dut, dutConfNIPath.PolicyForwarding().Config(), configurePBF(dut))
}

// configureDUT configures port1 and port2 on the DUT.
Expand Down
3 changes: 1 addition & 2 deletions feature/gribi/ate_tests/get_rpc_test/get_rpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,7 @@ func testIPv4LeaderActive(ctx context.Context, t *testing.T, args *testArgs) {
niProto := dc.NetworkInstance(deviations.DefaultNetworkInstance(args.dut)).
Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_STATIC, deviations.StaticProtocolName(args.dut))

dutConfNIPath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(args.dut))
gnmi.Replace(t, args.dut, dutConfNIPath.Type().Config(), oc.NetworkInstanceTypes_NETWORK_INSTANCE_TYPE_DEFAULT_INSTANCE)
fptest.ConfigureDefaultNetworkInstance(t, args.dut)

ni := &oc.NetworkInstance{Name: ygot.String(deviations.DefaultNetworkInstance(args.dut))}
static := ni.GetOrCreateProtocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_STATIC, deviations.StaticProtocolName(args.dut))
Expand Down
4 changes: 1 addition & 3 deletions feature/gribi/ate_tests/gribi_scaling/gribi_scaling_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,7 @@ func createVrf(t *testing.T, dut *ondatra.DUTDevice, vrfs []string) {
gnmi.Replace(t, dut, gnmi.OC().NetworkInstance(vrf).Config(), i)
} else {
// configure DEFAULT vrf
dutConfNIPath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut))
gnmi.Replace(t, dut, dutConfNIPath.Type().Config(), oc.NetworkInstanceTypes_NETWORK_INSTANCE_TYPE_DEFAULT_INSTANCE)

fptest.ConfigureDefaultNetworkInstance(t, dut)
}
if deviations.ExplicitGRIBIUnderNetworkInstance(dut) {
fptest.EnableGRIBIUnderNetworkInstance(t, dut, vrf)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ func configureNetworkInstance(t *testing.T, d *ondatra.DUTDevice) {

// configure PBF in DEFAULT vrf
defNIPath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(d))
gnmi.Replace(t, d, defNIPath.Type().Config(), oc.NetworkInstanceTypes_NETWORK_INSTANCE_TYPE_DEFAULT_INSTANCE)
fptest.ConfigureDefaultNetworkInstance(t, d)
gnmi.Replace(t, d, defNIPath.PolicyForwarding().Config(), configurePBF(d))

if deviations.ExplicitGRIBIUnderNetworkInstance(d) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,7 @@ type testArgs struct {
// Configure network instance
func configureNetworkInstance(t *testing.T) {
dut := ondatra.DUT(t, "dut")

dutConfPath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut))
gnmi.Replace(t, dut, dutConfPath.Type().Config(), oc.NetworkInstanceTypes_NETWORK_INSTANCE_TYPE_DEFAULT_INSTANCE)
fptest.ConfigureDefaultNetworkInstance(t, dut)
}

// configStaticRoute configures a static route.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,10 @@ func configureNetworkInstance(t *testing.T, dut *ondatra.DUTDevice) {
fptest.EnableGRIBIUnderNetworkInstance(t, dut, deviations.DefaultNetworkInstance(dut))
}

dutConfNIPath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut))
gnmi.Replace(t, dut, dutConfNIPath.Type().Config(), oc.NetworkInstanceTypes_NETWORK_INSTANCE_TYPE_DEFAULT_INSTANCE)
fptest.ConfigureDefaultNetworkInstance(t, dut)

// configure PBF in DEFAULT vrf
defNIPath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut))
gnmi.Replace(t, dut, defNIPath.Type().Config(), oc.NetworkInstanceTypes_NETWORK_INSTANCE_TYPE_DEFAULT_INSTANCE)
gnmi.Replace(t, dut, defNIPath.PolicyForwarding().Config(), configurePBF(dut))
}

Expand Down
5 changes: 3 additions & 2 deletions feature/gribi/otg_tests/get_rpc_test/get_rpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,9 @@ func testIPv4LeaderActive(ctx context.Context, t *testing.T, args *testArgs) {
dc := gnmi.OC()
niProto := dc.NetworkInstance(deviations.DefaultNetworkInstance(args.dut)).
Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_STATIC, deviations.StaticProtocolName(args.dut))
dutConfNIPath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(args.dut))
gnmi.Replace(t, args.dut, dutConfNIPath.Type().Config(), oc.NetworkInstanceTypes_NETWORK_INSTANCE_TYPE_DEFAULT_INSTANCE)

fptest.ConfigureDefaultNetworkInstance(t, args.dut)

ni := &oc.NetworkInstance{Name: ygot.String(deviations.DefaultNetworkInstance(args.dut))}
static := ni.GetOrCreateProtocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_STATIC, deviations.StaticProtocolName(args.dut))
staticRoute := static.GetOrCreateStatic(staticCIDR)
Expand Down
3 changes: 1 addition & 2 deletions feature/gribi/otg_tests/gribi_scaling/gribi_scaling_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,7 @@ func createVrf(t *testing.T, dut *ondatra.DUTDevice, vrfs []string) {
gnmi.Replace(t, dut, gnmi.OC().NetworkInstance(vrf).Config(), i)
} else {
// configure DEFAULT vrf
dutConfNIPath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut))
gnmi.Replace(t, dut, dutConfNIPath.Type().Config(), oc.NetworkInstanceTypes_NETWORK_INSTANCE_TYPE_DEFAULT_INSTANCE)
fptest.ConfigureDefaultNetworkInstance(t, dut)
}
if deviations.ExplicitGRIBIUnderNetworkInstance(dut) {
fptest.EnableGRIBIUnderNetworkInstance(t, dut, vrf)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ func TestDefaultAddressFamilies(t *testing.T) {
fptest.SetPortSpeed(t, dutP1)
fptest.SetPortSpeed(t, dutP2)
}

if tc.niName == deviations.DefaultNetworkInstance(dut) {
dutConfNIPath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut))
gnmi.Replace(t, dut, dutConfNIPath.Type().Config(), oc.NetworkInstanceTypes_NETWORK_INSTANCE_TYPE_DEFAULT_INSTANCE)
fptest.ConfigureDefaultNetworkInstance(t, dut)
}

d := &oc.Root{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,11 @@ func TestDefaultAddressFamilies(t *testing.T) {
fptest.SetPortSpeed(t, dutP1)
fptest.SetPortSpeed(t, dutP2)
}

if tc.niName == deviations.DefaultNetworkInstance(dut) {
dutConfNIPath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut))
gnmi.Replace(t, dut, dutConfNIPath.Type().Config(), oc.NetworkInstanceTypes_NETWORK_INSTANCE_TYPE_DEFAULT_INSTANCE)
fptest.ConfigureDefaultNetworkInstance(t, dut)
}

d := &oc.Root{}
// Assign two ports into the network instance & unnasign them at the end of the test
assignPort(t, d, dutP1.Name(), tc.niName, dutPort1, dut)
Expand Down
10 changes: 10 additions & 0 deletions internal/fptest/networkinstance.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,23 @@ import (
"fmt"
"testing"

"github.com/openconfig/featureprofiles/internal/deviations"
gpb "github.com/openconfig/gnmi/proto/gnmi"
"github.com/openconfig/ondatra"
"github.com/openconfig/ondatra/gnmi"
"github.com/openconfig/ondatra/gnmi/oc"
"github.com/openconfig/ygot/ygot"
)

// ConfigureDefaultNetworkInstance configures the default network instance name and type.
func ConfigureDefaultNetworkInstance(t testing.TB, d *ondatra.DUTDevice) {
defNiPath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(d))
gnmi.Update(t, d, defNiPath.Config(), &oc.NetworkInstance{
Name: ygot.String(deviations.DefaultNetworkInstance(d)),
Type: oc.NetworkInstanceTypes_NETWORK_INSTANCE_TYPE_DEFAULT_INSTANCE,
})
}

// AssignToNetworkInstance attaches a subinterface to a network instance.
func AssignToNetworkInstance(t testing.TB, d *ondatra.DUTDevice, i string, ni string, si uint32) {
t.Helper()
Expand Down

0 comments on commit f230879

Please sign in to comment.