Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions feature/gnmi/tests/gnmi_ni_test/gnmi_ni_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ func TestMain(m *testing.M) {
}

const (
customVRFName = "customVRFName"
customVRFName = "customVRFName"
gNMIPort = 50055
transportSecurity = false
)

var (
Expand Down Expand Up @@ -56,6 +58,7 @@ func TestGNMIAdditionalNetworkInstance(t *testing.T) {
dut := ondatra.DUT(t, "dut")
batch := &gnmi.SetBatch{}
ConfigureDUT(batch, t, dut)
//ConfigureAdditionalNetworkInstance(batch, t, dut, customVRFName)
ConfigureAdditionalNetworkInstance(batch, t, dut, customVRFName)
t.Log("\nApplying configuration to DUT\n")
batch.Set(t, dut)
Expand All @@ -78,8 +81,6 @@ func ConfigureDUT(batch *gnmi.SetBatch, t *testing.T, dut *ondatra.DUTDevice) {
// Configure default network instance.
cfgplugins.NewNetworkInstance(t, dut, batch, &dutPort1NetworkInstanceIParams)

// Configure gNMI server on default network instance.
cfgplugins.CreateGNMIServer(t, dut, batch, &dutPort1NetworkInstanceIParams)
}

// ConfigureAdditionalNetworkInstance configures a new network instance in DUT and changes the network instance of port2
Expand All @@ -96,7 +97,7 @@ func ConfigureAdditionalNetworkInstance(batch *gnmi.SetBatch, t *testing.T, dut
cfgplugins.NewNetworkInstance(t, dut, batch, &dutPort2NetworkInstanceIParams)

// Configure non-default gNMI server.
cfgplugins.CreateGNMIServer(t, dut, batch, &dutPort2NetworkInstanceIParams)
cfgplugins.CreateGNMIServer(t, dut, batch, &dutPort2NetworkInstanceIParams, gNMIPort, transportSecurity)
}

func ValidateNetworkInstance(t *testing.T, dut *ondatra.DUTDevice) {
Expand Down Expand Up @@ -130,7 +131,11 @@ func ValidateNetworkInstance(t *testing.T, dut *ondatra.DUTDevice) {
serverName := gnmiServer.GetName()
// Using gnmiServer.GetName() to get the state is better than hardcoding.
serverState := gnmi.Get(t, dut, gnmi.OC().System().GrpcServer(serverName).State())

// Skip for the internal Juniper system serverName DEFAULT
if dut.Vendor() == ondatra.JUNIPER && serverName == "DEFAULT" {
t.Logf("Skipping internal Juniper system server placeholder: %s", serverName)
continue
}
switch serverName {
case customGnmiServerName:
validateGnmiServerState(t, serverState)
Expand Down
1 change: 1 addition & 0 deletions feature/gnmi/tests/gnmi_ni_test/metadata.textproto
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@ platform_exceptions: {
}
deviations: {
interface_enabled: true
default_ni_gnmi_server_name: "all_50051"
}
}
11 changes: 6 additions & 5 deletions internal/cfgplugins/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import (
)

// CreateGNMIServer creates a gNMI server on the DUT on a given network-instance.
func CreateGNMIServer(t testing.TB, d *ondatra.DUTDevice, batch *gnmi.SetBatch, nip *NetworkInstanceParams) {
func CreateGNMIServer(t testing.TB, d *ondatra.DUTDevice, batch *gnmi.SetBatch, nip *NetworkInstanceParams, port uint16, transportSec bool) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The function signature for CreateGNMIServer violates the repository style guide for configuration plugins. It should use a configuration struct to pass parameters (such as port and transportSec) and return the *gnmi.SetBatch object. Additionally, adding parameters directly to the signature is a breaking change for other tests using this internal library.

References
  1. Configuration plugin functions must use a struct for parameters and return a *gnmi.SetBatch. (link)

var niName string
var gnmiServerName string

Expand All @@ -59,10 +59,11 @@ func CreateGNMIServer(t testing.TB, d *ondatra.DUTDevice, batch *gnmi.SetBatch,
t.Logf("Creating gNMI server %s on network instance: %s", gnmiServerName, niName)
gnmiServerPath := gnmi.OC().System().GrpcServer(gnmiServerName)
gnmiServer := &oc.System_GrpcServer{
Name: ygot.String(gnmiServerName),
Port: ygot.Uint16(9339),
Enable: ygot.Bool(true),
NetworkInstance: ygot.String(niName),
Name: ygot.String(gnmiServerName),
Port: ygot.Uint16(port),
Enable: ygot.Bool(true),
NetworkInstance: ygot.String(niName),
TransportSecurity: ygot.Bool(transportSec),
}
if !deviations.GrpcServerServicesUnsupported(d) {
gnmiServer.Services = []oc.E_SystemGrpc_GRPC_SERVICE{oc.SystemGrpc_GRPC_SERVICE_GNMI}
Expand Down
Loading