blob: c57dd54138db0bab1287cbd1a3bd736e293143df [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
Girish Gowdraa09aeab2020-09-14 16:30:52 -070023 "github.com/opencord/voltha-lib-go/v4/pkg/db"
24 tp "github.com/opencord/voltha-lib-go/v4/pkg/techprofile"
25 tp_pb "github.com/opencord/voltha-protos/v4/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
Matteo Scandolod9d6f512020-11-24 13:57:53 -080034func (m MockTechProfile) SetKVClient(ctx context.Context, pathPrefix string) *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) {
Girish Gowdra0aca4982021-01-04 12:44:27 -080046 logger.Debug(ctx, "GetTPInstanceFromKVStore")
47 if techProfiletblID == 64 {
48 return &tp.TechProfile{
49 Name: "mock-tech-profile",
50 SubscriberIdentifier: "257",
51 ProfileType: "mock",
52 Version: 0,
53 NumGemPorts: 1,
54 UsScheduler: tp.IScheduler{
55 AllocID: 1,
56 Direction: "upstream",
57 AdditionalBw: "None",
58 Priority: 0,
59 Weight: 0,
60 QSchedPolicy: "",
61 },
62 DsScheduler: tp.IScheduler{
63 AllocID: 1,
64 Direction: "downstream",
65 AdditionalBw: "None",
66 Priority: 0,
67 Weight: 0,
68 QSchedPolicy: "",
69 },
70 UpstreamGemPortAttributeList: []tp.IGemPortAttribute{{
71 GemportID: 1,
72 PbitMap: "0b11111111",
73 },
74 },
75 DownstreamGemPortAttributeList: []tp.IGemPortAttribute{{
76 GemportID: 1,
77 PbitMap: "0b11111111",
78 },
79 },
80 }, nil
81 } else if techProfiletblID == 65 {
82 return &tp.EponProfile{
83 Name: "mock-epon-profile",
84 SubscriberIdentifier: "257",
85 ProfileType: "mock",
86 Version: 0,
87 NumGemPorts: 2,
88 UpstreamQueueAttributeList: nil,
89 DownstreamQueueAttributeList: nil,
90 }, nil
91 } else {
92 return nil, nil
93 }
kdarapub26b4502019-10-05 03:02:33 +053094}
95
Girish Gowdra54934262019-11-13 14:19:55 +053096// CreateTechProfInstance to mock techprofile CreateTechProfInstance method
Takahiro Suzuki2ba0e0b2020-06-05 14:23:03 -070097func (m MockTechProfile) CreateTechProfInstance(ctx context.Context, techProfiletblID uint32, uniPortName string, intfID uint32) (interface{}, error) {
kdarapub26b4502019-10-05 03:02:33 +053098
Takahiro Suzuki2ba0e0b2020-06-05 14:23:03 -070099 if techProfiletblID == 64 {
100 return &tp.TechProfile{
Girish Gowdrafb3d6102020-10-16 16:32:36 -0700101 Name: "mock-tech-profile",
102 SubscriberIdentifier: "257",
103 ProfileType: "mock",
104 Version: 0,
105 NumGemPorts: 1,
106 UsScheduler: tp.IScheduler{
107 AllocID: 1,
108 Direction: "upstream",
109 AdditionalBw: "None",
110 Priority: 0,
111 Weight: 0,
112 QSchedPolicy: "",
113 },
114 DsScheduler: tp.IScheduler{
115 AllocID: 1,
116 Direction: "downstream",
117 AdditionalBw: "None",
118 Priority: 0,
119 Weight: 0,
120 QSchedPolicy: "",
121 },
122 UpstreamGemPortAttributeList: []tp.IGemPortAttribute{{
123 GemportID: 1,
124 PbitMap: "0b11111111",
125 },
126 },
127 DownstreamGemPortAttributeList: []tp.IGemPortAttribute{{
128 GemportID: 1,
129 PbitMap: "0b11111111",
130 },
131 },
Takahiro Suzuki2ba0e0b2020-06-05 14:23:03 -0700132 }, nil
133 } else if techProfiletblID == 65 {
134 return &tp.EponProfile{
135 Name: "mock-epon-profile",
136 SubscriberIdentifier: "257",
137 ProfileType: "mock",
138 Version: 0,
139 NumGemPorts: 2,
140 UpstreamQueueAttributeList: nil,
141 DownstreamQueueAttributeList: nil,
142 }, nil
143 } else {
144 return nil, nil
145 }
kdarapub26b4502019-10-05 03:02:33 +0530146
147}
148
Girish Gowdra54934262019-11-13 14:19:55 +0530149// DeleteTechProfileInstance to mock techprofile DeleteTechProfileInstance method
npujarec5762e2020-01-01 14:08:48 +0530150func (m MockTechProfile) DeleteTechProfileInstance(ctx context.Context, techProfiletblID uint32, uniPortName string) error {
kdarapub26b4502019-10-05 03:02:33 +0530151 return nil
152}
153
Girish Gowdra54934262019-11-13 14:19:55 +0530154// GetprotoBufParamValue to mock techprofile GetprotoBufParamValue method
Neha Sharma96b7bf22020-06-15 10:37:32 +0000155func (m MockTechProfile) GetprotoBufParamValue(ctx context.Context, paramType string, paramKey string) int32 {
kdarapub26b4502019-10-05 03:02:33 +0530156 return 0
157
158}
159
Girish Gowdra54934262019-11-13 14:19:55 +0530160// GetUsScheduler to mock techprofile GetUsScheduler method
Neha Sharma96b7bf22020-06-15 10:37:32 +0000161func (m MockTechProfile) GetUsScheduler(ctx context.Context, tpInstance *tp.TechProfile) (*tp_pb.SchedulerConfig, error) {
Girish Kumar8f73fe02019-12-09 13:19:37 +0000162 return &tp_pb.SchedulerConfig{}, nil
kdarapub26b4502019-10-05 03:02:33 +0530163
164}
165
Girish Gowdra54934262019-11-13 14:19:55 +0530166// GetDsScheduler to mock techprofile GetDsScheduler method
Neha Sharma96b7bf22020-06-15 10:37:32 +0000167func (m MockTechProfile) GetDsScheduler(ctx context.Context, tpInstance *tp.TechProfile) (*tp_pb.SchedulerConfig, error) {
Girish Kumar8f73fe02019-12-09 13:19:37 +0000168 return &tp_pb.SchedulerConfig{}, nil
kdarapub26b4502019-10-05 03:02:33 +0530169}
170
Girish Gowdra54934262019-11-13 14:19:55 +0530171// GetTrafficScheduler to mock techprofile GetTrafficScheduler method
kdarapub26b4502019-10-05 03:02:33 +0530172func (m MockTechProfile) GetTrafficScheduler(tpInstance *tp.TechProfile, SchedCfg *tp_pb.SchedulerConfig,
173 ShapingCfg *tp_pb.TrafficShapingInfo) *tp_pb.TrafficScheduler {
174 return &tp_pb.TrafficScheduler{}
175
176}
177
Girish Gowdra54934262019-11-13 14:19:55 +0530178// GetTrafficQueues to mock techprofile GetTrafficQueues method
Neha Sharma96b7bf22020-06-15 10:37:32 +0000179func (m MockTechProfile) GetTrafficQueues(ctx context.Context, tp *tp.TechProfile, Dir tp_pb.Direction) ([]*tp_pb.TrafficQueue, error) {
Girish Kumar8f73fe02019-12-09 13:19:37 +0000180 return []*tp_pb.TrafficQueue{{}}, nil
kdarapub26b4502019-10-05 03:02:33 +0530181}
182
Scott Bakeree7c0a02020-01-07 11:12:26 -0800183// GetMulticastTrafficQueues to mock techprofile GetMulticastTrafficQueues method
Neha Sharma96b7bf22020-06-15 10:37:32 +0000184func (m MockTechProfile) GetMulticastTrafficQueues(ctx context.Context, tp *tp.TechProfile) []*tp_pb.TrafficQueue {
Scott Bakeree7c0a02020-01-07 11:12:26 -0800185 return []*tp_pb.TrafficQueue{{}}
186}
187
Gamze Abaka7650be62021-02-26 10:50:36 +0000188// GetGemportForPbit to mock techprofile GetGemportForPbit method
189func (m MockTechProfile) GetGemportForPbit(ctx context.Context, tpInst interface{}, Dir tp_pb.Direction, pbit uint32) interface{} {
190 return tp.IGemPortAttribute{
191 GemportID: 1,
192 PbitMap: "0b11111111",
193 AesEncryption: "false",
194 }
kdarapub26b4502019-10-05 03:02:33 +0530195}
Girish Gowdra54934262019-11-13 14:19:55 +0530196
197// FindAllTpInstances to mock techprofile FindAllTpInstances method
Takahiro Suzuki2ba0e0b2020-06-05 14:23:03 -0700198func (m MockTechProfile) FindAllTpInstances(ctx context.Context, techProfiletblID uint32, ponIntf uint32, onuID uint32) interface{} {
Girish Gowdra54934262019-11-13 14:19:55 +0530199 return []tp.TechProfile{}
200}
Matteo Scandolo84585372021-03-18 14:21:22 -0700201
202// GetResourceID to mock techprofile GetResourceID method
203func (m MockTechProfile) GetResourceID(ctx context.Context, IntfID uint32, ResourceType string, NumIDs uint32) ([]uint32, error) {
204 return []uint32{}, nil
205}
206
207// FreeResourceID to mock techprofile FreeResourceID method
208func (m MockTechProfile) FreeResourceID(ctx context.Context, IntfID uint32, ResourceType string, ReleaseContent []uint32) error {
209 return nil
210}