VOL-3121 - Separated ports from devices.
Similar to flows/groups/meters/logical ports.
Also added ListDevicePorts and GetDevicePort to the adapter API.
Also removed unused `// +build integration` tests.
Change-Id: I586adb9f46a249c9430d4205ef5db2d105dbbe06
diff --git a/rw_core/core/api/grpc_nbi_handler_test.go b/rw_core/core/api/grpc_nbi_handler_test.go
index 434df90..6b37a14 100755
--- a/rw_core/core/api/grpc_nbi_handler_test.go
+++ b/rw_core/core/api/grpc_nbi_handler_test.go
@@ -205,6 +205,8 @@
// Now, verify the details of the device. First get the latest update
d, err := nbi.GetDevice(getContext(), &voltha.ID{Id: device.Id})
assert.Nil(t, err)
+ dPorts, err := nbi.ListDevicePorts(getContext(), &voltha.ID{Id: device.Id})
+ assert.Nil(t, err)
assert.Equal(t, voltha.AdminState_ENABLED, d.AdminState)
assert.Equal(t, voltha.ConnectStatus_REACHABLE, d.ConnectStatus)
assert.Equal(t, voltha.OperStatus_ACTIVE, d.OperStatus)
@@ -227,8 +229,8 @@
} else {
assert.Error(t, errors.New("invalid-device-type"))
}
- assert.Equal(t, 2, len(d.Ports))
- for _, p := range d.Ports {
+ assert.Equal(t, 2, len(dPorts.Items))
+ for _, p := range dPorts.Items {
assert.Equal(t, voltha.AdminState_ENABLED, p.AdminState)
assert.Equal(t, voltha.OperStatus_ACTIVE, p.OperStatus)
if p.Type == voltha.Port_ETHERNET_NNI || p.Type == voltha.Port_ETHERNET_UNI {
@@ -635,8 +637,10 @@
oltDevice, err := nb.getADevice(true, nbi)
assert.Nil(t, err)
assert.NotNil(t, oltDevice)
+ oltPorts, err := nbi.ListDevicePorts(getContext(), &voltha.ID{Id: oltDevice.Id})
+ assert.Nil(t, err)
- for _, cp = range oltDevice.Ports {
+ for _, cp = range oltPorts.Items {
if cp.Type == voltha.Port_PON_OLT {
break
}
@@ -649,15 +653,15 @@
_, err = nbi.DisablePort(getContext(), cp)
assert.Nil(t, err)
// Wait for the olt device Port to be disabled
- var vdFunction isDeviceConditionSatisfied = func(device *voltha.Device) bool {
- for _, port := range device.Ports {
+ var vdFunction isDevicePortsConditionSatisfied = func(ports *voltha.Ports) bool {
+ for _, port := range ports.Items {
if port.PortNo == cp.PortNo {
return port.AdminState == voltha.AdminState_DISABLED
}
}
return false
}
- err = waitUntilDeviceReadiness(oltDevice.Id, nb.maxTimeout, vdFunction, nbi)
+ err = waitUntilDevicePortsReadiness(oltDevice.Id, nb.maxTimeout, vdFunction, nbi)
assert.Nil(t, err)
// Wait for the logical device to satisfy the expected condition
var vlFunction = func(ports []*voltha.LogicalPort) bool {
@@ -677,15 +681,15 @@
assert.Nil(t, err)
// Wait for the olt device Port to be enabled
- vdFunction = func(device *voltha.Device) bool {
- for _, port := range device.Ports {
+ vdFunction = func(ports *voltha.Ports) bool {
+ for _, port := range ports.Items {
if port.PortNo == cp.PortNo {
return port.AdminState == voltha.AdminState_ENABLED
}
}
return false
}
- err = waitUntilDeviceReadiness(oltDevice.Id, nb.maxTimeout, vdFunction, nbi)
+ err = waitUntilDevicePortsReadiness(oltDevice.Id, nb.maxTimeout, vdFunction, nbi)
assert.Nil(t, err)
// Wait for the logical device to satisfy the expected condition
vlFunction = func(ports []*voltha.LogicalPort) bool {
@@ -701,7 +705,7 @@
assert.Nil(t, err)
// Disable a non-PON port
- for _, cp = range oltDevice.Ports {
+ for _, cp = range oltPorts.Items {
if cp.Type != voltha.Port_PON_OLT {
break
}