blob: 4a71661c6d14a6c6b0d81691b88c20d54e7ce7f0 [file] [log] [blame]
kdarapub26b4502019-10-05 03:02:33 +05301/*
2 * Copyright 2018-present Open Networking Foundation
3
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7
8 * http://www.apache.org/licenses/LICENSE-2.0
9
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17//Package mocks provides the mocks for openolt-adapter.
18package mocks
19
20import (
npujarec5762e2020-01-01 14:08:48 +053021 "context"
Takahiro Suzuki2ba0e0b2020-06-05 14:23:03 -070022
Esin Karamanccb714b2019-11-29 15:02:06 +000023 "github.com/opencord/voltha-lib-go/v3/pkg/db"
Esin Karamanccb714b2019-11-29 15:02:06 +000024 tp "github.com/opencord/voltha-lib-go/v3/pkg/techprofile"
25 tp_pb "github.com/opencord/voltha-protos/v3/go/tech_profile"
kdarapub26b4502019-10-05 03:02:33 +053026)
27
28// MockTechProfile mock struct for OpenoltClient.
29type MockTechProfile struct {
30 TpID uint32
31}
32
Girish Gowdra54934262019-11-13 14:19:55 +053033// SetKVClient to mock techprofile SetKVClient method
Neha Sharma96b7bf22020-06-15 10:37:32 +000034func (m MockTechProfile) SetKVClient(ctx context.Context) *db.Backend {
sbarbaria8910ba2019-11-05 10:12:23 -050035 return &db.Backend{Client: &MockKVClient{}}
kdarapub26b4502019-10-05 03:02:33 +053036}
37
Girish Gowdra54934262019-11-13 14:19:55 +053038// GetTechProfileInstanceKVPath to mock techprofile GetTechProfileInstanceKVPath method
Neha Sharma96b7bf22020-06-15 10:37:32 +000039func (m MockTechProfile) GetTechProfileInstanceKVPath(ctx context.Context, techProfiletblID uint32, uniPortName string) string {
kdarapub26b4502019-10-05 03:02:33 +053040 return ""
41
42}
43
Girish Gowdra54934262019-11-13 14:19:55 +053044// GetTPInstanceFromKVStore to mock techprofile GetTPInstanceFromKVStore method
Takahiro Suzuki2ba0e0b2020-06-05 14:23:03 -070045func (m MockTechProfile) GetTPInstanceFromKVStore(ctx context.Context, techProfiletblID uint32, path string) (interface{}, error) {
Neha Sharma96b7bf22020-06-15 10:37:32 +000046 logger.Debug(ctx, "Warning Warning Warning: GetTPInstanceFromKVStore")
kdarapub26b4502019-10-05 03:02:33 +053047 return nil, nil
48
49}
50
Girish Gowdra54934262019-11-13 14:19:55 +053051// CreateTechProfInstance to mock techprofile CreateTechProfInstance method
Takahiro Suzuki2ba0e0b2020-06-05 14:23:03 -070052func (m MockTechProfile) CreateTechProfInstance(ctx context.Context, techProfiletblID uint32, uniPortName string, intfID uint32) (interface{}, error) {
kdarapub26b4502019-10-05 03:02:33 +053053
Takahiro Suzuki2ba0e0b2020-06-05 14:23:03 -070054 if techProfiletblID == 64 {
55 return &tp.TechProfile{
56 Name: "mock-tech-profile",
57 SubscriberIdentifier: "257",
58 ProfileType: "mock",
59 Version: 0,
60 NumGemPorts: 2,
61 UpstreamGemPortAttributeList: nil,
62 DownstreamGemPortAttributeList: nil,
63 }, nil
64 } else if techProfiletblID == 65 {
65 return &tp.EponProfile{
66 Name: "mock-epon-profile",
67 SubscriberIdentifier: "257",
68 ProfileType: "mock",
69 Version: 0,
70 NumGemPorts: 2,
71 UpstreamQueueAttributeList: nil,
72 DownstreamQueueAttributeList: nil,
73 }, nil
74 } else {
75 return nil, nil
76 }
kdarapub26b4502019-10-05 03:02:33 +053077
78}
79
Girish Gowdra54934262019-11-13 14:19:55 +053080// DeleteTechProfileInstance to mock techprofile DeleteTechProfileInstance method
npujarec5762e2020-01-01 14:08:48 +053081func (m MockTechProfile) DeleteTechProfileInstance(ctx context.Context, techProfiletblID uint32, uniPortName string) error {
kdarapub26b4502019-10-05 03:02:33 +053082 return nil
83}
84
Girish Gowdra54934262019-11-13 14:19:55 +053085// GetprotoBufParamValue to mock techprofile GetprotoBufParamValue method
Neha Sharma96b7bf22020-06-15 10:37:32 +000086func (m MockTechProfile) GetprotoBufParamValue(ctx context.Context, paramType string, paramKey string) int32 {
kdarapub26b4502019-10-05 03:02:33 +053087 return 0
88
89}
90
Girish Gowdra54934262019-11-13 14:19:55 +053091// GetUsScheduler to mock techprofile GetUsScheduler method
Neha Sharma96b7bf22020-06-15 10:37:32 +000092func (m MockTechProfile) GetUsScheduler(ctx context.Context, tpInstance *tp.TechProfile) (*tp_pb.SchedulerConfig, error) {
Girish Kumar8f73fe02019-12-09 13:19:37 +000093 return &tp_pb.SchedulerConfig{}, nil
kdarapub26b4502019-10-05 03:02:33 +053094
95}
96
Girish Gowdra54934262019-11-13 14:19:55 +053097// GetDsScheduler to mock techprofile GetDsScheduler method
Neha Sharma96b7bf22020-06-15 10:37:32 +000098func (m MockTechProfile) GetDsScheduler(ctx context.Context, tpInstance *tp.TechProfile) (*tp_pb.SchedulerConfig, error) {
Girish Kumar8f73fe02019-12-09 13:19:37 +000099 return &tp_pb.SchedulerConfig{}, nil
kdarapub26b4502019-10-05 03:02:33 +0530100}
101
Girish Gowdra54934262019-11-13 14:19:55 +0530102// GetTrafficScheduler to mock techprofile GetTrafficScheduler method
kdarapub26b4502019-10-05 03:02:33 +0530103func (m MockTechProfile) GetTrafficScheduler(tpInstance *tp.TechProfile, SchedCfg *tp_pb.SchedulerConfig,
104 ShapingCfg *tp_pb.TrafficShapingInfo) *tp_pb.TrafficScheduler {
105 return &tp_pb.TrafficScheduler{}
106
107}
108
Girish Gowdra54934262019-11-13 14:19:55 +0530109// GetTrafficQueues to mock techprofile GetTrafficQueues method
Neha Sharma96b7bf22020-06-15 10:37:32 +0000110func (m MockTechProfile) GetTrafficQueues(ctx context.Context, tp *tp.TechProfile, Dir tp_pb.Direction) ([]*tp_pb.TrafficQueue, error) {
Girish Kumar8f73fe02019-12-09 13:19:37 +0000111 return []*tp_pb.TrafficQueue{{}}, nil
kdarapub26b4502019-10-05 03:02:33 +0530112}
113
Scott Bakeree7c0a02020-01-07 11:12:26 -0800114// GetMulticastTrafficQueues to mock techprofile GetMulticastTrafficQueues method
Neha Sharma96b7bf22020-06-15 10:37:32 +0000115func (m MockTechProfile) GetMulticastTrafficQueues(ctx context.Context, tp *tp.TechProfile) []*tp_pb.TrafficQueue {
Scott Bakeree7c0a02020-01-07 11:12:26 -0800116 return []*tp_pb.TrafficQueue{{}}
117}
118
Girish Gowdra54934262019-11-13 14:19:55 +0530119// GetGemportIDForPbit to mock techprofile GetGemportIDForPbit method
Neha Sharma96b7bf22020-06-15 10:37:32 +0000120func (m MockTechProfile) GetGemportIDForPbit(ctx context.Context, tp interface{}, Dir tp_pb.Direction, pbit uint32) uint32 {
kdarapub26b4502019-10-05 03:02:33 +0530121 return 0
122}
Girish Gowdra54934262019-11-13 14:19:55 +0530123
124// FindAllTpInstances to mock techprofile FindAllTpInstances method
Takahiro Suzuki2ba0e0b2020-06-05 14:23:03 -0700125func (m MockTechProfile) FindAllTpInstances(ctx context.Context, techProfiletblID uint32, ponIntf uint32, onuID uint32) interface{} {
Girish Gowdra54934262019-11-13 14:19:55 +0530126 return []tp.TechProfile{}
127}