| kdarapu | b26b450 | 2019-10-05 03:02:33 +0530 | [diff] [blame] | 1 | /* |
| Joey Armstrong | 11f5a57 | 2024-01-12 19:11:32 -0500 | [diff] [blame] | 2 | * Copyright 2018-2024 Open Networking Foundation (ONF) and the ONF Contributors |
| kdarapu | b26b450 | 2019-10-05 03:02:33 +0530 | [diff] [blame] | 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 | |
| Joey Armstrong | 3f0e242 | 2023-07-05 18:25:41 -0400 | [diff] [blame] | 17 | // Package mocks provides the mocks for openolt-adapter. |
| kdarapu | b26b450 | 2019-10-05 03:02:33 +0530 | [diff] [blame] | 18 | package mocks |
| 19 | |
| 20 | import ( |
| npujar | ec5762e | 2020-01-01 14:08:48 +0530 | [diff] [blame] | 21 | "context" |
| Takahiro Suzuki | 2ba0e0b | 2020-06-05 14:23:03 -0700 | [diff] [blame] | 22 | |
| khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 23 | "github.com/opencord/voltha-lib-go/v7/pkg/db" |
| 24 | tp_pb "github.com/opencord/voltha-protos/v5/go/tech_profile" |
| kdarapu | b26b450 | 2019-10-05 03:02:33 +0530 | [diff] [blame] | 25 | ) |
| 26 | |
| 27 | // MockTechProfile mock struct for OpenoltClient. |
| 28 | type MockTechProfile struct { |
| 29 | TpID uint32 |
| 30 | } |
| 31 | |
| Girish Gowdra | 5493426 | 2019-11-13 14:19:55 +0530 | [diff] [blame] | 32 | // SetKVClient to mock techprofile SetKVClient method |
| Matteo Scandolo | d9d6f51 | 2020-11-24 13:57:53 -0800 | [diff] [blame] | 33 | func (m MockTechProfile) SetKVClient(ctx context.Context, pathPrefix string) *db.Backend { |
| sbarbari | a8910ba | 2019-11-05 10:12:23 -0500 | [diff] [blame] | 34 | return &db.Backend{Client: &MockKVClient{}} |
| kdarapu | b26b450 | 2019-10-05 03:02:33 +0530 | [diff] [blame] | 35 | } |
| 36 | |
| Holger Hildebrandt | 143b5be | 2023-02-10 08:28:15 +0000 | [diff] [blame] | 37 | // CloseKVClient to mock techprofile CloseKVClient method |
| 38 | func (m MockTechProfile) CloseKVClient(ctx context.Context) { |
| 39 | } |
| 40 | |
| Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 41 | // GetTPInstance to mock techprofile GetTPInstance method |
| 42 | func (m MockTechProfile) GetTPInstance(ctx context.Context, path string) (interface{}, error) { |
| Girish Gowdra | 0aca498 | 2021-01-04 12:44:27 -0800 | [diff] [blame] | 43 | logger.Debug(ctx, "GetTPInstanceFromKVStore") |
| Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 44 | var usGemPortAttributeList []*tp_pb.GemPortAttributes |
| 45 | var dsGemPortAttributeList []*tp_pb.GemPortAttributes |
| 46 | usGemPortAttributeList = append(usGemPortAttributeList, &tp_pb.GemPortAttributes{ |
| 47 | GemportId: 1, |
| 48 | PbitMap: "0b11111111", |
| 49 | }) |
| 50 | dsGemPortAttributeList = append(dsGemPortAttributeList, &tp_pb.GemPortAttributes{ |
| 51 | GemportId: 1, |
| 52 | PbitMap: "0b11111111", |
| 53 | }) |
| 54 | return &tp_pb.TechProfileInstance{ |
| 55 | Name: "mock-tech-profile", |
| 56 | SubscriberIdentifier: "257", |
| 57 | ProfileType: "mock", |
| 58 | Version: 0, |
| 59 | NumGemPorts: 1, |
| 60 | InstanceControl: &tp_pb.InstanceControl{ |
| 61 | Onu: "multi-instance", |
| 62 | Uni: "single-instance", |
| 63 | MaxGemPayloadSize: "", |
| 64 | }, |
| 65 | UsScheduler: &tp_pb.SchedulerAttributes{ |
| 66 | AllocId: 1, |
| 67 | Direction: tp_pb.Direction_UPSTREAM, |
| 68 | AdditionalBw: tp_pb.AdditionalBW_AdditionalBW_None, |
| 69 | Priority: 0, |
| 70 | Weight: 0, |
| 71 | QSchedPolicy: tp_pb.SchedulingPolicy_WRR, |
| 72 | }, |
| 73 | DsScheduler: &tp_pb.SchedulerAttributes{ |
| 74 | AllocId: 1, |
| 75 | Direction: tp_pb.Direction_DOWNSTREAM, |
| 76 | AdditionalBw: tp_pb.AdditionalBW_AdditionalBW_None, |
| 77 | Priority: 0, |
| 78 | Weight: 0, |
| 79 | QSchedPolicy: tp_pb.SchedulingPolicy_WRR, |
| 80 | }, |
| 81 | UpstreamGemPortAttributeList: usGemPortAttributeList, |
| 82 | DownstreamGemPortAttributeList: dsGemPortAttributeList, |
| 83 | }, nil |
| kdarapu | b26b450 | 2019-10-05 03:02:33 +0530 | [diff] [blame] | 84 | } |
| 85 | |
| Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 86 | // CreateTechProfileInstance to mock techprofile CreateTechProfileInstance method |
| 87 | func (m MockTechProfile) CreateTechProfileInstance(ctx context.Context, techProfiletblID uint32, uniPortName string, intfID uint32) (interface{}, error) { |
| Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 88 | var usGemPortAttributeList []*tp_pb.GemPortAttributes |
| 89 | var dsGemPortAttributeList []*tp_pb.GemPortAttributes |
| mgouda | 8654358 | 2025-10-29 20:58:16 +0530 | [diff] [blame] | 90 | switch techProfiletblID { |
| 91 | case 64: |
| Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 92 | usGemPortAttributeList = append(usGemPortAttributeList, &tp_pb.GemPortAttributes{ |
| 93 | GemportId: 1, |
| 94 | PbitMap: "0b11111111", |
| 95 | }) |
| 96 | dsGemPortAttributeList = append(dsGemPortAttributeList, &tp_pb.GemPortAttributes{ |
| 97 | GemportId: 1, |
| 98 | PbitMap: "0b11111111", |
| 99 | }) |
| 100 | return &tp_pb.TechProfileInstance{ |
| Girish Gowdra | fb3d610 | 2020-10-16 16:32:36 -0700 | [diff] [blame] | 101 | Name: "mock-tech-profile", |
| 102 | SubscriberIdentifier: "257", |
| 103 | ProfileType: "mock", |
| 104 | Version: 0, |
| 105 | NumGemPorts: 1, |
| Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 106 | InstanceControl: &tp_pb.InstanceControl{ |
| 107 | Onu: "multi-instance", |
| 108 | Uni: "single-instance", |
| 109 | MaxGemPayloadSize: "", |
| 110 | }, |
| 111 | UsScheduler: &tp_pb.SchedulerAttributes{ |
| 112 | AllocId: 1, |
| 113 | Direction: tp_pb.Direction_UPSTREAM, |
| 114 | AdditionalBw: tp_pb.AdditionalBW_AdditionalBW_None, |
| Girish Gowdra | fb3d610 | 2020-10-16 16:32:36 -0700 | [diff] [blame] | 115 | Priority: 0, |
| 116 | Weight: 0, |
| Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 117 | QSchedPolicy: tp_pb.SchedulingPolicy_WRR, |
| Girish Gowdra | fb3d610 | 2020-10-16 16:32:36 -0700 | [diff] [blame] | 118 | }, |
| Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 119 | DsScheduler: &tp_pb.SchedulerAttributes{ |
| 120 | AllocId: 1, |
| 121 | Direction: tp_pb.Direction_DOWNSTREAM, |
| 122 | AdditionalBw: tp_pb.AdditionalBW_AdditionalBW_None, |
| Girish Gowdra | fb3d610 | 2020-10-16 16:32:36 -0700 | [diff] [blame] | 123 | Priority: 0, |
| 124 | Weight: 0, |
| Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 125 | QSchedPolicy: tp_pb.SchedulingPolicy_WRR, |
| Girish Gowdra | fb3d610 | 2020-10-16 16:32:36 -0700 | [diff] [blame] | 126 | }, |
| Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 127 | UpstreamGemPortAttributeList: usGemPortAttributeList, |
| 128 | DownstreamGemPortAttributeList: dsGemPortAttributeList, |
| Takahiro Suzuki | 2ba0e0b | 2020-06-05 14:23:03 -0700 | [diff] [blame] | 129 | }, nil |
| mgouda | 8654358 | 2025-10-29 20:58:16 +0530 | [diff] [blame] | 130 | case 65: |
| Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 131 | return &tp_pb.EponTechProfileInstance{ |
| Takahiro Suzuki | 2ba0e0b | 2020-06-05 14:23:03 -0700 | [diff] [blame] | 132 | Name: "mock-epon-profile", |
| 133 | SubscriberIdentifier: "257", |
| 134 | ProfileType: "mock", |
| 135 | Version: 0, |
| 136 | NumGemPorts: 2, |
| 137 | UpstreamQueueAttributeList: nil, |
| 138 | DownstreamQueueAttributeList: nil, |
| 139 | }, nil |
| mgouda | 8654358 | 2025-10-29 20:58:16 +0530 | [diff] [blame] | 140 | default: |
| Takahiro Suzuki | 2ba0e0b | 2020-06-05 14:23:03 -0700 | [diff] [blame] | 141 | return nil, nil |
| 142 | } |
| kdarapu | b26b450 | 2019-10-05 03:02:33 +0530 | [diff] [blame] | 143 | } |
| 144 | |
| Girish Gowdra | 5493426 | 2019-11-13 14:19:55 +0530 | [diff] [blame] | 145 | // DeleteTechProfileInstance to mock techprofile DeleteTechProfileInstance method |
| npujar | ec5762e | 2020-01-01 14:08:48 +0530 | [diff] [blame] | 146 | func (m MockTechProfile) DeleteTechProfileInstance(ctx context.Context, techProfiletblID uint32, uniPortName string) error { |
| kdarapu | b26b450 | 2019-10-05 03:02:33 +0530 | [diff] [blame] | 147 | return nil |
| 148 | } |
| 149 | |
| Girish Gowdra | 5493426 | 2019-11-13 14:19:55 +0530 | [diff] [blame] | 150 | // GetprotoBufParamValue to mock techprofile GetprotoBufParamValue method |
| Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 151 | func (m MockTechProfile) GetprotoBufParamValue(ctx context.Context, paramType string, paramKey string) int32 { |
| kdarapu | b26b450 | 2019-10-05 03:02:33 +0530 | [diff] [blame] | 152 | return 0 |
| kdarapu | b26b450 | 2019-10-05 03:02:33 +0530 | [diff] [blame] | 153 | } |
| 154 | |
| Girish Gowdra | 5493426 | 2019-11-13 14:19:55 +0530 | [diff] [blame] | 155 | // GetUsScheduler to mock techprofile GetUsScheduler method |
| Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 156 | func (m MockTechProfile) GetUsScheduler(tpInstance *tp_pb.TechProfileInstance) *tp_pb.SchedulerConfig { |
| 157 | return &tp_pb.SchedulerConfig{} |
| kdarapu | b26b450 | 2019-10-05 03:02:33 +0530 | [diff] [blame] | 158 | } |
| 159 | |
| Girish Gowdra | 5493426 | 2019-11-13 14:19:55 +0530 | [diff] [blame] | 160 | // GetDsScheduler to mock techprofile GetDsScheduler method |
| Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 161 | func (m MockTechProfile) GetDsScheduler(tpInstance *tp_pb.TechProfileInstance) *tp_pb.SchedulerConfig { |
| 162 | return &tp_pb.SchedulerConfig{} |
| kdarapu | b26b450 | 2019-10-05 03:02:33 +0530 | [diff] [blame] | 163 | } |
| 164 | |
| Girish Gowdra | 5493426 | 2019-11-13 14:19:55 +0530 | [diff] [blame] | 165 | // GetTrafficScheduler to mock techprofile GetTrafficScheduler method |
| Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 166 | func (m MockTechProfile) GetTrafficScheduler(tpInstance *tp_pb.TechProfileInstance, SchedCfg *tp_pb.SchedulerConfig, |
| kdarapu | b26b450 | 2019-10-05 03:02:33 +0530 | [diff] [blame] | 167 | ShapingCfg *tp_pb.TrafficShapingInfo) *tp_pb.TrafficScheduler { |
| 168 | return &tp_pb.TrafficScheduler{} |
| kdarapu | b26b450 | 2019-10-05 03:02:33 +0530 | [diff] [blame] | 169 | } |
| 170 | |
| Girish Gowdra | 5493426 | 2019-11-13 14:19:55 +0530 | [diff] [blame] | 171 | // GetTrafficQueues to mock techprofile GetTrafficQueues method |
| Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 172 | func (m MockTechProfile) GetTrafficQueues(ctx context.Context, tp *tp_pb.TechProfileInstance, Dir tp_pb.Direction) ([]*tp_pb.TrafficQueue, error) { |
| Girish Kumar | 8f73fe0 | 2019-12-09 13:19:37 +0000 | [diff] [blame] | 173 | return []*tp_pb.TrafficQueue{{}}, nil |
| kdarapu | b26b450 | 2019-10-05 03:02:33 +0530 | [diff] [blame] | 174 | } |
| 175 | |
| Scott Baker | ee7c0a0 | 2020-01-07 11:12:26 -0800 | [diff] [blame] | 176 | // GetMulticastTrafficQueues to mock techprofile GetMulticastTrafficQueues method |
| Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 177 | func (m MockTechProfile) GetMulticastTrafficQueues(ctx context.Context, tp *tp_pb.TechProfileInstance) []*tp_pb.TrafficQueue { |
| Scott Baker | ee7c0a0 | 2020-01-07 11:12:26 -0800 | [diff] [blame] | 178 | return []*tp_pb.TrafficQueue{{}} |
| 179 | } |
| 180 | |
| Gamze Abaka | 7650be6 | 2021-02-26 10:50:36 +0000 | [diff] [blame] | 181 | // GetGemportForPbit to mock techprofile GetGemportForPbit method |
| 182 | func (m MockTechProfile) GetGemportForPbit(ctx context.Context, tpInst interface{}, Dir tp_pb.Direction, pbit uint32) interface{} { |
| Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 183 | return &tp_pb.GemPortAttributes{ |
| 184 | GemportId: 1, |
| Gamze Abaka | 7650be6 | 2021-02-26 10:50:36 +0000 | [diff] [blame] | 185 | PbitMap: "0b11111111", |
| 186 | AesEncryption: "false", |
| 187 | } |
| kdarapu | b26b450 | 2019-10-05 03:02:33 +0530 | [diff] [blame] | 188 | } |
| Girish Gowdra | 5493426 | 2019-11-13 14:19:55 +0530 | [diff] [blame] | 189 | |
| 190 | // FindAllTpInstances to mock techprofile FindAllTpInstances method |
| Gamze Abaka | cb0e677 | 2021-06-10 08:32:12 +0000 | [diff] [blame] | 191 | func (m MockTechProfile) FindAllTpInstances(ctx context.Context, oltDeviceID string, tpID uint32, ponIntf uint32, onuID uint32) interface{} { |
| Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 192 | return []tp_pb.TechProfileInstance{} |
| Girish Gowdra | 5493426 | 2019-11-13 14:19:55 +0530 | [diff] [blame] | 193 | } |
| Matteo Scandolo | 8458537 | 2021-03-18 14:21:22 -0700 | [diff] [blame] | 194 | |
| 195 | // GetResourceID to mock techprofile GetResourceID method |
| 196 | func (m MockTechProfile) GetResourceID(ctx context.Context, IntfID uint32, ResourceType string, NumIDs uint32) ([]uint32, error) { |
| 197 | return []uint32{}, nil |
| 198 | } |
| 199 | |
| 200 | // FreeResourceID to mock techprofile FreeResourceID method |
| 201 | func (m MockTechProfile) FreeResourceID(ctx context.Context, IntfID uint32, ResourceType string, ReleaseContent []uint32) error { |
| 202 | return nil |
| 203 | } |
| Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 204 | |
| 205 | // GetTechProfileInstanceKey to mock techprofile GetTechProfileInstanceKey method |
| 206 | func (m MockTechProfile) GetTechProfileInstanceKey(ctx context.Context, tpID uint32, uniPortName string) string { |
| 207 | return "" |
| 208 | } |