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/db/model/proxy_test.go b/db/model/proxy_test.go
index a73a071..498eb45 100644
--- a/db/model/proxy_test.go
+++ b/db/model/proxy_test.go
@@ -28,7 +28,6 @@
"github.com/opencord/voltha-lib-go/v3/pkg/db"
"github.com/opencord/voltha-lib-go/v3/pkg/db/kvstore"
"github.com/opencord/voltha-lib-go/v3/pkg/log"
- "github.com/opencord/voltha-protos/v3/go/common"
"github.com/opencord/voltha-protos/v3/go/openflow_13"
"github.com/opencord/voltha-protos/v3/go/voltha"
"github.com/stretchr/testify/assert"
@@ -44,10 +43,7 @@
TestProxyLogicalDeviceID string
TestProxyTargetDeviceID string
TestProxyTargetLogicalDeviceID string
- TestProxyLogicalPorts []*voltha.LogicalPort
- TestProxyPorts []*voltha.Port
TestProxyStats *openflow_13.OfpFlowStats
- TestProxyFlows *openflow_13.Flows
TestProxyDevice *voltha.Device
TestProxyLogicalDevice *voltha.LogicalDevice
TestProxyAdapter *voltha.Adapter
@@ -72,46 +68,19 @@
TestProxyRootDevice = proxy.Proxy("device")
TestProxyRootAdapter = proxy.Proxy("adapters")
- TestProxyLogicalPorts = []*voltha.LogicalPort{
- {
- Id: "123",
- DeviceId: "logicalport-0-device-id",
- DevicePortNo: 123,
- RootPort: false,
- },
- }
- TestProxyPorts = []*voltha.Port{
- {
- PortNo: 123,
- Label: "test-port-0",
- Type: voltha.Port_PON_OLT,
- AdminState: common.AdminState_ENABLED,
- OperStatus: common.OperStatus_ACTIVE,
- DeviceId: "etcd_port-0-device-id",
- Peers: []*voltha.Port_PeerPort{},
- },
- }
-
TestProxyStats = &openflow_13.OfpFlowStats{
Id: 1111,
}
- TestProxyFlows = &openflow_13.Flows{
- Items: []*openflow_13.OfpFlowStats{TestProxyStats},
- }
TestProxyDevice = &voltha.Device{
Id: TestProxyDeviceID,
Type: "simulated_olt",
Address: &voltha.Device_HostAndPort{HostAndPort: "1.2.3.4:5555"},
AdminState: voltha.AdminState_PREPROVISIONED,
- Flows: TestProxyFlows,
- Ports: TestProxyPorts,
}
TestProxyLogicalDevice = &voltha.LogicalDevice{
Id: TestProxyDeviceID,
DatapathId: 0,
- Ports: TestProxyLogicalPorts,
- Flows: TestProxyFlows,
}
TestProxyAdapter = &voltha.Adapter{
diff --git a/go.mod b/go.mod
index 5ceffaa..ee14fab 100644
--- a/go.mod
+++ b/go.mod
@@ -6,8 +6,8 @@
github.com/gogo/protobuf v1.3.0
github.com/golang/protobuf v1.3.2
github.com/google/uuid v1.1.1
- github.com/opencord/voltha-lib-go/v3 v3.2.0
- github.com/opencord/voltha-protos/v3 v3.3.9
+ github.com/opencord/voltha-lib-go/v3 v3.2.1
+ github.com/opencord/voltha-protos/v3 v3.4.1
github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2
github.com/stretchr/testify v1.4.0
google.golang.org/grpc v1.24.0
diff --git a/go.sum b/go.sum
index 4f22a44..9c0256a 100644
--- a/go.sum
+++ b/go.sum
@@ -198,10 +198,10 @@
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/gomega v1.4.2 h1:3mYCb7aPxS/RU7TI1y4rkEn1oKmPRjNJLNEXgw7MH2I=
github.com/onsi/gomega v1.4.2/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
-github.com/opencord/voltha-lib-go/v3 v3.2.0 h1:r7X7jZE5oJklv7GgqkuZWJMqjDZNT35X7VOMY1oyfus=
-github.com/opencord/voltha-lib-go/v3 v3.2.0/go.mod h1:sa508HZ5vlOauh0i+WC0XFX1JZnfHtJqNIms5XBT/Z0=
-github.com/opencord/voltha-protos/v3 v3.3.9 h1:BnfDN9oaRBgyAiH9ZN7LpBpEJYxjX/ZS7R4OT2hDrtY=
-github.com/opencord/voltha-protos/v3 v3.3.9/go.mod h1:nl1ETp5Iw3avxOaKD8BJlYY5wYI4KeV95aT1pL63nto=
+github.com/opencord/voltha-lib-go/v3 v3.2.1 h1:s6thA7jLGkrx6S3fzyCBYkXS4c0lIlPgmI0nYCme6NA=
+github.com/opencord/voltha-lib-go/v3 v3.2.1/go.mod h1:RPWJ4EY9Q758uwYAAb2WqZYDSI2M0FCQqjIHJxxDiHY=
+github.com/opencord/voltha-protos/v3 v3.4.1 h1:Nrr0jKy7WiMiFlXYiK8z73RvI4K4L5b/top7d3htQQI=
+github.com/opencord/voltha-protos/v3 v3.4.1/go.mod h1:nl1ETp5Iw3avxOaKD8BJlYY5wYI4KeV95aT1pL63nto=
github.com/opentracing/opentracing-go v1.1.0 h1:pWlfV3Bxv7k65HYwkikxat0+s3pV4bsqf19k25Ur8rU=
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
diff --git a/rw_core/core/api/adapter_request_handler.go b/rw_core/core/api/adapter_request_handler.go
index d1e655e..79093a7 100644
--- a/rw_core/core/api/adapter_request_handler.go
+++ b/rw_core/core/api/adapter_request_handler.go
@@ -19,6 +19,7 @@
import (
"context"
"errors"
+
"github.com/golang/protobuf/ptypes"
"github.com/golang/protobuf/ptypes/empty"
"github.com/opencord/voltha-go/rw_core/core/adapter"
@@ -455,6 +456,7 @@
return nil, err
}
deviceID := &voltha.ID{}
+ portTypeFilter := &ic.IntType{}
operStatus := &ic.IntType{}
transactionID := &ic.StrType{}
for _, arg := range args {
@@ -464,6 +466,11 @@
logger.Warnw(ctx, "cannot-unmarshal-device-id", log.Fields{"error": err})
return nil, err
}
+ case "port_type_filter":
+ if err := ptypes.UnmarshalAny(arg.Value, portTypeFilter); err != nil {
+ logger.Warnw(ctx, "cannot-unmarshal-device-id", log.Fields{"error": err})
+ return nil, err
+ }
case "oper_status":
if err := ptypes.UnmarshalAny(arg.Value, operStatus); err != nil {
logger.Warnw(ctx, "cannot-unmarshal-operStatus", log.Fields{"error": err})
@@ -478,7 +485,7 @@
}
logger.Debugw(ctx, "PortsStateUpdate", log.Fields{"deviceID": deviceID.Id, "operStatus": operStatus, "transactionID": transactionID.Val})
- if err := rhp.deviceMgr.UpdatePortsState(context.TODO(), deviceID.Id, voltha.OperStatus_Types(operStatus.Val)); err != nil {
+ if err := rhp.deviceMgr.UpdatePortsState(context.TODO(), deviceID.Id, uint32(portTypeFilter.Val), voltha.OperStatus_Types(operStatus.Val)); err != nil {
logger.Debugw(ctx, "unable-to-update-ports-state", log.Fields{"error": err})
return nil, err
}
@@ -572,6 +579,68 @@
return &empty.Empty{}, nil
}
+// GetDevicePort returns a single port
+func (rhp *AdapterRequestHandlerProxy) GetDevicePort(ctx context.Context, args []*ic.Argument) (*voltha.Port, error) {
+ if len(args) < 3 {
+ logger.Warn(ctx, "invalid-number-of-args", log.Fields{"args": args})
+ err := errors.New("invalid-number-of-args")
+ return nil, err
+ }
+ deviceID := &voltha.ID{}
+ portNo := &ic.IntType{}
+ transactionID := &ic.StrType{}
+ for _, arg := range args {
+ switch arg.Key {
+ case "device_id":
+ if err := ptypes.UnmarshalAny(arg.Value, deviceID); err != nil {
+ logger.Warnw(ctx, "cannot-unmarshal-device-id", log.Fields{"error": err})
+ return nil, err
+ }
+ case "port_no":
+ if err := ptypes.UnmarshalAny(arg.Value, portNo); err != nil {
+ logger.Warnw(ctx, "cannot-unmarshal-port-no", log.Fields{"error": err})
+ return nil, err
+ }
+ case kafka.TransactionKey:
+ if err := ptypes.UnmarshalAny(arg.Value, transactionID); err != nil {
+ logger.Warnw(ctx, "cannot-unmarshal-transaction-ID", log.Fields{"error": err})
+ return nil, err
+ }
+ }
+ }
+ logger.Debugw(ctx, "GetDevicePort", log.Fields{"deviceID": deviceID.Id, "portNo": portNo.Val, "transactionID": transactionID.Val})
+
+ return rhp.deviceMgr.GetDevicePort(context.TODO(), deviceID.Id, uint32(portNo.Val))
+}
+
+// ListDevicePorts returns all ports belonging to the device
+func (rhp *AdapterRequestHandlerProxy) ListDevicePorts(ctx context.Context, args []*ic.Argument) (*voltha.Ports, error) {
+ if len(args) < 2 {
+ logger.Warn(ctx, "invalid-number-of-args", log.Fields{"args": args})
+ err := errors.New("invalid-number-of-args")
+ return nil, err
+ }
+ deviceID := &voltha.ID{}
+ transactionID := &ic.StrType{}
+ for _, arg := range args {
+ switch arg.Key {
+ case "device_id":
+ if err := ptypes.UnmarshalAny(arg.Value, deviceID); err != nil {
+ logger.Warnw(ctx, "cannot-unmarshal-device-id", log.Fields{"error": err})
+ return nil, err
+ }
+ case kafka.TransactionKey:
+ if err := ptypes.UnmarshalAny(arg.Value, transactionID); err != nil {
+ logger.Warnw(ctx, "cannot-unmarshal-transaction-ID", log.Fields{"error": err})
+ return nil, err
+ }
+ }
+ }
+ logger.Debugw(ctx, "ListDevicePorts", log.Fields{"deviceID": deviceID.Id, "transactionID": transactionID.Val})
+
+ return rhp.deviceMgr.ListDevicePorts(context.TODO(), deviceID)
+}
+
// ChildDevicesLost indicates that a parent device is in a state (Disabled) where it cannot manage the child devices.
// This will trigger the Core to disable all the child devices.
func (rhp *AdapterRequestHandlerProxy) ChildDevicesLost(ctx context.Context, args []*ic.Argument) (*empty.Empty, error) {
diff --git a/rw_core/core/api/common_test.go b/rw_core/core/api/common_test.go
index 6fcd511..92ba701 100644
--- a/rw_core/core/api/common_test.go
+++ b/rw_core/core/api/common_test.go
@@ -38,6 +38,7 @@
type isLogicalDeviceConditionSatisfied func(ld *voltha.LogicalDevice) bool
type isLogicalDevicePortsConditionSatisfied func(ports []*voltha.LogicalPort) bool
type isDeviceConditionSatisfied func(ld *voltha.Device) bool
+type isDevicePortsConditionSatisfied func(ports *voltha.Ports) bool
type isDevicesConditionSatisfied func(ds *voltha.Devices) bool
type isLogicalDevicesConditionSatisfied func(lds *voltha.LogicalDevices) bool
type isConditionSatisfied func() bool
@@ -88,6 +89,36 @@
}
}
+func waitUntilDevicePortsReadiness(deviceID string,
+ timeout time.Duration,
+ verificationFunction isDevicePortsConditionSatisfied,
+ nbi *NBIHandler) error {
+ ch := make(chan int, 1)
+ done := false
+ go func() {
+ for {
+ ports, _ := nbi.ListDevicePorts(getContext(), &voltha.ID{Id: deviceID})
+ if verificationFunction(ports) {
+ ch <- 1
+ break
+ }
+ if done {
+ break
+ }
+ time.Sleep(retryInterval)
+ }
+ }()
+ timer := time.NewTimer(timeout)
+ defer timer.Stop()
+ select {
+ case <-ch:
+ return nil
+ case <-timer.C:
+ done = true
+ return fmt.Errorf("expected-states-not-reached-for-device%s", deviceID)
+ }
+}
+
func waitUntilLogicalDeviceReadiness(oltDeviceID string,
timeout time.Duration,
nbi *NBIHandler,
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
}
diff --git a/rw_core/core/device/agent.go b/rw_core/core/device/agent.go
index 2b18296..9fbeb9d 100755
--- a/rw_core/core/device/agent.go
+++ b/rw_core/core/device/agent.go
@@ -29,6 +29,7 @@
"github.com/opencord/voltha-go/rw_core/core/adapter"
"github.com/opencord/voltha-go/rw_core/core/device/flow"
"github.com/opencord/voltha-go/rw_core/core/device/group"
+ "github.com/opencord/voltha-go/rw_core/core/device/port"
"github.com/opencord/voltha-go/rw_core/core/device/remote"
"github.com/opencord/voltha-lib-go/v3/pkg/kafka"
@@ -48,7 +49,7 @@
deviceID string
parentID string
deviceType string
- isRootdevice bool
+ isRootDevice bool
adapterProxy *remote.AdapterProxy
adapterMgr *adapter.Manager
deviceMgr *Manager
@@ -63,32 +64,33 @@
flowLoader *flow.Loader
groupLoader *group.Loader
+ portLoader *port.Loader
}
//newAgent creates a new device agent. The device will be initialized when start() is called.
-func newAgent(ap *remote.AdapterProxy, device *voltha.Device, deviceMgr *Manager, dbProxy *model.Path, deviceProxy *model.Proxy, timeout time.Duration) *Agent {
- var agent Agent
- agent.adapterProxy = ap
- if device.Id == "" {
- agent.deviceID = coreutils.CreateDeviceID()
- } else {
- agent.deviceID = device.Id
+func newAgent(ap *remote.AdapterProxy, device *voltha.Device, deviceMgr *Manager, dbPath *model.Path, deviceProxy *model.Proxy, timeout time.Duration) *Agent {
+ deviceID := device.Id
+ if deviceID == "" {
+ deviceID = coreutils.CreateDeviceID()
}
- agent.isRootdevice = device.Root
- agent.parentID = device.ParentId
- agent.deviceType = device.Type
- agent.deviceMgr = deviceMgr
- agent.adapterMgr = deviceMgr.adapterMgr
- agent.exitChannel = make(chan int, 1)
- agent.dbProxy = deviceProxy
- agent.defaultTimeout = timeout
- agent.device = proto.Clone(device).(*voltha.Device)
- agent.requestQueue = coreutils.NewRequestQueue()
- agent.flowLoader = flow.NewLoader(dbProxy.SubPath("flows").Proxy(device.Id))
- agent.groupLoader = group.NewLoader(dbProxy.SubPath("groups").Proxy(device.Id))
-
- return &agent
+ return &Agent{
+ deviceID: deviceID,
+ adapterProxy: ap,
+ isRootDevice: device.Root,
+ parentID: device.ParentId,
+ deviceType: device.Type,
+ deviceMgr: deviceMgr,
+ adapterMgr: deviceMgr.adapterMgr,
+ exitChannel: make(chan int, 1),
+ dbProxy: deviceProxy,
+ defaultTimeout: timeout,
+ device: proto.Clone(device).(*voltha.Device),
+ requestQueue: coreutils.NewRequestQueue(),
+ flowLoader: flow.NewLoader(dbPath.SubPath("flows").Proxy(deviceID)),
+ groupLoader: group.NewLoader(dbPath.SubPath("groups").Proxy(deviceID)),
+ portLoader: port.NewLoader(dbPath.SubPath("ports").Proxy(deviceID)),
+ }
}
// start() saves the device to the data model and registers for callbacks on that device if deviceToCreate!=nil.
@@ -124,6 +126,7 @@
// load the flows and groups from KV to cache
agent.flowLoader.Load(ctx)
agent.groupLoader.Load(ctx)
+ agent.portLoader.Load(ctx)
logger.Infow(ctx, "device-loaded-from-dB", log.Fields{"device-id": agent.deviceID})
} else {
@@ -134,8 +137,6 @@
device = (proto.Clone(deviceToCreate)).(*voltha.Device)
device.Id = agent.deviceID
device.AdminState = voltha.AdminState_PREPROVISIONED
- device.FlowGroups = &ofp.FlowGroups{Items: nil}
- device.Flows = &ofp.Flows{Items: nil}
if !deviceToCreate.GetRoot() && deviceToCreate.ProxyAddress != nil {
// Set the default vlan ID to the one specified by the parent adapter. It can be
// overwritten by the child adapter during a device update request
@@ -202,6 +203,7 @@
agent.device = device
agent.flowLoader.Load(ctx)
agent.groupLoader.Load(ctx)
+ agent.portLoader.Load(ctx)
logger.Debugw(ctx, "reconciled-device-agent-devicetype", log.Fields{"device-id": agent.deviceID, "type": agent.deviceType})
}
@@ -714,27 +716,26 @@
}
func (agent *Agent) ChildDeviceLost(ctx context.Context, device *voltha.Device) error {
- if err := agent.requestQueue.WaitForGreenLight(ctx); err != nil {
- return err
- }
- defer agent.requestQueue.RequestComplete()
-
logger.Debugw(ctx, "childDeviceLost", log.Fields{"child-device-id": device.Id, "parent-device-ud": agent.deviceID})
- //Remove the associated peer ports on the parent device
- parentDevice := agent.getDeviceWithoutLock()
- var updatedPeers []*voltha.Port_PeerPort
- for _, port := range parentDevice.Ports {
- updatedPeers = make([]*voltha.Port_PeerPort, 0)
- for _, peerPort := range port.Peers {
- if peerPort.DeviceId != device.Id {
- updatedPeers = append(updatedPeers, peerPort)
+ // Remove the associated peer ports on the parent device
+ for portID := range agent.portLoader.ListIDs() {
+ if portHandle, have := agent.portLoader.Lock(portID); have {
+ oldPort := portHandle.GetReadOnly()
+ updatedPeers := make([]*voltha.Port_PeerPort, 0)
+ for _, peerPort := range oldPort.Peers {
+ if peerPort.DeviceId != device.Id {
+ updatedPeers = append(updatedPeers, peerPort)
+ }
}
+ newPort := *oldPort
+ newPort.Peers = updatedPeers
+ if err := portHandle.Update(ctx, &newPort); err != nil {
+ portHandle.Unlock()
+ return nil
+ }
+ portHandle.Unlock()
}
- port.Peers = updatedPeers
- }
- if err := agent.updateDeviceInStoreWithoutLock(ctx, parentDevice, false, ""); err != nil {
- return err
}
//send request to adapter
diff --git a/rw_core/core/device/agent_port.go b/rw_core/core/device/agent_port.go
index b3de89d..5ac7aca 100644
--- a/rw_core/core/device/agent_port.go
+++ b/rw_core/core/device/agent_port.go
@@ -21,198 +21,229 @@
"fmt"
"github.com/gogo/protobuf/proto"
+ "github.com/opencord/voltha-go/rw_core/core/device/port"
"github.com/opencord/voltha-lib-go/v3/pkg/log"
"github.com/opencord/voltha-protos/v3/go/voltha"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
-// getPorts retrieves the ports information of the device based on the port type.
-func (agent *Agent) getPorts(ctx context.Context, portType voltha.Port_PortType) *voltha.Ports {
- logger.Debugw(ctx, "getPorts", log.Fields{"device-id": agent.deviceID, "port-type": portType})
- ports := &voltha.Ports{}
- if device, _ := agent.deviceMgr.getDevice(ctx, agent.deviceID); device != nil {
- for _, port := range device.Ports {
- if port.Type == portType {
- ports.Items = append(ports.Items, port)
- }
+// listDevicePorts returns device ports
+func (agent *Agent) listDevicePorts() map[uint32]*voltha.Port {
+ portIDs := agent.portLoader.ListIDs()
+ ports := make(map[uint32]*voltha.Port, len(portIDs))
+ for portID := range portIDs {
+ if portHandle, have := agent.portLoader.Lock(portID); have {
+ ports[portID] = portHandle.GetReadOnly()
+ portHandle.Unlock()
}
}
return ports
}
-func (agent *Agent) updatePortsOperState(ctx context.Context, operStatus voltha.OperStatus_Types) error {
+// getPorts retrieves the ports information of the device based on the port type.
+func (agent *Agent) getPorts(ctx context.Context, portType voltha.Port_PortType) *voltha.Ports {
+ logger.Debugw(ctx, "getPorts", log.Fields{"device-id": agent.deviceID, "port-type": portType})
+ ports := &voltha.Ports{}
+ for _, port := range agent.listDevicePorts() {
+ if port.Type == portType {
+ ports.Items = append(ports.Items, port)
+ }
+ }
+ return ports
+}
+
+func (agent *Agent) getDevicePort(portID uint32) (*voltha.Port, error) {
+ portHandle, have := agent.portLoader.Lock(portID)
+ if !have {
+ return nil, status.Errorf(codes.NotFound, "port-%d", portID)
+ }
+ defer portHandle.Unlock()
+ return portHandle.GetReadOnly(), nil
+}
+
+func (agent *Agent) updatePortsOperState(ctx context.Context, portTypeFilter uint32, operStatus voltha.OperStatus_Types) error {
logger.Debugw(ctx, "updatePortsOperState", log.Fields{"device-id": agent.deviceID})
- if err := agent.requestQueue.WaitForGreenLight(ctx); err != nil {
- return err
+
+ for portID := range agent.portLoader.ListIDs() {
+ if portHandle, have := agent.portLoader.Lock(portID); have {
+ if oldPort := portHandle.GetReadOnly(); (1<<oldPort.Type)&portTypeFilter == 0 { // only update port types not included in the mask
+ // clone top-level port struct
+ newPort := *oldPort
+ newPort.OperStatus = operStatus
+ if err := portHandle.Update(ctx, &newPort); err != nil {
+ portHandle.Unlock()
+ return err
+ }
+
+ // Notify the logical device manager to change the port state
+ // Do this for NNI and UNIs only. PON ports are not known by logical device
+ if newPort.Type == voltha.Port_ETHERNET_NNI || newPort.Type == voltha.Port_ETHERNET_UNI {
+ go func(portID uint32, ctx context.Context) {
+ if err := agent.deviceMgr.logicalDeviceMgr.updatePortState(ctx, agent.deviceID, portID, operStatus); err != nil {
+ // TODO: VOL-2707
+ logger.Warnw(ctx, "unable-to-update-logical-port-state", log.Fields{"error": err})
+ }
+ }(portID, context.Background())
+ }
+ }
+ portHandle.Unlock()
+ }
}
- defer agent.requestQueue.RequestComplete()
- cloned := agent.getDeviceWithoutLock()
- for _, port := range cloned.Ports {
- port.OperStatus = operStatus
- }
- // Store the device
- return agent.updateDeviceInStoreWithoutLock(ctx, cloned, false, "")
+ return nil
}
func (agent *Agent) updatePortState(ctx context.Context, portType voltha.Port_PortType, portNo uint32, operStatus voltha.OperStatus_Types) error {
- if err := agent.requestQueue.WaitForGreenLight(ctx); err != nil {
- return err
- }
- defer agent.requestQueue.RequestComplete()
- // Work only on latest data
- // TODO: Get list of ports from device directly instead of the entire device
- cloned := agent.getDeviceWithoutLock()
-
// Ensure the enums passed in are valid - they will be invalid if they are not set when this function is invoked
if _, ok := voltha.Port_PortType_value[portType.String()]; !ok {
return status.Errorf(codes.InvalidArgument, "%s", portType)
}
- for _, port := range cloned.Ports {
- if port.Type == portType && port.PortNo == portNo {
- port.OperStatus = operStatus
- }
+
+ portHandle, have := agent.portLoader.Lock(portNo)
+ if !have {
+ return nil
}
- logger.Debugw(ctx, "portStatusUpdate", log.Fields{"deviceId": cloned.Id})
- // Store the device
- return agent.updateDeviceInStoreWithoutLock(ctx, cloned, false, "")
+ defer portHandle.Unlock()
+
+ port := portHandle.GetReadOnly()
+ if port.Type != portType {
+ return nil
+ }
+
+ newPort := *port // clone top-level port struct
+ newPort.OperStatus = operStatus
+ return portHandle.Update(ctx, &newPort)
}
func (agent *Agent) deleteAllPorts(ctx context.Context) error {
logger.Debugw(ctx, "deleteAllPorts", log.Fields{"deviceId": agent.deviceID})
- if err := agent.requestQueue.WaitForGreenLight(ctx); err != nil {
+
+ device, err := agent.getDevice(ctx)
+ if err != nil {
return err
}
- defer agent.requestQueue.RequestComplete()
- cloned := agent.getDeviceWithoutLock()
-
- if cloned.AdminState != voltha.AdminState_DISABLED && cloned.AdminState != voltha.AdminState_DELETED {
- err := status.Error(codes.FailedPrecondition, fmt.Sprintf("invalid-state-%v", cloned.AdminState))
- logger.Warnw(ctx, "invalid-state-removing-ports", log.Fields{"state": cloned.AdminState, "error": err})
+ if device.AdminState != voltha.AdminState_DISABLED && device.AdminState != voltha.AdminState_DELETED {
+ err := status.Error(codes.FailedPrecondition, fmt.Sprintf("invalid-state-%v", device.AdminState))
+ logger.Warnw(ctx, "invalid-state-removing-ports", log.Fields{"state": device.AdminState, "error": err})
return err
}
- if len(cloned.Ports) == 0 {
- logger.Debugw(ctx, "no-ports-present", log.Fields{"deviceId": agent.deviceID})
- return nil
- }
- cloned.Ports = []*voltha.Port{}
- logger.Debugw(ctx, "portStatusUpdate", log.Fields{"deviceId": cloned.Id})
- // Store the device
- return agent.updateDeviceInStoreWithoutLock(ctx, cloned, false, "")
+ for portID := range agent.portLoader.ListIDs() {
+ if portHandle, have := agent.portLoader.Lock(portID); have {
+ if err := portHandle.Delete(ctx); err != nil {
+ portHandle.Unlock()
+ return err
+ }
+ portHandle.Unlock()
+ }
+ }
+ return nil
}
func (agent *Agent) addPort(ctx context.Context, port *voltha.Port) error {
- if err := agent.requestQueue.WaitForGreenLight(ctx); err != nil {
- return err
- }
- defer agent.requestQueue.RequestComplete()
logger.Debugw(ctx, "addPort", log.Fields{"deviceId": agent.deviceID})
- cloned := agent.getDeviceWithoutLock()
- updatePort := false
- if cloned.Ports == nil {
- // First port
- logger.Debugw(ctx, "addPort-first-port-to-add", log.Fields{"deviceId": agent.deviceID})
- cloned.Ports = make([]*voltha.Port, 0)
- } else {
- for _, p := range cloned.Ports {
- if p.Type == port.Type && p.PortNo == port.PortNo {
- if p.Label == "" && p.Type == voltha.Port_PON_OLT {
- //Creation of OLT PON port is being processed after a default PON port was created. Just update it.
- logger.Infow(ctx, "update-pon-port-created-by-default", log.Fields{"default-port": p, "port-to-add": port})
- p.Label = port.Label
- p.OperStatus = port.OperStatus
- updatePort = true
- break
- }
- logger.Debugw(ctx, "port already exists", log.Fields{"port": port})
- return nil
- }
- }
+ port.AdminState = voltha.AdminState_ENABLED
+
+ portHandle, created, err := agent.portLoader.LockOrCreate(ctx, port)
+ if err != nil {
+ return err
}
- if !updatePort {
- cp := proto.Clone(port).(*voltha.Port)
- // Set the admin state of the port to ENABLE
- cp.AdminState = voltha.AdminState_ENABLED
- cloned.Ports = append(cloned.Ports, cp)
+ defer portHandle.Unlock()
+
+ if created {
+ return nil
}
- // Store the device
- return agent.updateDeviceInStoreWithoutLock(ctx, cloned, false, "")
+
+ oldPort := portHandle.GetReadOnly()
+ if oldPort.Label != "" || oldPort.Type != voltha.Port_PON_OLT {
+ logger.Debugw(ctx, "port already exists", log.Fields{"port": port})
+ return nil
+ }
+
+ // Creation of OLT PON port is being processed after a default PON port was created. Just update it.
+ logger.Infow(ctx, "update-pon-port-created-by-default", log.Fields{"default-port": oldPort, "port-to-add": port})
+ newPort := *oldPort // clone top-level port struct
+ newPort.Label = port.Label
+ newPort.OperStatus = port.OperStatus
+
+ return portHandle.Update(ctx, &newPort)
}
func (agent *Agent) addPeerPort(ctx context.Context, peerPort *voltha.Port_PeerPort) error {
- if err := agent.requestQueue.WaitForGreenLight(ctx); err != nil {
- return err
- }
- defer agent.requestQueue.RequestComplete()
logger.Debugw(ctx, "adding-peer-peerPort", log.Fields{"device-id": agent.deviceID, "peer-peerPort": peerPort})
- cloned := agent.getDeviceWithoutLock()
-
- // Get the peer port on the device based on the peerPort no
- found := false
- for _, port := range cloned.Ports {
- if port.PortNo == peerPort.PortNo { // found peerPort
- cp := proto.Clone(peerPort).(*voltha.Port_PeerPort)
- port.Peers = append(port.Peers, cp)
- logger.Debugw(ctx, "found-peer", log.Fields{"device-id": agent.deviceID, "portNo": peerPort.PortNo, "deviceId": agent.deviceID})
- found = true
- break
- }
- }
- if !found && agent.isRootdevice {
- // An ONU PON port has been created before the corresponding creation of the OLT PON port. Create the OLT PON port
- // with default values which will be updated once the OLT PON port creation is processed.
+ var portHandle *port.Handle
+ if agent.isRootDevice {
+ // If an ONU PON port needs to be referenced before the corresponding creation of the OLT PON port, then create the OLT PON port
+ // with default values, and update it later when the OLT PON port creation is processed.
ponPort := &voltha.Port{
PortNo: peerPort.PortNo,
Type: voltha.Port_PON_OLT,
AdminState: voltha.AdminState_ENABLED,
DeviceId: agent.deviceID,
- Peers: []*voltha.Port_PeerPort{proto.Clone(peerPort).(*voltha.Port_PeerPort)},
+ Peers: []*voltha.Port_PeerPort{peerPort},
}
- cloned.Ports = append(cloned.Ports, ponPort)
- logger.Infow(ctx, "adding-default-pon-port", log.Fields{"device-id": agent.deviceID, "peer": peerPort, "pon-port": ponPort})
+
+ h, created, err := agent.portLoader.LockOrCreate(ctx, ponPort)
+ if err != nil {
+ return err
+ }
+ defer h.Unlock()
+
+ if created {
+ logger.Infow(ctx, "added-default-pon-port", log.Fields{"device-id": agent.deviceID, "peer": peerPort, "pon-port": ponPort})
+ return nil
+ }
+
+ portHandle = h
+ } else {
+ h, have := agent.portLoader.Lock(peerPort.PortNo)
+ if !have {
+ return nil
+ }
+ defer h.Unlock()
+
+ portHandle = h
}
- // Store the device
- return agent.updateDeviceInStoreWithoutLock(ctx, cloned, false, "")
+ logger.Debugw(ctx, "found-peer", log.Fields{"device-id": agent.deviceID, "portNo": peerPort.PortNo, "deviceId": agent.deviceID})
+
+ newPort := proto.Clone(portHandle.GetReadOnly()).(*voltha.Port)
+ newPort.Peers = append(newPort.Peers, peerPort)
+
+ return portHandle.Update(ctx, newPort)
}
-func (agent *Agent) disablePort(ctx context.Context, Port *voltha.Port) error {
- if err := agent.requestQueue.WaitForGreenLight(ctx); err != nil {
- return err
- }
- defer agent.requestQueue.RequestComplete()
- logger.Debugw(ctx, "disablePort", log.Fields{"device-id": agent.deviceID, "port-no": Port.PortNo})
- var cp *voltha.Port
- // Get the most up to date the device info
- device := agent.getDeviceWithoutLock()
- for _, port := range device.Ports {
- if port.PortNo == Port.PortNo {
- port.AdminState = voltha.AdminState_DISABLED
- cp = proto.Clone(port).(*voltha.Port)
- break
+func (agent *Agent) disablePort(ctx context.Context, portID uint32) error {
+ logger.Debugw(ctx, "disablePort", log.Fields{"device-id": agent.deviceID, "port-no": portID})
- }
+ portHandle, have := agent.portLoader.Lock(portID)
+ if !have {
+ return status.Errorf(codes.InvalidArgument, "%v", portID)
}
- if cp == nil {
- return status.Errorf(codes.InvalidArgument, "%v", Port.PortNo)
+ defer portHandle.Unlock()
+
+ oldPort := portHandle.GetReadOnly()
+
+ if oldPort.Type != voltha.Port_PON_OLT {
+ return status.Errorf(codes.InvalidArgument, "Disabling of Port Type %v unimplemented", oldPort.Type)
}
- if cp.Type != voltha.Port_PON_OLT {
- return status.Errorf(codes.InvalidArgument, "Disabling of Port Type %v unimplemented", cp.Type)
- }
- // Store the device
- if err := agent.updateDeviceInStoreWithoutLock(ctx, device, false, ""); err != nil {
- logger.Debugw(ctx, "updateDeviceInStoreWithoutLock error ", log.Fields{"device-id": agent.deviceID, "port-no": Port.PortNo, "error": err})
+ newPort := *oldPort
+ newPort.AdminState = voltha.AdminState_DISABLED
+ if err := portHandle.Update(ctx, &newPort); err != nil {
return err
}
//send request to adapter
+ device, err := agent.getDevice(ctx)
+ if err != nil {
+ return err
+ }
subCtx, cancel := context.WithTimeout(context.Background(), agent.defaultTimeout)
- ch, err := agent.adapterProxy.DisablePort(ctx, device, cp)
+ ch, err := agent.adapterProxy.DisablePort(ctx, device, &newPort)
if err != nil {
cancel()
return err
@@ -221,39 +252,34 @@
return nil
}
-func (agent *Agent) enablePort(ctx context.Context, Port *voltha.Port) error {
- if err := agent.requestQueue.WaitForGreenLight(ctx); err != nil {
+func (agent *Agent) enablePort(ctx context.Context, portID uint32) error {
+ logger.Debugw(ctx, "enablePort", log.Fields{"device-id": agent.deviceID, "port-no": portID})
+
+ portHandle, have := agent.portLoader.Lock(portID)
+ if !have {
+ return status.Errorf(codes.InvalidArgument, "%v", portID)
+ }
+ defer portHandle.Unlock()
+
+ oldPort := portHandle.GetReadOnly()
+
+ if oldPort.Type != voltha.Port_PON_OLT {
+ return status.Errorf(codes.InvalidArgument, "Enabling of Port Type %v unimplemented", oldPort.Type)
+ }
+
+ newPort := *oldPort
+ newPort.AdminState = voltha.AdminState_ENABLED
+ if err := portHandle.Update(ctx, &newPort); err != nil {
return err
}
- defer agent.requestQueue.RequestComplete()
- logger.Debugw(ctx, "enablePort", log.Fields{"device-id": agent.deviceID, "port-no": Port.PortNo})
- var cp *voltha.Port
- // Get the most up to date the device info
- device := agent.getDeviceWithoutLock()
- for _, port := range device.Ports {
- if port.PortNo == Port.PortNo {
- port.AdminState = voltha.AdminState_ENABLED
- cp = proto.Clone(port).(*voltha.Port)
- break
- }
- }
-
- if cp == nil {
- return status.Errorf(codes.InvalidArgument, "%v", Port.PortNo)
- }
-
- if cp.Type != voltha.Port_PON_OLT {
- return status.Errorf(codes.InvalidArgument, "Enabling of Port Type %v unimplemented", cp.Type)
- }
- // Store the device
- if err := agent.updateDeviceInStoreWithoutLock(ctx, device, false, ""); err != nil {
- logger.Debugw(ctx, "updateDeviceInStoreWithoutLock error ", log.Fields{"device-id": agent.deviceID, "port-no": Port.PortNo, "error": err})
- return err
- }
//send request to adapter
+ device, err := agent.getDevice(ctx)
+ if err != nil {
+ return err
+ }
subCtx, cancel := context.WithTimeout(context.Background(), agent.defaultTimeout)
- ch, err := agent.adapterProxy.EnablePort(ctx, device, cp)
+ ch, err := agent.adapterProxy.EnablePort(ctx, device, &newPort)
if err != nil {
cancel()
return err
diff --git a/rw_core/core/device/agent_test.go b/rw_core/core/device/agent_test.go
index e9bd663..92977ac 100755
--- a/rw_core/core/device/agent_test.go
+++ b/rw_core/core/device/agent_test.go
@@ -60,6 +60,7 @@
defaultTimeout time.Duration
maxTimeout time.Duration
device *voltha.Device
+ devicePorts map[uint32]*voltha.Port
done chan int
}
@@ -101,12 +102,12 @@
Reason: "All good",
ConnectStatus: voltha.ConnectStatus_UNKNOWN,
Custom: nil,
- Ports: []*voltha.Port{
- {PortNo: 1, Label: "pon-1", Type: voltha.Port_PON_ONU, AdminState: voltha.AdminState_ENABLED,
- OperStatus: voltha.OperStatus_ACTIVE, Peers: []*voltha.Port_PeerPort{{DeviceId: parentID, PortNo: 1}}},
- {PortNo: 100, Label: "uni-100", Type: voltha.Port_ETHERNET_UNI, AdminState: voltha.AdminState_ENABLED,
- OperStatus: voltha.OperStatus_ACTIVE},
- },
+ }
+ test.devicePorts = map[uint32]*voltha.Port{
+ 1: {PortNo: 1, Label: "pon-1", Type: voltha.Port_PON_ONU, AdminState: voltha.AdminState_ENABLED,
+ OperStatus: voltha.OperStatus_ACTIVE, Peers: []*voltha.Port_PeerPort{{DeviceId: parentID, PortNo: 1}}},
+ 100: {PortNo: 100, Label: "uni-100", Type: voltha.Port_ETHERNET_UNI, AdminState: voltha.AdminState_ENABLED,
+ OperStatus: voltha.OperStatus_ACTIVE},
}
return test
}
@@ -168,12 +169,17 @@
d, err := deviceAgent.start(context.TODO(), clonedDevice)
assert.Nil(t, err)
assert.NotNil(t, d)
+ for _, port := range dat.devicePorts {
+ err := deviceAgent.addPort(context.TODO(), port)
+ assert.Nil(t, err)
+ }
deviceMgr.addDeviceAgentToMap(deviceAgent)
return deviceAgent
}
func (dat *DATest) updateDeviceConcurrently(t *testing.T, da *Agent, globalWG *sync.WaitGroup) {
originalDevice, err := da.getDevice(context.Background())
+ originalDevicePorts := da.listDevicePorts()
assert.Nil(t, err)
assert.NotNil(t, originalDevice)
var localWG sync.WaitGroup
@@ -227,7 +233,6 @@
expectedChange := proto.Clone(originalDevice).(*voltha.Device)
expectedChange.OperStatus = voltha.OperStatus_ACTIVE
expectedChange.ConnectStatus = voltha.ConnectStatus_REACHABLE
- expectedChange.Ports = append(expectedChange.Ports, portToAdd)
expectedChange.Root = root
expectedChange.Vendor = vendor
expectedChange.Model = model
@@ -237,8 +242,11 @@
expectedChange.Reason = reason
updatedDevice, _ := da.getDevice(context.Background())
+ updatedDevicePorts := da.listDevicePorts()
assert.NotNil(t, updatedDevice)
assert.True(t, proto.Equal(expectedChange, updatedDevice))
+ assert.Equal(t, len(originalDevicePorts)+1, len(updatedDevicePorts))
+ assert.True(t, proto.Equal(updatedDevicePorts[portToAdd.PortNo], portToAdd))
globalWG.Done()
}
diff --git a/rw_core/core/device/flow/loader_test.go b/rw_core/core/device/flow/loader_test.go
index 8973f12..958124d 100644
--- a/rw_core/core/device/flow/loader_test.go
+++ b/rw_core/core/device/flow/loader_test.go
@@ -27,14 +27,14 @@
// TestLoadersIdentical ensures that the group, flow, and meter loaders always have an identical implementation.
func TestLoadersIdentical(t *testing.T) {
- types := []string{"flow", "group", "meter", "logical_port"}
+ types := []string{"flow", "group", "meter", "port", "logical_port"}
identical := [][]string{
- {`ofp\.OfpFlowStats`, `ofp\.OfpGroupEntry`, `ofp\.OfpMeterEntry`, `voltha\.LogicalPort`},
- {`\.Id`, `\.Desc\.GroupId`, `\.Config\.MeterId`, `\.OfpPort\.PortNo`},
- {`uint64`, `uint32`, `uint32`, `uint32`},
- {`Flow`, `Group`, `Meter`, `Port`},
- {`flow`, `group`, `meter`, `port|logical_port`},
+ {`ofp\.OfpFlowStats`, `ofp\.OfpGroupEntry`, `ofp\.OfpMeterEntry`, `voltha\.Port`, `voltha\.LogicalPort`},
+ {`\.Id`, `\.Desc\.GroupId`, `\.Config\.MeterId`, `\.PortNo`, `\.OfpPort\.PortNo`},
+ {`uint64`, `uint32`, `uint32`, `uint32`, `uint32`},
+ {`Flow`, `Group`, `Meter`, `Port`, `Port`},
+ {`flow`, `group`, `meter`, `port`, `port|logical_port`},
}
regexes := make([][]*regexp.Regexp, len(identical[0]))
diff --git a/rw_core/core/device/logical_agent.go b/rw_core/core/device/logical_agent.go
index 6a14e5a..07f85e8 100644
--- a/rw_core/core/device/logical_agent.go
+++ b/rw_core/core/device/logical_agent.go
@@ -66,13 +66,14 @@
func newLogicalAgent(ctx context.Context, id string, sn string, deviceID string, ldeviceMgr *LogicalManager,
deviceMgr *Manager, dbProxy *model.Path, ldProxy *model.Proxy, defaultTimeout time.Duration) *LogicalAgent {
- agent := &LogicalAgent{
+ return &LogicalAgent{
logicalDeviceID: id,
serialNumber: sn,
rootDeviceID: deviceID,
deviceMgr: deviceMgr,
ldProxy: ldProxy,
ldeviceMgr: ldeviceMgr,
+ deviceRoutes: route.NewDeviceRoutes(id, deviceID, deviceMgr.listDevicePorts),
flowDecomposer: fd.NewFlowDecomposer(deviceMgr),
defaultTimeout: defaultTimeout,
requestQueue: coreutils.NewRequestQueue(),
@@ -82,8 +83,6 @@
meterLoader: meter.NewLoader(dbProxy.SubPath("logical_meters").Proxy(id)),
portLoader: port.NewLoader(dbProxy.SubPath("logical_ports").Proxy(id)),
}
- agent.deviceRoutes = route.NewDeviceRoutes(ctx, agent.logicalDeviceID, agent.deviceMgr.getDevice)
- return agent
}
// start creates the logical device and add it to the data model
@@ -123,9 +122,6 @@
ld.Desc = (proto.Clone(switchCap.Desc)).(*ofp.OfpDesc)
logger.Debugw(ctx, "Switch-capability", log.Fields{"Desc": ld.Desc, "fromAd": switchCap.Desc})
ld.SwitchFeatures = (proto.Clone(switchCap.SwitchFeatures)).(*ofp.OfpSwitchFeatures)
- ld.Flows = &ofp.Flows{Items: nil}
- ld.FlowGroups = &ofp.FlowGroups{Items: nil}
- ld.Ports = []*voltha.LogicalPort{}
// Save the logical device
if err := agent.ldProxy.Set(ctx, ld.Id, ld); err != nil {
@@ -160,6 +156,9 @@
// Update the last data
agent.logicalDevice = ld
+ // now that the root device is known, create DeviceRoutes with it
+ agent.deviceRoutes = route.NewDeviceRoutes(agent.logicalDeviceID, agent.rootDeviceID, agent.deviceMgr.listDevicePorts)
+
// load the flows, meters and groups from KV to cache
agent.flowLoader.Load(ctx)
agent.meterLoader.Load(ctx)
diff --git a/rw_core/core/device/logical_agent_port.go b/rw_core/core/device/logical_agent_port.go
index 0229c18..40f058e 100644
--- a/rw_core/core/device/logical_agent_port.go
+++ b/rw_core/core/device/logical_agent_port.go
@@ -44,15 +44,15 @@
return ret
}
-func (agent *LogicalAgent) updateLogicalPort(ctx context.Context, device *voltha.Device, port *voltha.Port) error {
+func (agent *LogicalAgent) updateLogicalPort(ctx context.Context, device *voltha.Device, devicePorts map[uint32]*voltha.Port, port *voltha.Port) error {
logger.Debugw(ctx, "updateLogicalPort", log.Fields{"deviceId": device.Id, "port": port})
switch port.Type {
case voltha.Port_ETHERNET_NNI:
- if err := agent.addNNILogicalPort(ctx, device, port); err != nil {
+ if err := agent.addNNILogicalPort(ctx, device.Id, devicePorts, port); err != nil {
return err
}
case voltha.Port_ETHERNET_UNI:
- if err := agent.addUNILogicalPort(ctx, device, port); err != nil {
+ if err := agent.addUNILogicalPort(ctx, device.Id, device.AdminState, device.OperStatus, devicePorts, port); err != nil {
return err
}
case voltha.Port_PON_OLT:
@@ -60,16 +60,16 @@
go func() {
if err := agent.buildRoutes(context.Background()); err != nil {
// Not an error - temporary state
- logger.Infow(ctx, "failed-to-update-routes-after-adding-parent-pon-port", log.Fields{"device-id": device.Id, "port": port, "ports-count": len(device.Ports), "error": err})
+ logger.Infow(ctx, "failed-to-update-routes-after-adding-parent-pon-port", log.Fields{"device-id": device.Id, "port": port, "ports-count": len(devicePorts), "error": err})
}
}()
//fallthrough
case voltha.Port_PON_ONU:
// Add the routes corresponding to that child device
go func() {
- if err := agent.updateAllRoutes(context.Background(), device); err != nil {
+ if err := agent.updateAllRoutes(context.Background(), device.Id, devicePorts); err != nil {
// Not an error - temporary state
- logger.Infow(ctx, "failed-to-update-routes-after-adding-child-pon-port", log.Fields{"device-id": device.Id, "port": port, "ports-count": len(device.Ports), "error": err})
+ logger.Infow(ctx, "failed-to-update-routes-after-adding-child-pon-port", log.Fields{"device-id": device.Id, "port": port, "ports-count": len(devicePorts), "error": err})
}
}()
default:
@@ -99,13 +99,21 @@
for _, child := range children.Items {
response := coreutils.NewResponse()
responses = append(responses, response)
- go func(child *voltha.Device) {
- if err = agent.setupUNILogicalPorts(context.Background(), child); err != nil {
+ go func(ctx context.Context, child *voltha.Device) {
+ defer response.Done()
+
+ childPorts, err := agent.deviceMgr.listDevicePorts(ctx, child.Id)
+ if err != nil {
+ logger.Error(ctx, "setting-up-UNI-ports-failed", log.Fields{"deviceID": child.Id})
+ response.Error(status.Errorf(codes.Internal, "UNI-ports-setup-failed: %s", child.Id))
+ return
+ }
+
+ if err = agent.setupUNILogicalPorts(ctx, child, childPorts); err != nil {
logger.Error(ctx, "setting-up-UNI-ports-failed", log.Fields{"deviceID": child.Id})
response.Error(status.Errorf(codes.Internal, "UNI-ports-setup-failed: %s", child.Id))
}
- response.Done()
- }(child)
+ }(context.Background(), child)
}
// Wait for completion
if res := coreutils.WaitForNilOrErrorResponses(agent.defaultTimeout, responses...); res != nil {
@@ -118,19 +126,18 @@
func (agent *LogicalAgent) setupNNILogicalPorts(ctx context.Context, deviceID string) error {
logger.Infow(ctx, "setupNNILogicalPorts-start", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
// Build the logical device based on information retrieved from the device adapter
- var err error
- var device *voltha.Device
- if device, err = agent.deviceMgr.getDevice(ctx, deviceID); err != nil {
- logger.Errorw(ctx, "error-retrieving-device", log.Fields{"error": err, "deviceId": deviceID})
+ devicePorts, err := agent.deviceMgr.listDevicePorts(ctx, deviceID)
+ if err != nil {
+ logger.Errorw(ctx, "error-retrieving-device-ports", log.Fields{"error": err, "deviceId": deviceID})
return err
}
//Get UNI port number
- for _, port := range device.Ports {
+ for _, port := range devicePorts {
if port.Type == voltha.Port_ETHERNET_NNI {
- if err = agent.addNNILogicalPort(ctx, device, port); err != nil {
- logger.Errorw(ctx, "error-adding-UNI-port", log.Fields{"error": err})
+ if err = agent.addNNILogicalPort(ctx, deviceID, devicePorts, port); err != nil {
+ logger.Errorw(ctx, "error-adding-NNI-port", log.Fields{"error": err})
}
}
}
@@ -155,25 +162,6 @@
return nil
}
-// updatePortsState updates the ports state related to the device
-func (agent *LogicalAgent) updatePortsState(ctx context.Context, deviceID string, state voltha.OperStatus_Types) error {
- logger.Infow(ctx, "updatePortsState-start", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
-
- for portNo := range agent.portLoader.ListIDsForDevice(deviceID) {
- if portHandle, have := agent.portLoader.Lock(portNo); have {
- newPort := clonePortSetState(portHandle.GetReadOnly(), state)
- if err := portHandle.Update(ctx, newPort); err != nil {
- portHandle.Unlock()
- return err
- }
- agent.orderedEvents.send(ctx, agent, agent.logicalDeviceID, ofp.OfpPortReason_OFPPR_MODIFY, newPort.OfpPort)
-
- portHandle.Unlock()
- }
- }
- return nil
-}
-
func clonePortSetState(oldPort *voltha.LogicalPort, state voltha.OperStatus_Types) *voltha.LogicalPort {
newPort := *oldPort // only clone the struct(s) that will be changed
newOfpPort := *oldPort.OfpPort
@@ -190,14 +178,14 @@
}
// setupUNILogicalPorts creates a UNI port on the logical device that represents a child UNI interface
-func (agent *LogicalAgent) setupUNILogicalPorts(ctx context.Context, childDevice *voltha.Device) error {
+func (agent *LogicalAgent) setupUNILogicalPorts(ctx context.Context, childDevice *voltha.Device, childDevicePorts map[uint32]*voltha.Port) error {
logger.Infow(ctx, "setupUNILogicalPort", log.Fields{"logicalDeviceId": agent.logicalDeviceID})
// Build the logical device based on information retrieved from the device adapter
var err error
//Get UNI port number
- for _, port := range childDevice.Ports {
+ for _, port := range childDevicePorts {
if port.Type == voltha.Port_ETHERNET_UNI {
- if err = agent.addUNILogicalPort(ctx, childDevice, port); err != nil {
+ if err = agent.addUNILogicalPort(ctx, childDevice.Id, childDevice.AdminState, childDevice.OperStatus, childDevicePorts, port); err != nil {
logger.Errorw(ctx, "error-adding-UNI-port", log.Fields{"error": err})
}
}
@@ -312,7 +300,7 @@
// added and an error in case a valid error is encountered. If the port was successfully added it will return
// (true, nil). If the device is not in the correct state it will return (false, nil) as this is a valid
// scenario. This also applies to the case where the port was already added.
-func (agent *LogicalAgent) addNNILogicalPort(ctx context.Context, device *voltha.Device, port *voltha.Port) error {
+func (agent *LogicalAgent) addNNILogicalPort(ctx context.Context, deviceID string, devicePorts map[uint32]*voltha.Port, port *voltha.Port) error {
logger.Debugw(ctx, "addNNILogicalPort", log.Fields{"logical-device-id": agent.logicalDeviceID, "nni-port": port})
label := fmt.Sprintf("nni-%d", port.PortNo)
@@ -322,7 +310,7 @@
ofpPort.Name = label
nniPort := &voltha.LogicalPort{
RootPort: true,
- DeviceId: device.Id,
+ DeviceId: deviceID,
Id: label,
DevicePortNo: port.PortNo,
OfpPort: &ofpPort,
@@ -346,7 +334,7 @@
// Setup the routes for this device and then send the port update event to the OF Controller
go func() {
// First setup the routes
- if err := agent.updateRoutes(context.Background(), device, nniPort, agent.listLogicalDevicePorts(ctx)); err != nil {
+ if err := agent.updateRoutes(context.Background(), deviceID, devicePorts, nniPort, agent.listLogicalDevicePorts(ctx)); err != nil {
// This is not an error as we may not have enough logical ports to set up routes or some PON ports have not been
// created yet.
logger.Infow(ctx, "routes-not-ready", log.Fields{"logical-device-id": agent.logicalDeviceID, "logical-port": nniPort.OfpPort.PortNo, "error": err})
@@ -362,10 +350,10 @@
// added and an error in case a valid error is encountered. If the port was successfully added it will return
// (true, nil). If the device is not in the correct state it will return (false, nil) as this is a valid
// scenario. This also applies to the case where the port was already added.
-func (agent *LogicalAgent) addUNILogicalPort(ctx context.Context, childDevice *voltha.Device, port *voltha.Port) error {
+func (agent *LogicalAgent) addUNILogicalPort(ctx context.Context, deviceID string, deviceAdminState voltha.AdminState_Types, deviceOperStatus voltha.OperStatus_Types, devicePorts map[uint32]*voltha.Port, port *voltha.Port) error {
logger.Debugw(ctx, "addUNILogicalPort", log.Fields{"port": port})
- if childDevice.AdminState != voltha.AdminState_ENABLED || childDevice.OperStatus != voltha.OperStatus_ACTIVE {
- logger.Infow(ctx, "device-not-ready", log.Fields{"deviceId": childDevice.Id, "admin": childDevice.AdminState, "oper": childDevice.OperStatus})
+ if deviceAdminState != voltha.AdminState_ENABLED || deviceOperStatus != voltha.OperStatus_ACTIVE {
+ logger.Infow(ctx, "device-not-ready", log.Fields{"deviceId": deviceID, "admin": deviceAdminState, "oper": deviceOperStatus})
return nil
}
ofpPort := *port.OfpPort
@@ -373,7 +361,7 @@
ofpPort.PortNo = port.PortNo
uniPort := &voltha.LogicalPort{
RootPort: false,
- DeviceId: childDevice.Id,
+ DeviceId: deviceID,
Id: port.Label,
DevicePortNo: port.PortNo,
OfpPort: &ofpPort,
@@ -397,7 +385,7 @@
// Setup the routes for this device and then send the port update event to the OF Controller
go func() {
// First setup the routes
- if err := agent.updateRoutes(context.Background(), childDevice, uniPort, agent.listLogicalDevicePorts(ctx)); err != nil {
+ if err := agent.updateRoutes(context.Background(), deviceID, devicePorts, uniPort, agent.listLogicalDevicePorts(ctx)); err != nil {
// This is not an error as we may not have enough logical ports to set up routes or some PON ports have not been
// created yet.
logger.Infow(ctx, "routes-not-ready", log.Fields{"logical-device-id": agent.logicalDeviceID, "logical-port": uniPort.OfpPort.PortNo, "error": err})
diff --git a/rw_core/core/device/logical_agent_route.go b/rw_core/core/device/logical_agent_route.go
index 8043e54..62e8a5f 100644
--- a/rw_core/core/device/logical_agent_route.go
+++ b/rw_core/core/device/logical_agent_route.go
@@ -108,10 +108,10 @@
}
//updateRoutes updates the device routes
-func (agent *LogicalAgent) updateRoutes(ctx context.Context, device *voltha.Device, lp *voltha.LogicalPort, lps map[uint32]*voltha.LogicalPort) error {
- logger.Debugw(ctx, "updateRoutes", log.Fields{"logical-device-id": agent.logicalDeviceID, "device-id": device.Id, "port:": lp})
+func (agent *LogicalAgent) updateRoutes(ctx context.Context, deviceID string, devicePorts map[uint32]*voltha.Port, lp *voltha.LogicalPort, lps map[uint32]*voltha.LogicalPort) error {
+ logger.Debugw(ctx, "updateRoutes", log.Fields{"logical-device-id": agent.logicalDeviceID, "device-id": deviceID, "port:": lp})
- if err := agent.deviceRoutes.AddPort(ctx, lp, device, lps); err != nil {
+ if err := agent.deviceRoutes.AddPort(ctx, lp, deviceID, devicePorts, lps); err != nil {
return err
}
if err := agent.deviceRoutes.Print(ctx); err != nil {
@@ -121,10 +121,10 @@
}
//updateAllRoutes updates the device routes using all the logical ports on that device
-func (agent *LogicalAgent) updateAllRoutes(ctx context.Context, device *voltha.Device) error {
- logger.Debugw(ctx, "updateAllRoutes", log.Fields{"logical-device-id": agent.logicalDeviceID, "device-id": device.Id, "ports-count": len(device.Ports)})
+func (agent *LogicalAgent) updateAllRoutes(ctx context.Context, deviceID string, devicePorts map[uint32]*voltha.Port) error {
+ logger.Debugw(ctx, "updateAllRoutes", log.Fields{"logical-device-id": agent.logicalDeviceID, "device-id": deviceID, "ports-count": len(devicePorts)})
- if err := agent.deviceRoutes.AddAllPorts(ctx, device, agent.listLogicalDevicePorts(ctx)); err != nil {
+ if err := agent.deviceRoutes.AddAllPorts(ctx, deviceID, devicePorts, agent.listLogicalDevicePorts(ctx)); err != nil {
return err
}
if err := agent.deviceRoutes.Print(ctx); err != nil {
diff --git a/rw_core/core/device/logical_agent_test.go b/rw_core/core/device/logical_agent_test.go
index 5cd72b4..89b3cbe 100644
--- a/rw_core/core/device/logical_agent_test.go
+++ b/rw_core/core/device/logical_agent_test.go
@@ -53,6 +53,7 @@
defaultTimeout time.Duration
maxTimeout time.Duration
logicalDevice *voltha.LogicalDevice
+ logicalPorts map[uint32]*voltha.LogicalPort
deviceIds []string
done chan int
}
@@ -89,42 +90,42 @@
ofp.OfpCapabilities_OFPC_GROUP_STATS),
},
RootDeviceId: test.deviceIds[0],
- Ports: []*voltha.LogicalPort{
- {
- Id: "1001",
- DeviceId: test.deviceIds[0],
- DevicePortNo: 1,
- RootPort: true,
- OfpPort: &ofp.OfpPort{
- PortNo: 1,
- Name: "port1",
- Config: 4,
- State: 4,
- },
+ }
+ test.logicalPorts = map[uint32]*voltha.LogicalPort{
+ 1: {
+ Id: "1001",
+ DeviceId: test.deviceIds[0],
+ DevicePortNo: 1,
+ RootPort: true,
+ OfpPort: &ofp.OfpPort{
+ PortNo: 1,
+ Name: "port1",
+ Config: 4,
+ State: 4,
},
- {
- Id: "1002",
- DeviceId: test.deviceIds[1],
- DevicePortNo: 2,
- RootPort: false,
- OfpPort: &ofp.OfpPort{
- PortNo: 2,
- Name: "port2",
- Config: 4,
- State: 4,
- },
+ },
+ 2: {
+ Id: "1002",
+ DeviceId: test.deviceIds[1],
+ DevicePortNo: 2,
+ RootPort: false,
+ OfpPort: &ofp.OfpPort{
+ PortNo: 2,
+ Name: "port2",
+ Config: 4,
+ State: 4,
},
- {
- Id: "1003",
- DeviceId: test.deviceIds[2],
- DevicePortNo: 3,
- RootPort: false,
- OfpPort: &ofp.OfpPort{
- PortNo: 3,
- Name: "port3",
- Config: 4,
- State: 4,
- },
+ },
+ 3: {
+ Id: "1003",
+ DeviceId: test.deviceIds[2],
+ DevicePortNo: 3,
+ RootPort: false,
+ OfpPort: &ofp.OfpPort{
+ PortNo: 3,
+ Name: "port3",
+ Config: 4,
+ State: 4,
},
},
}
@@ -184,14 +185,15 @@
clonedLD.DatapathId = rand.Uint64()
lDeviceAgent := newLogicalAgent(context.Background(), clonedLD.Id, clonedLD.Id, clonedLD.RootDeviceId, lDeviceMgr, deviceMgr, lDeviceMgr.dbPath, lDeviceMgr.ldProxy, lDeviceMgr.defaultTimeout)
lDeviceAgent.logicalDevice = clonedLD
- for _, port := range clonedLD.Ports {
- handle, created, err := lDeviceAgent.portLoader.LockOrCreate(context.Background(), port)
+ for _, port := range lda.logicalPorts {
+ clonedPort := proto.Clone(port).(*voltha.LogicalPort)
+ handle, created, err := lDeviceAgent.portLoader.LockOrCreate(context.Background(), clonedPort)
if err != nil {
panic(err)
}
handle.Unlock()
if !created {
- t.Errorf("port %d already exists", port.OfpPort.PortNo)
+ t.Errorf("port %d already exists", clonedPort.OfpPort.PortNo)
}
}
err := lDeviceAgent.ldProxy.Set(context.Background(), clonedLD.Id, clonedLD)
@@ -201,14 +203,14 @@
}
func (lda *LDATest) updateLogicalDeviceConcurrently(t *testing.T, ldAgent *LogicalAgent, globalWG *sync.WaitGroup) {
- originalLogicalDevice, _ := ldAgent.GetLogicalDevice(context.Background())
- assert.NotNil(t, originalLogicalDevice)
+ originalLogicalPorts := ldAgent.listLogicalDevicePorts(context.Background())
+ assert.NotNil(t, originalLogicalPorts)
var localWG sync.WaitGroup
// Change the state of the first port to FAILED
localWG.Add(1)
go func() {
- err := ldAgent.updatePortState(context.Background(), lda.logicalDevice.Ports[0].DevicePortNo, voltha.OperStatus_FAILED)
+ err := ldAgent.updatePortState(context.Background(), 1, voltha.OperStatus_FAILED)
assert.Nil(t, err)
localWG.Done()
}()
@@ -216,7 +218,7 @@
// Change the state of the second port to TESTING
localWG.Add(1)
go func() {
- err := ldAgent.updatePortState(context.Background(), lda.logicalDevice.Ports[1].DevicePortNo, voltha.OperStatus_TESTING)
+ err := ldAgent.updatePortState(context.Background(), 2, voltha.OperStatus_TESTING)
assert.Nil(t, err)
localWG.Done()
}()
@@ -224,9 +226,9 @@
// Change the state of the third port to UNKNOWN and then back to ACTIVE
localWG.Add(1)
go func() {
- err := ldAgent.updatePortState(context.Background(), lda.logicalDevice.Ports[2].DevicePortNo, voltha.OperStatus_UNKNOWN)
+ err := ldAgent.updatePortState(context.Background(), 3, voltha.OperStatus_UNKNOWN)
assert.Nil(t, err)
- err = ldAgent.updatePortState(context.Background(), lda.logicalDevice.Ports[2].DevicePortNo, voltha.OperStatus_ACTIVE)
+ err = ldAgent.updatePortState(context.Background(), 3, voltha.OperStatus_ACTIVE)
assert.Nil(t, err)
localWG.Done()
}()
@@ -262,17 +264,27 @@
meterHandle.Unlock()
}
- expectedChange := proto.Clone(originalLogicalDevice).(*voltha.LogicalDevice)
- expectedChange.Ports[0].OfpPort.Config = originalLogicalDevice.Ports[0].OfpPort.Config | uint32(ofp.OfpPortConfig_OFPPC_PORT_DOWN)
- expectedChange.Ports[0].OfpPort.State = uint32(ofp.OfpPortState_OFPPS_LINK_DOWN)
- expectedChange.Ports[1].OfpPort.Config = originalLogicalDevice.Ports[0].OfpPort.Config | uint32(ofp.OfpPortConfig_OFPPC_PORT_DOWN)
- expectedChange.Ports[1].OfpPort.State = uint32(ofp.OfpPortState_OFPPS_LINK_DOWN)
- expectedChange.Ports[2].OfpPort.Config = originalLogicalDevice.Ports[0].OfpPort.Config & ^uint32(ofp.OfpPortConfig_OFPPC_PORT_DOWN)
- expectedChange.Ports[2].OfpPort.State = uint32(ofp.OfpPortState_OFPPS_LIVE)
+ expectedLogicalPorts := make(map[uint32]*voltha.LogicalPort)
+ for _, port := range originalLogicalPorts {
+ clonedPort := proto.Clone(port).(*voltha.LogicalPort)
+ switch clonedPort.OfpPort.PortNo {
+ case 1:
+ clonedPort.OfpPort.Config = originalLogicalPorts[1].OfpPort.Config | uint32(ofp.OfpPortConfig_OFPPC_PORT_DOWN)
+ clonedPort.OfpPort.State = uint32(ofp.OfpPortState_OFPPS_LINK_DOWN)
+ case 2:
+ clonedPort.OfpPort.Config = originalLogicalPorts[1].OfpPort.Config | uint32(ofp.OfpPortConfig_OFPPC_PORT_DOWN)
+ clonedPort.OfpPort.State = uint32(ofp.OfpPortState_OFPPS_LINK_DOWN)
+ case 3:
+ clonedPort.OfpPort.Config = originalLogicalPorts[1].OfpPort.Config & ^uint32(ofp.OfpPortConfig_OFPPC_PORT_DOWN)
+ clonedPort.OfpPort.State = uint32(ofp.OfpPortState_OFPPS_LIVE)
+ }
+ expectedLogicalPorts[clonedPort.OfpPort.PortNo] = clonedPort
+ }
- updatedLogicalDevicePorts := ldAgent.listLogicalDevicePorts(context.Background())
- for _, p := range expectedChange.Ports {
- assert.True(t, proto.Equal(p, updatedLogicalDevicePorts[p.DevicePortNo]))
+ updatedLogicalDevicePorts := ldAgent.listLogicalDevicePorts(ctx)
+ assert.Equal(t, len(expectedLogicalPorts), len(updatedLogicalDevicePorts))
+ for _, p := range updatedLogicalDevicePorts {
+ assert.True(t, proto.Equal(p, expectedLogicalPorts[p.OfpPort.PortNo]))
}
globalWG.Done()
}
diff --git a/rw_core/core/device/logical_manager.go b/rw_core/core/device/logical_manager.go
index 4eb5ea7..cf2beed 100644
--- a/rw_core/core/device/logical_manager.go
+++ b/rw_core/core/device/logical_manager.go
@@ -348,7 +348,7 @@
// updateLogicalPort sets up a logical port on the logical device based on the device port
// information, if needed
-func (ldMgr *LogicalManager) updateLogicalPort(ctx context.Context, device *voltha.Device, port *voltha.Port) error {
+func (ldMgr *LogicalManager) updateLogicalPort(ctx context.Context, device *voltha.Device, devicePorts map[uint32]*voltha.Port, port *voltha.Port) error {
ldID, err := ldMgr.getLogicalDeviceID(ctx, device)
if err != nil || *ldID == "" {
// This is not an error as the logical device may not have been created at this time. In such a case,
@@ -356,7 +356,7 @@
return nil
}
if agent := ldMgr.getLogicalDeviceAgent(ctx, *ldID); agent != nil {
- if err := agent.updateLogicalPort(ctx, device, port); err != nil {
+ if err := agent.updateLogicalPort(ctx, device, devicePorts, port); err != nil {
return err
}
}
@@ -381,7 +381,7 @@
return nil
}
-func (ldMgr *LogicalManager) setupUNILogicalPorts(ctx context.Context, childDevice *voltha.Device) error {
+func (ldMgr *LogicalManager) setupUNILogicalPorts(ctx context.Context, childDevice *voltha.Device, childDevicePorts map[uint32]*voltha.Port) error {
logger.Debugw(ctx, "setupUNILogicalPorts", log.Fields{"childDeviceId": childDevice.Id, "parentDeviceId": childDevice.ParentId, "current-data": childDevice})
// Sanity check
if childDevice.Root {
@@ -399,7 +399,7 @@
}
if agent := ldMgr.getLogicalDeviceAgent(ctx, logDeviceID); agent != nil {
- if err := agent.setupUNILogicalPorts(ctx, childDevice); err != nil {
+ if err := agent.setupUNILogicalPorts(ctx, childDevice, childDevicePorts); err != nil {
return err
}
}
@@ -442,24 +442,6 @@
return nil
}
-func (ldMgr *LogicalManager) updatePortsState(ctx context.Context, device *voltha.Device, state voltha.OperStatus_Types) error {
- logger.Debugw(ctx, "updatePortsState", log.Fields{"deviceId": device.Id, "state": state, "current-data": device})
-
- var ldID *string
- var err error
- //Get the logical device Id for this device
- if ldID, err = ldMgr.getLogicalDeviceID(ctx, device); err != nil {
- logger.Warnw(ctx, "no-logical-device-found", log.Fields{"deviceId": device.Id, "error": err})
- return err
- }
- if agent := ldMgr.getLogicalDeviceAgent(ctx, *ldID); agent != nil {
- if err := agent.updatePortsState(ctx, device.Id, state); err != nil {
- return err
- }
- }
- return nil
-}
-
// UpdateLogicalDeviceFlowTable updates logical device flow table
func (ldMgr *LogicalManager) UpdateLogicalDeviceFlowTable(ctx context.Context, flow *openflow_13.FlowTableUpdate) (*empty.Empty, error) {
logger.Debugw(ctx, "UpdateLogicalDeviceFlowTable", log.Fields{"logicalDeviceId": flow.Id})
diff --git a/rw_core/core/device/manager.go b/rw_core/core/device/manager.go
index 015c8a3..77da2f0 100755
--- a/rw_core/core/device/manager.go
+++ b/rw_core/core/device/manager.go
@@ -96,7 +96,7 @@
}
dMgr.lockRootDeviceMap.Lock()
defer dMgr.lockRootDeviceMap.Unlock()
- dMgr.rootDevices[agent.deviceID] = agent.isRootdevice
+ dMgr.rootDevices[agent.deviceID] = agent.isRootDevice
}
@@ -211,14 +211,31 @@
return &empty.Empty{}, agent.deleteDevice(ctx)
}
+// GetDevicePort returns the port details for a specific device port entry
+func (dMgr *Manager) GetDevicePort(ctx context.Context, deviceID string, portID uint32) (*voltha.Port, error) {
+ logger.Debugw(ctx, "ListDevicePorts", log.Fields{"device-id": deviceID})
+ agent := dMgr.getDeviceAgent(ctx, deviceID)
+ if agent == nil {
+ return nil, status.Errorf(codes.NotFound, "device-%s", deviceID)
+ }
+ return agent.getDevicePort(portID)
+}
+
// ListDevicePorts returns the ports details for a specific device entry
func (dMgr *Manager) ListDevicePorts(ctx context.Context, id *voltha.ID) (*voltha.Ports, error) {
logger.Debugw(ctx, "ListDevicePorts", log.Fields{"device-id": id.Id})
- device, err := dMgr.getDevice(ctx, id.Id)
- if err != nil {
- return &voltha.Ports{}, err
+ agent := dMgr.getDeviceAgent(ctx, id.Id)
+ if agent == nil {
+ return nil, status.Errorf(codes.NotFound, "device-%s", id.Id)
}
- return &voltha.Ports{Items: device.Ports}, nil
+
+ ports := agent.listDevicePorts()
+ ctr, ret := 0, make([]*voltha.Port, len(ports))
+ for _, port := range ports {
+ ret[ctr] = port
+ ctr++
+ }
+ return &voltha.Ports{Items: ret}, nil
}
// ListDeviceFlows returns the flow details for a specific device entry
@@ -226,7 +243,7 @@
logger.Debugw(ctx, "ListDeviceFlows", log.Fields{"device-id": id.Id})
agent := dMgr.getDeviceAgent(ctx, id.Id)
if agent == nil {
- return &ofp.Flows{}, status.Errorf(codes.NotFound, "device-%s", id.Id)
+ return nil, status.Errorf(codes.NotFound, "device-%s", id.Id)
}
flows := agent.listDeviceFlows()
@@ -293,41 +310,46 @@
return nil, status.Errorf(codes.NotFound, "%s", id)
}
+func (dMgr *Manager) listDevicePorts(ctx context.Context, id string) (map[uint32]*voltha.Port, error) {
+ logger.Debugw(ctx, "listDevicePorts", log.Fields{"deviceid": id})
+ agent := dMgr.getDeviceAgent(ctx, id)
+ if agent == nil {
+ return nil, status.Errorf(codes.NotFound, "%s", id)
+ }
+ return agent.listDevicePorts(), nil
+}
+
// GetChildDevice will return a device, either from memory or from the dB, if present
func (dMgr *Manager) GetChildDevice(ctx context.Context, parentDeviceID string, serialNumber string, onuID int64, parentPortNo int64) (*voltha.Device, error) {
logger.Debugw(ctx, "GetChildDevice", log.Fields{"parentDeviceid": parentDeviceID, "serialNumber": serialNumber,
"parentPortNo": parentPortNo, "onuId": onuID})
- var parentDevice *voltha.Device
- var err error
- if parentDevice, err = dMgr.getDevice(ctx, parentDeviceID); err != nil {
+ parentDevicePorts, err := dMgr.listDevicePorts(ctx, parentDeviceID)
+ if err != nil {
return nil, status.Errorf(codes.Aborted, "%s", err.Error())
}
- var childDeviceIds []string
- if childDeviceIds, err = dMgr.getAllChildDeviceIds(ctx, parentDevice); err != nil {
- return nil, status.Errorf(codes.Aborted, "%s", err.Error())
- }
+ childDeviceIds := dMgr.getAllChildDeviceIds(ctx, parentDevicePorts)
if len(childDeviceIds) == 0 {
- logger.Debugw(ctx, "no-child-devices", log.Fields{"parentDeviceId": parentDevice.Id, "serialNumber": serialNumber, "onuId": onuID})
+ logger.Debugw(ctx, "no-child-devices", log.Fields{"parentDeviceId": parentDeviceID, "serialNumber": serialNumber, "onuId": onuID})
return nil, status.Errorf(codes.NotFound, "%s", parentDeviceID)
}
var foundChildDevice *voltha.Device
- for _, childDeviceID := range childDeviceIds {
+ for childDeviceID := range childDeviceIds {
var found bool
if searchDevice, err := dMgr.getDevice(ctx, childDeviceID); err == nil {
foundOnuID := false
if searchDevice.ProxyAddress.OnuId == uint32(onuID) {
if searchDevice.ParentPortNo == uint32(parentPortNo) {
- logger.Debugw(ctx, "found-child-by-onuid", log.Fields{"parentDeviceId": parentDevice.Id, "onuId": onuID})
+ logger.Debugw(ctx, "found-child-by-onuid", log.Fields{"parentDeviceId": parentDeviceID, "onuId": onuID})
foundOnuID = true
}
}
foundSerialNumber := false
if searchDevice.SerialNumber == serialNumber {
- logger.Debugw(ctx, "found-child-by-serialnumber", log.Fields{"parentDeviceId": parentDevice.Id, "serialNumber": serialNumber})
+ logger.Debugw(ctx, "found-child-by-serialnumber", log.Fields{"parentDeviceId": parentDeviceID, "serialNumber": serialNumber})
foundSerialNumber = true
}
@@ -347,11 +369,11 @@
}
if foundChildDevice != nil {
- logger.Debugw(ctx, "child-device-found", log.Fields{"parentDeviceId": parentDevice.Id, "foundChildDevice": foundChildDevice})
+ logger.Debugw(ctx, "child-device-found", log.Fields{"parentDeviceId": parentDeviceID, "foundChildDevice": foundChildDevice})
return foundChildDevice, nil
}
- logger.Debugw(ctx, "child-device-not-found", log.Fields{"parentDeviceId": parentDevice.Id,
+ logger.Debugw(ctx, "child-device-not-found", log.Fields{"parentDeviceId": parentDeviceID,
"serialNumber": serialNumber, "onuId": onuID, "parentPortNo": parentPortNo})
return nil, status.Errorf(codes.NotFound, "%s", parentDeviceID)
}
@@ -360,22 +382,18 @@
func (dMgr *Manager) GetChildDeviceWithProxyAddress(ctx context.Context, proxyAddress *voltha.Device_ProxyAddress) (*voltha.Device, error) {
logger.Debugw(ctx, "GetChildDeviceWithProxyAddress", log.Fields{"proxyAddress": proxyAddress})
- var parentDevice *voltha.Device
- var err error
- if parentDevice, err = dMgr.getDevice(ctx, proxyAddress.DeviceId); err != nil {
+ parentDevicePorts, err := dMgr.listDevicePorts(ctx, proxyAddress.DeviceId)
+ if err != nil {
return nil, status.Errorf(codes.Aborted, "%s", err.Error())
}
- var childDeviceIds []string
- if childDeviceIds, err = dMgr.getAllChildDeviceIds(ctx, parentDevice); err != nil {
- return nil, status.Errorf(codes.Aborted, "%s", err.Error())
- }
+ childDeviceIds := dMgr.getAllChildDeviceIds(ctx, parentDevicePorts)
if len(childDeviceIds) == 0 {
- logger.Debugw(ctx, "no-child-devices", log.Fields{"parentDeviceId": parentDevice.Id})
+ logger.Debugw(ctx, "no-child-devices", log.Fields{"parentDeviceId": proxyAddress.DeviceId})
return nil, status.Errorf(codes.NotFound, "%s", proxyAddress)
}
var foundChildDevice *voltha.Device
- for _, childDeviceID := range childDeviceIds {
+ for childDeviceID := range childDeviceIds {
if searchDevice, err := dMgr.getDevice(ctx, childDeviceID); err == nil {
if searchDevice.ProxyAddress == proxyAddress {
foundChildDevice = searchDevice
@@ -522,30 +540,27 @@
}
// loadRootDeviceParentAndChildren loads the children and parents of a root device in memory
-func (dMgr *Manager) loadRootDeviceParentAndChildren(ctx context.Context, device *voltha.Device) error {
+func (dMgr *Manager) loadRootDeviceParentAndChildren(ctx context.Context, device *voltha.Device, devicePorts map[uint32]*voltha.Port) error {
logger.Debugw(ctx, "loading-parent-and-children", log.Fields{"deviceId": device.Id})
if device.Root {
// Scenario A
if device.ParentId != "" {
- // Load logical device if needed.
+ // Load logical device if needed.
if err := dMgr.logicalDeviceMgr.load(ctx, device.ParentId); err != nil {
logger.Warnw(ctx, "failure-loading-logical-device", log.Fields{"lDeviceId": device.ParentId})
}
} else {
logger.Debugw(ctx, "no-parent-to-load", log.Fields{"deviceId": device.Id})
}
- // Load all child devices, if needed
- if childDeviceIds, err := dMgr.getAllChildDeviceIds(ctx, device); err == nil {
- for _, childDeviceID := range childDeviceIds {
- if _, err := dMgr.loadDevice(ctx, childDeviceID); err != nil {
- logger.Warnw(ctx, "failure-loading-device", log.Fields{"deviceId": childDeviceID, "error": err})
- return err
- }
+ // Load all child devices, if needed
+ childDeviceIds := dMgr.getAllChildDeviceIds(ctx, devicePorts)
+ for childDeviceID := range childDeviceIds {
+ if _, err := dMgr.loadDevice(ctx, childDeviceID); err != nil {
+ logger.Warnw(ctx, "failure-loading-device", log.Fields{"deviceId": childDeviceID, "error": err})
+ return err
}
- logger.Debugw(ctx, "loaded-children", log.Fields{"deviceId": device.Id, "numChildren": len(childDeviceIds)})
- } else {
- logger.Debugw(ctx, "no-child-to-load", log.Fields{"deviceId": device.Id})
}
+ logger.Debugw(ctx, "loaded-children", log.Fields{"deviceId": device.Id, "numChildren": len(childDeviceIds)})
}
return nil
}
@@ -575,8 +590,10 @@
// Now we face two scenarios
if device.Root {
+ devicePorts := dAgent.listDevicePorts()
+
// Load all children as well as the parent of this device (logical_device)
- if err := dMgr.loadRootDeviceParentAndChildren(ctx, device); err != nil {
+ if err := dMgr.loadRootDeviceParentAndChildren(ctx, device, devicePorts); err != nil {
logger.Warnw(ctx, "failure-loading-device-parent-and-children", log.Fields{"deviceId": deviceID})
return err
}
@@ -656,8 +673,9 @@
logger.Debugw(ctx, "not-reconciling-root-device", log.Fields{"rootId": rootDevice.Id, "state": rootDevice.AdminState})
}
} else { // Should we be reconciling the root's children instead?
+ rootDevicePorts, _ := dMgr.listDevicePorts(ctx, rootDeviceID)
childManagedByAdapter:
- for _, port := range rootDevice.Ports {
+ for _, port := range rootDevicePorts {
for _, peer := range port.Peers {
if childDevice, _ := dMgr.getDeviceFromModel(ctx, peer.DeviceId); childDevice != nil {
isDeviceOwnedByService, err := dMgr.adapterProxy.IsDeviceOwnedByService(ctx, childDevice.Id, adapter.Type, adapter.CurrentReplica)
@@ -717,11 +735,11 @@
}
func (dMgr *Manager) ReconcileChildDevices(ctx context.Context, parentDeviceID string) error {
- if parentDevice, _ := dMgr.getDeviceFromModel(ctx, parentDeviceID); parentDevice != nil {
+ if parentDevicePorts, err := dMgr.listDevicePorts(ctx, parentDeviceID); err == nil {
responses := make([]utils.Response, 0)
- for _, port := range parentDevice.Ports {
+ for _, port := range parentDevicePorts {
for _, peer := range port.Peers {
- if childDevice, _ := dMgr.getDeviceFromModel(ctx, peer.DeviceId); childDevice != nil {
+ if childDevice, err := dMgr.getDeviceFromModel(ctx, peer.DeviceId); err == nil {
responses = append(responses, dMgr.sendReconcileDeviceRequest(ctx, childDevice))
}
}
@@ -758,7 +776,11 @@
if err != nil {
return err
}
- if err = dMgr.logicalDeviceMgr.updateLogicalPort(context.Background(), device, port); err != nil {
+ ports, err := dMgr.listDevicePorts(ctx, deviceID)
+ if err != nil {
+ return err
+ }
+ if err = dMgr.logicalDeviceMgr.updateLogicalPort(context.Background(), device, ports, port); err != nil {
return err
}
return nil
@@ -793,7 +815,7 @@
func (dMgr *Manager) deleteParentFlows(ctx context.Context, deviceID string, uniPort uint32, metadata *voltha.FlowMetadata) error {
logger.Debugw(ctx, "deleteParentFlows", log.Fields{"device-id": deviceID, "uni-port": uniPort, "metadata": metadata})
if agent := dMgr.getDeviceAgent(ctx, deviceID); agent != nil {
- if !agent.isRootdevice {
+ if !agent.isRootDevice {
return status.Errorf(codes.FailedPrecondition, "not-a-parent-device-%s", deviceID)
}
return agent.filterOutFlows(ctx, uniPort, metadata)
@@ -860,10 +882,11 @@
func (dMgr *Manager) GetPorts(ctx context.Context, deviceID string, portType voltha.Port_PortType) (*voltha.Ports, error) {
logger.Debugw(ctx, "GetPorts", log.Fields{"deviceid": deviceID, "portType": portType})
- if agent := dMgr.getDeviceAgent(ctx, deviceID); agent != nil {
- return agent.getPorts(ctx, portType), nil
+ agent := dMgr.getDeviceAgent(ctx, deviceID)
+ if agent == nil {
+ return nil, status.Errorf(codes.NotFound, "%s", deviceID)
}
- return nil, status.Errorf(codes.NotFound, "%s", deviceID)
+ return agent.getPorts(ctx, portType), nil
}
func (dMgr *Manager) UpdateDeviceStatus(ctx context.Context, deviceID string, operStatus voltha.OperStatus_Types, connStatus voltha.ConnectStatus_Types) error {
@@ -876,19 +899,11 @@
func (dMgr *Manager) UpdateChildrenStatus(ctx context.Context, deviceID string, operStatus voltha.OperStatus_Types, connStatus voltha.ConnectStatus_Types) error {
logger.Debugw(ctx, "UpdateChildrenStatus", log.Fields{"parentDeviceid": deviceID, "operStatus": operStatus, "connStatus": connStatus})
- var parentDevice *voltha.Device
- var err error
- if parentDevice, err = dMgr.getDevice(ctx, deviceID); err != nil {
+ parentDevicePorts, err := dMgr.listDevicePorts(ctx, deviceID)
+ if err != nil {
return status.Errorf(codes.Aborted, "%s", err.Error())
}
- var childDeviceIds []string
- if childDeviceIds, err = dMgr.getAllChildDeviceIds(ctx, parentDevice); err != nil {
- return status.Errorf(codes.Aborted, "%s", err.Error())
- }
- if len(childDeviceIds) == 0 {
- logger.Debugw(ctx, "no-child-device", log.Fields{"parentDeviceId": parentDevice.Id})
- }
- for _, childDeviceID := range childDeviceIds {
+ for childDeviceID := range dMgr.getAllChildDeviceIds(ctx, parentDevicePorts) {
if agent := dMgr.getDeviceAgent(ctx, childDeviceID); agent != nil {
if err = agent.updateDeviceStatus(ctx, operStatus, connStatus); err != nil {
return status.Errorf(codes.Aborted, "childDevice:%s, error:%s", childDeviceID, err.Error())
@@ -952,37 +967,20 @@
}
//UpdatePortsState updates all ports on the device
-func (dMgr *Manager) UpdatePortsState(ctx context.Context, deviceID string, state voltha.OperStatus_Types) error {
+func (dMgr *Manager) UpdatePortsState(ctx context.Context, deviceID string, portTypeFilter uint32, state voltha.OperStatus_Types) error {
logger.Debugw(ctx, "UpdatePortsState", log.Fields{"deviceid": deviceID})
-
- if agent := dMgr.getDeviceAgent(ctx, deviceID); agent != nil {
- switch state {
- case voltha.OperStatus_ACTIVE:
- if err := agent.updatePortsOperState(ctx, state); err != nil {
- logger.Warnw(ctx, "updatePortsOperState-failed", log.Fields{"deviceId": deviceID, "error": err})
- return err
- }
- case voltha.OperStatus_UNKNOWN:
- if err := agent.updatePortsOperState(ctx, state); err != nil {
- logger.Warnw(ctx, "updatePortsOperState-failed", log.Fields{"deviceId": deviceID, "error": err})
- return err
- }
- default:
- return status.Error(codes.Unimplemented, "state-change-not-implemented")
- }
- // Notify the logical device about the state change
- device, err := dMgr.getDevice(ctx, deviceID)
- if err != nil {
- logger.Warnw(ctx, "non-existent-device", log.Fields{"deviceId": deviceID, "error": err})
- return err
- }
- if err := dMgr.logicalDeviceMgr.updatePortsState(ctx, device, state); err != nil {
- logger.Warnw(ctx, "failed-updating-ports-state", log.Fields{"deviceId": deviceID, "error": err})
- return err
- }
- return nil
+ agent := dMgr.getDeviceAgent(ctx, deviceID)
+ if agent == nil {
+ return status.Errorf(codes.NotFound, "%s", deviceID)
}
- return status.Errorf(codes.NotFound, "%s", deviceID)
+ if state != voltha.OperStatus_ACTIVE && state != voltha.OperStatus_UNKNOWN {
+ return status.Error(codes.Unimplemented, "state-change-not-implemented")
+ }
+ if err := agent.updatePortsOperState(ctx, portTypeFilter, state); err != nil {
+ logger.Warnw(ctx, "updatePortsOperState-failed", log.Fields{"deviceId": deviceID, "error": err})
+ return err
+ }
+ return nil
}
func (dMgr *Manager) ChildDeviceDetected(ctx context.Context, parentDeviceID string, parentPortNo int64, deviceType string,
@@ -1176,9 +1174,8 @@
//cannot manage the child devices. This will trigger the Core to disable all the child devices.
func (dMgr *Manager) ChildDevicesLost(ctx context.Context, parentDeviceID string) error {
logger.Debug(ctx, "ChildDevicesLost")
- var err error
- var parentDevice *voltha.Device
- if parentDevice, err = dMgr.getDevice(ctx, parentDeviceID); err != nil {
+ parentDevice, err := dMgr.getDevice(ctx, parentDeviceID)
+ if err != nil {
logger.Warnw(ctx, "failed-getting-device", log.Fields{"deviceId": parentDeviceID, "error": err})
return err
}
@@ -1189,34 +1186,28 @@
// disable/enable sequence. This will trigger the Core to Enable all the child devices of that parent.
func (dMgr *Manager) ChildDevicesDetected(ctx context.Context, parentDeviceID string) error {
logger.Debug(ctx, "ChildDevicesDetected")
- var err error
- var parentDevice *voltha.Device
- var childDeviceIds []string
-
- if parentDevice, err = dMgr.getDevice(ctx, parentDeviceID); err != nil {
+ parentDevicePorts, err := dMgr.listDevicePorts(ctx, parentDeviceID)
+ if err != nil {
logger.Warnw(ctx, "failed-getting-device", log.Fields{"deviceId": parentDeviceID, "error": err})
return err
}
-
- if childDeviceIds, err = dMgr.getAllChildDeviceIds(ctx, parentDevice); err != nil {
- return status.Errorf(codes.NotFound, "%s", parentDevice.Id)
- }
+ childDeviceIds := dMgr.getAllChildDeviceIds(ctx, parentDevicePorts)
if len(childDeviceIds) == 0 {
- logger.Debugw(ctx, "no-child-device", log.Fields{"parentDeviceId": parentDevice.Id})
+ logger.Debugw(ctx, "no-child-device", log.Fields{"parentDeviceId": parentDeviceID})
}
allChildEnableRequestSent := true
- for _, childDeviceID := range childDeviceIds {
+ for childDeviceID := range childDeviceIds {
if agent := dMgr.getDeviceAgent(ctx, childDeviceID); agent != nil {
// Run the children re-registration in its own routine
- go func() {
- err = agent.enableDevice(context.Background())
+ go func(ctx context.Context) {
+ err = agent.enableDevice(ctx)
if err != nil {
logger.Errorw(ctx, "unable-to-enable-device", log.Fields{"error": err})
}
- }()
+ }(context.Background())
} else {
err = status.Errorf(codes.Unavailable, "no agent for child device %s", childDeviceID)
- logger.Errorw(ctx, "no-child-device-agent", log.Fields{"parentDeviceId": parentDevice.Id, "childId": childDeviceID})
+ logger.Errorw(ctx, "no-child-device-agent", log.Fields{"parentDeviceId": parentDeviceID, "childId": childDeviceID})
allChildEnableRequestSent = false
}
}
@@ -1234,17 +1225,10 @@
//DisableAllChildDevices is invoked as a callback when the parent device is disabled
func (dMgr *Manager) DisableAllChildDevices(ctx context.Context, parentCurrDevice *voltha.Device) error {
logger.Debug(ctx, "DisableAllChildDevices")
- var childDeviceIds []string
- var err error
- if childDeviceIds, err = dMgr.getAllChildDeviceIds(ctx, parentCurrDevice); err != nil {
- return status.Errorf(codes.NotFound, "%s", parentCurrDevice.Id)
- }
- if len(childDeviceIds) == 0 {
- logger.Debugw(ctx, "no-child-device", log.Fields{"parentDeviceId": parentCurrDevice.Id})
- }
- for _, childDeviceID := range childDeviceIds {
+ ports, _ := dMgr.listDevicePorts(ctx, parentCurrDevice.Id)
+ for childDeviceID := range dMgr.getAllChildDeviceIds(ctx, ports) {
if agent := dMgr.getDeviceAgent(ctx, childDeviceID); agent != nil {
- if err = agent.disableDevice(ctx); err != nil {
+ if err := agent.disableDevice(ctx); err != nil {
// Just log the error - this error happens only if the child device was already in deleted state.
logger.Errorw(ctx, "failure-disable-device", log.Fields{"deviceId": childDeviceID, "error": err.Error()})
}
@@ -1256,17 +1240,10 @@
//DeleteAllChildDevices is invoked as a callback when the parent device is deleted
func (dMgr *Manager) DeleteAllChildDevices(ctx context.Context, parentCurrDevice *voltha.Device) error {
logger.Debug(ctx, "DeleteAllChildDevices")
- var childDeviceIds []string
- var err error
- if childDeviceIds, err = dMgr.getAllChildDeviceIds(ctx, parentCurrDevice); err != nil {
- return status.Errorf(codes.NotFound, "%s", parentCurrDevice.Id)
- }
- if len(childDeviceIds) == 0 {
- logger.Debugw(ctx, "no-child-device", log.Fields{"parentDeviceId": parentCurrDevice.Id})
- }
- for _, childDeviceID := range childDeviceIds {
+ ports, _ := dMgr.listDevicePorts(ctx, parentCurrDevice.Id)
+ for childDeviceID := range dMgr.getAllChildDeviceIds(ctx, ports) {
if agent := dMgr.getDeviceAgent(ctx, childDeviceID); agent != nil {
- if err = agent.deleteDevice(ctx); err != nil {
+ if err := agent.deleteDevice(ctx); err != nil {
logger.Warnw(ctx, "failure-delete-device", log.Fields{"deviceId": childDeviceID, "error": err.Error()})
}
// No further action is required here. The deleteDevice will change the device state where the resulting
@@ -1300,30 +1277,26 @@
}
//getAllChildDeviceIds is a helper method to get all the child device IDs from the device passed as parameter
-func (dMgr *Manager) getAllChildDeviceIds(ctx context.Context, parentDevice *voltha.Device) ([]string, error) {
- logger.Debugw(ctx, "getAllChildDeviceIds", log.Fields{"parentDeviceId": parentDevice.Id})
- childDeviceIds := make([]string, 0)
- if parentDevice != nil {
- for _, port := range parentDevice.Ports {
- for _, peer := range port.Peers {
- childDeviceIds = append(childDeviceIds, peer.DeviceId)
- }
+func (dMgr *Manager) getAllChildDeviceIds(ctx context.Context, parentDevicePorts map[uint32]*voltha.Port) map[string]struct{} {
+ logger.Debug(ctx, "getAllChildDeviceIds")
+ childDeviceIds := make(map[string]struct{}, len(parentDevicePorts))
+ for _, port := range parentDevicePorts {
+ for _, peer := range port.Peers {
+ childDeviceIds[peer.DeviceId] = struct{}{}
}
- logger.Debugw(ctx, "returning-getAllChildDeviceIds", log.Fields{"parentDeviceId": parentDevice.Id, "childDeviceIds": childDeviceIds})
}
- return childDeviceIds, nil
+ logger.Debugw(ctx, "returning-getAllChildDeviceIds", log.Fields{"childDeviceIds": childDeviceIds})
+ return childDeviceIds
}
//GetAllChildDevices is a helper method to get all the child device IDs from the device passed as parameter
func (dMgr *Manager) GetAllChildDevices(ctx context.Context, parentDeviceID string) (*voltha.Devices, error) {
logger.Debugw(ctx, "GetAllChildDevices", log.Fields{"parentDeviceId": parentDeviceID})
- if parentDevice, err := dMgr.getDevice(ctx, parentDeviceID); err == nil {
+ if parentDevicePorts, err := dMgr.listDevicePorts(ctx, parentDeviceID); err == nil {
childDevices := make([]*voltha.Device, 0)
- if childDeviceIds, er := dMgr.getAllChildDeviceIds(ctx, parentDevice); er == nil {
- for _, deviceID := range childDeviceIds {
- if d, e := dMgr.getDevice(ctx, deviceID); e == nil && d != nil {
- childDevices = append(childDevices, d)
- }
+ for deviceID := range dMgr.getAllChildDeviceIds(ctx, parentDevicePorts) {
+ if d, e := dMgr.getDevice(ctx, deviceID); e == nil && d != nil {
+ childDevices = append(childDevices, d)
}
}
return &voltha.Devices{Items: childDevices}, nil
@@ -1334,7 +1307,11 @@
// SetupUNILogicalPorts creates UNI ports on the logical device that represents a child UNI interface
func (dMgr *Manager) SetupUNILogicalPorts(ctx context.Context, cDevice *voltha.Device) error {
logger.Info(ctx, "addUNILogicalPort")
- if err := dMgr.logicalDeviceMgr.setupUNILogicalPorts(ctx, cDevice); err != nil {
+ cDevicePorts, err := dMgr.listDevicePorts(ctx, cDevice.Id)
+ if err != nil {
+ return err
+ }
+ if err := dMgr.logicalDeviceMgr.setupUNILogicalPorts(ctx, cDevice, cDevicePorts); err != nil {
logger.Warnw(ctx, "addUNILogicalPort-error", log.Fields{"device": cDevice, "err": err})
return err
}
@@ -1529,7 +1506,7 @@
if agent == nil {
return nil, status.Errorf(codes.NotFound, "%s", port.DeviceId)
}
- return &empty.Empty{}, agent.enablePort(ctx, port)
+ return &empty.Empty{}, agent.enablePort(ctx, port.PortNo)
}
func (dMgr *Manager) DisablePort(ctx context.Context, port *voltha.Port) (*empty.Empty, error) {
@@ -1538,7 +1515,7 @@
if agent == nil {
return nil, status.Errorf(codes.NotFound, "%s", port.DeviceId)
}
- return &empty.Empty{}, agent.disablePort(ctx, port)
+ return &empty.Empty{}, agent.disablePort(ctx, port.PortNo)
}
// ChildDeviceLost calls parent adapter to delete child device and all its references
diff --git a/tests/core/api/common.go b/rw_core/core/device/port/common.go
similarity index 91%
rename from tests/core/api/common.go
rename to rw_core/core/device/port/common.go
index e694b19..df435c1 100644
--- a/tests/core/api/common.go
+++ b/rw_core/core/device/port/common.go
@@ -1,5 +1,3 @@
-// +build integration
-
/*
* Copyright 2020-present Open Networking Foundation
*
@@ -15,7 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package api
+
+// Package core Common Logger initialization
+package port
import (
"github.com/opencord/voltha-lib-go/v3/pkg/log"
@@ -26,7 +26,7 @@
func init() {
// Setup this package so that it's log level can be modified at run time
var err error
- logger, err = log.RegisterPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "api"})
+ logger, err = log.RegisterPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "port"})
if err != nil {
panic(err)
}
diff --git a/rw_core/core/device/port/loader.go b/rw_core/core/device/port/loader.go
new file mode 100644
index 0000000..479695a
--- /dev/null
+++ b/rw_core/core/device/port/loader.go
@@ -0,0 +1,187 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+
+ * http://www.apache.org/licenses/LICENSE-2.0
+
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package port
+
+import (
+ "context"
+ "fmt"
+ "sync"
+
+ "github.com/opencord/voltha-go/db/model"
+ "github.com/opencord/voltha-lib-go/v3/pkg/log"
+ "github.com/opencord/voltha-protos/v3/go/voltha"
+ "google.golang.org/grpc/codes"
+ "google.golang.org/grpc/status"
+)
+
+// Loader hides all low-level locking & synchronization related to port state updates
+type Loader struct {
+ dbProxy *model.Proxy
+ // this lock protects the ports map, it does not protect individual ports
+ lock sync.RWMutex
+ ports map[uint32]*chunk
+}
+
+// chunk keeps a port and the lock for this port
+type chunk struct {
+ // this lock is used to synchronize all access to the port, and also to the "deleted" variable
+ lock sync.Mutex
+ deleted bool
+
+ port *voltha.Port
+}
+
+func NewLoader(dbProxy *model.Proxy) *Loader {
+ return &Loader{
+ dbProxy: dbProxy,
+ ports: make(map[uint32]*chunk),
+ }
+}
+
+// Load queries existing ports from the kv,
+// and should only be called once when first created.
+func (loader *Loader) Load(ctx context.Context) {
+ loader.lock.Lock()
+ defer loader.lock.Unlock()
+
+ var ports []*voltha.Port
+ if err := loader.dbProxy.List(ctx, &ports); err != nil {
+ logger.Errorw(ctx, "failed-to-list-ports-from-cluster-data-proxy", log.Fields{"error": err})
+ return
+ }
+ for _, port := range ports {
+ loader.ports[port.PortNo] = &chunk{port: port}
+ }
+}
+
+// LockOrCreate locks this port if it exists, or creates a new port if it does not.
+// In the case of port creation, the provided "port" must not be modified afterwards.
+func (loader *Loader) LockOrCreate(ctx context.Context, port *voltha.Port) (*Handle, bool, error) {
+ // try to use read lock instead of full lock if possible
+ if handle, have := loader.Lock(port.PortNo); have {
+ return handle, false, nil
+ }
+
+ loader.lock.Lock()
+ entry, have := loader.ports[port.PortNo]
+ if !have {
+ entry := &chunk{port: port}
+ loader.ports[port.PortNo] = entry
+ entry.lock.Lock()
+ loader.lock.Unlock()
+
+ if err := loader.dbProxy.Set(ctx, fmt.Sprint(port.PortNo), port); err != nil {
+ // revert the map
+ loader.lock.Lock()
+ delete(loader.ports, port.PortNo)
+ loader.lock.Unlock()
+
+ entry.deleted = true
+ entry.lock.Unlock()
+ return nil, false, err
+ }
+ return &Handle{loader: loader, chunk: entry}, true, nil
+ }
+ loader.lock.Unlock()
+
+ entry.lock.Lock()
+ if entry.deleted {
+ entry.lock.Unlock()
+ return loader.LockOrCreate(ctx, port)
+ }
+ return &Handle{loader: loader, chunk: entry}, false, nil
+}
+
+// Lock acquires the lock for this port, and returns a handle which can be used to access the port until it's unlocked.
+// This handle ensures that the port cannot be accessed if the lock is not held.
+// Returns false if the port is not present.
+// TODO: consider accepting a ctx and aborting the lock attempt on cancellation
+func (loader *Loader) Lock(id uint32) (*Handle, bool) {
+ loader.lock.RLock()
+ entry, have := loader.ports[id]
+ loader.lock.RUnlock()
+
+ if !have {
+ return nil, false
+ }
+
+ entry.lock.Lock()
+ if entry.deleted {
+ entry.lock.Unlock()
+ return loader.Lock(id)
+ }
+ return &Handle{loader: loader, chunk: entry}, true
+}
+
+// Handle is allocated for each Lock() call, all modifications are made using it, and it is invalidated by Unlock()
+// This enforces correct Lock()-Usage()-Unlock() ordering.
+type Handle struct {
+ loader *Loader
+ chunk *chunk
+}
+
+// GetReadOnly returns an *voltha.Port which MUST NOT be modified externally, but which is safe to keep indefinitely
+func (h *Handle) GetReadOnly() *voltha.Port {
+ return h.chunk.port
+}
+
+// Update updates an existing port in the kv.
+// The provided "port" must not be modified afterwards.
+func (h *Handle) Update(ctx context.Context, port *voltha.Port) error {
+ if err := h.loader.dbProxy.Set(ctx, fmt.Sprint(port.PortNo), port); err != nil {
+ return status.Errorf(codes.Internal, "failed-update-port-%v: %s", port.PortNo, err)
+ }
+ h.chunk.port = port
+ return nil
+}
+
+// Delete removes the device from the kv
+func (h *Handle) Delete(ctx context.Context) error {
+ if err := h.loader.dbProxy.Remove(ctx, fmt.Sprint(h.chunk.port.PortNo)); err != nil {
+ return fmt.Errorf("couldnt-delete-port-from-store-%v", h.chunk.port.PortNo)
+ }
+ h.chunk.deleted = true
+
+ h.loader.lock.Lock()
+ delete(h.loader.ports, h.chunk.port.PortNo)
+ h.loader.lock.Unlock()
+
+ h.Unlock()
+ return nil
+}
+
+// Unlock releases the lock on the port
+func (h *Handle) Unlock() {
+ if h.chunk != nil {
+ h.chunk.lock.Unlock()
+ h.chunk = nil // attempting to access the port through this handle in future will panic
+ }
+}
+
+// ListIDs returns a snapshot of all the managed port IDs
+// TODO: iterating through ports safely is expensive now, since all ports are stored & locked separately
+// should avoid this where possible
+func (loader *Loader) ListIDs() map[uint32]struct{} {
+ loader.lock.RLock()
+ defer loader.lock.RUnlock()
+ // copy the IDs so caller can safely iterate
+ ret := make(map[uint32]struct{}, len(loader.ports))
+ for id := range loader.ports {
+ ret[id] = struct{}{}
+ }
+ return ret
+}
diff --git a/rw_core/core/device/remote/adapter_proxy_test.go b/rw_core/core/device/remote/adapter_proxy_test.go
index 5ab0127..46de80f 100755
--- a/rw_core/core/device/remote/adapter_proxy_test.go
+++ b/rw_core/core/device/remote/adapter_proxy_test.go
@@ -18,6 +18,10 @@
import (
"context"
"crypto/rand"
+ "strings"
+ "testing"
+ "time"
+
"github.com/golang/protobuf/ptypes"
any2 "github.com/golang/protobuf/ptypes/any"
cm "github.com/opencord/voltha-go/rw_core/mocks"
@@ -31,9 +35,6 @@
"github.com/stretchr/testify/assert"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
- "strings"
- "testing"
- "time"
)
const (
diff --git a/rw_core/flowdecomposition/flow_decomposer_test.go b/rw_core/flowdecomposition/flow_decomposer_test.go
index 80ff313..ea560e2 100644
--- a/rw_core/flowdecomposition/flow_decomposer_test.go
+++ b/rw_core/flowdecomposition/flow_decomposer_test.go
@@ -32,56 +32,58 @@
type testDeviceManager struct {
mocks.DeviceManager
- devices map[string]*voltha.Device
+ devices map[string]*voltha.Device
+ devicePorts map[string]map[uint32]*voltha.Port
}
func newTestDeviceManager() *testDeviceManager {
var tdm testDeviceManager
tdm.devices = make(map[string]*voltha.Device)
+ tdm.devicePorts = make(map[string]map[uint32]*voltha.Port)
tdm.devices["olt"] = &voltha.Device{
Id: "olt",
Root: true,
ParentId: "logical_device",
- Ports: []*voltha.Port{
- {PortNo: 1, Label: "pon"},
- {PortNo: 2, Label: "nni"},
- },
+ }
+ tdm.devicePorts["olt"] = map[uint32]*voltha.Port{
+ 1: {PortNo: 1, Label: "pon"},
+ 2: {PortNo: 2, Label: "nni"},
}
tdm.devices["onu1"] = &voltha.Device{
Id: "onu1",
Root: false,
ParentId: "olt",
- Ports: []*voltha.Port{
- {PortNo: 1, Label: "pon"},
- {PortNo: 2, Label: "uni"},
- },
+ }
+ tdm.devicePorts["onu1"] = map[uint32]*voltha.Port{
+ 1: {PortNo: 1, Label: "pon"},
+ 2: {PortNo: 2, Label: "uni"},
}
tdm.devices["onu2"] = &voltha.Device{
Id: "onu2",
Root: false,
ParentId: "olt",
- Ports: []*voltha.Port{
- {PortNo: 1, Label: "pon"},
- {PortNo: 2, Label: "uni"},
- },
+ }
+ tdm.devicePorts["onu2"] = map[uint32]*voltha.Port{
+ 1: {PortNo: 1, Label: "pon"},
+ 2: {PortNo: 2, Label: "uni"},
}
tdm.devices["onu3"] = &voltha.Device{
Id: "onu3",
Root: false,
ParentId: "olt",
- Ports: []*voltha.Port{
- {PortNo: 1, Label: "pon"},
- {PortNo: 2, Label: "uni"},
- },
+ }
+ tdm.devicePorts["onu3"] = map[uint32]*voltha.Port{
+ 1: {PortNo: 1, Label: "pon"},
+ 2: {PortNo: 2, Label: "uni"},
}
tdm.devices["onu4"] = &voltha.Device{
Id: "onu4",
Root: false,
ParentId: "olt",
- Ports: []*voltha.Port{
- {PortNo: 1, Label: "pon"},
- {PortNo: 2, Label: "uni"},
- },
+ }
+ tdm.devicePorts["onu4"] = map[uint32]*voltha.Port{
+ 1: {PortNo: 1, Label: "pon"},
+ 2: {PortNo: 2, Label: "uni"},
}
return &tdm
}
@@ -92,6 +94,13 @@
}
return nil, errors.New("ABSENT")
}
+func (tdm *testDeviceManager) listDevicePorts(ctx context.Context, deviceID string) (map[uint32]*voltha.Port, error) {
+ ports, have := tdm.devicePorts[deviceID]
+ if !have {
+ return nil, errors.New("ABSENT")
+ }
+ return ports, nil
+}
func (tdm *testDeviceManager) IsRootDevice(deviceID string) (bool, error) {
if d, ok := tdm.devices[deviceID]; ok {
return d.Root, nil
@@ -134,62 +143,62 @@
tfd.routes[route.OFPortLink{Ingress: 10, Egress: 1}] = []route.Hop{
{
DeviceID: "olt",
- Ingress: tfd.dMgr.devices["olt"].Ports[1].PortNo,
- Egress: tfd.dMgr.devices["olt"].Ports[0].PortNo,
+ Ingress: 2,
+ Egress: 1,
},
{
DeviceID: "onu1",
- Ingress: tfd.dMgr.devices["onu1"].Ports[0].PortNo,
- Egress: tfd.dMgr.devices["onu1"].Ports[1].PortNo,
+ Ingress: 1,
+ Egress: 2,
},
}
tfd.routes[route.OFPortLink{Ingress: 10, Egress: 2}] = []route.Hop{
{
DeviceID: "olt",
- Ingress: tfd.dMgr.devices["olt"].Ports[1].PortNo,
- Egress: tfd.dMgr.devices["olt"].Ports[0].PortNo,
+ Ingress: 2,
+ Egress: 1,
},
{
DeviceID: "onu2",
- Ingress: tfd.dMgr.devices["onu2"].Ports[0].PortNo,
- Egress: tfd.dMgr.devices["onu2"].Ports[1].PortNo,
+ Ingress: 1,
+ Egress: 2,
},
}
tfd.routes[route.OFPortLink{Ingress: 10, Egress: 3}] = []route.Hop{
{
DeviceID: "olt",
- Ingress: tfd.dMgr.devices["olt"].Ports[1].PortNo,
- Egress: tfd.dMgr.devices["olt"].Ports[0].PortNo,
+ Ingress: 2,
+ Egress: 1,
},
{
DeviceID: "onu3",
- Ingress: tfd.dMgr.devices["onu3"].Ports[0].PortNo,
- Egress: tfd.dMgr.devices["onu3"].Ports[1].PortNo,
+ Ingress: 1,
+ Egress: 2,
},
}
tfd.routes[route.OFPortLink{Ingress: 10, Egress: 4}] = []route.Hop{
{
DeviceID: "olt",
- Ingress: tfd.dMgr.devices["olt"].Ports[1].PortNo,
- Egress: tfd.dMgr.devices["olt"].Ports[0].PortNo,
+ Ingress: 2,
+ Egress: 1,
},
{
DeviceID: "onu4",
- Ingress: tfd.dMgr.devices["onu4"].Ports[0].PortNo,
- Egress: tfd.dMgr.devices["onu4"].Ports[1].PortNo,
+ Ingress: 1,
+ Egress: 2,
},
}
tfd.routes[route.OFPortLink{Ingress: 10, Egress: 10}] = []route.Hop{
{
DeviceID: "olt",
- Ingress: tfd.dMgr.devices["olt"].Ports[1].PortNo,
- Egress: tfd.dMgr.devices["olt"].Ports[1].PortNo,
+ Ingress: 2,
+ Egress: 2,
},
{
DeviceID: "olt",
- Ingress: tfd.dMgr.devices["olt"].Ports[1].PortNo,
- Egress: tfd.dMgr.devices["olt"].Ports[1].PortNo,
+ Ingress: 2,
+ Egress: 2,
},
}
@@ -198,49 +207,49 @@
tfd.routes[route.OFPortLink{Ingress: 1, Egress: 10}] = []route.Hop{
{
DeviceID: "onu1",
- Ingress: tfd.dMgr.devices["onu1"].Ports[1].PortNo,
- Egress: tfd.dMgr.devices["onu1"].Ports[0].PortNo,
+ Ingress: 2,
+ Egress: 1,
},
{
DeviceID: "olt",
- Ingress: tfd.dMgr.devices["olt"].Ports[0].PortNo,
- Egress: tfd.dMgr.devices["olt"].Ports[1].PortNo,
+ Ingress: 1,
+ Egress: 2,
},
}
tfd.routes[route.OFPortLink{Ingress: 2, Egress: 10}] = []route.Hop{
{
DeviceID: "onu2",
- Ingress: tfd.dMgr.devices["onu2"].Ports[1].PortNo,
- Egress: tfd.dMgr.devices["onu2"].Ports[0].PortNo,
+ Ingress: 2,
+ Egress: 1,
},
{
DeviceID: "olt",
- Ingress: tfd.dMgr.devices["olt"].Ports[0].PortNo,
- Egress: tfd.dMgr.devices["olt"].Ports[1].PortNo,
+ Ingress: 1,
+ Egress: 2,
},
}
tfd.routes[route.OFPortLink{Ingress: 3, Egress: 10}] = []route.Hop{
{
DeviceID: "onu3",
- Ingress: tfd.dMgr.devices["onu3"].Ports[1].PortNo,
- Egress: tfd.dMgr.devices["onu3"].Ports[0].PortNo,
+ Ingress: 2,
+ Egress: 1,
},
{
DeviceID: "olt",
- Ingress: tfd.dMgr.devices["olt"].Ports[0].PortNo,
- Egress: tfd.dMgr.devices["olt"].Ports[1].PortNo,
+ Ingress: 1,
+ Egress: 2,
},
}
tfd.routes[route.OFPortLink{Ingress: 4, Egress: 10}] = []route.Hop{
{
DeviceID: "onu4",
- Ingress: tfd.dMgr.devices["onu4"].Ports[1].PortNo,
- Egress: tfd.dMgr.devices["onu4"].Ports[0].PortNo,
+ Ingress: 2,
+ Egress: 1,
},
{
DeviceID: "olt",
- Ingress: tfd.dMgr.devices["olt"].Ports[0].PortNo,
- Egress: tfd.dMgr.devices["olt"].Ports[1].PortNo,
+ Ingress: 1,
+ Egress: 2,
},
}
@@ -250,49 +259,49 @@
tfd.routes[route.OFPortLink{Ingress: 1, Egress: 0}] = []route.Hop{
{
DeviceID: "onu1",
- Ingress: tfd.dMgr.devices["onu1"].Ports[1].PortNo,
- Egress: tfd.dMgr.devices["onu1"].Ports[0].PortNo,
+ Ingress: 2,
+ Egress: 1,
},
{
DeviceID: "olt",
- Ingress: tfd.dMgr.devices["olt"].Ports[0].PortNo,
- Egress: tfd.dMgr.devices["olt"].Ports[1].PortNo,
+ Ingress: 1,
+ Egress: 2,
},
}
tfd.routes[route.OFPortLink{Ingress: 2, Egress: 0}] = []route.Hop{
{
DeviceID: "onu2",
- Ingress: tfd.dMgr.devices["onu2"].Ports[1].PortNo,
- Egress: tfd.dMgr.devices["onu2"].Ports[0].PortNo,
+ Ingress: 2,
+ Egress: 1,
},
{
DeviceID: "olt",
- Ingress: tfd.dMgr.devices["olt"].Ports[0].PortNo,
- Egress: tfd.dMgr.devices["olt"].Ports[1].PortNo,
+ Ingress: 1,
+ Egress: 2,
},
}
tfd.routes[route.OFPortLink{Ingress: 3, Egress: 0}] = []route.Hop{
{
DeviceID: "onu3",
- Ingress: tfd.dMgr.devices["onu3"].Ports[1].PortNo,
- Egress: tfd.dMgr.devices["onu3"].Ports[0].PortNo,
+ Ingress: 2,
+ Egress: 1,
},
{
DeviceID: "olt",
- Ingress: tfd.dMgr.devices["olt"].Ports[0].PortNo,
- Egress: tfd.dMgr.devices["olt"].Ports[1].PortNo,
+ Ingress: 1,
+ Egress: 2,
},
}
tfd.routes[route.OFPortLink{Ingress: 4, Egress: 0}] = []route.Hop{
{
DeviceID: "onu4",
- Ingress: tfd.dMgr.devices["onu4"].Ports[1].PortNo,
- Egress: tfd.dMgr.devices["onu4"].Ports[0].PortNo,
+ Ingress: 2,
+ Egress: 1,
},
{
DeviceID: "olt",
- Ingress: tfd.dMgr.devices["olt"].Ports[0].PortNo,
- Egress: tfd.dMgr.devices["olt"].Ports[1].PortNo,
+ Ingress: 1,
+ Egress: 2,
},
}
@@ -301,8 +310,8 @@
tfd.routes[route.OFPortLink{Ingress: 10, Egress: 0}] = []route.Hop{
{
DeviceID: "olt",
- Ingress: tfd.dMgr.devices["olt"].Ports[1].PortNo,
- Egress: tfd.dMgr.devices["olt"].Ports[0].PortNo,
+ Ingress: 2,
+ Egress: 1,
},
{}, // 2nd hop is not known yet
}
@@ -311,8 +320,8 @@
{}, // 1st hop is wildcard
{
DeviceID: "olt",
- Ingress: tfd.dMgr.devices["olt"].Ports[0].PortNo,
- Egress: tfd.dMgr.devices["olt"].Ports[1].PortNo,
+ Ingress: 1,
+ Egress: 2,
},
}
@@ -384,7 +393,7 @@
tfd.defaultRules.AddFlowsAndGroup("onu4", fg)
//Set up the device graph - flow decomposer uses it only to verify whether a port is a root port.
- tfd.deviceRoutes = route.NewDeviceRoutes(context.Background(), "ldid", tfd.getDeviceHelper)
+ tfd.deviceRoutes = route.NewDeviceRoutes("ldid", "olt", tfd.dMgr.listDevicePorts)
tfd.deviceRoutes.RootPorts = make(map[uint32]uint32)
tfd.deviceRoutes.RootPorts[10] = 10
@@ -393,10 +402,6 @@
return &tfd
}
-func (tfd *testFlowDecomposer) getDeviceHelper(ctx context.Context, deviceID string) (*voltha.Device, error) {
- return tfd.dMgr.GetDevice(ctx, &voltha.ID{Id: deviceID})
-}
-
func (tfd *testFlowDecomposer) GetDeviceLogicalID() string {
return ""
}
diff --git a/rw_core/mocks/adapter_olt.go b/rw_core/mocks/adapter_olt.go
index d040f64..313ecc6 100644
--- a/rw_core/mocks/adapter_olt.go
+++ b/rw_core/mocks/adapter_olt.go
@@ -20,14 +20,16 @@
"context"
"errors"
"fmt"
+ "strings"
+
"github.com/gogo/protobuf/proto"
+ "github.com/opencord/voltha-lib-go/v3/pkg/adapters"
"github.com/opencord/voltha-lib-go/v3/pkg/adapters/adapterif"
com "github.com/opencord/voltha-lib-go/v3/pkg/adapters/common"
"github.com/opencord/voltha-lib-go/v3/pkg/log"
ic "github.com/opencord/voltha-protos/v3/go/inter_container"
of "github.com/opencord/voltha-protos/v3/go/openflow_13"
"github.com/opencord/voltha-protos/v3/go/voltha"
- "strings"
)
const (
@@ -35,6 +37,9 @@
startingUNIPortNo = 100
)
+// static implementation check
+var _ adapters.IAdapter = &OLTAdapter{}
+
// OLTAdapter represent OLT adapter
type OLTAdapter struct {
*Adapter
@@ -168,7 +173,7 @@
cloned := proto.Clone(device).(*voltha.Device)
// Update the all ports state on that device to disable
- if err := oltA.coreProxy.PortsStateUpdate(context.TODO(), cloned.Id, voltha.OperStatus_UNKNOWN); err != nil {
+ if err := oltA.coreProxy.PortsStateUpdate(context.TODO(), cloned.Id, 0, voltha.OperStatus_UNKNOWN); err != nil {
logger.Warnw(ctx, "updating-ports-failed", log.Fields{"deviceId": device.Id, "error": err})
}
@@ -202,7 +207,7 @@
cloned := proto.Clone(device).(*voltha.Device)
// Update the all ports state on that device to enable
- if err := oltA.coreProxy.PortsStateUpdate(context.TODO(), cloned.Id, voltha.OperStatus_ACTIVE); err != nil {
+ if err := oltA.coreProxy.PortsStateUpdate(context.TODO(), cloned.Id, 0, voltha.OperStatus_ACTIVE); err != nil {
logger.Fatalf(ctx, "updating-ports-failed", log.Fields{"deviceId": device.Id, "error": err})
}
@@ -262,7 +267,7 @@
if err := oltA.coreProxy.DeviceStateUpdate(context.TODO(), device.Id, voltha.ConnectStatus_UNREACHABLE, voltha.OperStatus_UNKNOWN); err != nil {
logger.Fatalf(ctx, "device-state-update-failed", log.Fields{"device-id": device.Id, "error": err})
}
- if err := oltA.coreProxy.PortsStateUpdate(context.TODO(), device.Id, voltha.OperStatus_UNKNOWN); err != nil {
+ if err := oltA.coreProxy.PortsStateUpdate(context.TODO(), device.Id, 0, voltha.OperStatus_UNKNOWN); err != nil {
// Not an error as the previous command will start the process of clearing the OLT
logger.Infow(ctx, "port-update-failed", log.Fields{"device-id": device.Id, "error": err})
}
diff --git a/rw_core/mocks/adapter_olt_test.go b/rw_core/mocks/adapter_olt_test.go
deleted file mode 100644
index 082c12e..0000000
--- a/rw_core/mocks/adapter_olt_test.go
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright 2019-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package mocks
-
-import (
- "context"
- "testing"
-
- "github.com/opencord/voltha-lib-go/v3/pkg/adapters"
-)
-
-func TestOLTAdapterImplementsIAdapter(t *testing.T) {
- adapter := NewOLTAdapter(context.Background(), nil)
-
- if _, ok := interface{}(adapter).(adapters.IAdapter); !ok {
- t.Error("OLT adapter does not implement voltha-lib-go/v2/pkg/adapters/IAdapter interface")
- }
-}
diff --git a/rw_core/mocks/adapter_onu.go b/rw_core/mocks/adapter_onu.go
index 8e7b867..f578df0 100644
--- a/rw_core/mocks/adapter_onu.go
+++ b/rw_core/mocks/adapter_onu.go
@@ -20,6 +20,8 @@
"context"
"errors"
"fmt"
+ "strings"
+
"github.com/gogo/protobuf/proto"
"github.com/opencord/voltha-lib-go/v3/pkg/adapters/adapterif"
com "github.com/opencord/voltha-lib-go/v3/pkg/adapters/common"
@@ -27,7 +29,6 @@
ic "github.com/opencord/voltha-protos/v3/go/inter_container"
of "github.com/opencord/voltha-protos/v3/go/openflow_13"
"github.com/opencord/voltha-protos/v3/go/voltha"
- "strings"
)
// ONUAdapter represent ONU adapter attributes
@@ -134,7 +135,7 @@
}
cloned := proto.Clone(device).(*voltha.Device)
// Update the all ports state on that device to disable
- if err := onuA.coreProxy.PortsStateUpdate(context.TODO(), cloned.Id, voltha.OperStatus_UNKNOWN); err != nil {
+ if err := onuA.coreProxy.PortsStateUpdate(context.TODO(), cloned.Id, 0, voltha.OperStatus_UNKNOWN); err != nil {
// Device may also have been deleted in the Core
logger.Warnw(ctx, "updating-ports-failed", log.Fields{"deviceId": device.Id, "error": err})
return
@@ -161,7 +162,7 @@
cloned := proto.Clone(device).(*voltha.Device)
// Update the all ports state on that device to enable
- if err := onuA.coreProxy.PortsStateUpdate(context.TODO(), cloned.Id, voltha.OperStatus_ACTIVE); err != nil {
+ if err := onuA.coreProxy.PortsStateUpdate(context.TODO(), cloned.Id, 0, voltha.OperStatus_ACTIVE); err != nil {
logger.Fatalf(ctx, "updating-ports-failed", log.Fields{"deviceId": device.Id, "error": err})
}
diff --git a/rw_core/route/device_route.go b/rw_core/route/device_route.go
index a1f2ae9..48339ec 100644
--- a/rw_core/route/device_route.go
+++ b/rw_core/route/device_route.go
@@ -48,13 +48,14 @@
Egress uint32
}
-// GetDeviceFunc returns device function
-type GetDeviceFunc func(ctx context.Context, id string) (*voltha.Device, error)
+// listDevicePortsFunc returns device ports
+type listDevicePortsFunc func(ctx context.Context, id string) (map[uint32]*voltha.Port, error)
// DeviceRoutes represent the set of routes between logical ports of a logical device
type DeviceRoutes struct {
logicalDeviceID string
- getDeviceFromModel GetDeviceFunc
+ rootDeviceID string
+ listDevicePorts listDevicePortsFunc
logicalPorts map[uint32]*voltha.LogicalPort
RootPorts map[uint32]uint32
rootPortsLock sync.RWMutex
@@ -65,17 +66,17 @@
}
// NewDeviceRoutes creates device graph instance
-func NewDeviceRoutes(ctx context.Context, logicalDeviceID string, getDevice GetDeviceFunc) *DeviceRoutes {
- var dr DeviceRoutes
- dr.logicalDeviceID = logicalDeviceID
- dr.getDeviceFromModel = getDevice
- dr.RootPorts = make(map[uint32]uint32)
- dr.Routes = make(map[PathID][]Hop)
- dr.devicesPonPorts = make(map[string][]*voltha.Port)
- dr.childConnectionPort = make(map[string]uint32)
- dr.logicalPorts = make(map[uint32]*voltha.LogicalPort)
- logger.Debug(ctx, "new device routes created ...")
- return &dr
+func NewDeviceRoutes(logicalDeviceID, rootDeviceID string, deviceMgr listDevicePortsFunc) *DeviceRoutes {
+ return &DeviceRoutes{
+ logicalDeviceID: logicalDeviceID,
+ rootDeviceID: rootDeviceID,
+ listDevicePorts: deviceMgr,
+ RootPorts: make(map[uint32]uint32),
+ Routes: make(map[PathID][]Hop),
+ devicesPonPorts: make(map[string][]*voltha.Port),
+ childConnectionPort: make(map[string]uint32),
+ logicalPorts: make(map[uint32]*voltha.LogicalPort),
+ }
}
//IsRootPort returns true if the port is a root port on a logical device
@@ -103,7 +104,7 @@
if err != nil {
return nil, err
}
- rootDevicePonPort, err := dr.getParentPonPort(ctx, nniPort.DeviceId, uniPort.DeviceId)
+ rootDevicePonPort, err := dr.getParentPonPort(ctx, uniPort.DeviceId)
if err != nil {
return nil, err
}
@@ -154,8 +155,6 @@
if len(nniPorts) == 0 {
return fmt.Errorf("no nni port :%w", ErrNoRoute)
}
- var rootDevice *voltha.Device
- var childDevice *voltha.Device
var copyFromNNIPort *voltha.LogicalPort
for idx, nniPort := range nniPorts {
if idx == 0 {
@@ -165,36 +164,38 @@
return nil
}
// Get root device
- rootDevice, err = dr.getDeviceWithCacheUpdate(ctx, nniPort.DeviceId)
+ rootDeviceID := nniPort.DeviceId
+ rootDevicePorts, err := dr.getDeviceWithCacheUpdate(ctx, nniPort.DeviceId)
if err != nil {
return err
}
- if len(rootDevice.Ports) == 0 {
- err = status.Errorf(codes.FailedPrecondition, "no-port-%s", rootDevice.Id)
+ if len(rootDevicePorts) == 0 {
+ err = status.Errorf(codes.FailedPrecondition, "no-port-%s", rootDeviceID)
return err
}
- for _, rootDevicePort := range rootDevice.Ports {
+ for _, rootDevicePort := range rootDevicePorts {
if rootDevicePort.Type == voltha.Port_PON_OLT {
- logger.Debugw(ctx, "peers", log.Fields{"root-device-id": rootDevice.Id, "port-no": rootDevicePort.PortNo, "len-peers": len(rootDevicePort.Peers)})
+ logger.Debugw(ctx, "peers", log.Fields{"root-device-id": rootDeviceID, "port-no": rootDevicePort.PortNo, "len-peers": len(rootDevicePort.Peers)})
for _, rootDevicePeer := range rootDevicePort.Peers {
- childDevice, err = dr.getDeviceWithCacheUpdate(ctx, rootDevicePeer.DeviceId)
+ childDeviceID := rootDevicePeer.DeviceId
+ childDevicePorts, err := dr.getDeviceWithCacheUpdate(ctx, rootDevicePeer.DeviceId)
if err != nil {
return err
}
- childPonPort, err := dr.getChildPonPort(ctx, childDevice.Id)
+ childPonPort, err := dr.getChildPonPort(ctx, childDeviceID)
if err != nil {
return err
}
- for _, childDevicePort := range childDevice.Ports {
+ for _, childDevicePort := range childDevicePorts {
if childDevicePort.Type == voltha.Port_ETHERNET_UNI {
- childLogicalPort, exist := physPortToLogicalPortMap[concatDeviceIDPortID(childDevice.Id, childDevicePort.PortNo)]
+ childLogicalPort, exist := physPortToLogicalPortMap[concatDeviceIDPortID(childDeviceID, childDevicePort.PortNo)]
if !exist {
// This can happen if this logical port has not been created yet for that device
continue
}
dr.Routes[PathID{Ingress: nniPort.OfpPort.PortNo, Egress: childLogicalPort}] = []Hop{
- {DeviceID: rootDevice.Id, Ingress: nniPort.DevicePortNo, Egress: rootDevicePort.PortNo},
- {DeviceID: childDevice.Id, Ingress: childPonPort, Egress: childDevicePort.PortNo},
+ {DeviceID: rootDeviceID, Ingress: nniPort.DevicePortNo, Egress: rootDevicePort.PortNo},
+ {DeviceID: childDeviceID, Ingress: childPonPort, Egress: childDevicePort.PortNo},
}
dr.Routes[PathID{Ingress: childLogicalPort, Egress: nniPort.OfpPort.PortNo}] = getReverseRoute(
dr.Routes[PathID{Ingress: nniPort.OfpPort.PortNo, Egress: childLogicalPort}])
@@ -209,20 +210,20 @@
// AddPort augments the current set of routes with new routes corresponding to the logical port "lp". If the routes have
// not been built yet then use logical port "lps" to compute all current routes (lps includes lp)
-func (dr *DeviceRoutes) AddPort(ctx context.Context, lp *voltha.LogicalPort, device *voltha.Device, lps map[uint32]*voltha.LogicalPort) error {
+func (dr *DeviceRoutes) AddPort(ctx context.Context, lp *voltha.LogicalPort, deviceID string, devicePorts map[uint32]*voltha.Port, lps map[uint32]*voltha.LogicalPort) error {
logger.Debugw(ctx, "add-port-to-routes", log.Fields{"port": lp, "count-logical-ports": len(lps)})
// Adding NNI port
if lp.RootPort {
- return dr.AddNNIPort(ctx, lp, device, lps)
+ return dr.AddNNIPort(ctx, lp, deviceID, devicePorts, lps)
}
// Adding UNI port
- return dr.AddUNIPort(ctx, lp, device, lps)
+ return dr.AddUNIPort(ctx, lp, deviceID, devicePorts, lps)
}
// AddUNIPort setup routes between the logical UNI port lp and all registered NNI ports
-func (dr *DeviceRoutes) AddUNIPort(ctx context.Context, lp *voltha.LogicalPort, device *voltha.Device, lps map[uint32]*voltha.LogicalPort) error {
+func (dr *DeviceRoutes) AddUNIPort(ctx context.Context, lp *voltha.LogicalPort, deviceID string, devicePorts map[uint32]*voltha.Port, lps map[uint32]*voltha.LogicalPort) error {
logger.Debugw(ctx, "add-uni-port-to-routes", log.Fields{"port": lp, "count-logical-ports": len(lps)})
dr.routeBuildLock.Lock()
@@ -232,14 +233,14 @@
dr.logicalPorts[lp.OfpPort.PortNo] = lp
// Update internal structures with device data
- dr.updateCache(device)
+ dr.updateCache(deviceID, devicePorts)
// Adding a UNI port
childPonPort, err := dr.getChildPonPort(ctx, lp.DeviceId)
if err != nil {
return err
}
- rootDevicePonPort, err := dr.getParentPonPort(ctx, device.ParentId, device.Id)
+ rootDevicePonPort, err := dr.getParentPonPort(ctx, deviceID)
if err != nil {
return err
}
@@ -259,14 +260,14 @@
}
// AddNNIPort setup routes between the logical NNI port lp and all registered UNI ports
-func (dr *DeviceRoutes) AddNNIPort(ctx context.Context, lp *voltha.LogicalPort, device *voltha.Device, lps map[uint32]*voltha.LogicalPort) error {
- logger.Debugw(ctx, "add-port-to-routes", log.Fields{"port": lp, "logical-ports-count": len(lps), "device-id": device.Id})
+func (dr *DeviceRoutes) AddNNIPort(ctx context.Context, lp *voltha.LogicalPort, deviceID string, devicePorts map[uint32]*voltha.Port, lps map[uint32]*voltha.LogicalPort) error {
+ logger.Debugw(ctx, "add-port-to-routes", log.Fields{"port": lp, "logical-ports-count": len(lps), "device-id": deviceID})
dr.routeBuildLock.Lock()
defer dr.routeBuildLock.Unlock()
// Update internal structures with device data
- dr.updateCache(device)
+ dr.updateCache(deviceID, devicePorts)
// Setup the physical ports to logical ports map, the nni ports as well as the root ports map
physPortToLogicalPortMap := make(map[string]uint32)
@@ -280,22 +281,23 @@
dr.logicalPorts[lp.OfpPort.PortNo] = lp
}
- for _, rootDevicePort := range device.Ports {
+ for _, rootDevicePort := range devicePorts {
if rootDevicePort.Type == voltha.Port_PON_OLT {
- logger.Debugw(ctx, "peers", log.Fields{"root-device-id": device.Id, "port-no": rootDevicePort.PortNo, "len-peers": len(rootDevicePort.Peers)})
+ logger.Debugw(ctx, "peers", log.Fields{"root-device-id": deviceID, "port-no": rootDevicePort.PortNo, "len-peers": len(rootDevicePort.Peers)})
for _, rootDevicePeer := range rootDevicePort.Peers {
- childDevice, err := dr.getDeviceWithCacheUpdate(ctx, rootDevicePeer.DeviceId)
+ childDeviceID := rootDevicePeer.DeviceId
+ childDevicePorts, err := dr.getDeviceWithCacheUpdate(ctx, rootDevicePeer.DeviceId)
if err != nil {
continue
}
- childPonPort, err := dr.getChildPonPort(ctx, childDevice.Id)
+ childPonPort, err := dr.getChildPonPort(ctx, childDeviceID)
if err != nil {
continue
}
- for _, childDevicePort := range childDevice.Ports {
- childLogicalPort, exist := physPortToLogicalPortMap[concatDeviceIDPortID(childDevice.Id, childDevicePort.PortNo)]
+ for _, childDevicePort := range childDevicePorts {
+ childLogicalPort, exist := physPortToLogicalPortMap[concatDeviceIDPortID(childDeviceID, childDevicePort.PortNo)]
if !exist {
// This can happen if this logical port has not been created yet for that device
continue
@@ -303,8 +305,8 @@
if childDevicePort.Type == voltha.Port_ETHERNET_UNI {
dr.Routes[PathID{Ingress: lp.OfpPort.PortNo, Egress: childLogicalPort}] = []Hop{
- {DeviceID: device.Id, Ingress: lp.DevicePortNo, Egress: rootDevicePort.PortNo},
- {DeviceID: childDevice.Id, Ingress: childPonPort, Egress: childDevicePort.PortNo},
+ {DeviceID: deviceID, Ingress: lp.DevicePortNo, Egress: rootDevicePort.PortNo},
+ {DeviceID: childDeviceID, Ingress: childPonPort, Egress: childDevicePort.PortNo},
}
dr.Routes[PathID{Ingress: childLogicalPort, Egress: lp.OfpPort.PortNo}] = getReverseRoute(
dr.Routes[PathID{Ingress: lp.OfpPort.PortNo, Egress: childLogicalPort}])
@@ -317,11 +319,11 @@
}
// AddAllPorts setups up new routes using all ports on the device. lps includes the device's logical port
-func (dr *DeviceRoutes) AddAllPorts(ctx context.Context, device *voltha.Device, lps map[uint32]*voltha.LogicalPort) error {
- logger.Debugw(ctx, "add-all-port-to-routes", log.Fields{"logical-ports-count": len(lps), "device-id": device.Id})
+func (dr *DeviceRoutes) AddAllPorts(ctx context.Context, deviceID string, devicePorts map[uint32]*voltha.Port, lps map[uint32]*voltha.LogicalPort) error {
+ logger.Debugw(ctx, "add-all-port-to-routes", log.Fields{"logical-ports-count": len(lps), "device-id": deviceID})
for _, lp := range lps {
- if lp.DeviceId == device.Id {
- if err := dr.AddPort(ctx, lp, device, lps); err != nil {
+ if lp.DeviceId == deviceID {
+ if err := dr.AddPort(ctx, lp, deviceID, devicePorts, lps); err != nil {
return err
}
}
@@ -411,14 +413,14 @@
}
//getDeviceWithCacheUpdate returns the from the model and updates the PON ports map of that device.
-func (dr *DeviceRoutes) getDeviceWithCacheUpdate(ctx context.Context, deviceID string) (*voltha.Device, error) {
- device, err := dr.getDeviceFromModel(ctx, deviceID)
+func (dr *DeviceRoutes) getDeviceWithCacheUpdate(ctx context.Context, deviceID string) (map[uint32]*voltha.Port, error) {
+ devicePorts, err := dr.listDevicePorts(ctx, deviceID)
if err != nil {
logger.Errorw(ctx, "device-not-found", log.Fields{"deviceId": deviceID, "error": err})
return nil, err
}
- dr.updateCache(device)
- return device, nil
+ dr.updateCache(deviceID, devicePorts)
+ return devicePorts, nil
}
//copyFromExistingNNIRoutes copies routes from an existing set of NNI routes
@@ -491,14 +493,14 @@
}
// getParentPonPort returns the parent PON port of the child device
-func (dr *DeviceRoutes) getParentPonPort(ctx context.Context, deviceID string, childDeviceID string) (uint32, error) {
+func (dr *DeviceRoutes) getParentPonPort(ctx context.Context, childDeviceID string) (uint32, error) {
if pNo, exist := dr.childConnectionPort[childDeviceID]; exist {
return pNo, nil
}
// Get parent device from the model
- if _, err := dr.getDeviceWithCacheUpdate(ctx, deviceID); err != nil {
- logger.Errorw(ctx, "device-not-found", log.Fields{"deviceId": deviceID, "error": err})
+ if _, err := dr.getDeviceWithCacheUpdate(ctx, dr.rootDeviceID); err != nil {
+ logger.Errorw(ctx, "device-not-found", log.Fields{"deviceId": dr.rootDeviceID, "error": err})
return 0, err
}
// Try again
@@ -508,10 +510,10 @@
return 0, fmt.Errorf("pon port associated with child device %s not found", childDeviceID)
}
-func (dr *DeviceRoutes) updateCache(device *voltha.Device) {
- for _, port := range device.Ports {
+func (dr *DeviceRoutes) updateCache(deviceID string, devicePorts map[uint32]*voltha.Port) {
+ for _, port := range devicePorts {
if port.Type == voltha.Port_PON_ONU || port.Type == voltha.Port_PON_OLT {
- dr.devicesPonPorts[device.Id] = append(dr.devicesPonPorts[device.Id], port)
+ dr.devicesPonPorts[deviceID] = append(dr.devicesPonPorts[deviceID], port)
for _, peer := range port.Peers {
if port.Type == voltha.Port_PON_ONU {
dr.childConnectionPort[port.DeviceId] = peer.PortNo
diff --git a/rw_core/route/device_route_test.go b/rw_core/route/device_route_test.go
index 0fd0836..3857837 100644
--- a/rw_core/route/device_route_test.go
+++ b/rw_core/route/device_route_test.go
@@ -48,13 +48,15 @@
//onuRegistration is a message sent from an ONU device to an OLT device to register an ONU
type onuRegistration struct {
- onu *voltha.Device
+ onuID string
+ onuPorts map[uint32]*voltha.Port
oltPonNo uint32
onuPonNo uint32
}
type logicalDeviceManager struct {
logicalDeviceID string
+ rootDeviceID string
ports map[uint32]*voltha.LogicalPort
deviceRoutes *DeviceRoutes
ldChnl chan portRegistration
@@ -62,23 +64,19 @@
done chan struct{}
}
-func newLogicalDeviceManager(ld *voltha.LogicalDevice, ch chan portRegistration, totalLogicalPorts int, done chan struct{}) *logicalDeviceManager {
- ports := make(map[uint32]*voltha.LogicalPort)
- for _, p := range ld.Ports {
- ports[p.DevicePortNo] = p
- }
-
+func newLogicalDeviceManager(ld *voltha.LogicalDevice, rootDeviceID string, ch chan portRegistration, totalLogicalPorts int, done chan struct{}) *logicalDeviceManager {
return &logicalDeviceManager{
logicalDeviceID: ld.Id,
- ports: ports,
+ rootDeviceID: rootDeviceID,
+ ports: make(map[uint32]*voltha.LogicalPort),
ldChnl: ch,
numLogicalPorts: totalLogicalPorts,
done: done,
}
}
-func (ldM *logicalDeviceManager) start(ctx context.Context, getDevice GetDeviceFunc, buildRoutes bool) {
- ldM.deviceRoutes = NewDeviceRoutes(ctx, ldM.logicalDeviceID, getDevice)
+func (ldM *logicalDeviceManager) start(ctx context.Context, listDevicePorts listDevicePortsFunc, buildRoutes bool) {
+ ldM.deviceRoutes = NewDeviceRoutes(ldM.logicalDeviceID, ldM.rootDeviceID, listDevicePorts)
ofpPortNo := uint32(1)
for portReg := range ldM.ldChnl {
if portReg.port == nil {
@@ -94,11 +92,11 @@
}
ldM.ports[lp.DevicePortNo] = lp
if buildRoutes {
- device, err := getDevice(context.WithValue(context.Background(), testSetupPhase, true), lp.DeviceId)
+ devicePorts, err := listDevicePorts(context.WithValue(context.Background(), testSetupPhase, true), lp.DeviceId)
if err != nil {
fmt.Println("Error when getting device:", lp.DeviceId, err)
}
- if err := ldM.deviceRoutes.AddPort(context.Background(), lp, device, ldM.ports); err != nil && !strings.Contains(err.Error(), "code = FailedPrecondition") {
+ if err := ldM.deviceRoutes.AddPort(context.Background(), lp, lp.DeviceId, devicePorts, ldM.ports); err != nil && !strings.Contains(err.Error(), "code = FailedPrecondition") {
fmt.Println("(Error when adding port:", lp, len(ldM.ports), err)
}
}
@@ -109,7 +107,8 @@
}
type oltManager struct {
- olt *voltha.Device
+ oltID string
+ oltPorts map[uint32]*voltha.Port
logicalDeviceMgr *logicalDeviceManager
numNNIPort int
numPonPortOnOlt int
@@ -118,7 +117,8 @@
func newOltManager(oltDeviceID string, ldMgr *logicalDeviceManager, numNNIPort int, numPonPortOnOlt int, ch chan onuRegistration) *oltManager {
return &oltManager{
- olt: &voltha.Device{Id: oltDeviceID, ParentId: ldMgr.logicalDeviceID, Root: true},
+ oltID: oltDeviceID, // ParentId: ldMgr.logicalDeviceID, Root: true},
+ oltPorts: make(map[uint32]*voltha.Port),
logicalDeviceMgr: ldMgr,
numNNIPort: numNNIPort,
numPonPortOnOlt: numPonPortOnOlt,
@@ -127,41 +127,40 @@
}
func (oltM *oltManager) start() {
- oltM.olt.Ports = make([]*voltha.Port, 0)
// Setup the OLT nni ports and trigger the nni ports creation
for nniPort := 1; nniPort < oltM.numNNIPort+1; nniPort++ {
- p := &voltha.Port{Label: fmt.Sprintf("nni-%d", nniPort), PortNo: uint32(nniPort), DeviceId: oltM.olt.Id, Type: voltha.Port_ETHERNET_NNI}
- oltM.olt.Ports = append(oltM.olt.Ports, p)
+ p := &voltha.Port{Label: fmt.Sprintf("nni-%d", nniPort), PortNo: uint32(nniPort), DeviceId: oltM.oltID, Type: voltha.Port_ETHERNET_NNI}
+ oltM.oltPorts[p.PortNo] = p
oltM.logicalDeviceMgr.ldChnl <- portRegistration{port: p, rootPort: true}
}
// Create OLT pon ports
for ponPort := oltM.numNNIPort + 1; ponPort < oltM.numPonPortOnOlt+oltM.numNNIPort+1; ponPort++ {
- p := voltha.Port{PortNo: uint32(ponPort), DeviceId: oltM.olt.Id, Type: voltha.Port_PON_OLT}
- oltM.olt.Ports = append(oltM.olt.Ports, &p)
+ p := &voltha.Port{PortNo: uint32(ponPort), DeviceId: oltM.oltID, Type: voltha.Port_PON_OLT}
+ oltM.oltPorts[p.PortNo] = p
}
// Wait for onu registration
for onuReg := range oltM.oltChnl {
- if onuReg.onu == nil {
+ if onuReg.onuPorts == nil {
// All onu has registered - exit the loop
break
}
- oltM.registerOnu(onuReg.onu, onuReg.oltPonNo, onuReg.onuPonNo)
+ oltM.registerOnu(onuReg.onuID, onuReg.onuPorts, onuReg.oltPonNo, onuReg.onuPonNo)
}
// Inform the logical device manager we are done
oltM.logicalDeviceMgr.ldChnl <- portRegistration{port: nil}
}
-func (oltM *oltManager) registerOnu(onu *voltha.Device, oltPonNo uint32, onuPonNo uint32) {
+func (oltM *oltManager) registerOnu(onuID string, onuPorts map[uint32]*voltha.Port, oltPonNo uint32, onuPonNo uint32) {
// Update the olt pon peers
- for _, port := range oltM.olt.Ports {
+ for _, port := range oltM.oltPorts {
if port.Type == voltha.Port_PON_OLT && port.PortNo == oltPonNo {
- port.Peers = append(port.Peers, &voltha.Port_PeerPort{DeviceId: onu.Id, PortNo: onuPonNo})
+ port.Peers = append(port.Peers, &voltha.Port_PeerPort{DeviceId: onuID, PortNo: onuPonNo})
}
}
// For each uni port on the ONU trigger the creation of a logical port
- for _, port := range onu.Ports {
+ for _, port := range onuPorts {
if port.Type == voltha.Port_ETHERNET_UNI {
oltM.logicalDeviceMgr.ldChnl <- portRegistration{port: port, rootPort: false}
}
@@ -177,6 +176,7 @@
numGetDeviceInvokedLock sync.RWMutex
deviceLock sync.RWMutex
onus []*voltha.Device
+ onuPorts map[string]map[uint32]*voltha.Port
}
func newOnuManager(oltMgr *oltManager, numOnus int, numUnisPerOnu int, startingUniPortNo int) *onuManager {
@@ -186,6 +186,7 @@
numUnisPerOnu: numUnisPerOnu,
startingUniPortNo: startingUniPortNo,
onus: make([]*voltha.Device, 0),
+ onuPorts: make(map[string]map[uint32]*voltha.Port),
}
}
@@ -198,22 +199,24 @@
var onu *voltha.Device
defer wg.Done()
id := fmt.Sprintf("%d-onu-%d", oltPonNum, onuID)
- onu = &voltha.Device{Id: id, ParentId: onuM.oltMgr.olt.Id, ParentPortNo: uint32(oltPonNum)}
+ onu = &voltha.Device{Id: id, ParentId: onuM.oltMgr.oltID, ParentPortNo: uint32(oltPonNum)}
ponPort := &voltha.Port{Label: fmt.Sprintf("%s:pon-%d", onu.Id, onuID), PortNo: 1, DeviceId: onu.Id, Type: voltha.Port_PON_ONU}
ponPort.Peers = make([]*voltha.Port_PeerPort, 0)
- peerPort := voltha.Port_PeerPort{DeviceId: onuM.oltMgr.olt.Id, PortNo: uint32(oltPonNum)}
+ peerPort := voltha.Port_PeerPort{DeviceId: onuM.oltMgr.oltID, PortNo: uint32(oltPonNum)}
ponPort.Peers = append(ponPort.Peers, &peerPort)
- onu.Ports = make([]*voltha.Port, 0)
- onu.Ports = append(onu.Ports, ponPort)
+ onuPorts := make(map[uint32]*voltha.Port)
+ onuPorts[ponPort.PortNo] = ponPort
for j := onuM.startingUniPortNo; j < onuM.numUnisPerOnu+onuM.startingUniPortNo; j++ {
uniPort := &voltha.Port{Label: fmt.Sprintf("%s:uni-%d", onu.Id, j), PortNo: uint32(oltPonNum)<<12 + uint32(onuID+1)<<4 + uint32(j), DeviceId: onu.Id, Type: voltha.Port_ETHERNET_UNI}
- onu.Ports = append(onu.Ports, uniPort)
+ onuPorts[uniPort.PortNo] = uniPort
}
onuM.deviceLock.Lock()
onuM.onus = append(onuM.onus, onu)
+ onuM.onuPorts[id] = onuPorts
onuM.deviceLock.Unlock()
onuM.oltMgr.oltChnl <- onuRegistration{
- onu: onu,
+ onuID: onu.Id,
+ onuPorts: onuPorts,
oltPonNo: uint32(oltPonNum),
onuPonNo: 1,
}
@@ -223,34 +226,30 @@
wg.Wait()
//send an empty device to indicate the end of onu registration
onuM.oltMgr.oltChnl <- onuRegistration{
- onu: nil,
+ onuPorts: nil,
oltPonNo: 0,
onuPonNo: 1,
}
}
-func (onuM *onuManager) getOnu(deviceID string) *voltha.Device {
+func (onuM *onuManager) getOnuPorts(deviceID string) (map[uint32]*voltha.Port, bool) {
onuM.deviceLock.Lock()
defer onuM.deviceLock.Unlock()
- for _, onu := range onuM.onus {
- if onu.Id == deviceID {
- return onu
- }
- }
- return nil
+ ports, have := onuM.onuPorts[deviceID]
+ return ports, have
}
-func (onuM *onuManager) GetDeviceHelper(ctx context.Context, id string) (*voltha.Device, error) {
+func (onuM *onuManager) ListDevicePortsHelper(ctx context.Context, id string) (map[uint32]*voltha.Port, error) {
if ctx.Value(testSetupPhase) != true {
onuM.numGetDeviceInvokedLock.Lock()
onuM.numGetDeviceInvoked++
onuM.numGetDeviceInvokedLock.Unlock()
}
if id == oltDeviceID {
- return onuM.oltMgr.olt, nil
+ return onuM.oltMgr.oltPorts, nil
}
- if onu := onuM.getOnu(id); onu != nil {
- return onu, nil
+ if onuPorts, have := onuM.getOnuPorts(id); have {
+ return onuPorts, nil
}
return nil, errors.New("not-found")
}
@@ -268,14 +267,13 @@
// Create all the devices and logical device before computing the routes in one go
ld := &voltha.LogicalDevice{Id: logicalDeviceID}
ldMgrChnl := make(chan portRegistration, numNNIPort*numPonPortOnOlt*numOnuPerOltPonPort*numUniPerOnu)
- ldMgr := newLogicalDeviceManager(ld, ldMgrChnl, numNNIPort+numPonPortOnOlt*numOnuPerOltPonPort*numUniPerOnu, done)
+ ldMgr := newLogicalDeviceManager(ld, oltDeviceID, ldMgrChnl, numNNIPort+numPonPortOnOlt*numOnuPerOltPonPort*numUniPerOnu, done)
oltMgrChnl := make(chan onuRegistration, numPonPortOnOlt*numOnuPerOltPonPort)
oltMgr := newOltManager(oltDeviceID, ldMgr, numNNIPort, numPonPortOnOlt, oltMgrChnl)
onuMgr := newOnuManager(oltMgr, numOnuPerOltPonPort, numUniPerOnu, 2)
- getDevice := onuMgr.GetDeviceHelper
// Start the managers. Only the devices are created. No routes will be built.
ctx := context.Background()
- go ldMgr.start(ctx, getDevice, false)
+ go ldMgr.start(ctx, onuMgr.ListDevicePortsHelper, false)
go oltMgr.start()
go onuMgr.start(numNNIPort+1, numPonPortOnOlt)
@@ -316,14 +314,13 @@
// Create all the devices and logical device before computing the routes in one go
ld := &voltha.LogicalDevice{Id: logicalDeviceID}
ldMgrChnl := make(chan portRegistration, numNNIPort*numPonPortOnOlt*numOnuPerOltPonPort*numUniPerOnu)
- ldMgr := newLogicalDeviceManager(ld, ldMgrChnl, numNNIPort+numPonPortOnOlt*numOnuPerOltPonPort*numUniPerOnu, done)
+ ldMgr := newLogicalDeviceManager(ld, oltDeviceID, ldMgrChnl, numNNIPort+numPonPortOnOlt*numOnuPerOltPonPort*numUniPerOnu, done)
oltMgrChnl := make(chan onuRegistration, numPonPortOnOlt*numOnuPerOltPonPort)
oltMgr := newOltManager(oltDeviceID, ldMgr, numNNIPort, numPonPortOnOlt, oltMgrChnl)
onuMgr := newOnuManager(oltMgr, numOnuPerOltPonPort, numUniPerOnu, 2)
- getDevice := onuMgr.GetDeviceHelper
-
- ctx := context.Background()
+ getDevice := onuMgr.ListDevicePortsHelper
// Start the managers and trigger the routes to be built as the logical ports become available
+ ctx := context.Background()
go ldMgr.start(ctx, getDevice, true)
go oltMgr.start()
go onuMgr.start(numNNIPort+1, numPonPortOnOlt)
@@ -362,11 +359,11 @@
// Create all the devices and logical device before computing the routes in one go
ld1 := &voltha.LogicalDevice{Id: logicalDeviceID}
ldMgrChnl1 := make(chan portRegistration, numNNIPort*numPonPortOnOlt*numOnuPerOltPonPort*numUniPerOnu)
- ldMgr1 := newLogicalDeviceManager(ld1, ldMgrChnl1, numNNIPort+numPonPortOnOlt*numOnuPerOltPonPort*numUniPerOnu, done)
+ ldMgr1 := newLogicalDeviceManager(ld1, oltDeviceID, ldMgrChnl1, numNNIPort+numPonPortOnOlt*numOnuPerOltPonPort*numUniPerOnu, done)
oltMgrChnl1 := make(chan onuRegistration, numPonPortOnOlt*numOnuPerOltPonPort)
oltMgr1 := newOltManager(oltDeviceID, ldMgr1, numNNIPort, numPonPortOnOlt, oltMgrChnl1)
onuMgr1 := newOnuManager(oltMgr1, numOnuPerOltPonPort, numUniPerOnu, 2)
- getDevice := onuMgr1.GetDeviceHelper
+ getDevice := onuMgr1.ListDevicePortsHelper
ctx := context.Background()
// Start the managers. Only the devices are created. No routes will be built.
go ldMgr1.start(ctx, getDevice, false)
@@ -387,7 +384,7 @@
// Create all the devices and logical device before computing the routes in one go
ld2 := &voltha.LogicalDevice{Id: logicalDeviceID}
ldMgrChnl2 := make(chan portRegistration, numNNIPort*numPonPortOnOlt*numOnuPerOltPonPort*numUniPerOnu)
- ldMgr2 := newLogicalDeviceManager(ld2, ldMgrChnl2, numNNIPort+numPonPortOnOlt*numOnuPerOltPonPort*numUniPerOnu, done)
+ ldMgr2 := newLogicalDeviceManager(ld2, oltDeviceID, ldMgrChnl2, numNNIPort+numPonPortOnOlt*numOnuPerOltPonPort*numUniPerOnu, done)
oltMgrChnl2 := make(chan onuRegistration, numPonPortOnOlt*numOnuPerOltPonPort)
oltMgr2 := newOltManager(oltDeviceID, ldMgr2, numNNIPort, numPonPortOnOlt, oltMgrChnl2)
onuMgr2 := newOnuManager(oltMgr2, numOnuPerOltPonPort, numUniPerOnu, 2)
diff --git a/tests/core/api/grpc_nbi_api_handler_client_test.go b/tests/core/api/grpc_nbi_api_handler_client_test.go
deleted file mode 100644
index b70531a..0000000
--- a/tests/core/api/grpc_nbi_api_handler_client_test.go
+++ /dev/null
@@ -1,677 +0,0 @@
-// +build integration
-
-/*
- * Copyright 2018-present Open Networking Foundation
-
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
-
- * http://www.apache.org/licenses/LICENSE-2.0
-
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package api
-
-import (
- "context"
- "fmt"
- "os"
- "os/exec"
- "strings"
- "testing"
- "time"
-
- "github.com/golang/protobuf/ptypes/empty"
- com "github.com/opencord/voltha-lib-go/v3/pkg/adapters/common"
- "github.com/opencord/voltha-lib-go/v3/pkg/log"
- "github.com/opencord/voltha-protos/v3/go/common"
- "github.com/opencord/voltha-protos/v3/go/openflow_13"
- "github.com/opencord/voltha-protos/v3/go/voltha"
- "github.com/stretchr/testify/assert"
- "google.golang.org/grpc"
- "google.golang.org/grpc/codes"
- "google.golang.org/grpc/metadata"
- "google.golang.org/grpc/status"
-)
-
-var conn *grpc.ClientConn
-var stub voltha.VolthaServiceClient
-var testMode string
-
-/*
-Prerequite: These tests require the rw_core to run prior to executing these test cases.
-*/
-
-var devices map[string]*voltha.Device
-
-func setup() {
- //Start kafka and Etcd
- startKafka()
- startEtcd()
- time.Sleep(10 * time.Second) //TODO: Find a better way to ascertain they are up
-
- stub = setupGrpcConnection()
- testMode = common.TestModeKeys_api_test.String()
- devices = make(map[string]*voltha.Device)
-}
-
-func setupGrpcConnection() voltha.VolthaServiceClient {
- grpcHostIP := os.Getenv("DOCKER_HOST_IP")
- grpcPort := 50057
- grpcHost := fmt.Sprintf("%s:%d", grpcHostIP, grpcPort)
- var err error
- conn, err = grpc.Dial(grpcHost, grpc.WithInsecure())
- if err != nil {
- logger.Fatalf(ctx, "did not connect: %s", err)
- }
- return voltha.NewVolthaServiceClient(conn)
-}
-
-func clearAllDevices(clearMap bool) {
- for key, _ := range devices {
- ctx := context.Background()
- response, err := stub.DeleteDevice(ctx, &voltha.ID{Id: key})
- logger.Infow(ctx, "response", log.Fields{"res": response, "error": err})
- if clearMap {
- delete(devices, key)
- }
- }
-}
-
-// Verify if all ids are present in the global list of devices
-func hasAllIds(ids *voltha.IDs) bool {
- if ids == nil && len(devices) == 0 {
- return true
- }
- if ids == nil {
- return false
- }
- for _, id := range ids.Items {
- if _, exist := devices[id.Id]; !exist {
- return false
- }
- }
- return true
-}
-
-func startKafka() {
- fmt.Println("Starting Kafka and Etcd ...")
- command := "docker-compose"
- cmd := exec.Command(command, "-f", "../../../compose/docker-compose-zk-kafka-test.yml", "up", "-d")
- if err := cmd.Run(); err != nil {
- logger.Fatal(ctx, err)
- }
-}
-
-func startEtcd() {
- fmt.Println("Starting Etcd ...")
- command := "docker-compose"
- cmd := exec.Command(command, "-f", "../../../compose/docker-compose-etcd.yml", "up", "-d")
- if err := cmd.Run(); err != nil {
- logger.Fatal(ctx, err)
- }
-}
-
-func stopKafka() {
- fmt.Println("Stopping Kafka and Etcd ...")
- command := "docker-compose"
- cmd := exec.Command(command, "-f", "../../../compose/docker-compose-zk-kafka-test.yml", "down")
- if err := cmd.Run(); err != nil {
- // ignore error - as this is mostly due network being left behind as its being used by other
- // containers
- logger.Warn(ctx, err)
- }
-}
-
-func stopEtcd() {
- fmt.Println("Stopping Etcd ...")
- command := "docker-compose"
- cmd := exec.Command(command, "-f", "../../../compose/docker-compose-etcd.yml", "down")
- if err := cmd.Run(); err != nil {
- // ignore error - as this is mostly due network being left behind as its being used by other
- // containers
- logger.Warn(ctx, err)
- }
-}
-
-func startCore() {
- fmt.Println("Starting voltha core ...")
- command := "docker-compose"
- cmd := exec.Command(command, "-f", "../../../compose/rw_core.yml", "up", "-d")
- if err := cmd.Run(); err != nil {
- logger.Fatal(ctx, err)
- }
-}
-
-func stopCore() {
- fmt.Println("Stopping voltha core ...")
- command := "docker-compose"
- cmd := exec.Command(command, "-f", "../../../compose/rw_core.yml", "down")
- if err := cmd.Run(); err != nil {
- // ignore error - as this is mostly due network being left behind as its being used by other
- // containers
- logger.Warn(ctx, err)
- }
-}
-
-func startSimulatedOLTAndONUAdapters() {
- fmt.Println("Starting simulated OLT and ONU adapters ...")
- command := "docker-compose"
- cmd := exec.Command(command, "-f", "../../../compose/adapters-simulated.yml", "up", "-d")
- if err := cmd.Run(); err != nil {
- logger.Fatal(ctx, err)
- }
-}
-
-func stopSimulatedOLTAndONUAdapters() {
- fmt.Println("Stopping simulated OLT and ONU adapters ...")
- command := "docker-compose"
- cmd := exec.Command(command, "-f", "../../../compose/adapters-simulated.yml", "down")
- if err := cmd.Run(); err != nil {
- // ignore error - as this is mostly due network being left behind as its being used by other
- // containers
- logger.Warn(ctx, err)
- }
-}
-
-func TestListDeviceIds(t *testing.T) {
- fmt.Println("Testing list Devices Ids ...")
- //0. Start kafka and Ectd
- startKafka()
- startEtcd()
-
- //1. Start the core
- startCore()
-
- // Wait until it's up - TODO: find a better way to check
- time.Sleep(10 * time.Second)
-
- //2. Create a set of devices into the Core
- for i := 0; i < 10; i++ {
- ctx := context.Background()
- device := &voltha.Device{Type: "simulated_olt"}
- response, err := stub.CreateDevice(ctx, device)
- logger.Infow(ctx, "response", log.Fields{"res": response, "error": err})
- assert.NotNil(t, response)
- assert.Nil(t, err)
- devices[response.Id] = response
- }
-
- //3. Verify devices have been added correctly
- ctx := context.Background()
- response, err := stub.ListDeviceIds(ctx, &empty.Empty{})
- logger.Infow(ctx, "response", log.Fields{"res": response, "error": err})
- assert.Nil(t, err)
- assert.True(t, hasAllIds(response))
-
- //4. Stop the core
- stopCore()
-
- //5. Stop Kafka and Etcd
- stopKafka()
- stopEtcd()
-}
-
-func TestReconcileDevices(t *testing.T) {
- fmt.Println("Testing Reconcile Devices ...")
-
- //0. Start kafka and Ectd
- startKafka()
- startEtcd()
-
- //1. Start the core
- startCore()
-
- // Wait until it's up - TODO: find a better way to check
- time.Sleep(10 * time.Second)
-
- //2. Create a set of devices into the Core
- for i := 0; i < 10; i++ {
- ctx := context.Background()
- device := &voltha.Device{Type: "simulated_olt"}
- response, err := stub.CreateDevice(ctx, device)
- logger.Infow(ctx, "response", log.Fields{"res": response, "error": err})
- assert.Nil(t, err)
- devices[response.Id] = response
- }
- //3. Verify devices have been added correctly
- ctx := context.Background()
- response, err := stub.ListDeviceIds(ctx, &empty.Empty{})
- logger.Infow(ctx, "response", log.Fields{"res": response, "error": err})
- assert.Nil(t, err)
- assert.True(t, hasAllIds(response))
-
- //4. Stop the core and restart it. This will start the core with no data in memory but
- // etcd will still have the data.
- stopCore()
- time.Sleep(5 * time.Second)
- startCore()
- time.Sleep(10 * time.Second)
-
- //5. Setup the connection again
- stub = setupGrpcConnection()
-
- //6. Verify there are no devices left
- ctx = context.Background()
- response, err = stub.ListDeviceIds(ctx, &empty.Empty{})
- logger.Infow(ctx, "response", log.Fields{"res": response, "error": err})
- assert.Nil(t, err)
- assert.Equal(t, len(response.Items), 0)
-
- //7. Invoke reconcile with all stored list
- toRestore := &voltha.IDs{Items: make([]*voltha.ID, 0)}
- for key, _ := range devices {
- toRestore.Items = append(toRestore.Items, &voltha.ID{Id: key})
- }
- ctx = context.Background()
- _, err = stub.ReconcileDevices(ctx, toRestore)
- assert.Nil(t, err)
-
- //8. Verify all devices have been restored
- ctx = context.Background()
- response, err = stub.ListDeviceIds(ctx, &empty.Empty{})
- logger.Infow(ctx, "response", log.Fields{"res": response, "error": err})
- assert.Nil(t, err)
- assert.True(t, hasAllIds(response))
-
- for _, id := range response.Items {
- fmt.Println("id", id.Id)
- }
-
- //9. Store the core
- stopCore()
-
- //10. Stop Kafka and Etcd
- stopKafka()
- stopEtcd()
-}
-
-func TestDeviceManagement(t *testing.T) {
- fmt.Println("Testing Device Management ...")
-
- numberOfOLTDevices := 1
-
- //0. Start kafka and Ectd
- startKafka()
- startEtcd()
-
- //1. Start the core
- startCore()
-
- //2. Start the simulated adapters
- startSimulatedOLTAndONUAdapters()
-
- // Wait until the core and adapters sync up
- time.Sleep(10 * time.Second)
-
- //3. Create a set of devices into the Core
- devices = make(map[string]*voltha.Device)
- logicalDevices := make(map[string]*voltha.LogicalDevice)
- for i := 0; i < numberOfOLTDevices; i++ {
- ctx := context.Background()
- randomMacAddress := strings.ToUpper(com.GetRandomMacAddress())
- device := &voltha.Device{Type: "simulated_olt", MacAddress: randomMacAddress}
- response, err := stub.CreateDevice(ctx, device)
- logger.Infow(ctx, "response", log.Fields{"res": response, "error": err})
- assert.Nil(t, err)
- devices[response.Id] = response
- }
-
- //4. Enable all the devices
- for id, _ := range devices {
- ctx := context.Background()
- response, err := stub.EnableDevice(ctx, &common.ID{Id: id})
- logger.Infow(ctx, "response", log.Fields{"res": response, "error": err})
- assert.Nil(t, err)
- }
-
- // Wait until all devices have been enabled
- if numberOfOLTDevices < 5 {
- time.Sleep(3 * time.Second)
- } else if numberOfOLTDevices < 20 {
- time.Sleep(20 * time.Second)
- } else {
- time.Sleep(30 * time.Second)
- }
- //time.Sleep(1 * time.Second * time.Duration(numberOfDevices))
-
- //5. Verify that all devices are in enabled state
- ctx := context.Background()
- response, err := stub.ListDevices(ctx, &empty.Empty{})
- logger.Infow(ctx, "response", log.Fields{"res": response, "error": err})
- assert.Nil(t, err)
- assert.Equal(t, len(devices)*2, len(response.Items))
- for _, d := range response.Items {
- devices[d.Id] = d
- assert.Equal(t, d.AdminState, voltha.AdminState_ENABLED)
- }
-
- //6. Get the logical devices
- ctx = context.Background()
- lresponse, lerr := stub.ListLogicalDevices(ctx, &empty.Empty{})
- logger.Infow(ctx, "response", log.Fields{"res": response, "error": lerr})
- assert.Nil(t, lerr)
- assert.Equal(t, numberOfOLTDevices, len(lresponse.Items))
- for _, ld := range lresponse.Items {
- logicalDevices[ld.Id] = ld
- // Ensure each logical device have two ports
- ports, err := stub.ListLogicalDevicePorts(ctx, &voltha.ID{Id: ld.Id})
- assert.Nil(t, err)
- assert.Equal(t, 2, len(ports.Items))
- }
-
- //7. Disable all ONUs & check status & check logical device
- for id, d := range devices {
- ctx := context.Background()
- if d.Type == "simulated_onu" {
- response, err := stub.DisableDevice(ctx, &common.ID{Id: id})
- logger.Infow(ctx, "response", log.Fields{"res": response, "error": err})
- assert.Nil(t, err)
- }
- }
-
- // Wait for all the changes to be populated
- time.Sleep(3 * time.Second)
-
- ctx = context.Background()
- response, err = stub.ListDevices(ctx, &empty.Empty{})
- logger.Infow(ctx, "response", log.Fields{"res": response, "error": err})
- assert.Nil(t, err)
- assert.Equal(t, len(devices), len(response.Items))
- for _, d := range response.Items {
- if d.Type == "simulated_onu" {
- assert.Equal(t, d.AdminState, voltha.AdminState_DISABLED)
- devices[d.Id] = d
- } else {
- assert.Equal(t, d.AdminState, voltha.AdminState_ENABLED)
- }
- }
-
- ctx = context.Background()
- lresponse, lerr = stub.ListLogicalDevices(ctx, &empty.Empty{})
- logger.Infow(ctx, "response", log.Fields{"res": response, "error": lerr})
- assert.Nil(t, lerr)
- assert.Equal(t, numberOfOLTDevices, len(lresponse.Items))
- for _, ld := range lresponse.Items {
- logicalDevices[ld.Id] = ld
- // Ensure each logical device have one port - only olt port
- ports, err := stub.ListLogicalDevicePorts(ctx, &common.ID{Id: ld.Id})
- assert.Nil(t, err)
- assert.Equal(t, 1, len(ports.Items))
- }
-
- //8. Enable all ONUs & check status & check logical device
- for id, d := range devices {
- ctx := context.Background()
- if d.Type == "simulated_onu" {
- response, err := stub.EnableDevice(ctx, &common.ID{Id: id})
- logger.Infow(ctx, "response", log.Fields{"res": response, "error": err})
- assert.Nil(t, err)
- }
- }
-
- // Wait for all the changes to be populated
- time.Sleep(3 * time.Second)
-
- ctx = context.Background()
- response, err = stub.ListDevices(ctx, &empty.Empty{})
- logger.Infow(ctx, "response", log.Fields{"res": response, "error": err})
- assert.Nil(t, err)
- assert.Equal(t, len(devices), len(response.Items))
- for _, d := range response.Items {
- assert.Equal(t, d.AdminState, voltha.AdminState_ENABLED)
- devices[d.Id] = d
- }
-
- //ctx = context.Background()
- //lresponse, lerr = stub.ListLogicalDevices(ctx, &empty.Empty{})
- //logger.Infow(ctx, "response", log.Fields{"res": response, "error": lerr})
- //assert.Nil(t, lerr)
- //assert.Equal(t, numberOfOLTDevices, len(lresponse.Items))
- //for _, ld := range (lresponse.Items) {
- // logicalDevices[ld.Id] = ld
- // // Ensure each logical device have two ports
- // assert.Equal(t, 2, len(ld.Ports))
- //}
-
- //9. Disable all OLTs & check status & check logical device
-
- //10. Enable all OLTs & Enable all ONUs & check status & check logical device
-
- //11. Disable all OLTs & check status & check logical device
-
- //12. Delete all Devices & check status & check logical device
-
- ////13. Store simulated adapters
- //stopSimulatedOLTAndONUAdapters()
- //
- ////14. Store the core
- //stopCore()
- //
- ////15. Stop Kafka and Etcd
- //stopKafka()
- //stopEtcd()
-}
-
-func TestGetDevice(t *testing.T) {
- var id common.ID
- id.Id = "anyid"
- ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
- response, err := stub.GetDevice(ctx, &id)
- assert.Nil(t, response)
- st, _ := status.FromError(err)
- assert.Equal(t, id.Id, st.Message())
- assert.Equal(t, codes.NotFound, st.Code())
-}
-
-func TestUpdateLogLevelError(t *testing.T) {
- ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
- level := voltha.Logging{PackageName: "github.com/opencord/voltha-go/rw_core/core", Level: common.LogLevel_ERROR}
- response, err := stub.UpdateLogLevel(ctx, &level)
- logger.Infow(ctx, "response", log.Fields{"res": response, "error": err})
- assert.Equal(t, &empty.Empty{}, response)
- assert.Nil(t, err)
-}
-
-func TestGetVoltha(t *testing.T) {
- ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
- response, err := stub.GetVoltha(ctx, &empty.Empty{})
- assert.Nil(t, response)
- st, _ := status.FromError(err)
- assert.Equal(t, "UnImplemented", st.Message())
-}
-
-func TestUpdateLogLevelDebug(t *testing.T) {
- ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
- level := voltha.Logging{PackageName: "github.com/opencord/voltha-go/rw_core/core", Level: common.LogLevel_DEBUG}
- response, err := stub.UpdateLogLevel(ctx, &level)
- logger.Infow(ctx, "response", log.Fields{"res": response, "error": err})
- assert.Equal(t, &empty.Empty{}, response)
- assert.Nil(t, err)
-}
-
-func TestGetCoreInstance(t *testing.T) {
- id := &voltha.ID{Id: "getCoreInstance"}
- ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
- response, err := stub.GetCoreInstance(ctx, id)
- assert.Nil(t, response)
- st, _ := status.FromError(err)
- assert.Equal(t, "UnImplemented", st.Message())
-}
-
-func TestGetLogicalDevice(t *testing.T) {
- id := &voltha.ID{Id: "getLogicalDevice"}
- ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
- response, err := stub.GetLogicalDevice(ctx, id)
- assert.Nil(t, response)
- st, _ := status.FromError(err)
- assert.Equal(t, id.Id, st.Message())
- assert.Equal(t, codes.NotFound, st.Code())
-}
-
-func TestGetLogicalDevicePort(t *testing.T) {
- id := &voltha.LogicalPortId{Id: "GetLogicalDevicePort"}
- ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
- response, err := stub.GetLogicalDevicePort(ctx, id)
- assert.Nil(t, response)
- st, _ := status.FromError(err)
- assert.Equal(t, "UnImplemented", st.Message())
-}
-
-func TestListLogicalDevicePorts(t *testing.T) {
- id := &voltha.ID{Id: "listLogicalDevicePorts"}
- ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
- response, err := stub.ListLogicalDevicePorts(ctx, id)
- assert.Nil(t, response)
- st, _ := status.FromError(err)
- assert.Equal(t, "UnImplemented", st.Message())
-}
-
-func TestListLogicalDeviceFlows(t *testing.T) {
- id := &voltha.ID{Id: "ListLogicalDeviceFlows"}
- ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
- response, err := stub.ListLogicalDeviceFlows(ctx, id)
- assert.Nil(t, response)
- st, _ := status.FromError(err)
- assert.Equal(t, "UnImplemented", st.Message())
-}
-
-func TestListLogicalDeviceFlowGroups(t *testing.T) {
- id := &voltha.ID{Id: "ListLogicalDeviceFlowGroups"}
- ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
- response, err := stub.ListLogicalDeviceFlowGroups(ctx, id)
- assert.Nil(t, response)
- st, _ := status.FromError(err)
- assert.Equal(t, "UnImplemented", st.Message())
-}
-
-func TestListDevices(t *testing.T) {
- ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
- response, _ := stub.ListDevices(ctx, &empty.Empty{})
- assert.Equal(t, len(response.Items), 0)
-}
-
-func TestListAdapters(t *testing.T) {
- ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
- response, err := stub.ListAdapters(ctx, &empty.Empty{})
- assert.Nil(t, response)
- st, _ := status.FromError(err)
- assert.Equal(t, "UnImplemented", st.Message())
-}
-
-func TestListLogicalDevices(t *testing.T) {
- ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
- response, _ := stub.ListLogicalDevices(ctx, &empty.Empty{})
- assert.Equal(t, len(response.Items), 0)
-}
-
-func TestListCoreInstances(t *testing.T) {
- ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
- response, err := stub.ListCoreInstances(ctx, &empty.Empty{})
- assert.Nil(t, response)
- st, _ := status.FromError(err)
- assert.Equal(t, "UnImplemented", st.Message())
-}
-
-func TestCreateDevice(t *testing.T) {
- ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
- device := &voltha.Device{Id: "newdevice"}
- response, err := stub.CreateDevice(ctx, device)
- logger.Infow(ctx, "response", log.Fields{"res": response, "error": err})
- assert.Equal(t, &voltha.Device{Id: "newdevice"}, response)
- assert.Nil(t, err)
-}
-
-func TestEnableDevice(t *testing.T) {
- ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
- id := &voltha.ID{Id: "enabledevice"}
- response, err := stub.EnableDevice(ctx, id)
- logger.Infow(ctx, "response", log.Fields{"res": response, "error": err})
- assert.Equal(t, &empty.Empty{}, response)
- assert.Nil(t, err)
-}
-
-func TestDisableDevice(t *testing.T) {
- ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
- id := &voltha.ID{Id: "DisableDevice"}
- response, err := stub.DisableDevice(ctx, id)
- logger.Infow(ctx, "response", log.Fields{"res": response, "error": err})
- assert.Equal(t, &empty.Empty{}, response)
- assert.Nil(t, err)
-}
-
-func TestRebootDevice(t *testing.T) {
- ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
- id := &voltha.ID{Id: "RebootDevice"}
- response, err := stub.RebootDevice(ctx, id)
- logger.Infow(ctx, "response", log.Fields{"res": response, "error": err})
- assert.Equal(t, &empty.Empty{}, response)
- assert.Nil(t, err)
-}
-
-func TestDeleteDevice(t *testing.T) {
- ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
- id := &voltha.ID{Id: "DeleteDevice"}
- response, err := stub.DeleteDevice(ctx, id)
- logger.Infow(ctx, "response", log.Fields{"res": response, "error": err})
- assert.Equal(t, &empty.Empty{}, response)
- assert.Nil(t, err)
-}
-
-func TestEnableLogicalDevicePort(t *testing.T) {
- ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
- id := &voltha.LogicalPortId{Id: "EnableLogicalDevicePort"}
- response, err := stub.EnableLogicalDevicePort(ctx, id)
- if e, ok := status.FromError(err); ok {
- logger.Infow(ctx, "response", log.Fields{"error": err, "errorcode": e.Code(), "msg": e.Message()})
- }
- logger.Infow(ctx, "response", log.Fields{"res": response, "error": err})
- assert.Equal(t, &empty.Empty{}, response)
- assert.Nil(t, err)
-}
-
-func TestDisableLogicalDevicePort(t *testing.T) {
- ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
- id := &voltha.LogicalPortId{Id: "DisableLogicalDevicePort"}
- response, err := stub.DisableLogicalDevicePort(ctx, id)
- logger.Infow(ctx, "response", log.Fields{"res": response, "error": err})
- assert.Equal(t, &empty.Empty{}, response)
- assert.Nil(t, err)
-}
-
-func TestUpdateLogicalDeviceFlowGroupTable(t *testing.T) {
- ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
- flow := &openflow_13.FlowGroupTableUpdate{Id: "UpdateLogicalDeviceFlowGroupTable"}
- response, err := stub.UpdateLogicalDeviceFlowGroupTable(ctx, flow)
- logger.Infow(ctx, "response", log.Fields{"res": response, "error": err})
- assert.Equal(t, &empty.Empty{}, response)
- assert.Nil(t, err)
-}
-
-func TestGetImageDownloadStatus(t *testing.T) {
- ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
- img := &voltha.ImageDownload{Id: "GetImageDownloadStatus"}
- response, err := stub.GetImageDownloadStatus(ctx, img)
- assert.Nil(t, response)
- st, _ := status.FromError(err)
- assert.Equal(t, "UnImplemented", st.Message())
-}
-
-// TODO: complete the remaining tests
-
-func shutdown() {
- conn.Close()
-}
-
-func TestMain(m *testing.M) {
- setup()
- code := m.Run()
- shutdown()
- os.Exit(code)
-}
diff --git a/tests/core/common.go b/tests/core/common.go
deleted file mode 100644
index b96b648..0000000
--- a/tests/core/common.go
+++ /dev/null
@@ -1,33 +0,0 @@
-// +build integration
-
-/*
- * Copyright 2020-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package core
-
-import (
- "github.com/opencord/voltha-lib-go/v3/pkg/log"
-)
-
-var logger log.CLogger
-
-func init() {
- // Setup this package so that it's log level can be modified at run time
- var err error
- logger, err = log.RegisterPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "core"})
- if err != nil {
- panic(err)
- }
-}
diff --git a/tests/core/concurrency/common_test.go b/tests/core/concurrency/common_test.go
deleted file mode 100644
index ccf2126..0000000
--- a/tests/core/concurrency/common_test.go
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright 2020-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package concurrency
-
-import (
- "github.com/opencord/voltha-lib-go/v3/pkg/log"
-)
-
-var logger log.Logger
-
-func init() {
- // Setup this package so that it's log level can be modified at run time
- var err error
- logger, err = log.AddPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "concurrency"})
- if err != nil {
- panic(err)
- }
-}
diff --git a/tests/core/concurrency/core_concurrency_test.go b/tests/core/concurrency/core_concurrency_test.go
deleted file mode 100644
index 87d4e82..0000000
--- a/tests/core/concurrency/core_concurrency_test.go
+++ /dev/null
@@ -1,375 +0,0 @@
-// +build integration
-
-/*
- * Copyright 2018-present Open Networking Foundation
-
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
-
- * http://www.apache.org/licenses/LICENSE-2.0
-
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package concurrency
-
-import (
- "context"
- "errors"
- "fmt"
- "os"
- "os/exec"
- "strings"
- "testing"
-
- "github.com/golang/protobuf/ptypes/empty"
- "github.com/google/uuid"
- com "github.com/opencord/voltha-lib-go/v3/pkg/adapters/common"
- "github.com/opencord/voltha-lib-go/v3/pkg/log"
- "github.com/opencord/voltha-protos/v3/go/common"
- "github.com/opencord/voltha-protos/v3/go/voltha"
- "github.com/stretchr/testify/assert"
- "google.golang.org/grpc"
- "google.golang.org/grpc/metadata"
-)
-
-var conns []*grpc.ClientConn
-var stubs []voltha.VolthaServiceClient
-var volthaSerialNumberKey string
-var grpcPorts []int
-
-/*
- This series of tests are executed with two RW_Cores
-*/
-
-var devices map[string]*voltha.Device
-
-func setup() {
- grpcPorts = []int{50057, 50058}
- stubs = make([]voltha.VolthaServiceClient, 0)
- conns = make([]*grpc.ClientConn, 0)
-
- volthaSerialNumberKey = "voltha_serial_number"
- devices = make(map[string]*voltha.Device)
-}
-
-func connectToCore(port int) (voltha.VolthaServiceClient, error) {
- grpcHostIP := os.Getenv("DOCKER_HOST_IP")
- grpcHost := fmt.Sprintf("%s:%d", grpcHostIP, port)
- conn, err := grpc.Dial(grpcHost, grpc.WithInsecure())
- if err != nil {
- logger.Fatalf(ctx, "did not connect: %s", err)
- return nil, errors.New("failure-to-connect")
- }
- conns = append(conns, conn)
- return voltha.NewVolthaServiceClient(conn), nil
-}
-
-func setupGrpcConnection() []voltha.VolthaServiceClient {
- // We have 2 concurrent cores. Connect to them
- for _, port := range grpcPorts {
- if client, err := connectToCore(port); err == nil {
- stubs = append(stubs, client)
- logger.Infow(ctx, "connected", log.Fields{"port": port})
- }
- }
- return stubs
-}
-
-func clearAllDevices(clearMap bool) {
- for key, _ := range devices {
- ctx := context.Background()
- response, err := stubs[1].DeleteDevice(ctx, &voltha.ID{Id: key})
- logger.Infow(ctx, "response", log.Fields{"res": response, "error": err})
- if clearMap {
- delete(devices, key)
- }
- }
-}
-
-// Verify if all ids are present in the global list of devices
-func hasAllIds(ids *voltha.IDs) bool {
- if ids == nil && len(devices) == 0 {
- return true
- }
- if ids == nil {
- return false
- }
- for _, id := range ids.Items {
- if _, exist := devices[id.Id]; !exist {
- return false
- }
- }
- return true
-}
-
-func startKafka() {
- fmt.Println("Starting Kafka and Etcd ...")
- command := "docker-compose"
- cmd := exec.Command(command, "-f", "../../../compose/docker-compose-zk-kafka-test.yml", "up", "-d")
- if err := cmd.Run(); err != nil {
- logger.Fatal(ctx, err)
- }
-}
-
-func startEtcd() {
- fmt.Println("Starting Etcd ...")
- command := "docker-compose"
- cmd := exec.Command(command, "-f", "../../../compose/docker-compose-etcd.yml", "up", "-d")
- if err := cmd.Run(); err != nil {
- logger.Fatal(ctx, err)
- }
-}
-
-func stopKafka() {
- fmt.Println("Stopping Kafka and Etcd ...")
- command := "docker-compose"
- cmd := exec.Command(command, "-f", "../../../compose/docker-compose-zk-kafka-test.yml", "down")
- if err := cmd.Run(); err != nil {
- // ignore error - as this is mostly due network being left behind as its being used by other
- // containers
- logger.Warn(ctx, err)
- }
-}
-
-func stopEtcd() {
- fmt.Println("Stopping Etcd ...")
- command := "docker-compose"
- cmd := exec.Command(command, "-f", "../../../compose/docker-compose-etcd.yml", "down")
- if err := cmd.Run(); err != nil {
- // ignore error - as this is mostly due network being left behind as its being used by other
- // containers
- logger.Warn(ctx, err)
- }
-}
-
-func startCores() {
- fmt.Println("Starting voltha cores ...")
- command := "docker-compose"
- cmd := exec.Command(command, "-f", "../../../compose/rw_core_concurrency_test.yml", "up", "-d")
- if err := cmd.Run(); err != nil {
- logger.Fatal(ctx, err)
- }
-}
-
-func stopCores() {
- fmt.Println("Stopping voltha cores ...")
- command := "docker-compose"
- cmd := exec.Command(command, "-f", "../../../compose/rw_core_concurrency_test.yml", "down")
- if err := cmd.Run(); err != nil {
- // ignore error - as this is mostly due network being left behind as its being used by other
- // containers
- logger.Warn(ctx, err)
- }
-}
-
-func startSimulatedOLTAndONUAdapters() {
- fmt.Println("Starting simulated OLT and ONU adapters ...")
- command := "docker-compose"
- cmd := exec.Command(command, "-f", "../../../compose/adapters-simulated.yml", "up", "-d")
- if err := cmd.Run(); err != nil {
- logger.Fatal(ctx, err)
- }
-}
-
-func stopSimulatedOLTAndONUAdapters() {
- fmt.Println("Stopping simulated OLT and ONU adapters ...")
- command := "docker-compose"
- cmd := exec.Command(command, "-f", "../../../compose/adapters-simulated.yml", "down")
- if err := cmd.Run(); err != nil {
- // ignore error - as this is mostly due network being left behind as its being used by other
- // containers
- logger.Warn(ctx, err)
- }
-}
-
-func sendCreateDeviceRequest(ctx context.Context, stub voltha.VolthaServiceClient, device *voltha.Device, ch chan interface{}) {
- fmt.Println("Sending create device ...")
- if response, err := stub.CreateDevice(ctx, device); err != nil {
- ch <- err
- } else {
- ch <- response
- }
-}
-
-func sendEnableDeviceRequest(ctx context.Context, stub voltha.VolthaServiceClient, deviceId string, ch chan interface{}) {
- fmt.Println("Sending enable device ...")
- if response, err := stub.EnableDevice(ctx, &common.ID{Id: deviceId}); err != nil {
- ch <- err
- } else {
- ch <- response
- }
-}
-
-//// createPonsimDevice sends two requests to each core and waits for both responses
-//func createPonsimDevice(stubs []voltha.VolthaServiceClient) (*voltha.Device, error) {
-// ui := uuid.New()
-// ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(volthaSerialNumberKey, ui.String()))
-// //preprovision_olt -t ponsim_olt -H 172.20.0.11:50060
-// device := &voltha.Device{Type: "ponsim_olt"}
-// device.Address = &voltha.Device_HostAndPort{HostAndPort:"172.20.0.11:50060"}
-// ch := make(chan interface{})
-// defer close(ch)
-// requestNum := 0
-// for _, stub := range stubs {
-// go sendCreateDeviceRequest(ctx, stub, device, ch)
-// requestNum += 1
-// }
-// fmt.Println("Waiting for create device response ...")
-// receivedResponse := 0
-// var err error
-// var returnedDevice *voltha.Device
-// select {
-// case res, ok := <-ch:
-// receivedResponse += 1
-// if !ok {
-// } else if er, ok := res.(error); ok {
-// err = er
-// } else if d, ok := res.(*voltha.Device); ok {
-// returnedDevice = d
-// }
-// if receivedResponse == requestNum {
-// break
-// }
-// }
-// if returnedDevice != nil {
-// return returnedDevice, nil
-// }
-// return nil, err
-//}
-
-// createDevice sends two requests to each core and waits for both responses
-func createDevice(stubs []voltha.VolthaServiceClient) (*voltha.Device, error) {
- ui := uuid.New()
- ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(volthaSerialNumberKey, ui.String()))
- randomMacAddress := strings.ToUpper(com.GetRandomMacAddress())
- device := &voltha.Device{Type: "simulated_olt", MacAddress: randomMacAddress}
- ch := make(chan interface{})
- defer close(ch)
- requestNum := 0
- for _, stub := range stubs {
- go sendCreateDeviceRequest(ctx, stub, device, ch)
- requestNum += 1
- }
- fmt.Println("Waiting for create device response ...")
- receivedResponse := 0
- var err error
- var returnedDevice *voltha.Device
- select {
- case res, ok := <-ch:
- receivedResponse += 1
- if !ok {
- } else if er, ok := res.(error); ok {
- err = er
- } else if d, ok := res.(*voltha.Device); ok {
- returnedDevice = d
- }
- if receivedResponse == requestNum {
- break
- }
- }
- if returnedDevice != nil {
- return returnedDevice, nil
- }
- return nil, err
-}
-
-// enableDevices sends two requests to each core for each device and waits for both responses before sending another
-// enable request for a different device.
-func enableAllDevices(stubs []voltha.VolthaServiceClient) error {
- for deviceId, val := range devices {
- if val.AdminState == voltha.AdminState_PREPROVISIONED {
- ui := uuid.New()
- ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(volthaSerialNumberKey, ui.String()))
- ch := make(chan interface{})
- defer close(ch)
- requestNum := 0
- for _, stub := range stubs {
- go sendEnableDeviceRequest(ctx, stub, deviceId, ch)
- requestNum += 1
- }
- receivedResponse := 0
- var err error
- fmt.Println("Waiting for enable device response ...")
- validResponseReceived := false
- select {
- case res, ok := <-ch:
- receivedResponse += 1
- if !ok {
- } else if er, ok := res.(error); ok {
- err = er
- } else if _, ok := res.(*empty.Empty); ok {
- validResponseReceived = true
- }
- if receivedResponse == requestNum {
- break
- }
- }
- if validResponseReceived {
- return nil
- }
- return err
- }
- }
- return nil
-}
-
-func TestConcurrentRequests(t *testing.T) {
- fmt.Println("Testing Concurrent requests ...")
-
- ////0. Start kafka and Ectd
- startKafka()
- defer stopKafka()
- startEtcd()
- defer stopKafka()
- //
- ////1. Start the core
- startCores()
- defer stopCores()
- //
- ////2. Start the simulated adapters
- startSimulatedOLTAndONUAdapters()
- defer stopSimulatedOLTAndONUAdapters()
- //
- //// Wait until the core and adapters sync up
- //time.Sleep(10 * time.Second)
-
- stubs = setupGrpcConnection()
-
- //3. Create the devices
- response, err := createDevice(stubs)
- logger.Infow(ctx, "response", log.Fields{"res": response, "error": err})
- assert.Nil(t, err)
- devices[response.Id] = response
-
- //4. Enable all the devices
- err = enableAllDevices(stubs)
- assert.Nil(t, err)
-
- ////5. Store simulated adapters
- //stopSimulatedOLTAndONUAdapters()
- //
- ////6. Store the core
- //stopCores()
- //
- ////7. Stop Kafka and Etcd
- //stopKafka()
- //stopEtcd()
-}
-
-func shutdown() {
- for _, conn := range conns {
- conn.Close()
- }
-}
-
-func TestMain(m *testing.M) {
- setup()
- code := m.Run()
- shutdown()
- os.Exit(code)
-}
diff --git a/tests/core/flow_management_test.go b/tests/core/flow_management_test.go
deleted file mode 100644
index 7a1079d..0000000
--- a/tests/core/flow_management_test.go
+++ /dev/null
@@ -1,901 +0,0 @@
-// +build integration
-
-/*
- * Copyright 2018-present Open Networking Foundation
-
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
-
- * http://www.apache.org/licenses/LICENSE-2.0
-
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package core
-
-import (
- "context"
- "fmt"
- "github.com/google/uuid"
- fu "github.com/opencord/voltha-go/rw_core/utils"
- tu "github.com/opencord/voltha-go/tests/utils"
- "github.com/opencord/voltha-lib-go/v3/pkg/log"
- "github.com/opencord/voltha-protos/v3/go/common"
- ofp "github.com/opencord/voltha-protos/v3/go/openflow_13"
- "github.com/opencord/voltha-protos/v3/go/voltha"
- "github.com/stretchr/testify/assert"
- "google.golang.org/grpc/metadata"
- "math"
- "os"
- "reflect"
- "sync"
- "testing"
- "time"
-)
-
-var stub voltha.VolthaServiceClient
-var volthaSerialNumberKey string
-var mutex sync.Mutex
-
-/*
- This local "integration" test uses one RW-Core, one simulated_olt and one simulated_onu adapter to test flows
-(add/delete), in a development environment. It uses docker-compose to set up the local environment. However, it can
-easily be extended to run in k8s environment.
-
-The compose files used are located under %GOPATH/src/github.com/opencord/voltha-go/compose. If the GOPATH is not set
-then you can specify the location of the compose files by using COMPOSE_PATH to set the compose files location.
-
-To run this test: DOCKER_HOST_IP=<local IP> go test -v
-
-NOTE: Since this is an integration test that involves several containers and features (device creation, device
-activation, validation of parent and discovered devices, validation of logical device as well as add/delete flows)
-then a failure can occur anywhere not just when testing flows.
-
-*/
-
-var allDevices map[string]*voltha.Device
-var allLogicalDevices map[string]*voltha.LogicalDevice
-
-var composePath string
-
-const (
- GrpcPort = 50057
- NumOfOLTs = 1
- NumOfONUsPerOLT = 4 // This should coincide with the number of onus per olt in adapters-simulated.yml file
- MeterIDStart = 1
- MeterIDStop = 1000
-)
-
-func setup() {
- volthaSerialNumberKey = "voltha_serial_number"
- allDevices = make(map[string]*voltha.Device)
- allLogicalDevices = make(map[string]*voltha.LogicalDevice)
-
- grpcHostIP := os.Getenv("DOCKER_HOST_IP")
- goPath := os.Getenv("GOPATH")
- if goPath != "" {
- composePath = fmt.Sprintf("%s/src/github.com/opencord/voltha-go/compose", goPath)
- } else {
- composePath = os.Getenv("COMPOSE_PATH")
- }
-
- fmt.Println("Using compose path:", composePath)
-
- //Start the simulated environment
- if err = tu.StartSimulatedEnv(composePath); err != nil {
- fmt.Println("Failure starting simulated environment:", err)
- os.Exit(10)
- }
-
- stub, err = tu.SetupGrpcConnectionToCore(grpcHostIP, GrpcPort)
- if err != nil {
- fmt.Println("Failure connecting to Voltha Core:", err)
- os.Exit(11)
- }
-
- // Wait for the simulated devices to be registered in the Voltha Core
- adapters := []string{"simulated_olt", "simulated_onu"}
- if _, err = tu.WaitForAdapterRegistration(stub, adapters, 20); err != nil {
- fmt.Println("Failure retrieving adapters:", err)
- os.Exit(12)
- }
-}
-
-func shutdown() {
- err := tu.StopSimulatedEnv(composePath)
- if err != nil {
- fmt.Println("Failure stop simulated environment:", err)
- }
-}
-
-func refreshLocalDeviceCache(stub voltha.VolthaServiceClient) error {
- retrievedDevices, err := tu.ListDevices(stub)
- if err != nil {
- return err
- }
- mutex.Lock()
- for _, d := range retrievedDevices.Items {
- allDevices[d.Id] = d
- }
- retrievedLogicalDevices, err := tu.ListLogicalDevices(stub)
- if err != nil {
- return err
- }
-
- for _, ld := range retrievedLogicalDevices.Items {
- allLogicalDevices[ld.Id] = ld
- }
- mutex.Unlock()
- return nil
-}
-
-func makeSimpleFlowMod(fa *fu.FlowArgs) *ofp.OfpFlowMod {
- matchFields := make([]*ofp.OfpOxmField, 0)
- for _, val := range fa.MatchFields {
- matchFields = append(matchFields, &ofp.OfpOxmField{Field: &ofp.OfpOxmField_OfbField{OfbField: val}})
- }
- return fu.MkSimpleFlowMod(matchFields, fa.Actions, fa.Command, fa.KV)
-}
-
-func addEAPOLFlow(stub voltha.VolthaServiceClient, ld *voltha.LogicalDevice, port *voltha.LogicalPort, meterID uint64,
- ch chan interface{}) {
- var fa *fu.FlowArgs
- fa = &fu.FlowArgs{
- KV: fu.OfpFlowModArgs{"priority": 2000, "meter_id": meterID},
- MatchFields: []*ofp.OfpOxmOfbField{
- fu.InPort(port.OfpPort.PortNo),
- fu.EthType(0x888e),
- },
- Actions: []*ofp.OfpAction{
- fu.Output(uint32(ofp.OfpPortNo_OFPP_CONTROLLER)),
- },
- }
- // Don't add meterID 0
- if meterID == 0 {
- delete(fa.KV, "meter_id")
- }
-
- matchFields := make([]*ofp.OfpOxmField, 0)
- for _, val := range fa.MatchFields {
- matchFields = append(matchFields, &ofp.OfpOxmField{Field: &ofp.OfpOxmField_OfbField{OfbField: val}})
- }
- f := ofp.FlowTableUpdate{FlowMod: makeSimpleFlowMod(fa), Id: ld.Id}
-
- ui := uuid.New()
- ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(volthaSerialNumberKey, ui.String()))
- if response, err := stub.UpdateLogicalDeviceFlowTable(ctx, &f); err != nil {
- ch <- err
- } else {
- ch <- response
- }
-}
-
-func getNumUniPort(ld *voltha.LogicalDevice, lPortNos ...uint32) int {
- num := 0
- if len(lPortNos) > 0 {
- for _, pNo := range lPortNos {
- for _, lPort := range ld.Ports {
- if !lPort.RootPort && lPort.OfpPort.PortNo == pNo {
- num += 1
- }
- }
- }
- } else {
- for _, port := range ld.Ports {
- if !port.RootPort {
- num += 1
- }
- }
- }
- return num
-}
-
-func filterOutPort(lPort *voltha.LogicalPort, lPortNos ...uint32) bool {
- if len(lPortNos) == 0 {
- return false
- }
- for _, pNo := range lPortNos {
- if lPort.OfpPort.PortNo == pNo {
- return false
- }
- }
- return true
-}
-
-func verifyEAPOLFlows(t *testing.T, ld *voltha.LogicalDevice, meterID uint64, lPortNos ...uint32) {
- // First get the flows from the logical device
- fmt.Println("Info: verifying EAPOL flows")
- lFlows := ld.Flows
- assert.Equal(t, getNumUniPort(ld, lPortNos...), len(lFlows.Items))
-
- onuDeviceId := ""
-
- // Verify that the flows in the logical device is what was pushed
- for _, lPort := range ld.Ports {
- if lPort.RootPort {
- continue
- }
- if filterOutPort(lPort, lPortNos...) {
- continue
- }
- onuDeviceId = lPort.DeviceId
- var fa *fu.FlowArgs
- fa = &fu.FlowArgs{
- KV: fu.OfpFlowModArgs{"priority": 2000, "meter_id": meterID},
- MatchFields: []*ofp.OfpOxmOfbField{
- fu.InPort(lPort.OfpPort.PortNo),
- fu.EthType(0x888e),
- },
- Actions: []*ofp.OfpAction{
- fu.Output(uint32(ofp.OfpPortNo_OFPP_CONTROLLER)),
- },
- }
- if meterID == 0 {
- delete(fa.KV, "meter_id")
- }
- expectedLdFlow := fu.MkFlowStat(fa)
- assert.Equal(t, true, tu.IsFlowPresent(expectedLdFlow, lFlows.Items))
- }
-
- // Verify the OLT flows
- retrievedOltFlows := allDevices[ld.RootDeviceId].Flows.Items
- assert.Equal(t, NumOfOLTs*getNumUniPort(ld, lPortNos...)*1, len(retrievedOltFlows))
- for _, lPort := range ld.Ports {
- if lPort.RootPort {
- continue
- }
- if filterOutPort(lPort, lPortNos...) {
- continue
- }
-
- fa := &fu.FlowArgs{
- KV: fu.OfpFlowModArgs{"priority": 2000, "meter_id": meterID},
- MatchFields: []*ofp.OfpOxmOfbField{
- fu.InPort(1),
- fu.TunnelId(uint64(lPort.OfpPort.PortNo)),
- fu.EthType(0x888e),
- },
- Actions: []*ofp.OfpAction{
- fu.PushVlan(0x8100),
- fu.SetField(fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 4000)),
- fu.Output(uint32(ofp.OfpPortNo_OFPP_CONTROLLER)),
- },
- }
- expectedOltFlow := fu.MkFlowStat(fa)
- assert.Equal(t, true, tu.IsFlowPresent(expectedOltFlow, retrievedOltFlows))
- }
- // Verify the ONU flows
- retrievedOnuFlows := allDevices[onuDeviceId].Flows.Items
- assert.Equal(t, 0, len(retrievedOnuFlows))
-}
-
-func verifyNOFlows(t *testing.T, ld *voltha.LogicalDevice, lPortNos ...uint32) {
- if len(lPortNos) == 0 {
- assert.Equal(t, 0, len(ld.Flows.Items))
- for _, d := range allDevices {
- if d.ParentId == ld.Id {
- assert.Equal(t, 0, len(d.Flows.Items))
- }
- }
- return
- }
- for _, p := range lPortNos {
- // Check absence of flows in logical device for that port
- for _, f := range ld.Flows.Items {
- assert.NotEqual(t, p, fu.GetInPort(f))
- }
- // Check absence of flows in the parent device for that port
- for _, d := range allDevices {
- if d.ParentId == ld.Id {
- for _, f := range d.Flows.Items {
- assert.NotEqual(t, p, fu.GetTunnelId(f))
- }
- }
- }
- // TODO: check flows in child device. Not required for the use cases being tested
- }
-
-}
-
-func installEapolFlows(stub voltha.VolthaServiceClient, lDevice *voltha.LogicalDevice, meterID uint64, lPortNos ...uint32) error {
- requestNum := 0
- combineCh := make(chan interface{})
- if len(lPortNos) > 0 {
- fmt.Println("Installing EAPOL flows on ports:", lPortNos)
- for _, p := range lPortNos {
- for _, lport := range lDevice.Ports {
- if !lport.RootPort && lport.OfpPort.PortNo == p {
- go addEAPOLFlow(stub, lDevice, lport, meterID, combineCh)
- requestNum += 1
- }
- }
- }
- } else {
- fmt.Println("Installing EAPOL flows on logical device", lDevice.Id)
- for _, lport := range lDevice.Ports {
- if !lport.RootPort {
- go addEAPOLFlow(stub, lDevice, lport, meterID, combineCh)
- requestNum += 1
- }
- }
- }
- receivedResponse := 0
- var err error
- for {
- select {
- case res, ok := <-combineCh:
- receivedResponse += 1
- if !ok {
- } else if er, ok := res.(error); ok {
- err = er
- }
- }
- if receivedResponse == requestNum {
- break
- }
- }
- return err
-}
-
-func deleteAllFlows(stub voltha.VolthaServiceClient, lDevice *voltha.LogicalDevice) error {
- fmt.Println("Deleting all flows for logical device:", lDevice.Id)
- ui := uuid.New()
- ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(volthaSerialNumberKey, ui.String()))
- ch := make(chan interface{})
- defer close(ch)
- fa := &fu.FlowArgs{
- KV: fu.OfpFlowModArgs{"table_id": uint64(ofp.OfpTable_OFPTT_ALL),
- "cookie_mask": 0,
- "out_port": uint64(ofp.OfpPortNo_OFPP_ANY),
- "out_group": uint64(ofp.OfpGroup_OFPG_ANY),
- },
- }
- cmd := ofp.OfpFlowModCommand_OFPFC_DELETE
- fa.Command = &cmd
- flowMod := fu.MkSimpleFlowMod(fu.ToOfpOxmField(fa.MatchFields), fa.Actions, fa.Command, fa.KV)
- f := ofp.FlowTableUpdate{FlowMod: flowMod, Id: lDevice.Id}
- _, err := stub.UpdateLogicalDeviceFlowTable(ctx, &f)
- return err
-}
-
-func deleteEapolFlow(stub voltha.VolthaServiceClient, lDevice *voltha.LogicalDevice, meterID uint64, lPortNo uint32) error {
- fmt.Println("Deleting flows from port ", lPortNo, " of logical device ", lDevice.Id)
- ui := uuid.New()
- var fa *fu.FlowArgs
- ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(volthaSerialNumberKey, ui.String()))
- fa = &fu.FlowArgs{
- KV: fu.OfpFlowModArgs{"priority": 2000, "meter_id": meterID},
- MatchFields: []*ofp.OfpOxmOfbField{
- fu.InPort(lPortNo),
- fu.EthType(0x888e),
- },
- Actions: []*ofp.OfpAction{
- fu.Output(uint32(ofp.OfpPortNo_OFPP_CONTROLLER)),
- },
- }
- matchFields := make([]*ofp.OfpOxmField, 0)
- for _, val := range fa.MatchFields {
- matchFields = append(matchFields, &ofp.OfpOxmField{Field: &ofp.OfpOxmField_OfbField{OfbField: val}})
- }
- cmd := ofp.OfpFlowModCommand_OFPFC_DELETE
- fa.Command = &cmd
- f := ofp.FlowTableUpdate{FlowMod: makeSimpleFlowMod(fa), Id: lDevice.Id}
- _, err := stub.UpdateLogicalDeviceFlowTable(ctx, &f)
- return err
-}
-
-func runInstallEapolFlows(t *testing.T, stub voltha.VolthaServiceClient, meterID uint64, lPortNos ...uint32) {
- err := refreshLocalDeviceCache(stub)
- assert.Nil(t, err)
-
- for _, ld := range allLogicalDevices {
- err = installEapolFlows(stub, ld, meterID, lPortNos...)
- assert.Nil(t, err)
- }
-
- err = refreshLocalDeviceCache(stub)
- assert.Nil(t, err)
- for _, ld := range allLogicalDevices {
- verifyEAPOLFlows(t, ld, meterID, lPortNos...)
- }
-}
-
-func runDeleteAllFlows(t *testing.T, stub voltha.VolthaServiceClient) {
- fmt.Println("Removing ALL flows ...")
- err := refreshLocalDeviceCache(stub)
- assert.Nil(t, err)
-
- for _, ld := range allLogicalDevices {
- err = deleteAllFlows(stub, ld)
- assert.Nil(t, err)
- }
-
- err = refreshLocalDeviceCache(stub)
- assert.Nil(t, err)
-
- for _, ld := range allLogicalDevices {
- verifyNOFlows(t, ld)
- }
-}
-
-func runDeleteEapolFlows(t *testing.T, stub voltha.VolthaServiceClient, ld *voltha.LogicalDevice, meterID uint64, lPortNos ...uint32) {
- err := refreshLocalDeviceCache(stub)
- assert.Nil(t, err)
-
- if len(lPortNos) == 0 {
- err = deleteAllFlows(stub, ld)
- assert.Nil(t, err)
- } else {
- for _, lPortNo := range lPortNos {
- err = deleteEapolFlow(stub, ld, meterID, lPortNo)
- assert.Nil(t, err)
- }
- }
-
- err = refreshLocalDeviceCache(stub)
- assert.Nil(t, err)
-
- for _, lde := range allLogicalDevices {
- if lde.Id == ld.Id {
- verifyNOFlows(t, lde, lPortNos...)
- break
- }
- }
-}
-
-func formulateMeterModUpdateRequest(command ofp.OfpMeterModCommand, meterType ofp.OfpMeterBandType, ldID string, rate,
- burstSize uint32, meterID uint32) *ofp.MeterModUpdate {
- meterModUpdateRequest := &ofp.MeterModUpdate{
- Id: ldID,
- MeterMod: &ofp.OfpMeterMod{
- Command: command,
- Flags: 0,
- MeterId: meterID,
- Bands: []*ofp.OfpMeterBandHeader{{
- Type: meterType,
- Rate: rate,
- BurstSize: burstSize,
- Data: nil,
- }},
- },
- }
- return meterModUpdateRequest
-}
-
-func formulateMeters(rate, burstsize, meterID uint32, flowCount uint32) *ofp.Meters {
- // Formulate and return the applied meter band
- ofpMeterBandHeaderSlice := []*ofp.OfpMeterBandHeader{{
- Type: ofp.OfpMeterBandType_OFPMBT_EXPERIMENTER,
- Rate: rate,
- BurstSize: burstsize,
- }}
- BandStats := []*ofp.OfpMeterBandStats{{}}
- appliedMeters_Meters := []*ofp.OfpMeterEntry{{
- Config: &ofp.OfpMeterConfig{
- Flags: 0,
- MeterId: meterID,
- Bands: ofpMeterBandHeaderSlice,
- },
- Stats: &ofp.OfpMeterStats{
- MeterId: meterID,
- BandStats: BandStats,
- FlowCount: flowCount,
- },
- }}
- appliedMeters := &ofp.Meters{
- Items: appliedMeters_Meters,
- }
- return appliedMeters
-}
-
-func meterAdd(t *testing.T, meterID, rate, burstSize uint32) {
- var err error
- for _, logicalDevice := range allLogicalDevices {
- meterModupdateRequest := formulateMeterModUpdateRequest(ofp.OfpMeterModCommand_OFPMC_ADD,
- ofp.OfpMeterBandType_OFPMBT_EXPERIMENTER, logicalDevice.Id, rate, burstSize, meterID)
- _, err = stub.UpdateLogicalDeviceMeterTable(context.Background(), meterModupdateRequest)
- assert.Nil(t, err)
- }
-}
-
-func meterMod(t *testing.T, meterID, rate, burstSize uint32) {
- for _, logicalDevice := range allLogicalDevices {
- meterModUpdateRequest := formulateMeterModUpdateRequest(ofp.OfpMeterModCommand_OFPMC_MODIFY,
- ofp.OfpMeterBandType_OFPMBT_EXPERIMENTER, logicalDevice.Id, rate, burstSize, meterID)
- _, err := stub.UpdateLogicalDeviceMeterTable(context.Background(), meterModUpdateRequest)
- assert.Nil(t, err)
- }
-}
-
-//MeterDel deletes a meter with given meter-ID
-func meterDel(t *testing.T, meterID uint32) {
- for _, logicalDevice := range allLogicalDevices {
- meterModUpdateRequest := formulateMeterModUpdateRequest(ofp.OfpMeterModCommand_OFPMC_DELETE,
- ofp.OfpMeterBandType_OFPMBT_EXPERIMENTER, logicalDevice.Id, uint32(1600), uint32(1600), meterID)
- _, err := stub.UpdateLogicalDeviceMeterTable(context.Background(), meterModUpdateRequest)
- assert.Nil(t, err)
- }
-}
-
-// WaitGroup passed to this function must not be nil
-func addMultipleMeterSequentially(t *testing.T, startMeterId, endMeterId, rate, burstSize uint32, wg *sync.WaitGroup) {
- defer wg.Done()
- for meterID := startMeterId; meterID <= endMeterId; meterID++ {
- meterAdd(t, meterID, rate, burstSize)
- }
-}
-
-func modMultipleMeterSequentially(t *testing.T, startMeterId, endMeterId, rate, burstSize uint32, wg *sync.WaitGroup) {
- defer wg.Done()
- for meterID := startMeterId; meterID <= endMeterId; meterID++ {
- meterMod(t, meterID, rate, burstSize)
- }
-}
-
-func delMultipleMeterSequential(t *testing.T, startMeterId, endMeterId uint32, wg *sync.WaitGroup) {
- defer wg.Done()
- for meterID := startMeterId; meterID <= endMeterId; meterID++ {
- meterDel(t, meterID)
- }
-}
-
-func verifyMeter(t *testing.T, meterID, rate, burstSize, flowCount uint32) {
- expectedMeter := formulateOfpMeterEntry(meterID, flowCount, rate, burstSize)
- isMeterPresent := false
- for _, lD := range allLogicalDevices {
- for _, meter := range lD.Meters.Items {
- isMeterPresent = reflect.DeepEqual(meter, expectedMeter)
- if isMeterPresent == true {
- break
- }
- }
- if isMeterPresent {
- break
- }
- }
- if !isMeterPresent {
- fmt.Printf("Error : Expected %+v\n", expectedMeter)
- }
- assert.Equal(t, true, isMeterPresent)
-}
-
-func verifyNoMeters(t *testing.T) {
- err := refreshLocalDeviceCache(stub)
- assert.Nil(t, err)
- expectedMeters := &ofp.Meters{}
- for _, logicalDevice := range allLogicalDevices {
- result := reflect.DeepEqual(logicalDevice.Meters, expectedMeters)
- fmt.Println("Meter Present After Delete :--- ", logicalDevice.Meters)
- assert.Equal(t, true, result)
- }
-}
-
-func formulateOfpMeterEntry(meterID, flowCount, rate, burstSize uint32) *ofp.OfpMeterEntry {
- value := &ofp.OfpMeterEntry{
- Config: &ofp.OfpMeterConfig{
- MeterId: meterID,
- Bands: []*ofp.OfpMeterBandHeader{{
- Type: ofp.OfpMeterBandType_OFPMBT_EXPERIMENTER,
- Rate: rate,
- BurstSize: burstSize,
- }},
- },
- Stats: &ofp.OfpMeterStats{
- MeterId: meterID,
- FlowCount: flowCount,
- BandStats: []*ofp.OfpMeterBandStats{{}},
- },
- }
-
- return value
-}
-
-func deleteAllMeters(t *testing.T) {
- err := refreshLocalDeviceCache(stub)
- assert.Nil(t, err)
- for _, lD := range allLogicalDevices {
- for _, meter := range lD.Meters.Items {
- meterDel(t, meter.Config.MeterId)
- }
- }
-}
-
-func installMultipleFlowsWithMeter(t *testing.T, startMeterId, stopMeterId uint64, wg *sync.WaitGroup) {
- defer wg.Done()
- err := refreshLocalDeviceCache(stub)
- assert.Nil(t, err)
-
- for meterID := startMeterId; meterID <= stopMeterId; meterID++ {
- runInstallEapolFlows(t, stub, uint64(meterID), 100, 101)
- }
-}
-
-func createAndEnableDevices(t *testing.T) {
- err := tu.SetAllLogLevel(stub, voltha.Logging{Level: common.LogLevel_WARNING})
- assert.Nil(t, err)
-
- err = tu.SetLogLevel(stub, voltha.Logging{Level: common.LogLevel_DEBUG, PackageName: "github.com/opencord/voltha-go/rw_core/core"})
- assert.Nil(t, err)
-
- startTime := time.Now()
-
- //Pre-provision the parent device
- oltDevice, err := tu.PreProvisionDevice(stub)
- assert.Nil(t, err)
-
- fmt.Println("Creation of ", NumOfOLTs, " OLT devices took:", time.Since(startTime))
-
- startTime = time.Now()
-
- //Enable all parent device - this will enable the child devices as well as validate the child devices
- err = tu.EnableDevice(stub, oltDevice, NumOfONUsPerOLT)
- assert.Nil(t, err)
-
- fmt.Println("Enabling of OLT device took:", time.Since(startTime))
-
- // Wait until the core and adapters sync up after an enabled
- time.Sleep(time.Duration(math.Max(10, float64(NumOfOLTs*NumOfONUsPerOLT)/2)) * time.Second)
-
- err = tu.VerifyDevices(stub, NumOfONUsPerOLT)
- assert.Nil(t, err)
-
- lds, err := tu.VerifyLogicalDevices(stub, oltDevice, NumOfONUsPerOLT)
- assert.Nil(t, err)
- assert.Equal(t, 1, len(lds.Items))
-}
-
-func TestFlowManagement(t *testing.T) {
- //1. Test creation and activation of the devices. This will validate the devices as well as the logical device created
- createAndEnableDevices(t)
-
- //2. Test installation of EAPOL flows
- runInstallEapolFlows(t, stub, 0)
-
- //3. Test deletion of all EAPOL flows
- runDeleteAllFlows(t, stub)
-
- //4. Test installation of EAPOL flows on specific ports
- runInstallEapolFlows(t, stub, 0, 101, 102)
-
- lds, err := tu.ListLogicalDevices(stub)
- assert.Nil(t, err)
-
- //5. Test deletion of EAPOL on a specific port for a given logical device
- runDeleteEapolFlows(t, stub, lds.Items[0], 0, 101)
-}
-
-// Meter Add Test
-func TestMeters(t *testing.T) {
- //1. Start test for meter add
- meterAdd(t, 1, 1600, 1600)
- err := refreshLocalDeviceCache(stub)
- assert.Nil(t, err)
- verifyMeter(t, 1, 1600, 1600, 0)
-
- //2. Start test for meter mod
- meterMod(t, 1, 6400, 6400)
- err = refreshLocalDeviceCache(stub)
- assert.Nil(t, err)
- verifyMeter(t, 1, 6400, 6400, 0)
-
- //3. Start test for meter del
- meterDel(t, 1)
- err = refreshLocalDeviceCache(stub)
- assert.Nil(t, err)
- verifyNoMeters(t)
-}
-
-func TestFlowManagementWithMeters(t *testing.T) {
- //1. Delete existing flows
- for _, logicaldevice := range allLogicalDevices {
- err := deleteAllFlows(stub, logicaldevice)
- assert.Nil(t, err)
- }
- deleteAllMeters(t)
- //2. Refresh the local cache so that the changes are reflected here
- err := refreshLocalDeviceCache(stub)
- assert.Nil(t, err)
-
- //3. Add meter with ID
- meterAdd(t, 1, 1600, 1600)
-
- err = refreshLocalDeviceCache(stub)
- assert.Nil(t, err)
-
- //4. Verify that the meter is installed
- verifyMeter(t, 1, 1600, 1600, 0)
-
- //3. Test installation of EAPOL flows with meter (Add and verify the flow)
- runInstallEapolFlows(t, stub, MeterIDStart)
-
- //4. Test deletion of all EAPOL flows
- runDeleteAllFlows(t, stub)
-
- //5. Test installation of EAPOL flows on specific ports with meter (Add and verify the flows)
- runInstallEapolFlows(t, stub, MeterIDStart, 101, 102)
-
- lds, err := tu.ListLogicalDevices(stub)
- assert.Nil(t, err)
-
- //6. Test deletion of EAPOL on a specific port for a given logical device
- runDeleteEapolFlows(t, stub, lds.Items[0], MeterIDStart, 101)
-}
-
-func TestMultipleMeterAddSequential(t *testing.T) {
- //1. Delete existing flows
- for _, logicaldevice := range allLogicalDevices {
- err := deleteAllFlows(stub, logicaldevice)
- assert.Nil(t, err)
- }
-
- // Delete All The Previously Installed Meters
- deleteAllMeters(t)
- // Verify that no meters are present
- err := refreshLocalDeviceCache(stub)
- assert.Nil(t, err)
- verifyNoMeters(t)
- //2. Add Meter Sequentially
- // Here wait-group is not required, creating and passing wait-group only because the function addMultipleMeterSequentially
- // expects wait group.
- var wg sync.WaitGroup
- wg.Add(1)
- addMultipleMeterSequentially(t, MeterIDStart, MeterIDStop, 1600, 1600, &wg)
-
- err = refreshLocalDeviceCache(stub)
- assert.Nil(t, err)
-
- //3. Verify that the meters are installed
- for meterID := MeterIDStart; meterID <= MeterIDStop; meterID++ {
- verifyMeter(t, uint32(meterID), 1600, 1600, 0)
- }
-}
-
-func TestMeterDeleteParallel(t *testing.T) {
- var wg sync.WaitGroup
- wg.Add(4)
- go delMultipleMeterSequential(t, MeterIDStart, MeterIDStop/4, &wg)
- go delMultipleMeterSequential(t, MeterIDStop/4+1, (MeterIDStop / 2), &wg)
- go delMultipleMeterSequential(t, (MeterIDStop/2)+1, MeterIDStop/4*3, &wg)
- go delMultipleMeterSequential(t, (MeterIDStop/4*3)+1, MeterIDStop, &wg)
- wg.Wait()
-
- verifyNoMeters(t)
-}
-
-func TestMultipleMeterAddParallel(t *testing.T) {
- err := refreshLocalDeviceCache(stub)
- assert.Nil(t, err)
-
- for _, logicaldevice := range allLogicalDevices {
- err := deleteAllFlows(stub, logicaldevice)
- assert.Nil(t, err)
- }
-
- var wg sync.WaitGroup
- wg.Add(4)
- go addMultipleMeterSequentially(t, MeterIDStart, (MeterIDStop / 4), 3200, 3200, &wg)
- go addMultipleMeterSequentially(t, (MeterIDStop/4 + 1), MeterIDStop/2, 3200, 3200, &wg)
- go addMultipleMeterSequentially(t, MeterIDStop/2+1, (MeterIDStop / 4 * 3), 3200, 3200, &wg)
- go addMultipleMeterSequentially(t, (MeterIDStop/4*3)+1, MeterIDStop, 3200, 3200, &wg)
-
- wg.Wait()
-
- // Verify the devices
- err = tu.VerifyDevices(stub, NumOfONUsPerOLT)
- assert.Nil(t, err)
-
- err = refreshLocalDeviceCache(stub)
- assert.Nil(t, err)
- for meterID := MeterIDStart; meterID <= MeterIDStop; meterID++ {
- fmt.Println("Verifying meter ID :", meterID)
- verifyMeter(t, uint32(meterID), 3200, 3200, 0)
- }
-}
-
-func TestMultipleMeterModSequential(t *testing.T) {
- var wg sync.WaitGroup
- wg.Add(1)
- //1. Modify all the existing meters
- modMultipleMeterSequentially(t, MeterIDStart, MeterIDStop, 6400, 6400, &wg)
- //2. Verify that the device state is proper after updating so many meters
- err := tu.VerifyDevices(stub, NumOfONUsPerOLT)
- assert.Nil(t, err)
-
- //3. Refresh logical device cache
- err = refreshLocalDeviceCache(stub)
- assert.Nil(t, err)
-
- //4. Verify that all the meters got modified
- for meterID := MeterIDStart; meterID <= MeterIDStop; meterID++ {
- fmt.Println("Verifying meter ID :", meterID)
- verifyMeter(t, uint32(meterID), 6400, 6400, 0)
- }
-}
-
-func TestMultipleMeterModParallel(t *testing.T) {
- var wg sync.WaitGroup
- wg.Add(4)
- //1. Modify all the existing meters
- go modMultipleMeterSequentially(t, MeterIDStart, MeterIDStop/4, 1600, 1600, &wg)
- go modMultipleMeterSequentially(t, (MeterIDStop/4 + 1), MeterIDStop/2, 1600, 1600, &wg)
- go modMultipleMeterSequentially(t, (MeterIDStop/2 + 1), (MeterIDStop / 4 * 3), 1600, 1600, &wg)
- go modMultipleMeterSequentially(t, (MeterIDStop/4*3)+1, MeterIDStop, 1600, 1600, &wg)
- //2. Verify that the device state is proper after updating so many meters
- err := tu.VerifyDevices(stub, NumOfONUsPerOLT)
- assert.Nil(t, err)
- wg.Wait()
-
- //3. Refresh logical device cache
- err = refreshLocalDeviceCache(stub)
- assert.Nil(t, err)
-
- //4. Verify that all the meters got modified
- for meterID := MeterIDStart; meterID <= MeterIDStop; meterID++ {
- fmt.Println("Verifying meter ID :", meterID)
- verifyMeter(t, uint32(meterID), 1600, 1600, 0)
- }
-}
-
-func TestMultipleMeterDelSequential(t *testing.T) {
- var wg sync.WaitGroup
- wg.Add(1)
- //1. Delete all the given meters sequentially
- delMultipleMeterSequential(t, MeterIDStart, MeterIDStop, &wg)
- //2. Verify that all the given meters are deleted
- verifyNoMeters(t)
-}
-
-func TestMultipleFlowsWithMeters(t *testing.T) {
- err := refreshLocalDeviceCache(stub)
- assert.Nil(t, err)
-
- //1. Delete all the previous flows
- for _, lD := range allLogicalDevices {
- deleteAllFlows(stub, lD)
- }
-
- //2. Add multiple meters for the flows to refer to
- var wg sync.WaitGroup
- wg.Add(2)
- addMultipleMeterSequentially(t, MeterIDStart, 10, 1600, 1600, &wg)
- // Adding meter verification here again will increase the time taken by the test. So leaving meter verification
- installMultipleFlowsWithMeter(t, 1, 10, &wg)
-}
-
-func TestFlowDeletionWithMeterDelete(t *testing.T) {
- err := refreshLocalDeviceCache(stub)
- assert.Nil(t, err)
-
- //1. Delete all meters
- deleteAllMeters(t)
- //2. Verify that all the meters are deleted
- verifyNoMeters(t)
- //3. As no meters are present, so all flows referring to these meters should also be deleted
- // Flow referring to meterID 1 - 10 were installed in the above test "TestMultipleFlowsWithMeters"
- err = refreshLocalDeviceCache(stub)
- assert.Nil(t, err)
- for _, lD := range allLogicalDevices {
- verifyNOFlows(t, lD, 100, 101)
- }
-}
-
-func TestAddFlowWithInvalidMeter(t *testing.T) {
- var err error
- for _, ld := range allLogicalDevices {
- // Adding flows with meter-ID which is not present should throw error stating -
- // "Meter-referred-by-flow-is-not-found-in-logicaldevice"
- err = installEapolFlows(stub, ld, 1, 100, 101)
- assert.NotNil(t, err)
- }
-}
-
-func TestMain(m *testing.M) {
- setup()
- code := m.Run()
- shutdown()
- os.Exit(code)
-}
diff --git a/tests/core/performance_metrics_test.go b/tests/core/performance_metrics_test.go
deleted file mode 100644
index 60b0bba..0000000
--- a/tests/core/performance_metrics_test.go
+++ /dev/null
@@ -1,305 +0,0 @@
-// +build integration
-
-/*
- * Copyright 2018-present Open Networking Foundation
-
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
-
- * http://www.apache.org/licenses/LICENSE-2.0
-
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package core
-
-import (
- "context"
- "fmt"
- "github.com/google/uuid"
- tu "github.com/opencord/voltha-go/tests/utils"
- "github.com/opencord/voltha-lib-go/v3/pkg/log"
- "github.com/opencord/voltha-protos/v3/go/common"
- "github.com/opencord/voltha-protos/v3/go/voltha"
- "github.com/stretchr/testify/assert"
- "google.golang.org/grpc/metadata"
- "math"
- "os"
- "testing"
- "time"
-)
-
-var stub voltha.VolthaServiceClient
-var volthaSerialNumberKey string
-
-/*
- This local "integration" test uses one RW-Core, one simulated_olt and one simulated_onu adapter to test performance
-metrics, in a development environment. It uses docker-compose to set up the local environment. However, it can
-easily be extended to run in k8s environment.
-
-The compose files used are located under %GOPATH/src/github.com/opencord/voltha-go/compose. If the GOPATH is not set
-then you can specify the location of the compose files by using COMPOSE_PATH to set the compose files location.
-
-To run this test: DOCKER_HOST_IP=<local IP> go test -v
-
-*/
-
-var allDevices map[string]*voltha.Device
-var allLogicalDevices map[string]*voltha.LogicalDevice
-
-var composePath string
-
-const (
- GRPC_PORT = 50057
- NUM_OLTS = 1
- NUM_ONUS_PER_OLT = 4 // This should coincide with the number of onus per olt in adapters-simulated.yml file
-)
-
-var parentPmNames = []string{
- "tx_64_pkts",
- "tx_65_127_pkts",
- "tx_128_255_pkts",
- "tx_256_511_pkts",
- "tx_512_1023_pkts",
- "tx_1024_1518_pkts",
- "tx_1519_9k_pkts",
- "rx_64_pkts",
- "rx_65_127_pkts",
- "rx_128_255_pkts",
- "rx_256_511_pkts",
- "rx_512_1023_pkts",
- "rx_1024_1518_pkts",
- "rx_1519_9k_pkts",
-}
-
-var childPmNames = []string{
- "tx_64_pkts",
- "tx_65_127_pkts",
- "tx_128_255_pkts",
- "tx_1024_1518_pkts",
- "tx_1519_9k_pkts",
- "rx_64_pkts",
- "rx_64_pkts",
- "rx_65_127_pkts",
- "rx_128_255_pkts",
- "rx_1024_1518_pkts",
- "rx_1519_9k_pkts",
-}
-
-func setup() {
- volthaSerialNumberKey = "voltha_serial_number"
- allDevices = make(map[string]*voltha.Device)
- allLogicalDevices = make(map[string]*voltha.LogicalDevice)
-
- grpcHostIP := os.Getenv("DOCKER_HOST_IP")
- goPath := os.Getenv("GOPATH")
- if goPath != "" {
- composePath = fmt.Sprintf("%s/src/github.com/opencord/voltha-go/compose", goPath)
- } else {
- composePath = os.Getenv("COMPOSE_PATH")
- }
-
- fmt.Println("Using compose path:", composePath)
-
- //Start the simulated environment
- if err = tu.StartSimulatedEnv(composePath); err != nil {
- fmt.Println("Failure starting simulated environment:", err)
- os.Exit(10)
- }
-
- stub, err = tu.SetupGrpcConnectionToCore(grpcHostIP, GRPC_PORT)
- if err != nil {
- fmt.Println("Failure connecting to Voltha Core:", err)
- os.Exit(11)
- }
-
- // Wait for the simulated devices to be registered in the Voltha Core
- adapters := []string{"simulated_olt", "simulated_onu"}
- if _, err = tu.WaitForAdapterRegistration(stub, adapters, 40); err != nil {
- fmt.Println("Failure retrieving adapters:", err)
- os.Exit(12)
- }
-}
-
-func shutdown() {
- err := tu.StopSimulatedEnv(composePath)
- if err != nil {
- fmt.Println("Failure stop simulated environment:", err)
- }
-}
-
-func refreshLocalDeviceCache(stub voltha.VolthaServiceClient) error {
- retrievedDevices, err := tu.ListDevices(stub)
- if err != nil {
- return err
- }
- for _, d := range retrievedDevices.Items {
- allDevices[d.Id] = d
- }
-
- retrievedLogicalDevices, err := tu.ListLogicalDevices(stub)
- if err != nil {
- return err
- }
-
- for _, ld := range retrievedLogicalDevices.Items {
- allLogicalDevices[ld.Id] = ld
- }
- return nil
-}
-
-func isPresent(pmName string, pmNames []string) bool {
- for _, name := range pmNames {
- if name == pmName {
- return true
- }
- }
- return false
-}
-
-func verifyDevicePMs(t *testing.T, stub voltha.VolthaServiceClient, device *voltha.Device, allPmNames []string, disabledPmNames []string, frequency uint32) {
- ui := uuid.New()
- ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(volthaSerialNumberKey, ui.String()))
- pmConfigs, err := stub.ListDevicePmConfigs(ctx, &common.ID{Id: device.Id})
- assert.Nil(t, err)
- assert.Equal(t, device.Id, pmConfigs.Id)
- assert.Equal(t, uint32(frequency), pmConfigs.DefaultFreq)
- assert.Equal(t, false, pmConfigs.FreqOverride)
- assert.Equal(t, false, pmConfigs.Grouped)
- assert.Nil(t, pmConfigs.Groups)
- assert.True(t, len(pmConfigs.Metrics) > 0)
- metrics := pmConfigs.Metrics
- for _, m := range metrics {
- if m.Enabled {
- assert.True(t, isPresent(m.Name, allPmNames))
- } else {
- assert.True(t, isPresent(m.Name, disabledPmNames))
- }
- assert.Equal(t, voltha.PmConfig_COUNTER, m.Type)
- }
-}
-
-func verifyInitialPmConfigs(t *testing.T, stub voltha.VolthaServiceClient) {
- fmt.Println("Verifying initial PM configs")
- err := refreshLocalDeviceCache(stub)
- assert.Nil(t, err)
- for _, d := range allDevices {
- if d.Root {
- verifyDevicePMs(t, stub, d, parentPmNames, []string{}, 150)
- } else {
- verifyDevicePMs(t, stub, d, childPmNames, []string{}, 150)
- }
- }
-}
-
-func verifyPmFrequencyUpdate(t *testing.T, stub voltha.VolthaServiceClient, device *voltha.Device) {
- ui := uuid.New()
- ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(volthaSerialNumberKey, ui.String()))
- pmConfigs, err := stub.ListDevicePmConfigs(ctx, &common.ID{Id: device.Id})
- assert.Nil(t, err)
- pmConfigs.DefaultFreq = 10
- _, err = stub.UpdateDevicePmConfigs(ctx, pmConfigs)
- assert.Nil(t, err)
- if device.Root {
- verifyDevicePMs(t, stub, device, parentPmNames, []string{}, 10)
- } else {
- verifyDevicePMs(t, stub, device, childPmNames, []string{}, 10)
- }
-}
-
-func updatePmFrequencies(t *testing.T, stub voltha.VolthaServiceClient) {
- fmt.Println("Verifying update to PMs frequencies")
- err := refreshLocalDeviceCache(stub)
- assert.Nil(t, err)
- for _, d := range allDevices {
- verifyPmFrequencyUpdate(t, stub, d)
- }
-}
-
-func verifyDisablingSomePmMetrics(t *testing.T, stub voltha.VolthaServiceClient, device *voltha.Device) {
- ui := uuid.New()
- ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(volthaSerialNumberKey, ui.String()))
- pmConfigs, err := stub.ListDevicePmConfigs(ctx, &common.ID{Id: device.Id})
- assert.Nil(t, err)
- metricsToDisable := []string{"tx_64_pkts", "rx_64_pkts", "tx_65_127_pkts", "rx_65_127_pkts"}
- for _, m := range pmConfigs.Metrics {
- if isPresent(m.Name, metricsToDisable) {
- m.Enabled = false
- }
- }
- _, err = stub.UpdateDevicePmConfigs(ctx, pmConfigs)
- assert.Nil(t, err)
- if device.Root {
- verifyDevicePMs(t, stub, device, parentPmNames, metricsToDisable, 10)
- } else {
- verifyDevicePMs(t, stub, device, childPmNames, metricsToDisable, 10)
- }
-}
-
-func disableSomePmMetrics(t *testing.T, stub voltha.VolthaServiceClient) {
- fmt.Println("Verifying disabling of some PMs")
- err := refreshLocalDeviceCache(stub)
- assert.Nil(t, err)
- for _, d := range allDevices {
- verifyDisablingSomePmMetrics(t, stub, d)
- }
-}
-
-func createAndEnableDevices(t *testing.T) {
- err := tu.SetAllLogLevel(stub, voltha.Logging{Level: common.LogLevel_WARNING})
- assert.Nil(t, err)
-
- err = tu.SetLogLevel(stub, voltha.Logging{Level: common.LogLevel_DEBUG, PackageName: "github.com/opencord/voltha-go/rw_core/core"})
- assert.Nil(t, err)
-
- startTime := time.Now()
-
- //Pre-provision the parent device
- oltDevice, err := tu.PreProvisionDevice(stub)
- assert.Nil(t, err)
-
- fmt.Println("Creation of ", NUM_OLTS, " OLT devices took:", time.Since(startTime))
-
- startTime = time.Now()
-
- //Enable all parent device - this will enable the child devices as well as validate the child devices
- err = tu.EnableDevice(stub, oltDevice, NUM_ONUS_PER_OLT)
- assert.Nil(t, err)
-
- fmt.Println("Enabling of OLT device took:", time.Since(startTime))
-
- // Wait until the core and adapters sync up after an enabled
- time.Sleep(time.Duration(math.Max(10, float64(NUM_OLTS*NUM_ONUS_PER_OLT)/2)) * time.Second)
-
- err = tu.VerifyDevices(stub, NUM_ONUS_PER_OLT)
- assert.Nil(t, err)
-
- lds, err := tu.VerifyLogicalDevices(stub, oltDevice, NUM_ONUS_PER_OLT)
- assert.Nil(t, err)
- assert.Equal(t, 1, len(lds.Items))
-}
-
-func TestPerformanceMetrics(t *testing.T) {
- //1. Test creation and activation of the devices. This will validate the devices as well as the logical device created/
- createAndEnableDevices(t)
-
- // 2. Test initial PMs on each device
- verifyInitialPmConfigs(t, stub)
-
- // 3. Test frequency update of the pmConfigs
- updatePmFrequencies(t, stub)
-
- // 4. Test disable some PM metrics
- disableSomePmMetrics(t, stub)
-}
-
-func TestMain(m *testing.M) {
- setup()
- code := m.Run()
- shutdown()
- os.Exit(code)
-}
diff --git a/tests/kafka/common.go b/tests/kafka/common.go
deleted file mode 100644
index a26ece9..0000000
--- a/tests/kafka/common.go
+++ /dev/null
@@ -1,33 +0,0 @@
-// +build integration
-
-/*
- * Copyright 2020-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package kafka
-
-import (
- "github.com/opencord/voltha-lib-go/v3/pkg/log"
-)
-
-var logger log.CLogger
-
-func init() {
- // Setup this package so that it's log level can be modified at run time
- var err error
- logger, err = log.RegisterPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "kafka"})
- if err != nil {
- panic(err)
- }
-}
diff --git a/tests/kafka/kafka_client_test.go b/tests/kafka/kafka_client_test.go
deleted file mode 100644
index cce5d7e..0000000
--- a/tests/kafka/kafka_client_test.go
+++ /dev/null
@@ -1,189 +0,0 @@
-// +build integration
-
-/*
- * Copyright 2018-present Open Networking Foundation
-
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
-
- * http://www.apache.org/licenses/LICENSE-2.0
-
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package kafka
-
-import (
- "fmt"
- "os"
- "testing"
- "time"
-
- "github.com/golang/protobuf/ptypes"
- "github.com/golang/protobuf/ptypes/any"
- "github.com/google/uuid"
- kk "github.com/opencord/voltha-lib-go/v3/pkg/kafka"
- "github.com/opencord/voltha-lib-go/v3/pkg/log"
- ic "github.com/opencord/voltha-protos/v3/go/inter_container"
- "github.com/stretchr/testify/assert"
-)
-
-/*
-Prerequite: Start the kafka/zookeeper containers.
-*/
-
-var partionClient kk.Client
-var groupClient kk.Client
-var totalTime int64
-var numMessageToSend int
-var totalMessageReceived int
-
-type sendToKafka func(interface{}, *kk.Topic, ...string) error
-
-func init() {
- hostIP := os.Getenv("DOCKER_HOST_IP")
- partionClient = kk.NewSaramaClient(
- kk.ConsumerType(kk.PartitionConsumer),
- kk.Host(hostIP),
- kk.Port(9092),
- kk.AutoCreateTopic(true),
- kk.ProducerFlushFrequency(5))
- partionClient.Start()
- groupClient = kk.NewSaramaClient(
- kk.ConsumerType(kk.GroupCustomer),
- kk.Host(hostIP),
- kk.Port(9092),
- kk.AutoCreateTopic(false),
- kk.ProducerFlushFrequency(5))
- groupClient.Start()
- numMessageToSend = 1
-}
-
-func waitForMessage(ch <-chan *ic.InterContainerMessage, doneCh chan string, maxMessages int) {
- totalTime = 0
- totalMessageReceived = 0
- mytime := time.Now()
-startloop:
- for {
- select {
- case msg := <-ch:
- if totalMessageReceived == 0 {
- mytime = time.Now()
- }
- totalTime = totalTime + (time.Now().UnixNano()-msg.Header.Timestamp)/int64(time.Millisecond)
- //logger.Debugw(ctx, "msg-received", log.Fields{"msg":msg})
- totalMessageReceived = totalMessageReceived + 1
- if totalMessageReceived == maxMessages {
- doneCh <- "All received"
- break startloop
- }
- if totalMessageReceived%10000 == 0 {
- fmt.Println("received-so-far", totalMessageReceived, totalTime, totalTime/int64(totalMessageReceived))
- }
- }
- }
- logger.Infow(ctx, "Received all messages", log.Fields{"total": time.Since(mytime)})
-}
-
-func sendMessages(topic *kk.Topic, numMessages int, fn sendToKafka) error {
- // Loop for numMessages
- for i := 0; i < numMessages; i++ {
- msg := &ic.InterContainerMessage{}
- msg.Header = &ic.Header{
- Id: uuid.New().String(),
- Type: ic.MessageType_REQUEST,
- FromTopic: topic.Name,
- ToTopic: topic.Name,
- Timestamp: time.Now().UnixNano(),
- }
- var marshalledArg *any.Any
- var err error
- body := &ic.InterContainerRequestBody{Rpc: "testRPC", Args: []*ic.Argument{}}
- if marshalledArg, err = ptypes.MarshalAny(body); err != nil {
- logger.Warnw(ctx, "cannot-marshal-request", log.Fields{"error": err})
- return err
- }
- msg.Body = marshalledArg
- msg.Header.Timestamp = time.Now().UnixNano()
- go fn(msg, topic)
- //go partionClient.Send(msg, topic)
- }
- return nil
-}
-
-func runWithPartionConsumer(topic *kk.Topic, numMessages int, doneCh chan string) error {
- var ch <-chan *ic.InterContainerMessage
- var err error
- if ch, err = partionClient.Subscribe(topic); err != nil {
- return nil
- }
- go waitForMessage(ch, doneCh, numMessages)
-
- //Now create a routine to send messages
- go sendMessages(topic, numMessages, partionClient.Send)
-
- return nil
-}
-
-func runWithGroupConsumer(topic *kk.Topic, numMessages int, doneCh chan string) error {
- var ch <-chan *ic.InterContainerMessage
- var err error
- if ch, err = groupClient.Subscribe(topic); err != nil {
- return nil
- }
- go waitForMessage(ch, doneCh, numMessages)
-
- //Now create a routine to send messages
- go sendMessages(topic, numMessages, groupClient.Send)
-
- return nil
-}
-
-func TestPartitionConsumer(t *testing.T) {
- done := make(chan string)
- topic := &kk.Topic{Name: "CoreTest1"}
- runWithPartionConsumer(topic, numMessageToSend, done)
- start := time.Now()
- // Wait for done
- val := <-done
- err := partionClient.DeleteTopic(topic)
- assert.Nil(t, err)
- partionClient.Stop()
- assert.Equal(t, numMessageToSend, totalMessageReceived)
- logger.Infow(ctx, "Partition consumer completed", log.Fields{"TotalMesages": totalMessageReceived, "TotalTime": totalTime, "val": val, "AverageTime": totalTime / int64(totalMessageReceived), "execTime": time.Since(start)})
-}
-
-func TestGroupConsumer(t *testing.T) {
- done := make(chan string)
- topic := &kk.Topic{Name: "CoreTest2"}
- runWithGroupConsumer(topic, numMessageToSend, done)
- start := time.Now()
- // Wait for done
- val := <-done
- err := groupClient.DeleteTopic(topic)
- assert.Nil(t, err)
- groupClient.Stop()
- assert.Equal(t, numMessageToSend, totalMessageReceived)
- logger.Infow(ctx, "Group consumer completed", log.Fields{"TotalMesages": totalMessageReceived, "TotalTime": totalTime, "val": val, "AverageTime": totalTime / int64(totalMessageReceived), "execTime": time.Since(start)})
-
-}
-
-func TestCreateDeleteTopic(t *testing.T) {
- hostIP := os.Getenv("DOCKER_HOST_IP")
- client := kk.NewSaramaClient(
- kk.ConsumerType(kk.PartitionConsumer),
- kk.Host(hostIP),
- kk.Port(9092),
- kk.AutoCreateTopic(true),
- kk.ProducerFlushFrequency(5))
- client.Start()
- topic := &kk.Topic{Name: "CoreTest20"}
- err := client.CreateTopic(topic, 3, 1)
- assert.Nil(t, err)
- err = client.DeleteTopic(topic)
- assert.Nil(t, err)
-}
diff --git a/tests/kafka/kafka_inter_container_messaging_test.go b/tests/kafka/kafka_inter_container_messaging_test.go
deleted file mode 100644
index d0bd26e..0000000
--- a/tests/kafka/kafka_inter_container_messaging_test.go
+++ /dev/null
@@ -1,554 +0,0 @@
-// +build integration
-
-/*
- * Copyright 2018-present Open Networking Foundation
-
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
-
- * http://www.apache.org/licenses/LICENSE-2.0
-
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package kafka
-
-import (
- "context"
- "os"
- "testing"
- "time"
-
- "github.com/golang/protobuf/ptypes"
- "github.com/google/uuid"
- "github.com/opencord/voltha-go/rw_core/core/api"
- kk "github.com/opencord/voltha-lib-go/v3/pkg/kafka"
- "github.com/opencord/voltha-lib-go/v3/pkg/log"
- ic "github.com/opencord/voltha-protos/v3/go/inter_container"
- "github.com/opencord/voltha-protos/v3/go/voltha"
- "github.com/stretchr/testify/assert"
-)
-
-/*
-Prerequite: Start the kafka/zookeeper containers.
-*/
-
-const (
- TEST_RPC_KEY = ""
-)
-
-var coreKafkaProxy *kk.InterContainerProxy
-var adapterKafkaProxy *kk.InterContainerProxy
-var kafkaPartitionClient kk.Client
-var deviceDiscoveryTopic string
-var hostIP string
-var kafkaClient kk.Client
-
-func init() {
- deviceDiscoveryTopic = "deviceDiscovery"
- hostIP = os.Getenv("DOCKER_HOST_IP")
- kafkaClient = kk.NewSaramaClient(
- kk.Host(hostIP),
- kk.Port(9092))
-
- coreKafkaProxy = kk.NewInterContainerProxy(
- kk.InterContainerHost(hostIP),
- kk.InterContainerPort(9092),
- kk.DefaultTopic(&kk.Topic{Name: "Core"}),
- kk.MsgClient(kafkaClient),
- kk.DeviceDiscoveryTopic(&kk.Topic{Name: deviceDiscoveryTopic}))
-
- adapterKafkaProxy = kk.NewInterContainerProxy(
- kk.InterContainerHost(hostIP),
- kk.InterContainerPort(9092),
- kk.DefaultTopic(&kk.Topic{Name: "Adapter"}),
- kk.MsgClient(kafkaClient))
-
- kafkaPartitionClient = kk.NewSaramaClient(
- kk.ConsumerType(kk.PartitionConsumer),
- kk.Host(hostIP),
- kk.Port(9092),
- kk.AutoCreateTopic(true),
- kk.ProducerFlushFrequency(5))
- kafkaPartitionClient.Start()
-
- coreKafkaProxy.Start()
- adapterKafkaProxy.Start()
- subscribeTarget(context.Background(), coreKafkaProxy)
-}
-
-func subscribeTarget(ctx context.Context, kmp *kk.InterContainerProxy) {
- topic := kk.Topic{Name: "Core"}
- requestProxy := &api.AdapterRequestHandlerProxy{TestMode: true}
- kmp.SubscribeWithRequestHandlerInterface(ctx, topic, requestProxy)
-}
-
-func waitForRPCMessage(ctx context.Context, topic kk.Topic, ch <-chan *ic.InterContainerMessage, doneCh chan string) {
- for msg := range ch {
- logger.Debugw(ctx, "Got-RPC-message", log.Fields{"msg": msg})
- // Unpack message
- requestBody := &ic.InterContainerRequestBody{}
- if err := ptypes.UnmarshalAny(msg.Body, requestBody); err != nil {
- doneCh <- "Error"
- } else {
- doneCh <- requestBody.Rpc
- }
- break
- }
-}
-
-//func TestSubscribeUnsubscribe(t *testing.T) {
-// // First subscribe to the specific topic
-// topic := kk.Topic{Name: "Core"}
-// ch, err := coreKafkaProxy.Subs(topic)
-// assert.NotNil(t, ch)
-// assert.Nil(t, err)
-// // Create a channel to receive a response
-// waitCh := make(chan string)
-// // Wait for a message
-// go waitForRPCMessage(topic, ch, waitCh)
-// // Send the message - don't care of the response
-// rpc := "AnyRPCRequestForTest"
-// adapterKafkaProxy.InvokeRPC(nil, rpc, &topic, true)
-// // Wait for the result on ouw own channel
-// result := <-waitCh
-// assert.Equal(t, result, rpc)
-// close(waitCh)
-// err = coreKafkaProxy.UnSubscribe(topic, ch)
-// assert.Nil(t, err)
-//}
-//
-//func TestMultipleSubscribeUnsubscribe(t *testing.T) {
-// // First subscribe to the specific topic
-// //log.SetPackageLogLevel("github.com/opencord/voltha-lib-go/v3/pkg/kafka", log.DebugLevel)
-// var err error
-// var ch1 <-chan *ic.InterContainerMessage
-// var ch2 <-chan *ic.InterContainerMessage
-// topic := kk.Topic{Name: "Core"}
-// ch1, err = coreKafkaProxy.Subscribe(topic)
-// assert.NotNil(t, ch1)
-// assert.Nil(t, err)
-// // Create a channel to receive responses
-// waitCh := make(chan string)
-// ch2, err = coreKafkaProxy.Subscribe(topic)
-// assert.NotNil(t, ch2)
-// assert.Nil(t, err)
-// // Wait for a message
-// go waitForRPCMessage(topic, ch2, waitCh)
-// go waitForRPCMessage(topic, ch1, waitCh)
-//
-// // Send the message - don't care of the response
-// rpc := "AnyRPCRequestForTest"
-// adapterKafkaProxy.InvokeRPC(nil, rpc, &topic, true)
-// // Wait for the result on ouw own channel
-//
-// responses := 0
-// for msg := range waitCh {
-// assert.Equal(t, msg, rpc)
-// responses = responses + 1
-// if responses > 1 {
-// break
-// }
-// }
-// assert.Equal(t, responses, 2)
-// close(waitCh)
-// err = coreKafkaProxy.UnSubscribe(topic, ch1)
-// assert.Nil(t, err)
-// err = coreKafkaProxy.UnSubscribe(topic, ch2)
-// assert.Nil(t, err)
-//}
-
-func TestIncorrectAPI(t *testing.T) {
- log.SetPackageLogLevel("github.com/opencord/voltha-lib-go/v3/pkg/kafka", log.ErrorLevel)
- trnsId := uuid.New().String()
- protoMsg := &voltha.Device{Id: trnsId}
- args := make([]*kk.KVArg, 1)
- args[0] = &kk.KVArg{
- Key: "device",
- Value: protoMsg,
- }
- rpc := "IncorrectAPI"
- topic := kk.Topic{Name: "Core"}
- start := time.Now()
- status, result := adapterKafkaProxy.InvokeRPC(nil, rpc, &topic, &topic, true, TEST_RPC_KEY, args...)
- elapsed := time.Since(start)
- logger.Infow(ctx, "Result", log.Fields{"status": status, "result": result, "time": elapsed})
- assert.Equal(t, status, false)
- //Unpack the result into the actual proto object
- unpackResult := &ic.Error{}
- if err := ptypes.UnmarshalAny(result, unpackResult); err != nil {
- logger.Warnw(ctx, "cannot-unmarshal-response", log.Fields{"error": err})
- }
- assert.NotNil(t, unpackResult)
-}
-
-func TestIncorrectAPIParams(t *testing.T) {
- trnsId := uuid.New().String()
- protoMsg := &voltha.Device{Id: trnsId}
- args := make([]*kk.KVArg, 1)
- args[0] = &kk.KVArg{
- Key: "device",
- Value: protoMsg,
- }
- rpc := "GetDevice"
- topic := kk.Topic{Name: "Core"}
- start := time.Now()
- status, result := adapterKafkaProxy.InvokeRPC(nil, rpc, &topic, &topic, true, TEST_RPC_KEY, args...)
- elapsed := time.Since(start)
- logger.Infow(ctx, "Result", log.Fields{"status": status, "result": result, "time": elapsed})
- assert.Equal(t, status, false)
- //Unpack the result into the actual proto object
- unpackResult := &ic.Error{}
- if err := ptypes.UnmarshalAny(result, unpackResult); err != nil {
- logger.Warnw(ctx, "cannot-unmarshal-response", log.Fields{"error": err})
- }
- assert.NotNil(t, unpackResult)
-}
-
-func TestGetDevice(t *testing.T) {
- trnsId := uuid.New().String()
- protoMsg := &voltha.ID{Id: trnsId}
- args := make([]*kk.KVArg, 1)
- args[0] = &kk.KVArg{
- Key: "deviceID",
- Value: protoMsg,
- }
- rpc := "GetDevice"
- topic := kk.Topic{Name: "Core"}
- expectedResponse := &voltha.Device{Id: trnsId}
- timeout := time.Duration(50) * time.Millisecond
- ctx, cancel := context.WithTimeout(context.Background(), timeout)
- defer cancel()
- start := time.Now()
- status, result := adapterKafkaProxy.InvokeRPC(ctx, rpc, &topic, &topic, true, TEST_RPC_KEY, args...)
- elapsed := time.Since(start)
- logger.Infow(ctx, "Result", log.Fields{"status": status, "result": result, "time": elapsed})
- assert.Equal(t, status, true)
- unpackResult := &voltha.Device{}
- if err := ptypes.UnmarshalAny(result, unpackResult); err != nil {
- logger.Warnw(ctx, "cannot-unmarshal-response", log.Fields{"error": err})
- }
- assert.Equal(t, unpackResult, expectedResponse)
-}
-
-func TestGetDeviceTimeout(t *testing.T) {
- trnsId := uuid.New().String()
- protoMsg := &voltha.ID{Id: trnsId}
- args := make([]*kk.KVArg, 1)
- args[0] = &kk.KVArg{
- Key: "deviceID",
- Value: protoMsg,
- }
- rpc := "GetDevice"
- topic := kk.Topic{Name: "Core"}
- timeout := time.Duration(2) * time.Millisecond
- ctx, cancel := context.WithTimeout(context.Background(), timeout)
- defer cancel()
- start := time.Now()
- status, result := adapterKafkaProxy.InvokeRPC(ctx, rpc, &topic, &topic, true, TEST_RPC_KEY, args...)
- elapsed := time.Since(start)
- logger.Infow(ctx, "Result", log.Fields{"status": status, "result": result, "time": elapsed})
- assert.Equal(t, status, false)
- unpackResult := &ic.Error{}
- if err := ptypes.UnmarshalAny(result, unpackResult); err != nil {
- logger.Warnw(ctx, "cannot-unmarshal-response", log.Fields{"error": err})
- }
- assert.NotNil(t, unpackResult)
-}
-
-func TestGetChildDevice(t *testing.T) {
- trnsId := uuid.New().String()
- protoMsg := &voltha.ID{Id: trnsId}
- args := make([]*kk.KVArg, 1)
- args[0] = &kk.KVArg{
- Key: "deviceID",
- Value: protoMsg,
- }
- rpc := "GetChildDevice"
- topic := kk.Topic{Name: "Core"}
- expectedResponse := &voltha.Device{Id: trnsId}
- start := time.Now()
- status, result := adapterKafkaProxy.InvokeRPC(nil, rpc, &topic, &topic, true, TEST_RPC_KEY, args...)
- elapsed := time.Since(start)
- logger.Infow(ctx, "Result", log.Fields{"status": status, "result": result, "time": elapsed})
- assert.Equal(t, status, true)
- unpackResult := &voltha.Device{}
- if err := ptypes.UnmarshalAny(result, unpackResult); err != nil {
- logger.Warnw(ctx, "cannot-unmarshal-response", log.Fields{"error": err})
- }
- assert.Equal(t, unpackResult, expectedResponse)
-}
-
-func TestGetChildDevices(t *testing.T) {
- trnsId := uuid.New().String()
- protoMsg := &voltha.ID{Id: trnsId}
- args := make([]*kk.KVArg, 1)
- args[0] = &kk.KVArg{
- Key: "deviceID",
- Value: protoMsg,
- }
- rpc := "GetChildDevices"
- topic := kk.Topic{Name: "Core"}
- expectedResponse := &voltha.Device{Id: trnsId}
- start := time.Now()
- status, result := adapterKafkaProxy.InvokeRPC(nil, rpc, &topic, &topic, true, TEST_RPC_KEY, args...)
- elapsed := time.Since(start)
- logger.Infow(ctx, "Result", log.Fields{"status": status, "result": result, "time": elapsed})
- assert.Equal(t, status, true)
- unpackResult := &voltha.Device{}
- if err := ptypes.UnmarshalAny(result, unpackResult); err != nil {
- logger.Warnw(ctx, "cannot-unmarshal-response", log.Fields{"error": err})
- }
- assert.Equal(t, unpackResult, expectedResponse)
-}
-
-func TestGetPorts(t *testing.T) {
- trnsId := uuid.New().String()
- protoArg1 := &voltha.ID{Id: trnsId}
- args := make([]*kk.KVArg, 2)
- args[0] = &kk.KVArg{
- Key: "deviceID",
- Value: protoArg1,
- }
- protoArg2 := &ic.IntType{Val: 1}
- args[1] = &kk.KVArg{
- Key: "portType",
- Value: protoArg2,
- }
- rpc := "GetPorts"
- topic := kk.Topic{Name: "Core"}
- start := time.Now()
- status, result := adapterKafkaProxy.InvokeRPC(nil, rpc, &topic, &topic, true, TEST_RPC_KEY, args...)
- elapsed := time.Since(start)
- logger.Infow(ctx, "Result", log.Fields{"status": status, "result": result, "time": elapsed})
- assert.Equal(t, status, true)
- unpackResult := &voltha.Ports{}
- if err := ptypes.UnmarshalAny(result, unpackResult); err != nil {
- logger.Warnw(ctx, "cannot-unmarshal-response", log.Fields{"error": err})
- }
- expectedLen := len(unpackResult.Items) >= 1
- assert.Equal(t, true, expectedLen)
-}
-
-func TestGetPortsMissingArgs(t *testing.T) {
- trnsId := uuid.New().String()
- protoArg1 := &voltha.ID{Id: trnsId}
- args := make([]*kk.KVArg, 1)
- args[0] = &kk.KVArg{
- Key: "deviceID",
- Value: protoArg1,
- }
- rpc := "GetPorts"
- topic := kk.Topic{Name: "Core"}
- start := time.Now()
- status, result := adapterKafkaProxy.InvokeRPC(nil, rpc, &topic, &topic, true, TEST_RPC_KEY, args...)
- elapsed := time.Since(start)
- logger.Infow(ctx, "Result", log.Fields{"status": status, "result": result, "time": elapsed})
- assert.Equal(t, status, false)
- //Unpack the result into the actual proto object
- unpackResult := &ic.Error{}
- if err := ptypes.UnmarshalAny(result, unpackResult); err != nil {
- logger.Warnw(ctx, "cannot-unmarshal-response", log.Fields{"error": err})
- }
- assert.NotNil(t, unpackResult)
-}
-
-func TestChildDeviceDetected(t *testing.T) {
- trnsId := uuid.New().String()
- protoArg1 := &ic.StrType{Val: trnsId}
- args := make([]*kk.KVArg, 5)
- args[0] = &kk.KVArg{
- Key: "deviceID",
- Value: protoArg1,
- }
- protoArg2 := &ic.IntType{Val: 1}
- args[1] = &kk.KVArg{
- Key: "parentPortNo",
- Value: protoArg2,
- }
- protoArg3 := &ic.StrType{Val: "great_onu"}
- args[2] = &kk.KVArg{
- Key: "childDeviceType",
- Value: protoArg3,
- }
- protoArg4 := &voltha.Device_ProxyAddress{DeviceId: trnsId, ChannelId: 100}
- args[3] = &kk.KVArg{
- Key: "proxyAddress",
- Value: protoArg4,
- }
- protoArg5 := &ic.IntType{Val: 1}
- args[4] = &kk.KVArg{
- Key: "portType",
- Value: protoArg5,
- }
-
- rpc := "ChildDeviceDetected"
- topic := kk.Topic{Name: "Core"}
- start := time.Now()
- status, result := adapterKafkaProxy.InvokeRPC(nil, rpc, &topic, &topic, true, TEST_RPC_KEY, args...)
- elapsed := time.Since(start)
- logger.Infow(ctx, "Result", log.Fields{"status": status, "result": result, "time": elapsed})
- assert.Equal(t, status, true)
- assert.Nil(t, result)
-}
-
-func TestChildDeviceDetectedNoWait(t *testing.T) {
- trnsId := uuid.New().String()
- protoArg1 := &ic.StrType{Val: trnsId}
- args := make([]*kk.KVArg, 5)
- args[0] = &kk.KVArg{
- Key: "deviceID",
- Value: protoArg1,
- }
- protoArg2 := &ic.IntType{Val: 1}
- args[1] = &kk.KVArg{
- Key: "parentPortNo",
- Value: protoArg2,
- }
- protoArg3 := &ic.StrType{Val: "great_onu"}
- args[2] = &kk.KVArg{
- Key: "childDeviceType",
- Value: protoArg3,
- }
- protoArg4 := &voltha.Device_ProxyAddress{DeviceId: trnsId, ChannelId: 100}
- args[3] = &kk.KVArg{
- Key: "proxyAddress",
- Value: protoArg4,
- }
- protoArg5 := &ic.IntType{Val: 1}
- args[4] = &kk.KVArg{
- Key: "portType",
- Value: protoArg5,
- }
-
- rpc := "ChildDeviceDetected"
- topic := kk.Topic{Name: "Core"}
- start := time.Now()
- status, result := adapterKafkaProxy.InvokeRPC(nil, rpc, &topic, &topic, false, TEST_RPC_KEY, args...)
- elapsed := time.Since(start)
- logger.Infow(ctx, "Result", log.Fields{"status": status, "result": result, "time": elapsed})
- assert.Equal(t, status, true)
- assert.Nil(t, result)
-}
-
-func TestChildDeviceDetectedMissingArgs(t *testing.T) {
- trnsId := uuid.New().String()
- protoArg1 := &ic.StrType{Val: trnsId}
- args := make([]*kk.KVArg, 4)
- args[0] = &kk.KVArg{
- Key: "deviceID",
- Value: protoArg1,
- }
- protoArg2 := &ic.IntType{Val: 1}
- args[1] = &kk.KVArg{
- Key: "parentPortNo",
- Value: protoArg2,
- }
- protoArg3 := &ic.StrType{Val: "great_onu"}
- args[2] = &kk.KVArg{
- Key: "childDeviceType",
- Value: protoArg3,
- }
-
- rpc := "ChildDeviceDetected"
- topic := kk.Topic{Name: "Core"}
- start := time.Now()
- status, result := adapterKafkaProxy.InvokeRPC(nil, rpc, &topic, &topic, true, TEST_RPC_KEY, args...)
- elapsed := time.Since(start)
- logger.Infow(ctx, "Result", log.Fields{"status": status, "result": result, "time": elapsed})
- assert.Equal(t, status, false)
- unpackResult := &ic.Error{}
- if err := ptypes.UnmarshalAny(result, unpackResult); err != nil {
- logger.Warnw(ctx, "cannot-unmarshal-response", log.Fields{"error": err})
- }
- assert.NotNil(t, unpackResult)
-}
-
-func TestDeviceStateChange(t *testing.T) {
- log.SetAllLogLevel(log.DebugLevel)
- trnsId := uuid.New().String()
- protoArg1 := &voltha.ID{Id: trnsId}
- args := make([]*kk.KVArg, 4)
- args[0] = &kk.KVArg{
- Key: "device_id",
- Value: protoArg1,
- }
- protoArg2 := &ic.IntType{Val: 1}
- args[1] = &kk.KVArg{
- Key: "oper_status",
- Value: protoArg2,
- }
- protoArg3 := &ic.IntType{Val: 1}
- args[2] = &kk.KVArg{
- Key: "connect_status",
- Value: protoArg3,
- }
-
- rpc := "DeviceStateUpdate"
- topic := kk.Topic{Name: "Core"}
- start := time.Now()
- status, result := adapterKafkaProxy.InvokeRPC(nil, rpc, &topic, &topic, true, TEST_RPC_KEY, args...)
- elapsed := time.Since(start)
- logger.Infow(ctx, "Result", log.Fields{"status": status, "result": result, "time": elapsed})
- assert.Equal(t, status, true)
- assert.Nil(t, result)
-}
-
-func subscribeToTopic(topic *kk.Topic, waitingChannel chan *ic.InterContainerMessage) error {
- var ch <-chan *ic.InterContainerMessage
- var err error
- if ch, err = kafkaPartitionClient.Subscribe(topic); err != nil {
- return nil
- }
- msg := <-ch
-
- logger.Debugw(ctx, "msg-received", log.Fields{"msg": msg})
- waitingChannel <- msg
- return nil
-}
-
-func TestDeviceDiscovery(t *testing.T) {
- // Create an intercontainer proxy - similar to the Core
- testProxy := kk.NewInterContainerProxy(
- kk.InterContainerHost(hostIP),
- kk.InterContainerPort(9092),
- kk.DefaultTopic(&kk.Topic{Name: "Test"}),
- kk.MsgClient(kafkaClient),
- kk.DeviceDiscoveryTopic(&kk.Topic{Name: deviceDiscoveryTopic}))
-
- // First start to wait for the message
- waitingChannel := make(chan *ic.InterContainerMessage)
- go subscribeToTopic(&kk.Topic{Name: deviceDiscoveryTopic}, waitingChannel)
-
- // Sleep to make sure the consumer is ready
- time.Sleep(time.Millisecond * 100)
-
- // Send the message
- go testProxy.DeviceDiscovered("TestDeviceId", "TestDevicetype", "TestParentId", "myPODName")
-
- msg := <-waitingChannel
- totalTime := (time.Now().UnixNano() - msg.Header.Timestamp) / int64(time.Millisecond)
- assert.Equal(t, msg.Header.Type, ic.MessageType_DEVICE_DISCOVERED)
- // Unpack message
- dd := &ic.DeviceDiscovered{}
- err := ptypes.UnmarshalAny(msg.Body, dd)
- assert.Nil(t, err)
- assert.Equal(t, dd.Id, "TestDeviceId")
- assert.Equal(t, dd.DeviceType, "TestDevicetype")
- assert.Equal(t, dd.ParentId, "TestParentId")
- assert.Equal(t, dd.Publisher, "myPODName")
- logger.Debugw(ctx, "TotalTime", log.Fields{"time": totalTime})
-}
-
-func TestStopKafkaProxy(t *testing.T) {
- adapterKafkaProxy.Stop()
- coreKafkaProxy.Stop()
-}
-
-//func TestMain(m *testing.T) {
-// logger.Info(ctx, "Main")
-//}
diff --git a/tests/utils/common.go b/tests/utils/common.go
deleted file mode 100644
index f81e3b8..0000000
--- a/tests/utils/common.go
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright 2020-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// Package utils Common Logger initialization
-package utils
-
-import (
- "github.com/opencord/voltha-lib-go/v3/pkg/log"
-)
-
-var logger log.CLogger
-
-func init() {
- // Setup this package so that it's log level can be modified at run time
- var err error
- logger, err = log.RegisterPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "utils"})
- if err != nil {
- panic(err)
- }
-}
diff --git a/tests/utils/test_utils.go b/tests/utils/test_utils.go
deleted file mode 100644
index 9f8fbc8..0000000
--- a/tests/utils/test_utils.go
+++ /dev/null
@@ -1,473 +0,0 @@
-// "build integration
-
-/*
- * Copyright 2018-present Open Networking Foundation
-
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
-
- * http://www.apache.org/licenses/LICENSE-2.0
-
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package utils
-
-import (
- "context"
- "fmt"
- "os/exec"
- "strings"
- "time"
-
- "github.com/golang/protobuf/ptypes/empty"
- "github.com/google/uuid"
- com "github.com/opencord/voltha-lib-go/v3/pkg/adapters/common"
- "github.com/opencord/voltha-lib-go/v3/pkg/log"
- "github.com/opencord/voltha-protos/v3/go/common"
- ofp "github.com/opencord/voltha-protos/v3/go/openflow_13"
- "github.com/opencord/voltha-protos/v3/go/voltha"
-
- "google.golang.org/grpc"
- "google.golang.org/grpc/codes"
- "google.golang.org/grpc/metadata"
- "google.golang.org/grpc/status"
-)
-
-// constant represents voltha serial number
-const (
- VolthaSerialNumberKey = "voltha_serial_number"
-)
-
-func startKafka(composePath string) error {
- fmt.Println("Starting Kafka and Etcd ...")
- command := "docker-compose"
- fileName := fmt.Sprintf("%s/docker-compose-zk-kafka-test.yml", composePath)
- cmd := exec.Command(command, "-f", fileName, "up", "-d")
- if err := cmd.Run(); err != nil {
- return err
- }
- return nil
-}
-
-func startEtcd(composePath string) error {
- fmt.Println("Starting Etcd ...")
- command := "docker-compose"
- fileName := fmt.Sprintf("%s/docker-compose-etcd.yml", composePath)
- cmd := exec.Command(command, "-f", fileName, "up", "-d")
- if err := cmd.Run(); err != nil {
- return err
- }
- return nil
-}
-
-func stopKafka(composePath string) error {
- fmt.Println("Stopping Kafka and Etcd ...")
- command := "docker-compose"
- fileName := fmt.Sprintf("%s/docker-compose-zk-kafka-test.yml", composePath)
- cmd := exec.Command(command, "-f", fileName, "down")
- if err := cmd.Run(); err != nil {
- return err
- }
- return nil
-}
-
-func stopEtcd(composePath string) error {
- fmt.Println("Stopping Etcd ...")
- command := "docker-compose"
- fileName := fmt.Sprintf("%s/docker-compose-etcd.yml", composePath)
- cmd := exec.Command(command, "-f", fileName, "down")
- if err := cmd.Run(); err != nil {
- return err
- }
- return nil
-}
-
-func startCore(composePath string) error {
- fmt.Println("Starting voltha core ...")
- command := "docker-compose"
- fileName := fmt.Sprintf("%s/rw_core.yml", composePath)
- cmd := exec.Command(command, "-f", fileName, "up", "-d")
- if err := cmd.Run(); err != nil {
- return err
- }
- return nil
-}
-
-func stopCore(composePath string) error {
- fmt.Println("Stopping voltha core ...")
- command := "docker-compose"
- fileName := fmt.Sprintf("%s/rw_core.yml", composePath)
- cmd := exec.Command(command, "-f", fileName, "down")
- if err := cmd.Run(); err != nil {
- return err
- }
- return nil
-}
-
-func startSimulatedOLTAndONUAdapters(composePath string) error {
- fmt.Println("Starting simulated OLT and ONU adapters ...")
- command := "docker-compose"
- fileName := fmt.Sprintf("%s/adapters-simulated.yml", composePath)
- cmd := exec.Command(command, "-f", fileName, "up", "-d")
- if err := cmd.Run(); err != nil {
- return err
- }
- return nil
-}
-
-func stopSimulatedOLTAndONUAdapters(composePath string) error {
- fmt.Println("Stopping simulated OLT and ONU adapters ...")
- command := "docker-compose"
- fileName := fmt.Sprintf("%s/adapters-simulated.yml", composePath)
- cmd := exec.Command(command, "-f", fileName, "down")
- if err := cmd.Run(); err != nil {
- return err
- }
- return nil
-}
-
-// ListLogicalDevices lists all logical devices managed by the Voltha cluster
-func ListLogicalDevices(stub voltha.VolthaServiceClient) (*voltha.LogicalDevices, error) {
- ui := uuid.New()
- ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(VolthaSerialNumberKey, ui.String()))
- return stub.ListLogicalDevices(ctx, &empty.Empty{})
-}
-
-func sendCreateDeviceRequest(ctx context.Context, stub voltha.VolthaServiceClient, device *voltha.Device, ch chan interface{}) {
- if response, err := stub.CreateDevice(ctx, device); err != nil {
- ch <- err
- } else {
- ch <- response
- }
-}
-
-func sendListAdapters(ctx context.Context, stub voltha.VolthaServiceClient, ch chan interface{}) {
- if response, err := stub.ListAdapters(ctx, &empty.Empty{}); err != nil {
- ch <- err
- } else {
- ch <- response
- }
-}
-
-func sendEnableDeviceRequest(ctx context.Context, stub voltha.VolthaServiceClient, deviceID string, ch chan interface{}) {
- if response, err := stub.EnableDevice(ctx, &common.ID{Id: deviceID}); err != nil {
- ch <- err
- } else {
- ch <- response
- }
-}
-
-func getDevices(ctx context.Context, stub voltha.VolthaServiceClient) (*voltha.Devices, error) {
- return stub.ListDevices(ctx, &empty.Empty{})
-}
-
-func getLogicalDevices(ctx context.Context, stub voltha.VolthaServiceClient) (*voltha.LogicalDevices, error) {
- return stub.ListLogicalDevices(ctx, &empty.Empty{})
-}
-
-// IsFlowPresent returns true if flow is present
-func IsFlowPresent(lookingFor *voltha.OfpFlowStats, flows []*voltha.OfpFlowStats) bool {
- for _, f := range flows {
- if f.String() == lookingFor.String() {
- return true
- }
- }
- return false
-}
-
-// ListDevices lists all physical devices controlled by the Voltha cluster
-func ListDevices(stub voltha.VolthaServiceClient) (*voltha.Devices, error) {
- ui := uuid.New()
- ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(VolthaSerialNumberKey, ui.String()))
- return getDevices(ctx, stub)
-}
-
-func sendFlow(ctx context.Context, stub voltha.VolthaServiceClient, flow *ofp.FlowTableUpdate, ch chan interface{}) {
- if response, err := stub.UpdateLogicalDeviceFlowTable(ctx, flow); err != nil {
- ch <- err
- } else {
- ch <- response
- }
-}
-
-// SetupGrpcConnectionToCore sets up client connection to an RPC server.
-func SetupGrpcConnectionToCore(grpcHostIP string, grpcPort int) (voltha.VolthaServiceClient, error) {
- grpcHost := fmt.Sprintf("%s:%d", grpcHostIP, grpcPort)
- fmt.Println("Connecting to voltha using:", grpcHost)
- conn, err := grpc.Dial(grpcHost, grpc.WithInsecure())
- if err != nil {
- return nil, err
- }
- return voltha.NewVolthaServiceClient(conn), nil
-}
-
-// VerifyLogicalDevices verifies all logical devices managed by the Voltha cluster
-func VerifyLogicalDevices(stub voltha.VolthaServiceClient, parentDevice *voltha.Device, numONUsPerOLT int) (*voltha.LogicalDevices, error) {
- ui := uuid.New()
- ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(VolthaSerialNumberKey, ui.String()))
- retrievedLogicalDevices, err := getLogicalDevices(ctx, stub)
- if err != nil {
- return nil, err
- }
- if len(retrievedLogicalDevices.Items) != 1 {
- return nil, status.Errorf(codes.Internal, "Logical device number incorrect. Expected:{%d}, Created:{%d}", 1, len(retrievedLogicalDevices.Items))
- }
-
- // Verify that each device has two ports
- for _, ld := range retrievedLogicalDevices.Items {
- if ld.Id == "" ||
- ld.DatapathId == uint64(0) ||
- ld.Desc.HwDesc != "simulated_pon" ||
- ld.Desc.SwDesc != "simulated_pon" ||
- ld.RootDeviceId == "" ||
- ld.Desc.SerialNum == "" ||
- ld.SwitchFeatures.NBuffers != uint32(256) ||
- ld.SwitchFeatures.NTables != uint32(2) ||
- ld.SwitchFeatures.Capabilities != uint32(15) ||
- len(ld.Ports) != 1+numONUsPerOLT ||
- ld.RootDeviceId != parentDevice.Id {
- return nil, status.Errorf(codes.Internal, "incorrect logical device status:{%v}", ld)
- }
- for _, p := range ld.Ports {
- if p.DevicePortNo != p.OfpPort.PortNo ||
- p.OfpPort.State != uint32(4) {
- return nil, status.Errorf(codes.Internal, "incorrect logical ports status:{%v}", p)
- }
- if strings.HasPrefix(p.Id, "nni") {
- if !p.RootPort || fmt.Sprintf("nni-%d", p.DevicePortNo) != p.Id {
- return nil, status.Errorf(codes.Internal, "incorrect nni port status:{%v}", p)
- }
- } else {
- if p.RootPort || fmt.Sprintf("uni-%d", p.DevicePortNo) != p.Id {
- return nil, status.Errorf(codes.Internal, "incorrect uni port status:{%v}", p)
- }
- }
- }
- }
- return retrievedLogicalDevices, nil
-}
-
-// VerifyDevices verifies all physical devices controlled by the Voltha cluster
-func VerifyDevices(stub voltha.VolthaServiceClient, numONUsPerOLT int) error {
- ui := uuid.New()
- ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(VolthaSerialNumberKey, ui.String()))
- retrievedDevices, err := getDevices(ctx, stub)
- if err != nil {
- return err
- }
- if len(retrievedDevices.Items) != 1+numONUsPerOLT {
- return status.Errorf(codes.Internal, "Device number incorrect. Expected:{%d}, Created:{%d}", 1, len(retrievedDevices.Items))
- }
- // Verify that each device has two ports
- for _, d := range retrievedDevices.Items {
- if d.AdminState != voltha.AdminState_ENABLED ||
- d.ConnectStatus != voltha.ConnectStatus_REACHABLE ||
- d.OperStatus != voltha.OperStatus_ACTIVE ||
- d.Type != d.Adapter ||
- d.Id == "" ||
- d.MacAddress == "" ||
- d.SerialNumber == "" {
- return status.Errorf(codes.Internal, "incorrect device state - %s", d.Id)
- }
-
- if d.Type == "simulated_olt" && (!d.Root || d.ProxyAddress != nil) {
- return status.Errorf(codes.Internal, "invalid olt status:{%v}", d)
- } else if d.Type == "simulated_onu" && (d.Root ||
- d.Vlan == uint32(0) ||
- d.ParentId == "" ||
- d.ProxyAddress.DeviceId == "" ||
- d.ProxyAddress.DeviceType != "simulated_olt") {
- return status.Errorf(codes.Internal, "invalid onu status:{%s}", d.Id)
- }
-
- if len(d.Ports) != 2 {
- return status.Errorf(codes.Internal, "invalid number of ports:{%s, %v}", d.Id, d.Ports)
- }
-
- for _, p := range d.Ports {
- if p.AdminState != voltha.AdminState_ENABLED ||
- p.OperStatus != voltha.OperStatus_ACTIVE {
- return status.Errorf(codes.Internal, "invalid port state:{%s, %v}", d.Id, p)
- }
-
- if p.Type == voltha.Port_ETHERNET_NNI || p.Type == voltha.Port_ETHERNET_UNI {
- if len(p.Peers) != 0 {
- return status.Errorf(codes.Internal, "invalid length of peers:{%s, %d}", d.Id, p.Type)
- }
- } else if p.Type == voltha.Port_PON_OLT {
- if len(p.Peers) != numONUsPerOLT ||
- p.PortNo != uint32(1) {
- return status.Errorf(codes.Internal, "invalid length of peers for PON OLT port:{%s, %v}", d.Id, p)
- }
- } else if p.Type == voltha.Port_PON_ONU {
- if len(p.Peers) != 1 ||
- p.PortNo != uint32(1) {
- return status.Errorf(codes.Internal, "invalid length of peers for PON ONU port:{%s, %v}", d.Id, p)
- }
- }
- }
- }
- return nil
-}
-
-func areAdaptersPresent(requiredAdapterNames []string, retrievedAdapters *voltha.Adapters) bool {
- if len(requiredAdapterNames) == 0 {
- return true
- }
- for _, nAName := range requiredAdapterNames {
- found := false
- for _, rA := range retrievedAdapters.Items {
- if nAName == rA.Id {
- found = true
- break
- }
- }
- if !found {
- return false
- }
- }
- return true
-}
-
-// WaitForAdapterRegistration waits on channel for response of list adapters
-func WaitForAdapterRegistration(stub voltha.VolthaServiceClient, requiredAdapterNames []string, timeout int) (*voltha.Adapters, error) {
- fmt.Println("Waiting for adapter registration ...")
- ui := uuid.New()
- ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(VolthaSerialNumberKey, ui.String()))
- ch := make(chan interface{})
- defer close(ch)
- for {
- go sendListAdapters(ctx, stub, ch)
- select {
- case res, ok := <-ch:
- if !ok {
- return nil, status.Error(codes.Aborted, "channel closed")
- } else if er, ok := res.(error); ok {
- return nil, er
- } else if a, ok := res.(*voltha.Adapters); ok {
- if areAdaptersPresent(requiredAdapterNames, a) {
- fmt.Println("All adapters registered:", a.Items)
- return a, nil
- }
- }
- case <-time.After(time.Duration(timeout) * time.Second):
- return nil, status.Error(codes.Aborted, "timeout while waiting for adapter registration")
- }
- time.Sleep(1 * time.Second)
- }
-}
-
-// PreProvisionDevice pre-provisions a new physical device
-func PreProvisionDevice(stub voltha.VolthaServiceClient) (*voltha.Device, error) {
- ui := uuid.New()
- ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(VolthaSerialNumberKey, ui.String()))
- randomMacAddress := strings.ToUpper(com.GetRandomMacAddress())
- device := &voltha.Device{Type: "simulated_olt", MacAddress: randomMacAddress}
- ch := make(chan interface{})
- defer close(ch)
- go sendCreateDeviceRequest(ctx, stub, device, ch)
- res, ok := <-ch
- if !ok {
- return nil, status.Error(codes.Aborted, "channel closed")
- } else if er, ok := res.(error); ok {
- return nil, er
- } else if d, ok := res.(*voltha.Device); ok {
- return d, nil
- }
- return nil, status.Errorf(codes.Unknown, "cannot provision device:{%v}", device)
-}
-
-// EnableDevice - if the device was in pre-provisioned state then it
-// will transition to ENABLED state. If it was is DISABLED state then it
-// will transition to ENABLED state as well.
-func EnableDevice(stub voltha.VolthaServiceClient, device *voltha.Device, numONUs int) error {
- if device.AdminState == voltha.AdminState_PREPROVISIONED {
- ui := uuid.New()
- ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(VolthaSerialNumberKey, ui.String()))
- ch := make(chan interface{})
- defer close(ch)
- go sendEnableDeviceRequest(ctx, stub, device.Id, ch)
- res, ok := <-ch
- if !ok {
- return status.Error(codes.Aborted, "channel closed")
- } else if er, ok := res.(error); ok {
- return er
- } else if _, ok := res.(*empty.Empty); ok {
- return nil
- }
- }
- return status.Errorf(codes.Unknown, "cannot enable device:{%s}", device.Id)
-}
-
-// UpdateFlow updates flow table for logical device
-func UpdateFlow(stub voltha.VolthaServiceClient, flow *ofp.FlowTableUpdate) error {
- ui := uuid.New()
- ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(VolthaSerialNumberKey, ui.String()))
- ch := make(chan interface{})
- defer close(ch)
- go sendFlow(ctx, stub, flow, ch)
- res, ok := <-ch
- if !ok {
- return status.Error(codes.Aborted, "channel closed")
- } else if er, ok := res.(error); ok {
- return er
- } else if _, ok := res.(*empty.Empty); ok {
- return nil
- }
- return status.Errorf(codes.Unknown, "cannot add flow:{%v}", flow)
-}
-
-// StartSimulatedEnv starts kafka, etcd, olt, onu adapters, core
-func StartSimulatedEnv(composePath string) error {
- fmt.Println("Starting simulated environment ...")
- // Start kafka and Etcd
- if err := startKafka(composePath); err != nil {
- return err
- }
- if err := startEtcd(composePath); err != nil {
- return err
- }
- time.Sleep(5 * time.Second)
-
- //Start the simulated adapters
- if err := startSimulatedOLTAndONUAdapters(composePath); err != nil {
- return err
- }
-
- //Start the core
- if err := startCore(composePath); err != nil {
- return err
- }
-
- time.Sleep(10 * time.Second)
-
- fmt.Println("Simulated environment started.")
- return nil
-}
-
-// StopSimulatedEnv stops kafka, etcd, olt, onu adapters, core
-func StopSimulatedEnv(ctx context.Context, composePath string) error {
- err := stopSimulatedOLTAndONUAdapters(composePath)
- if err != nil {
- logger.Errorw(ctx, "unable-to-stop-simulated-olt-onu-adapters", log.Fields{"error": err})
- }
- err = stopCore(composePath)
- if err != nil {
- logger.Errorw(ctx, "unable-to-stop-core", log.Fields{"error": err})
- }
- err = stopKafka(composePath)
- if err != nil {
- logger.Errorw(ctx, "unable-to-stop-kafka", log.Fields{"error": err})
- }
- err = stopEtcd(composePath)
- if err != nil {
- logger.Errorw(ctx, "unable-to-stop-etcd", log.Fields{"error": err})
- }
- return nil
-}
diff --git a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/adapters/adapterif/core_proxy_if.go b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/adapters/adapterif/core_proxy_if.go
index 9636a7d..a7ab6dc 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/adapters/adapterif/core_proxy_if.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/adapters/adapterif/core_proxy_if.go
@@ -18,6 +18,7 @@
import (
"context"
+
"github.com/opencord/voltha-protos/v3/go/voltha"
)
@@ -25,14 +26,13 @@
type CoreProxy interface {
UpdateCoreReference(deviceID string, coreReference string)
DeleteCoreReference(deviceID string)
- // getCoreTopic(deviceID string) kafka.Topic
- //GetAdapterTopic(args ...string) kafka.Topic
- // getAdapterTopic(args ...string) kafka.Topic
RegisterAdapter(ctx context.Context, adapter *voltha.Adapter, deviceTypes *voltha.DeviceTypes) error
DeviceUpdate(ctx context.Context, device *voltha.Device) error
PortCreated(ctx context.Context, deviceID string, port *voltha.Port) error
- PortsStateUpdate(ctx context.Context, deviceID string, operStatus voltha.OperStatus_Types) error
+ PortsStateUpdate(ctx context.Context, deviceID string, portTypeFilter uint32, operStatus voltha.OperStatus_Types) error
DeleteAllPorts(ctx context.Context, deviceID string) error
+ GetDevicePort(ctx context.Context, deviceID string, portNo uint32) (*voltha.Port, error)
+ ListDevicePorts(ctx context.Context, deviceID string) ([]*voltha.Port, error)
DeviceStateUpdate(ctx context.Context, deviceID string,
connStatus voltha.ConnectStatus_Types, operStatus voltha.OperStatus_Types) error
diff --git a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/adapters/common/core_proxy.go b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/adapters/common/core_proxy.go
index 28b532f..505dc79 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/adapters/common/core_proxy.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/adapters/common/core_proxy.go
@@ -175,24 +175,22 @@
return unPackResponse(ctx, rpc, deviceId, success, result)
}
-func (ap *CoreProxy) PortsStateUpdate(ctx context.Context, deviceId string, operStatus voltha.OperStatus_Types) error {
+func (ap *CoreProxy) PortsStateUpdate(ctx context.Context, deviceId string, portTypeFilter uint32, operStatus voltha.OperStatus_Types) error {
logger.Debugw(ctx, "PortsStateUpdate", log.Fields{"deviceId": deviceId})
rpc := "PortsStateUpdate"
// Use a device specific topic to send the request. The adapter handling the device creates a device
// specific topic
toTopic := ap.getCoreTopic(deviceId)
- args := make([]*kafka.KVArg, 2)
- id := &voltha.ID{Id: deviceId}
- oStatus := &ic.IntType{Val: int64(operStatus)}
-
- args[0] = &kafka.KVArg{
+ args := []*kafka.KVArg{{
Key: "device_id",
- Value: id,
- }
- args[1] = &kafka.KVArg{
+ Value: &voltha.ID{Id: deviceId},
+ }, {
+ Key: "port_type_filter",
+ Value: &ic.IntType{Val: int64(portTypeFilter)},
+ }, {
Key: "oper_status",
- Value: oStatus,
- }
+ Value: &ic.IntType{Val: int64(operStatus)},
+ }}
// Use a device specific topic as we are the only adaptercore handling requests for this device
replyToTopic := ap.getAdapterTopic()
@@ -222,6 +220,77 @@
return unPackResponse(ctx, rpc, deviceId, success, result)
}
+func (ap *CoreProxy) GetDevicePort(ctx context.Context, deviceID string, portNo uint32) (*voltha.Port, error) {
+ logger.Debugw(ctx, "GetDevicePort", log.Fields{"device-id": deviceID})
+ rpc := "GetDevicePort"
+
+ toTopic := ap.getCoreTopic(deviceID)
+ replyToTopic := ap.getAdapterTopic()
+
+ args := []*kafka.KVArg{{
+ Key: "device_id",
+ Value: &voltha.ID{Id: deviceID},
+ }, {
+ Key: "port_no",
+ Value: &ic.IntType{Val: int64(portNo)},
+ }}
+
+ success, result := ap.kafkaICProxy.InvokeRPC(context.Background(), rpc, &toTopic, &replyToTopic, true, deviceID, args...)
+ logger.Debugw(ctx, "GetDevicePort-response", log.Fields{"device-id": deviceID, "success": success})
+
+ if success {
+ port := &voltha.Port{}
+ if err := ptypes.UnmarshalAny(result, port); err != nil {
+ logger.Warnw(ctx, "cannot-unmarshal-response", log.Fields{"error": err})
+ return nil, status.Error(codes.InvalidArgument, err.Error())
+ }
+ return port, nil
+ } else {
+ unpackResult := &ic.Error{}
+ var err error
+ if err = ptypes.UnmarshalAny(result, unpackResult); err != nil {
+ logger.Warnw(ctx, "cannot-unmarshal-response", log.Fields{"error": err})
+ }
+ logger.Debugw(ctx, "GetDevicePort-return", log.Fields{"device-id": deviceID, "success": success, "error": err})
+ // TODO: Need to get the real error code
+ return nil, status.Error(ICProxyErrorCodeToGrpcErrorCode(ctx, unpackResult.Code), unpackResult.Reason)
+ }
+}
+
+func (ap *CoreProxy) ListDevicePorts(ctx context.Context, deviceID string) ([]*voltha.Port, error) {
+ logger.Debugw(ctx, "ListDevicePorts", log.Fields{"device-id": deviceID})
+ rpc := "ListDevicePorts"
+
+ toTopic := ap.getCoreTopic(deviceID)
+ replyToTopic := ap.getAdapterTopic()
+
+ args := []*kafka.KVArg{{
+ Key: "device_id",
+ Value: &voltha.ID{Id: deviceID},
+ }}
+
+ success, result := ap.kafkaICProxy.InvokeRPC(context.Background(), rpc, &toTopic, &replyToTopic, true, deviceID, args...)
+ logger.Debugw(ctx, "ListDevicePorts-response", log.Fields{"device-id": deviceID, "success": success})
+
+ if success {
+ ports := &voltha.Ports{}
+ if err := ptypes.UnmarshalAny(result, ports); err != nil {
+ logger.Warnw(ctx, "cannot-unmarshal-response", log.Fields{"error": err})
+ return nil, status.Error(codes.InvalidArgument, err.Error())
+ }
+ return ports.Items, nil
+ } else {
+ unpackResult := &ic.Error{}
+ var err error
+ if err = ptypes.UnmarshalAny(result, unpackResult); err != nil {
+ logger.Warnw(ctx, "cannot-unmarshal-response", log.Fields{"error": err})
+ }
+ logger.Debugw(ctx, "ListDevicePorts-return", log.Fields{"device-id": deviceID, "success": success, "error": err})
+ // TODO: Need to get the real error code
+ return nil, status.Error(ICProxyErrorCodeToGrpcErrorCode(ctx, unpackResult.Code), unpackResult.Reason)
+ }
+}
+
func (ap *CoreProxy) DeviceStateUpdate(ctx context.Context, deviceId string,
connStatus voltha.ConnectStatus_Types, operStatus voltha.OperStatus_Types) error {
logger.Debugw(ctx, "DeviceStateUpdate", log.Fields{"deviceId": deviceId})
diff --git a/vendor/github.com/opencord/voltha-protos/v3/go/voltha/adapter.pb.go b/vendor/github.com/opencord/voltha-protos/v3/go/voltha/adapter.pb.go
index 9359dc1..3d12f3f 100644
--- a/vendor/github.com/opencord/voltha-protos/v3/go/voltha/adapter.pb.go
+++ b/vendor/github.com/opencord/voltha-protos/v3/go/voltha/adapter.pb.go
@@ -238,34 +238,34 @@
func init() { proto.RegisterFile("voltha_protos/adapter.proto", fileDescriptor_7e998ce153307274) }
var fileDescriptor_7e998ce153307274 = []byte{
- // 463 bytes of a gzipped FileDescriptorProto
+ // 455 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 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0x0c, 0x7e, 0x40, 0xb8,
+ 0x60, 0xc6, 0xae, 0x38, 0x94, 0xe5, 0x46, 0x2b, 0xce, 0x5c, 0x7a, 0xcf, 0xa5, 0xcf, 0xfe, 0x4b,
+ 0x7f, 0x6c, 0x6f, 0x89, 0x5e, 0xec, 0x5c, 0x77, 0x87, 0x26, 0xfc, 0x19, 0xbd, 0xe2, 0x9b, 0xba,
+ 0x96, 0xda, 0x52, 0x59, 0x15, 0x8a, 0x33, 0xd2, 0x8f, 0xa3, 0xa4, 0x47, 0x4f, 0x50, 0xfc, 0x11,
+ 0x8d, 0x2d, 0x58, 0x56, 0x84, 0xda, 0x90, 0x81, 0x93, 0x1d, 0x83, 0x78, 0x86, 0x86, 0x52, 0x8b,
+ 0x0a, 0x94, 0xb6, 0x64, 0xb8, 0xdb, 0x35, 0xfd, 0x57, 0x63, 0x8c, 0xce, 0xec, 0xb6, 0x92, 0x64,
+ 0xe4, 0x70, 0xf7, 0x3f, 0xff, 0x8a, 0x86, 0x61, 0xc7, 0x06, 0x7f, 0x42, 0x3d, 0x65, 0x65, 0x69,
+ 0x48, 0x14, 0x77, 0x93, 0xf3, 0x9b, 0xd7, 0x27, 0x97, 0x40, 0x3d, 0xbb, 0x7c, 0x44, 0x6f, 0xa0,
+ 0xce, 0x53, 0xa8, 0xa4, 0xe6, 0x50, 0x8b, 0xa0, 0x5a, 0x8e, 0xbf, 0xbb, 0x6f, 0x10, 0xff, 0x48,
+ 0x73, 0x65, 0x9f, 0x37, 0xeb, 0x94, 0x43, 0x99, 0xb5, 0xd2, 0xcc, 0x4b, 0xaf, 0xc3, 0xc3, 0x6e,
+ 0x6e, 0xb3, 0x1c, 0x02, 0xb6, 0xee, 0x3b, 0xf0, 0xf6, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x4c,
+ 0x2f, 0x33, 0x61, 0x3d, 0x03, 0x00, 0x00,
}
diff --git a/vendor/github.com/opencord/voltha-protos/v3/go/voltha/device.pb.go b/vendor/github.com/opencord/voltha-protos/v3/go/voltha/device.pb.go
index ebbd8dc..764edcf 100644
--- a/vendor/github.com/opencord/voltha-protos/v3/go/voltha/device.pb.go
+++ b/vendor/github.com/opencord/voltha-protos/v3/go/voltha/device.pb.go
@@ -501,6 +501,7 @@
FreqOverride bool `protobuf:"varint,4,opt,name=freq_override,json=freqOverride,proto3" json:"freq_override,omitempty"`
Groups []*PmGroupConfig `protobuf:"bytes,5,rep,name=groups,proto3" json:"groups,omitempty"`
Metrics []*PmConfig `protobuf:"bytes,6,rep,name=metrics,proto3" json:"metrics,omitempty"`
+ MaxSkew uint32 `protobuf:"varint,7,opt,name=max_skew,json=maxSkew,proto3" json:"max_skew,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
@@ -573,6 +574,13 @@
return nil
}
+func (m *PmConfigs) GetMaxSkew() uint32 {
+ if m != nil {
+ return m.MaxSkew
+ }
+ return 0
+}
+
// Describes instance of software image on the device
type Image struct {
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
@@ -712,6 +720,7 @@
return nil
}
+//TODO: ImageDownload is not actively used (05/19/2020). When this is tackled, can remove extra/unnecessary fields.
type ImageDownload struct {
// Device Identifier
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
@@ -1172,10 +1181,7 @@
Reason string `protobuf:"bytes,22,opt,name=reason,proto3" json:"reason,omitempty"`
ConnectStatus common.ConnectStatus_Types `protobuf:"varint,18,opt,name=connect_status,json=connectStatus,proto3,enum=common.ConnectStatus_Types" json:"connect_status,omitempty"`
// Device type specific attributes
- Custom *any.Any `protobuf:"bytes,64,opt,name=custom,proto3" json:"custom,omitempty"`
- Ports []*Port `protobuf:"bytes,128,rep,name=ports,proto3" json:"ports,omitempty"`
- Flows *openflow_13.Flows `protobuf:"bytes,129,opt,name=flows,proto3" json:"flows,omitempty"`
- FlowGroups *openflow_13.FlowGroups `protobuf:"bytes,130,opt,name=flow_groups,json=flowGroups,proto3" json:"flow_groups,omitempty"`
+ Custom *any.Any `protobuf:"bytes,64,opt,name=custom,proto3" json:"custom,omitempty"`
// PmConfigs will eventually converted to a child node of the
// device to falicitata callbacks and to simplify manipulation.
PmConfigs *PmConfigs `protobuf:"bytes,131,opt,name=pm_configs,json=pmConfigs,proto3" json:"pm_configs,omitempty"`
@@ -1414,27 +1420,6 @@
return nil
}
-func (m *Device) GetPorts() []*Port {
- if m != nil {
- return m.Ports
- }
- return nil
-}
-
-func (m *Device) GetFlows() *openflow_13.Flows {
- if m != nil {
- return m.Flows
- }
- return nil
-}
-
-func (m *Device) GetFlowGroups() *openflow_13.FlowGroups {
- if m != nil {
- return m.FlowGroups
- }
- return nil
-}
-
func (m *Device) GetPmConfigs() *PmConfigs {
if m != nil {
return m.PmConfigs
@@ -1724,154 +1709,152 @@
func init() { proto.RegisterFile("voltha_protos/device.proto", fileDescriptor_200940f73d155856) }
var fileDescriptor_200940f73d155856 = []byte{
- // 2383 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x58, 0x4d, 0x6f, 0xdb, 0xc8,
- 0xf9, 0x8f, 0x64, 0x93, 0x12, 0x1f, 0xbd, 0x98, 0x99, 0x38, 0x1b, 0x26, 0xfe, 0x1b, 0xc9, 0x5f,
- 0xd9, 0xa2, 0xde, 0x6c, 0x63, 0xa7, 0x9b, 0x62, 0x77, 0x7b, 0x28, 0x10, 0x59, 0x62, 0x12, 0xa2,
- 0xae, 0xec, 0x8e, 0x24, 0x6f, 0xdb, 0x0b, 0x41, 0x8b, 0x23, 0x9b, 0x08, 0xc9, 0x51, 0x86, 0x94,
- 0xe3, 0xec, 0xa9, 0xed, 0xa2, 0x3d, 0xf5, 0xd6, 0x2f, 0xd1, 0x6f, 0xb0, 0xc7, 0x16, 0xe8, 0x79,
- 0xd1, 0xef, 0xd0, 0x02, 0x45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, 0x52, 0x56, 0xc3, 0x77, 0x72, 0xe9, 0x31, 0xcd, 0x54, 0xfd, 0xc6, 0xba, 0x1b,
+ 0xaf, 0x45, 0x9c, 0xce, 0x33, 0xc5, 0x5b, 0x0d, 0xeb, 0x81, 0x5c, 0x6d, 0x4a, 0xae, 0x02, 0xf2,
+ 0x3a, 0x52, 0x29, 0xba, 0x86, 0xad, 0x94, 0x5c, 0x79, 0xaf, 0xe5, 0x53, 0xfc, 0xb6, 0xe6, 0xbb,
+ 0x98, 0x67, 0xf5, 0x23, 0x65, 0x47, 0x51, 0x5e, 0xc8, 0xb1, 0x2f, 0xc1, 0x96, 0x91, 0xaa, 0x4f,
+ 0x16, 0x54, 0xdc, 0x7d, 0x64, 0x38, 0xfe, 0x2e, 0x46, 0x55, 0xc0, 0x2b, 0x6d, 0xd5, 0xd0, 0x6d,
+ 0x8c, 0xbb, 0x3f, 0x82, 0x76, 0x49, 0x86, 0x6c, 0xa8, 0xe1, 0x9e, 0x3f, 0xf6, 0xf4, 0xef, 0x26,
+ 0xfd, 0x13, 0xaf, 0x87, 0x9d, 0xca, 0xf1, 0x18, 0xee, 0x30, 0x7e, 0xa1, 0x3a, 0x90, 0x19, 0xe3,
+ 0x51, 0x3e, 0xd7, 0x71, 0xeb, 0x4c, 0xfd, 0xd7, 0x3c, 0xfd, 0xee, 0xf0, 0x82, 0x66, 0x97, 0xcb,
+ 0x73, 0x99, 0x00, 0x8e, 0x8c, 0xe6, 0x91, 0xd6, 0x7c, 0x9c, 0xff, 0x6e, 0xb7, 0x7a, 0x7a, 0x74,
+ 0xc1, 0x72, 0xec, 0xdc, 0x52, 0xe0, 0xd3, 0xff, 0x04, 0x00, 0x00, 0xff, 0xff, 0xc5, 0x1d, 0x9a,
+ 0xe9, 0x51, 0x14, 0x00, 0x00,
}
diff --git a/vendor/github.com/opencord/voltha-protos/v3/go/voltha/logical_device.pb.go b/vendor/github.com/opencord/voltha-protos/v3/go/voltha/logical_device.pb.go
index 8ebaa02..7aef243 100644
--- a/vendor/github.com/opencord/voltha-protos/v3/go/voltha/logical_device.pb.go
+++ b/vendor/github.com/opencord/voltha-protos/v3/go/voltha/logical_device.pb.go
@@ -200,18 +200,10 @@
// device features
SwitchFeatures *openflow_13.OfpSwitchFeatures `protobuf:"bytes,4,opt,name=switch_features,json=switchFeatures,proto3" json:"switch_features,omitempty"`
// name of the root device anchoring logical device
- RootDeviceId string `protobuf:"bytes,5,opt,name=root_device_id,json=rootDeviceId,proto3" json:"root_device_id,omitempty"`
- // logical device ports
- Ports []*LogicalPort `protobuf:"bytes,128,rep,name=ports,proto3" json:"ports,omitempty"`
- // flows configured on the logical device
- Flows *openflow_13.Flows `protobuf:"bytes,129,opt,name=flows,proto3" json:"flows,omitempty"`
- // flow groups configured on the logical device
- FlowGroups *openflow_13.FlowGroups `protobuf:"bytes,130,opt,name=flow_groups,json=flowGroups,proto3" json:"flow_groups,omitempty"`
- // meters configured on the logical device
- Meters *openflow_13.Meters `protobuf:"bytes,131,opt,name=meters,proto3" json:"meters,omitempty"`
- XXX_NoUnkeyedLiteral struct{} `json:"-"`
- XXX_unrecognized []byte `json:"-"`
- XXX_sizecache int32 `json:"-"`
+ RootDeviceId string `protobuf:"bytes,5,opt,name=root_device_id,json=rootDeviceId,proto3" json:"root_device_id,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
}
func (m *LogicalDevice) Reset() { *m = LogicalDevice{} }
@@ -274,34 +266,6 @@
return ""
}
-func (m *LogicalDevice) GetPorts() []*LogicalPort {
- if m != nil {
- return m.Ports
- }
- return nil
-}
-
-func (m *LogicalDevice) GetFlows() *openflow_13.Flows {
- if m != nil {
- return m.Flows
- }
- return nil
-}
-
-func (m *LogicalDevice) GetFlowGroups() *openflow_13.FlowGroups {
- if m != nil {
- return m.FlowGroups
- }
- return nil
-}
-
-func (m *LogicalDevice) GetMeters() *openflow_13.Meters {
- if m != nil {
- return m.Meters
- }
- return nil
-}
-
type LogicalDevices struct {
Items []*LogicalDevice `protobuf:"bytes,1,rep,name=items,proto3" json:"items,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
@@ -352,40 +316,34 @@
func init() { proto.RegisterFile("voltha_protos/logical_device.proto", fileDescriptor_caf139ab3abc8240) }
var fileDescriptor_caf139ab3abc8240 = []byte{
- // 550 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x93, 0xcf, 0x6a, 0xdb, 0x40,
- 0x10, 0xc6, 0xab, 0xd8, 0x72, 0xec, 0x91, 0xe3, 0xc0, 0x9a, 0x10, 0x91, 0xb4, 0xc4, 0x88, 0x1e,
- 0x1c, 0x4a, 0xa5, 0xd4, 0xa6, 0xd0, 0x1e, 0x0a, 0xad, 0x09, 0x2e, 0x86, 0xfe, 0x63, 0x0b, 0x3d,
- 0xf4, 0x22, 0x36, 0xd2, 0x5a, 0x16, 0xd8, 0x1a, 0xa1, 0x5d, 0x3b, 0xd7, 0xfe, 0x79, 0xad, 0xbe,
- 0x42, 0x5f, 0xa2, 0x8f, 0xd0, 0x43, 0xcf, 0x65, 0x77, 0xa5, 0xd4, 0x8a, 0xd3, 0xa3, 0xbe, 0xf9,
- 0x7d, 0x33, 0xb3, 0xdf, 0x20, 0xf0, 0x36, 0xb8, 0x94, 0x0b, 0x16, 0xe6, 0x05, 0x4a, 0x14, 0xc1,
- 0x12, 0x93, 0x34, 0x62, 0xcb, 0x30, 0xe6, 0x9b, 0x34, 0xe2, 0xbe, 0x56, 0x49, 0xcb, 0x30, 0x27,
- 0xf7, 0x13, 0xc4, 0x64, 0xc9, 0x03, 0x96, 0xa7, 0x01, 0xcb, 0x32, 0x94, 0x4c, 0xa6, 0x98, 0x09,
- 0x43, 0x9d, 0xb8, 0xf5, 0x4e, 0x2b, 0x2e, 0x59, 0x59, 0x39, 0xab, 0x57, 0x30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, 0x88, 0x4b, 0x76, 0x72, 0xf8, 0x7e, 0x5a, 0xc3, 0x3f, 0xfb, 0x49,
- 0x2a, 0x17, 0xeb, 0x2b, 0x3f, 0xc2, 0x55, 0x50, 0xc1, 0x81, 0x81, 0x1f, 0x97, 0x3f, 0xf1, 0x66,
- 0x1c, 0x24, 0x58, 0x6a, 0x57, 0x2d, 0x2d, 0x8e, 0xff, 0x06, 0x00, 0x00, 0xff, 0xff, 0xdd, 0xad,
- 0x36, 0xdf, 0x4d, 0x04, 0x00, 0x00,
+ // 456 bytes of a gzipped FileDescriptorProto
+ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x92, 0xc1, 0x6a, 0xdb, 0x40,
+ 0x10, 0x86, 0x91, 0x63, 0x3b, 0xce, 0xca, 0x51, 0x40, 0x21, 0x54, 0x24, 0x85, 0x08, 0xd1, 0x83,
+ 0x43, 0xa9, 0xd4, 0xda, 0x97, 0xf6, 0xd0, 0x43, 0x43, 0x08, 0x18, 0x4a, 0x5b, 0xb6, 0xd0, 0x43,
+ 0x2f, 0x62, 0xa3, 0x5d, 0xcb, 0x0b, 0xb2, 0x46, 0x68, 0x37, 0xce, 0xcb, 0xf6, 0x29, 0xfa, 0x04,
+ 0x65, 0x67, 0x57, 0x8d, 0x15, 0xfb, 0xa8, 0x7f, 0xbe, 0x99, 0xf9, 0xe7, 0x5f, 0x91, 0x64, 0x0b,
+ 0x95, 0x5e, 0xb3, 0xbc, 0x69, 0x41, 0x83, 0xca, 0x2a, 0x28, 0x65, 0xc1, 0xaa, 0x9c, 0x8b, 0xad,
+ 0x2c, 0x44, 0x8a, 0x6a, 0x38, 0xb6, 0xcc, 0xe5, 0xeb, 0x12, 0xa0, 0xac, 0x44, 0xc6, 0x1a, 0x99,
+ 0xb1, 0xba, 0x06, 0xcd, 0xb4, 0x84, 0x5a, 0x59, 0xea, 0x32, 0xea, 0x4f, 0xda, 0x08, 0xcd, 0x5c,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0x8f, 0xfa, 0x0e, 0x2d, 0xef, 0x25, 0x76, 0x4d, 0x7c, 0xce, 0x34, 0x6b, 0x98, 0x5e, 0x77,
+ 0x71, 0x0f, 0x29, 0xe9, 0xa4, 0x25, 0x0f, 0x6f, 0xc8, 0x90, 0x0b, 0x55, 0x60, 0x36, 0x87, 0xe2,
+ 0x34, 0x45, 0x8a, 0x48, 0xb8, 0x24, 0x67, 0xea, 0x49, 0xea, 0x62, 0x9d, 0xaf, 0x04, 0xd3, 0x8f,
+ 0xad, 0x50, 0x98, 0x97, 0x3f, 0x8f, 0xf7, 0xba, 0x5e, 0x70, 0x34, 0xb0, 0xc2, 0xbd, 0xfb, 0x36,
+ 0xc9, 0x63, 0xa6, 0xcf, 0x6f, 0x33, 0x42, 0xcb, 0x53, 0xa3, 0xde, 0xb9, 0xf7, 0x49, 0x3e, 0x93,
+ 0xa0, 0x77, 0x9d, 0x0a, 0xdf, 0xf6, 0xb3, 0xb9, 0x78, 0x91, 0x8d, 0xc5, 0x5c, 0x3a, 0xb7, 0xbf,
+ 0xc8, 0x39, 0xb4, 0x25, 0x7a, 0x2b, 0xa0, 0xe5, 0x8e, 0xbd, 0x3d, 0xfb, 0x7e, 0xdf, 0xc3, 0x7f,
+ 0xa7, 0xa5, 0xd4, 0xeb, 0xc7, 0x87, 0xb4, 0x80, 0x4d, 0xd6, 0xc1, 0x99, 0x85, 0xdf, 0xb9, 0x9f,
+ 0x7c, 0xbb, 0xc8, 0x4a, 0x70, 0xda, 0xc3, 0x18, 0xc5, 0xc5, 0xbf, 0x00, 0x00, 0x00, 0xff, 0xff,
+ 0x91, 0x0c, 0xf4, 0xf2, 0x6d, 0x03, 0x00, 0x00,
}
diff --git a/vendor/modules.txt b/vendor/modules.txt
index 013efb0..526fc15 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -99,7 +99,7 @@
github.com/modern-go/concurrent
# github.com/modern-go/reflect2 v1.0.1
github.com/modern-go/reflect2
-# github.com/opencord/voltha-lib-go/v3 v3.2.0
+# github.com/opencord/voltha-lib-go/v3 v3.2.1
github.com/opencord/voltha-lib-go/v3/pkg/adapters
github.com/opencord/voltha-lib-go/v3/pkg/adapters/adapterif
github.com/opencord/voltha-lib-go/v3/pkg/adapters/common
@@ -114,7 +114,7 @@
github.com/opencord/voltha-lib-go/v3/pkg/mocks/kafka
github.com/opencord/voltha-lib-go/v3/pkg/probe
github.com/opencord/voltha-lib-go/v3/pkg/version
-# github.com/opencord/voltha-protos/v3 v3.3.9
+# github.com/opencord/voltha-protos/v3 v3.4.1
github.com/opencord/voltha-protos/v3/go/common
github.com/opencord/voltha-protos/v3/go/inter_container
github.com/opencord/voltha-protos/v3/go/omci