[VOL-4292] OpenOLT Adapter changes for gRPC migration
Change-Id: I5af2125f2c2f53ffc78c474a94314bba408f8bae
diff --git a/pkg/mocks/common.go b/pkg/mocks/common.go
index ac7d68d..1de8a1f 100644
--- a/pkg/mocks/common.go
+++ b/pkg/mocks/common.go
@@ -18,7 +18,7 @@
package mocks
import (
- "github.com/opencord/voltha-lib-go/v6/pkg/log"
+ "github.com/opencord/voltha-lib-go/v7/pkg/log"
)
var logger log.CLogger
diff --git a/pkg/mocks/mockAdapterProxy.go b/pkg/mocks/mockAdapterProxy.go
deleted file mode 100644
index 20ea24d..0000000
--- a/pkg/mocks/mockAdapterProxy.go
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * 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 mocks provides the mocks for openolt-adapter.
-package mocks
-
-import (
- "context"
- "errors"
-
- "github.com/golang/protobuf/proto"
- "github.com/opencord/voltha-protos/v4/go/inter_container"
-)
-
-// MockAdapterProxy mocks the AdapterProxy interface.
-type MockAdapterProxy struct {
-}
-
-// SendInterAdapterMessage mocks SendInterAdapterMessage function.
-func (ma *MockAdapterProxy) SendInterAdapterMessage(ctx context.Context,
- msg proto.Message,
- msgType inter_container.InterAdapterMessageType_Types,
- fromAdapter string,
- toAdapter string,
- toDeviceID string,
- proxyDeviceID string,
- messageID string) error {
- if toDeviceID == "" {
- return errors.New("no deviceid")
- }
- return nil
-}
-
-// TechProfileInstanceRequest mocks TechProfileInstanceRequest function
-func (ma *MockAdapterProxy) TechProfileInstanceRequest(ctx context.Context,
- tpPath string,
- parentPonPort uint32,
- onuID uint32,
- uniID uint32,
- fromAdapter string,
- toAdapter string,
- toDeviceID string,
- proxyDeviceID string) (*inter_container.InterAdapterTechProfileDownloadMessage, error) {
- return nil, nil
-}
diff --git a/pkg/mocks/mockCoreClient.go b/pkg/mocks/mockCoreClient.go
new file mode 100644
index 0000000..bc0e0a2
--- /dev/null
+++ b/pkg/mocks/mockCoreClient.go
@@ -0,0 +1,259 @@
+/*
+ * Copyright 2021-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 provides the mocks for openolt-adapter.
+package mocks
+
+import (
+ "context"
+ "errors"
+ "fmt"
+ "strings"
+
+ "github.com/golang/protobuf/ptypes/empty"
+ vgrpc "github.com/opencord/voltha-lib-go/v7/pkg/grpc"
+ "github.com/opencord/voltha-protos/v5/go/common"
+ ic "github.com/opencord/voltha-protos/v5/go/inter_container"
+ "github.com/opencord/voltha-protos/v5/go/voltha"
+ "google.golang.org/grpc"
+)
+
+// NewMockCoreClient creates a new mock core client for a given core service
+func NewMockCoreClient(coreService *MockCoreService) *vgrpc.Client {
+ cc, _ := vgrpc.NewClient("mock-endpoint", nil)
+ cc.SetService(coreService)
+ return cc
+}
+
+// MockCoreService represents a mock core service
+type MockCoreService struct {
+ // Values to be used in test can reside inside this structure
+ // TODO store relevant info in this, use this info for negative and positive tests
+ Devices map[string]*voltha.Device
+ DevicePorts map[string][]*voltha.Port
+}
+
+// GetHealthStatus implements mock GetHealthStatus
+func (mcs MockCoreService) GetHealthStatus(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*voltha.HealthStatus, error) {
+ return &voltha.HealthStatus{State: voltha.HealthStatus_HEALTHY}, nil
+}
+
+// RegisterAdapter implements mock RegisterAdapter
+func (mcs MockCoreService) RegisterAdapter(ctx context.Context, in *ic.AdapterRegistration, opts ...grpc.CallOption) (*empty.Empty, error) {
+ if ctx == nil || in.Adapter == nil || in.DTypes == nil {
+ return nil, errors.New("registerAdapter func parameters cannot be nil")
+ }
+ return &empty.Empty{}, nil
+}
+
+// DeviceUpdate implements mock DeviceUpdate
+func (mcs MockCoreService) DeviceUpdate(ctx context.Context, in *voltha.Device, opts ...grpc.CallOption) (*empty.Empty, error) {
+ if in.Id == "" {
+ return nil, errors.New("no Device")
+ }
+ return &empty.Empty{}, nil
+}
+
+// PortCreated implements mock PortCreated
+func (mcs MockCoreService) PortCreated(ctx context.Context, in *voltha.Port, opts ...grpc.CallOption) (*empty.Empty, error) {
+ if in.DeviceId == "" {
+ return nil, errors.New("no deviceID")
+ }
+ if in.Type > 7 {
+ return nil, errors.New("invalid porttype")
+ }
+ return &empty.Empty{}, nil
+}
+
+// PortsStateUpdate implements mock PortsStateUpdate
+func (mcs MockCoreService) PortsStateUpdate(ctx context.Context, in *ic.PortStateFilter, opts ...grpc.CallOption) (*empty.Empty, error) {
+ if in.DeviceId == "" {
+ return nil, errors.New("no Device")
+ }
+ return &empty.Empty{}, nil
+}
+
+// DeleteAllPorts implements mock DeleteAllPorts
+func (mcs MockCoreService) DeleteAllPorts(ctx context.Context, in *common.ID, opts ...grpc.CallOption) (*empty.Empty, error) {
+ if in.Id == "" {
+ return nil, errors.New("no Device id")
+ }
+ return &empty.Empty{}, nil
+}
+
+// GetDevicePort implements mock GetDevicePort
+func (mcs MockCoreService) GetDevicePort(ctx context.Context, in *ic.PortFilter, opts ...grpc.CallOption) (*voltha.Port, error) {
+ for _, port := range mcs.DevicePorts[in.DeviceId] {
+ if port.PortNo == in.Port {
+ return port, nil
+ }
+ }
+ return nil, errors.New("device/port not found")
+}
+
+// ListDevicePorts implements mock ListDevicePorts
+func (mcs MockCoreService) ListDevicePorts(ctx context.Context, in *common.ID, opts ...grpc.CallOption) (*voltha.Ports, error) {
+ ports, have := mcs.DevicePorts[in.Id]
+ if !have {
+ return nil, errors.New("device id not found")
+ }
+ return &voltha.Ports{Items: ports}, nil
+}
+
+// DeviceStateUpdate implements mock DeviceStateUpdate
+func (mcs MockCoreService) DeviceStateUpdate(ctx context.Context, in *ic.DeviceStateFilter, opts ...grpc.CallOption) (*empty.Empty, error) {
+ if in.DeviceId == "" {
+ return nil, errors.New("no Device id")
+ }
+ return &empty.Empty{}, nil
+}
+
+// DevicePMConfigUpdate implements mock DevicePMConfigUpdate
+func (mcs MockCoreService) DevicePMConfigUpdate(ctx context.Context, in *voltha.PmConfigs, opts ...grpc.CallOption) (*empty.Empty, error) {
+ return &empty.Empty{}, nil
+}
+
+// ChildDeviceDetected implements mock ChildDeviceDetected
+func (mcs MockCoreService) ChildDeviceDetected(ctx context.Context, in *ic.DeviceDiscovery, opts ...grpc.CallOption) (*voltha.Device, error) {
+ if in.ParentId == "" {
+ return nil, errors.New("no deviceID")
+ }
+ for k, v := range mcs.Devices {
+ if strings.Contains(k, "onu") {
+ return v, nil
+ }
+ }
+ return nil, errors.New("no deviceID")
+}
+
+// ChildDevicesLost implements mock ChildDevicesLost
+func (mcs MockCoreService) ChildDevicesLost(ctx context.Context, in *common.ID, opts ...grpc.CallOption) (*empty.Empty, error) {
+ if in.Id == "" {
+ return nil, errors.New("no device id")
+ }
+ return &empty.Empty{}, nil
+}
+
+// ChildDevicesDetected implements mock ChildDevicesDetected
+func (mcs MockCoreService) ChildDevicesDetected(ctx context.Context, in *common.ID, opts ...grpc.CallOption) (*empty.Empty, error) {
+ if in.Id == "" {
+ return nil, errors.New("no device id")
+ }
+ return &empty.Empty{}, nil
+}
+
+// GetDevice implements mock GetDevice
+func (mcs MockCoreService) GetDevice(ctx context.Context, in *common.ID, opts ...grpc.CallOption) (*voltha.Device, error) {
+ if in.Id == "" {
+ return &voltha.Device{}, errors.New("no deviceID")
+ }
+ for k, v := range mcs.Devices {
+ if k == "olt" {
+ return v, nil
+ }
+ }
+ return nil, errors.New("device detection failed")
+}
+
+// GetChildDevice implements mock GetChildDevice
+func (mcs MockCoreService) GetChildDevice(ctx context.Context, in *ic.ChildDeviceFilter, opts ...grpc.CallOption) (*voltha.Device, error) {
+ if in.ParentId == "" {
+ return nil, errors.New("device detection failed")
+ }
+ var onuDevice *voltha.Device
+ for _, val := range mcs.Devices {
+ if val.GetId() == fmt.Sprintf("%d", in.OnuId) {
+ onuDevice = val
+ break
+ }
+ }
+ if onuDevice != nil {
+ return onuDevice, nil
+ }
+ //return &voltha.Device{}, nil
+ return nil, errors.New("device detection failed")
+}
+
+// GetChildDevices implements mock GetChildDevices
+func (mcs MockCoreService) GetChildDevices(ctx context.Context, in *common.ID, opts ...grpc.CallOption) (*voltha.Devices, error) {
+ if in.Id == "" {
+ return nil, errors.New("no deviceID")
+ }
+ onuDevices := make([]*voltha.Device, 0)
+
+ for _, val := range mcs.Devices {
+ if val != nil && val.ParentId == in.Id {
+ onuDevices = append(onuDevices, val)
+ }
+ }
+
+ deviceList := &voltha.Devices{Items: onuDevices}
+ if len(deviceList.Items) > 0 {
+ return deviceList, nil
+ }
+ return nil, errors.New("device detection failed")
+}
+
+// SendPacketIn implements mock SendPacketIn
+func (mcs MockCoreService) SendPacketIn(ctx context.Context, in *ic.PacketIn, opts ...grpc.CallOption) (*empty.Empty, error) {
+ if in.DeviceId == "" {
+ return nil, errors.New("no Device ID")
+ }
+ return &empty.Empty{}, nil
+}
+
+// DeviceReasonUpdate implements mock DeviceReasonUpdate
+func (mcs MockCoreService) DeviceReasonUpdate(ctx context.Context, in *ic.DeviceReason, opts ...grpc.CallOption) (*empty.Empty, error) {
+ if in.DeviceId == "" {
+ return nil, errors.New("no Device ID")
+ }
+ return &empty.Empty{}, nil
+}
+
+// PortStateUpdate implements mock PortStateUpdate
+func (mcs MockCoreService) PortStateUpdate(ctx context.Context, in *ic.PortState, opts ...grpc.CallOption) (*empty.Empty, error) {
+ if in.DeviceId == "" {
+ return nil, errors.New("no Device")
+ }
+ return &empty.Empty{}, nil
+}
+
+// Additional API found in the Core - unused?
+
+// ReconcileChildDevices implements mock ReconcileChildDevices
+func (mcs MockCoreService) ReconcileChildDevices(ctx context.Context, in *common.ID, opts ...grpc.CallOption) (*empty.Empty, error) {
+ return &empty.Empty{}, nil
+}
+
+// GetChildDeviceWithProxyAddress implements mock GetChildDeviceWithProxyAddress
+func (mcs MockCoreService) GetChildDeviceWithProxyAddress(ctx context.Context, in *voltha.Device_ProxyAddress, opts ...grpc.CallOption) (*voltha.Device, error) {
+ return nil, nil
+}
+
+// GetPorts implements mock GetPorts
+func (mcs MockCoreService) GetPorts(ctx context.Context, in *ic.PortFilter, opts ...grpc.CallOption) (*voltha.Ports, error) {
+ return nil, nil
+}
+
+// ChildrenStateUpdate implements mock ChildrenStateUpdate
+func (mcs MockCoreService) ChildrenStateUpdate(ctx context.Context, in *ic.DeviceStateFilter, opts ...grpc.CallOption) (*empty.Empty, error) {
+ return &empty.Empty{}, nil
+}
+
+// UpdateImageDownload implements mock UpdateImageDownload
+func (mcs MockCoreService) UpdateImageDownload(ctx context.Context, in *voltha.ImageDownload, opts ...grpc.CallOption) (*empty.Empty, error) {
+ return &empty.Empty{}, nil
+}
diff --git a/pkg/mocks/mockCoreProxy.go b/pkg/mocks/mockCoreProxy.go
deleted file mode 100644
index afcfc59..0000000
--- a/pkg/mocks/mockCoreProxy.go
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- * 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 mocks provides the mocks for openolt-adapter.
-package mocks
-
-import (
- "context"
- "errors"
- "fmt"
-
- "github.com/opencord/voltha-lib-go/v6/pkg/kafka"
- "github.com/opencord/voltha-protos/v4/go/voltha"
-)
-
-// MockCoreProxy mocks the CoreProxy interface
-type MockCoreProxy struct {
- // Values to be used in test can reside inside this structure
- // TODO store relevant info in this, use this info for negative and positive tests
- Devices map[string]*voltha.Device
- DevicePorts map[string][]*voltha.Port
-}
-
-// UpdateCoreReference mock updatesCoreReference
-func (mcp *MockCoreProxy) UpdateCoreReference(deviceID string, coreReference string) {
- panic("implement me")
-}
-
-// DeleteCoreReference mock DeleteCoreReference function
-func (mcp *MockCoreProxy) DeleteCoreReference(deviceID string) {
- panic("implement me")
-}
-
-// GetCoreTopic implements mock GetCoreTopic
-func (mcp *MockCoreProxy) GetCoreTopic(deviceID string) kafka.Topic {
- panic("implement me")
-}
-
-// GetAdapterTopic implements mock GetAdapterTopic
-func (mcp *MockCoreProxy) GetAdapterTopic(args ...string) kafka.Topic {
- panic("implement me")
-}
-
-// RegisterAdapter implements mock RegisterAdapter
-func (mcp *MockCoreProxy) RegisterAdapter(ctx context.Context, adapter *voltha.Adapter,
- deviceTypes *voltha.DeviceTypes) error {
- if ctx == nil || adapter == nil || deviceTypes == nil {
- return errors.New("registerAdapter func parameters cannot be nil")
- }
- return nil
-}
-
-// DeviceUpdate implements mock DeviceUpdate
-func (mcp *MockCoreProxy) DeviceUpdate(ctx context.Context, device *voltha.Device) error {
- if device.Id == "" {
- return errors.New("no Device")
- }
- return nil
-}
-
-// PortCreated implements mock PortCreated
-func (mcp *MockCoreProxy) PortCreated(ctx context.Context, deviceID string, port *voltha.Port) error {
- if deviceID == "" {
- return errors.New("no deviceID")
- }
- if port.Type > 7 {
- return errors.New("invalid porttype")
- }
- return nil
-}
-
-// PortsStateUpdate implements mock PortsStateUpdate
-func (mcp *MockCoreProxy) PortsStateUpdate(ctx context.Context, deviceID string, portTypeFilter uint32, operStatus voltha.OperStatus_Types) error {
- if deviceID == "" {
- return errors.New("no Device")
- }
- return nil
-}
-
-// DeleteAllPorts implements mock DeleteAllPorts
-func (mcp *MockCoreProxy) DeleteAllPorts(ctx context.Context, deviceID string) error {
- if deviceID == "" {
- return errors.New("no Device id")
- }
- return nil
-}
-
-// GetDevicePort implements mock GetDevicePort
-func (mcp *MockCoreProxy) GetDevicePort(ctx context.Context, deviceID string, portID uint32) (*voltha.Port, error) {
- for _, port := range mcp.DevicePorts[deviceID] {
- if port.PortNo == portID {
- return port, nil
- }
- }
- return nil, errors.New("device/port not found")
-}
-
-// ListDevicePorts implements mock ListDevicePorts
-func (mcp *MockCoreProxy) ListDevicePorts(ctx context.Context, deviceID string) ([]*voltha.Port, error) {
- ports, have := mcp.DevicePorts[deviceID]
- if !have {
- return nil, errors.New("device id not found")
- }
- return ports, nil
-}
-
-// DeviceStateUpdate implements mock DeviceStateUpdate
-func (mcp *MockCoreProxy) DeviceStateUpdate(ctx context.Context, deviceID string,
- connStatus voltha.ConnectStatus_Types, operStatus voltha.OperStatus_Types) error {
- if deviceID == "" {
- return errors.New("no Device id")
- }
- return nil
-}
-
-// ChildDeviceDetected implements mock ChildDeviceDetected
-func (mcp *MockCoreProxy) ChildDeviceDetected(ctx context.Context, parentdeviceID string, parentPortNo int,
- childDeviceType string, channelID int, vendorID string, serialNumber string, onuID int64) (*voltha.Device, error) {
- if parentdeviceID == "" {
- return nil, errors.New("no deviceID")
- }
- for k, v := range mcp.Devices {
- if k == "olt" {
- return v, nil
- }
- }
- return nil, nil
-}
-
-// ChildDevicesLost implements mock ChildDevicesLost.
-func (mcp *MockCoreProxy) ChildDevicesLost(ctx context.Context, parentdeviceID string) error {
- //panic("implement me")
- if parentdeviceID == "" {
- return errors.New("no device id")
- }
- return nil
-}
-
-// ChildDevicesDetected implements mock ChildDevicesDetecte
-func (mcp *MockCoreProxy) ChildDevicesDetected(ctx context.Context, parentdeviceID string) error {
- if parentdeviceID == "" {
- return errors.New("no device id")
- }
- return nil
-}
-
-// GetDevice implements mock GetDevice
-func (mcp *MockCoreProxy) GetDevice(ctx context.Context, parentdeviceID string, deviceID string) (*voltha.Device, error) {
- if parentdeviceID == "" || deviceID == "" {
- return &voltha.Device{}, errors.New("no deviceID")
- }
- for k, v := range mcp.Devices {
- if k == "olt" {
- return v, nil
- }
- }
- return nil, errors.New("device detection failed")
-}
-
-// GetChildDevice implements mock GetChildDevice
-func (mcp *MockCoreProxy) GetChildDevice(ctx context.Context, parentdeviceID string, kwargs map[string]interface{}) (*voltha.Device, error) {
-
- if parentdeviceID == "" {
- return nil, errors.New("device detection failed")
- }
- onuID := kwargs["onu_id"]
- var onuDevice *voltha.Device
- for _, val := range mcp.Devices {
- if val.GetId() == fmt.Sprintf("%v", onuID) {
- onuDevice = val
- break
- }
- }
- if onuDevice != nil {
- return onuDevice, nil
- }
- //return &voltha.Device{}, nil
- return nil, errors.New("device detection failed")
-}
-
-// GetChildDevices implements mock GetChildDevices
-func (mcp *MockCoreProxy) GetChildDevices(ctx context.Context, parentdeviceID string) (*voltha.Devices, error) {
- if parentdeviceID == "" {
- return nil, errors.New("no deviceID")
- }
- onuDevices := make([]*voltha.Device, 0)
-
- for _, val := range mcp.Devices {
- if val != nil {
- onuDevices = append(onuDevices, val)
- }
- }
-
- deviceList := &voltha.Devices{Items: onuDevices}
- if len(deviceList.Items) > 0 {
- return deviceList, nil
- }
- return nil, errors.New("device detection failed")
-}
-
-// SendPacketIn implements mock SendPacketIn
-func (mcp *MockCoreProxy) SendPacketIn(ctx context.Context, deviceID string, port uint32, pktPayload []byte) error {
- if deviceID == "" {
- return errors.New("no Device ID")
- }
- return nil
-}
-
-// DeviceReasonUpdate implements mock SendPacketIn
-func (mcp *MockCoreProxy) DeviceReasonUpdate(ctx context.Context, deviceID string, reason string) error {
- if deviceID == "" {
- return errors.New("no Device ID")
- }
- return nil
-}
-
-// DevicePMConfigUpdate implements mock DevicePMConfigUpdate
-func (mcp *MockCoreProxy) DevicePMConfigUpdate(ctx context.Context, pmConfigs *voltha.PmConfigs) error {
- return nil
-}
-
-// PortStateUpdate implements mock PortStateUpdate
-func (mcp *MockCoreProxy) PortStateUpdate(ctx context.Context, deviceID string, pType voltha.Port_PortType, portNo uint32,
- operStatus voltha.OperStatus_Types) error {
- if deviceID == "" {
- return errors.New("no Device")
- }
- return nil
-}
diff --git a/pkg/mocks/mockEventproxy.go b/pkg/mocks/mockEventproxy.go
index 50ffbd9..892e159 100644
--- a/pkg/mocks/mockEventproxy.go
+++ b/pkg/mocks/mockEventproxy.go
@@ -20,7 +20,8 @@
import (
"context"
"errors"
- "github.com/opencord/voltha-protos/v4/go/voltha"
+
+ "github.com/opencord/voltha-protos/v5/go/voltha"
)
// MockEventProxy for mocking EventProxyIntf
@@ -63,3 +64,12 @@
func (me *MockEventProxy) SendLiveness(ctx context.Context) error {
return nil
}
+
+// Start starts the proxy
+func (me *MockEventProxy) Start() error {
+ return nil
+}
+
+// Stop stops the proxy
+func (me *MockEventProxy) Stop() {
+}
diff --git a/pkg/mocks/mockKVClient.go b/pkg/mocks/mockKVClient.go
index bad9030..796c698 100644
--- a/pkg/mocks/mockKVClient.go
+++ b/pkg/mocks/mockKVClient.go
@@ -25,9 +25,9 @@
"strings"
"time"
- "github.com/opencord/voltha-lib-go/v6/pkg/db/kvstore"
- "github.com/opencord/voltha-lib-go/v6/pkg/log"
- ofp "github.com/opencord/voltha-protos/v4/go/openflow_13"
+ "github.com/opencord/voltha-lib-go/v7/pkg/db/kvstore"
+ "github.com/opencord/voltha-lib-go/v7/pkg/log"
+ ofp "github.com/opencord/voltha-protos/v5/go/openflow_13"
)
const (
diff --git a/pkg/mocks/mockOnuInterAdapterClient.go b/pkg/mocks/mockOnuInterAdapterClient.go
new file mode 100644
index 0000000..522fb4f
--- /dev/null
+++ b/pkg/mocks/mockOnuInterAdapterClient.go
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2021-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 provides the mocks for openolt-adapter.
+package mocks
+
+import (
+ "context"
+
+ "github.com/golang/protobuf/ptypes/empty"
+ vgrpc "github.com/opencord/voltha-lib-go/v7/pkg/grpc"
+ ic "github.com/opencord/voltha-protos/v5/go/inter_container"
+ "github.com/opencord/voltha-protos/v5/go/voltha"
+ "google.golang.org/grpc"
+)
+
+// NewMockChildAdapterClient create a mock child adapter client
+func NewMockChildAdapterClient(srv *MockOnuInterAdapterService) *vgrpc.Client {
+ cc, _ := vgrpc.NewClient("mock-endpoint", nil)
+ cc.SetService(srv)
+ return cc
+}
+
+// MockOnuInterAdapterService represents a child adapter mock service
+type MockOnuInterAdapterService struct {
+}
+
+// GetHealthStatus implements mock GetHealthStatus
+func (mos MockOnuInterAdapterService) GetHealthStatus(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*voltha.HealthStatus, error) {
+ return &voltha.HealthStatus{State: voltha.HealthStatus_HEALTHY}, nil
+}
+
+// OnuIndication implements mock OnuIndication
+func (mos *MockOnuInterAdapterService) OnuIndication(ctx context.Context, in *ic.OnuIndicationMessage, opts ...grpc.CallOption) (*empty.Empty, error) {
+ return &empty.Empty{}, nil
+}
+
+// OmciResponse implements mock OmciResponse
+func (mos *MockOnuInterAdapterService) OmciResponse(ctx context.Context, in *ic.OmciMessage, opts ...grpc.CallOption) (*empty.Empty, error) {
+ return &empty.Empty{}, nil
+}
+
+// DownloadTechProfile implements mock DownloadTechProfile
+func (mos *MockOnuInterAdapterService) DownloadTechProfile(ctx context.Context, in *ic.TechProfileDownloadMessage, opts ...grpc.CallOption) (*empty.Empty, error) {
+ return &empty.Empty{}, nil
+}
+
+// DeleteGemPort implements mock DeleteGemPort
+func (mos *MockOnuInterAdapterService) DeleteGemPort(ctx context.Context, in *ic.DeleteGemPortMessage, opts ...grpc.CallOption) (*empty.Empty, error) {
+ return &empty.Empty{}, nil
+}
+
+// DeleteTCont implements mock DeleteTCont
+func (mos *MockOnuInterAdapterService) DeleteTCont(ctx context.Context, in *ic.DeleteTcontMessage, opts ...grpc.CallOption) (*empty.Empty, error) {
+ return &empty.Empty{}, nil
+}
diff --git a/pkg/mocks/mockOpenOltClient.go b/pkg/mocks/mockOpenOltClient.go
index 89babc5..a795ecb 100644
--- a/pkg/mocks/mockOpenOltClient.go
+++ b/pkg/mocks/mockOpenOltClient.go
@@ -22,9 +22,9 @@
"errors"
"io"
- config "github.com/opencord/voltha-protos/v4/go/ext/config"
- openolt "github.com/opencord/voltha-protos/v4/go/openolt"
- tech_profile "github.com/opencord/voltha-protos/v4/go/tech_profile"
+ config "github.com/opencord/voltha-protos/v5/go/ext/config"
+ openolt "github.com/opencord/voltha-protos/v5/go/openolt"
+ tech_profile "github.com/opencord/voltha-protos/v5/go/tech_profile"
"google.golang.org/grpc"
"google.golang.org/grpc/metadata"
)
diff --git a/pkg/mocks/mockTechprofile.go b/pkg/mocks/mockTechprofile.go
index 628ec4e..9469711 100644
--- a/pkg/mocks/mockTechprofile.go
+++ b/pkg/mocks/mockTechprofile.go
@@ -20,8 +20,8 @@
import (
"context"
- "github.com/opencord/voltha-lib-go/v6/pkg/db"
- tp_pb "github.com/opencord/voltha-protos/v4/go/tech_profile"
+ "github.com/opencord/voltha-lib-go/v7/pkg/db"
+ tp_pb "github.com/opencord/voltha-protos/v5/go/tech_profile"
)
// MockTechProfile mock struct for OpenoltClient.