kdarapu | 3248f9a | 2019-10-03 13:54:52 +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 | 3248f9a | 2019-10-03 13:54:52 +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 | 3248f9a | 2019-10-03 13:54:52 +0530 | [diff] [blame] | 18 | package mocks |
| 19 | |
| 20 | import ( |
npujar | ec5762e | 2020-01-01 14:08:48 +0530 | [diff] [blame] | 21 | "context" |
kdarapu | 3248f9a | 2019-10-03 13:54:52 +0530 | [diff] [blame] | 22 | "encoding/json" |
| 23 | "errors" |
| 24 | "strconv" |
| 25 | "strings" |
npujar | ec5762e | 2020-01-01 14:08:48 +0530 | [diff] [blame] | 26 | "time" |
kdarapu | 3248f9a | 2019-10-03 13:54:52 +0530 | [diff] [blame] | 27 | |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 28 | "github.com/opencord/voltha-lib-go/v7/pkg/db/kvstore" |
| 29 | "github.com/opencord/voltha-lib-go/v7/pkg/log" |
| 30 | ofp "github.com/opencord/voltha-protos/v5/go/openflow_13" |
kdarapu | 3248f9a | 2019-10-03 13:54:52 +0530 | [diff] [blame] | 31 | ) |
| 32 | |
| 33 | const ( |
| 34 | // MeterConfig meter to extarct meter |
| 35 | MeterConfig = "meter_id" |
| 36 | // TpIDPathSuffix to extract Techprofile |
| 37 | TpIDPathSuffix = "tp_id" |
kdarapu | b26b450 | 2019-10-05 03:02:33 +0530 | [diff] [blame] | 38 | // FlowIDpool to extract Flow ids |
| 39 | FlowIDpool = "flow_id_pool" |
| 40 | // FlowIDs to extract flow_ids |
| 41 | FlowIDs = "flow_ids" |
| 42 | // FlowIDInfo to extract flowId info |
| 43 | FlowIDInfo = "flow_id_info" |
| 44 | // GemportIDs to gemport_ids |
| 45 | GemportIDs = "gemport_ids" |
| 46 | // AllocIDs to extract alloc_ids |
| 47 | AllocIDs = "alloc_ids" |
Esin Karaman | ccb714b | 2019-11-29 15:02:06 +0000 | [diff] [blame] | 48 | //FlowGroup flow_groups/<flow_group_id> |
| 49 | FlowGroup = "flow_groups" |
| 50 | //FlowGroupCached flow_groups_cached/<flow_group_id> |
| 51 | FlowGroupCached = "flow_groups_cached" |
Esin Karaman | 7fb80c2 | 2020-07-16 14:23:33 +0000 | [diff] [blame] | 52 | //OnuPacketIn to extract gem port from packet-in |
| 53 | OnuPacketIn = "onu_packetin" |
Girish Gowdra | fb3d610 | 2020-10-16 16:32:36 -0700 | [diff] [blame] | 54 | // OnuGemInfoPath has path on the kvstore to store OnuGemInfo info per PON interface |
| 55 | OnuGemInfoPath = "onu_gem_info" |
kdarapu | 3248f9a | 2019-10-03 13:54:52 +0530 | [diff] [blame] | 56 | ) |
| 57 | |
| 58 | // MockKVClient mocks the AdapterProxy interface. |
| 59 | type MockKVClient struct { |
| 60 | } |
| 61 | |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 62 | // OnuGemInfo holds onu information along with gem port list and uni port list |
| 63 | type OnuGemInfo struct { |
| 64 | OnuID uint32 |
| 65 | SerialNumber string |
| 66 | IntfID uint32 |
| 67 | GemPorts []uint32 |
| 68 | UniPorts []uint32 |
| 69 | } |
| 70 | |
| 71 | // GroupInfo holds group information |
| 72 | type GroupInfo struct { |
| 73 | GroupID uint32 |
| 74 | OutPorts []uint32 |
| 75 | } |
| 76 | |
kdarapu | 3248f9a | 2019-10-03 13:54:52 +0530 | [diff] [blame] | 77 | // List mock function implementation for KVClient |
npujar | ec5762e | 2020-01-01 14:08:48 +0530 | [diff] [blame] | 78 | func (kvclient *MockKVClient) List(ctx context.Context, key string) (map[string]*kvstore.KVPair, error) { |
kdarapu | 3248f9a | 2019-10-03 13:54:52 +0530 | [diff] [blame] | 79 | if key != "" { |
| 80 | maps := make(map[string]*kvstore.KVPair) |
| 81 | maps[key] = &kvstore.KVPair{Key: key} |
| 82 | return maps, nil |
| 83 | } |
| 84 | return nil, errors.New("key didn't find") |
| 85 | } |
| 86 | |
| 87 | // Get mock function implementation for KVClient |
Girish Gowdra | fb3d610 | 2020-10-16 16:32:36 -0700 | [diff] [blame] | 88 | // nolint: gocyclo |
npujar | ec5762e | 2020-01-01 14:08:48 +0530 | [diff] [blame] | 89 | func (kvclient *MockKVClient) Get(ctx context.Context, key string) (*kvstore.KVPair, error) { |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 90 | logger.Debugw(ctx, "Get of MockKVClient called", log.Fields{"key": key}) |
kdarapu | 3248f9a | 2019-10-03 13:54:52 +0530 | [diff] [blame] | 91 | if key != "" { |
kdarapu | b26b450 | 2019-10-05 03:02:33 +0530 | [diff] [blame] | 92 | if strings.Contains(key, "meter_id/{0,62,8}/{upstream}") { |
| 93 | meterConfig := ofp.OfpMeterConfig{ |
| 94 | Flags: 0, |
| 95 | MeterId: 1, |
| 96 | } |
| 97 | str, _ := json.Marshal(meterConfig) |
| 98 | return kvstore.NewKVPair(key, string(str), "mock", 3000, 1), nil |
| 99 | } |
kdarapu | 3248f9a | 2019-10-03 13:54:52 +0530 | [diff] [blame] | 100 | if strings.Contains(key, MeterConfig) { |
| 101 | var bands []*ofp.OfpMeterBandHeader |
| 102 | bands = append(bands, &ofp.OfpMeterBandHeader{Type: ofp.OfpMeterBandType_OFPMBT_DSCP_REMARK, |
| 103 | Rate: 1024, Data: &ofp.OfpMeterBandHeader_DscpRemark{DscpRemark: &ofp.OfpMeterBandDscpRemark{PrecLevel: 2}}}) |
| 104 | |
| 105 | bands = append(bands, &ofp.OfpMeterBandHeader{Type: ofp.OfpMeterBandType_OFPMBT_DSCP_REMARK, |
| 106 | Rate: 1024, Data: &ofp.OfpMeterBandHeader_DscpRemark{DscpRemark: &ofp.OfpMeterBandDscpRemark{PrecLevel: 3}}}) |
| 107 | |
Gamze Abaka | fee3639 | 2019-10-03 11:17:24 +0000 | [diff] [blame] | 108 | sep := strings.Split(key, "/")[1] |
kdarapu | 3248f9a | 2019-10-03 13:54:52 +0530 | [diff] [blame] | 109 | val, _ := strconv.ParseInt(strings.Split(sep, ",")[1], 10, 32) |
| 110 | if uint32(val) > 1 { |
| 111 | meterConfig := &ofp.OfpMeterConfig{MeterId: uint32(val), Bands: bands} |
| 112 | str, _ := json.Marshal(meterConfig) |
kdarapu | b26b450 | 2019-10-05 03:02:33 +0530 | [diff] [blame] | 113 | |
| 114 | return kvstore.NewKVPair(key, str, "mock", 3000, 1), nil |
| 115 | } |
| 116 | |
| 117 | if strings.Contains(key, "meter_id/{1,1,1}/{downstream}") { |
| 118 | |
| 119 | band1 := &ofp.OfpMeterBandHeader{Type: ofp.OfpMeterBandType_OFPMBT_DROP, Rate: 1000, BurstSize: 5000} |
| 120 | band2 := &ofp.OfpMeterBandHeader{Type: ofp.OfpMeterBandType_OFPMBT_DROP, Rate: 2000, BurstSize: 5000} |
| 121 | bands := []*ofp.OfpMeterBandHeader{band1, band2} |
| 122 | ofpMeterConfig := &ofp.OfpMeterConfig{Flags: 1, MeterId: 1, Bands: bands} |
| 123 | str, _ := json.Marshal(ofpMeterConfig) |
| 124 | return kvstore.NewKVPair(key, str, "mock", 3000, 1), nil |
kdarapu | 3248f9a | 2019-10-03 13:54:52 +0530 | [diff] [blame] | 125 | } |
| 126 | if uint32(val) == 1 { |
| 127 | return nil, nil |
| 128 | } |
| 129 | return nil, errors.New("invalid meter") |
| 130 | } |
| 131 | if strings.Contains(key, TpIDPathSuffix) { |
Girish Gowdra | fb3d610 | 2020-10-16 16:32:36 -0700 | [diff] [blame] | 132 | data := []uint32{64} |
| 133 | str, _ := json.Marshal(data) |
kdarapu | b26b450 | 2019-10-05 03:02:33 +0530 | [diff] [blame] | 134 | return kvstore.NewKVPair(key, str, "mock", 3000, 1), nil |
| 135 | } |
| 136 | if strings.Contains(key, FlowIDpool) { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 137 | logger.Debug(ctx, "Error Error Error Key:", FlowIDpool) |
kdarapu | b26b450 | 2019-10-05 03:02:33 +0530 | [diff] [blame] | 138 | data := make(map[string]interface{}) |
| 139 | data["pool"] = "1024" |
| 140 | data["start_idx"] = 1 |
| 141 | data["end_idx"] = 1024 |
| 142 | str, _ := json.Marshal(data) |
| 143 | return kvstore.NewKVPair(key, str, "mock", 3000, 1), nil |
| 144 | } |
| 145 | if strings.Contains(key, FlowIDs) { |
| 146 | data := []uint32{1, 2} |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 147 | logger.Debug(ctx, "Error Error Error Key:", FlowIDs) |
kdarapu | b26b450 | 2019-10-05 03:02:33 +0530 | [diff] [blame] | 148 | str, _ := json.Marshal(data) |
| 149 | return kvstore.NewKVPair(key, str, "mock", 3000, 1), nil |
| 150 | } |
Esin Karaman | d519bbf | 2020-07-01 11:16:03 +0000 | [diff] [blame] | 151 | |
kdarapu | b26b450 | 2019-10-05 03:02:33 +0530 | [diff] [blame] | 152 | if strings.Contains(key, GemportIDs) { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 153 | logger.Debug(ctx, "Error Error Error Key:", GemportIDs) |
Girish Gowdra | fb3d610 | 2020-10-16 16:32:36 -0700 | [diff] [blame] | 154 | data := []uint32{1} |
| 155 | str, _ := json.Marshal(data) |
kdarapu | b26b450 | 2019-10-05 03:02:33 +0530 | [diff] [blame] | 156 | return kvstore.NewKVPair(key, str, "mock", 3000, 1), nil |
| 157 | } |
| 158 | if strings.Contains(key, AllocIDs) { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 159 | logger.Debug(ctx, "Error Error Error Key:", AllocIDs) |
Girish Gowdra | fb3d610 | 2020-10-16 16:32:36 -0700 | [diff] [blame] | 160 | data := []uint32{1} |
| 161 | str, _ := json.Marshal(data) |
kdarapu | 3248f9a | 2019-10-03 13:54:52 +0530 | [diff] [blame] | 162 | return kvstore.NewKVPair(key, str, "mock", 3000, 1), nil |
| 163 | } |
Esin Karaman | ccb714b | 2019-11-29 15:02:06 +0000 | [diff] [blame] | 164 | if strings.Contains(key, FlowGroup) || strings.Contains(key, FlowGroupCached) { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 165 | logger.Debug(ctx, "Error Error Error Key:", FlowGroup) |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 166 | groupInfo := GroupInfo{ |
Esin Karaman | ccb714b | 2019-11-29 15:02:06 +0000 | [diff] [blame] | 167 | GroupID: 2, |
| 168 | OutPorts: []uint32{1}, |
| 169 | } |
| 170 | str, _ := json.Marshal(&groupInfo) |
| 171 | return kvstore.NewKVPair(key, str, "mock", 3000, 1), nil |
| 172 | } |
Esin Karaman | 7fb80c2 | 2020-07-16 14:23:33 +0000 | [diff] [blame] | 173 | if strings.Contains(key, OnuPacketIn) { |
| 174 | return getPacketInGemPort(key) |
| 175 | } |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 176 | |
Girish Gowdra | fb3d610 | 2020-10-16 16:32:36 -0700 | [diff] [blame] | 177 | if strings.Contains(key, OnuGemInfoPath) { |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 178 | var data []OnuGemInfo |
Girish Gowdra | fb3d610 | 2020-10-16 16:32:36 -0700 | [diff] [blame] | 179 | str, _ := json.Marshal(data) |
| 180 | return kvstore.NewKVPair(key, str, "mock", 3000, 1), nil |
| 181 | } |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 182 | |
Esin Karaman | df392e1 | 2020-12-16 13:33:09 +0000 | [diff] [blame] | 183 | //Interface, GEM port path |
| 184 | if strings.Contains(key, "0,255") { |
| 185 | //return onuID, uniID associated with the given interface and GEM port |
| 186 | data := []uint32{1, 0} |
| 187 | str, _ := json.Marshal(data) |
| 188 | return kvstore.NewKVPair(key, str, "mock", 3000, 1), nil |
| 189 | } |
| 190 | //Interface, GEM port path |
| 191 | if strings.Contains(key, "0,257") { |
| 192 | //return onuID, uniID associated with the given interface and GEM port |
| 193 | data := []uint32{1, 0} |
| 194 | str, _ := json.Marshal(data) |
| 195 | return kvstore.NewKVPair(key, str, "mock", 3000, 1), nil |
| 196 | } |
Esin Karaman | 7fb80c2 | 2020-07-16 14:23:33 +0000 | [diff] [blame] | 197 | |
kdarapu | 3248f9a | 2019-10-03 13:54:52 +0530 | [diff] [blame] | 198 | maps := make(map[string]*kvstore.KVPair) |
| 199 | maps[key] = &kvstore.KVPair{Key: key} |
| 200 | return maps[key], nil |
| 201 | } |
| 202 | return nil, errors.New("key didn't find") |
| 203 | } |
| 204 | |
Joey Armstrong | 3f0e242 | 2023-07-05 18:25:41 -0400 | [diff] [blame] | 205 | // getPacketInGemPort returns the GEM port associated with the given key |
Esin Karaman | 7fb80c2 | 2020-07-16 14:23:33 +0000 | [diff] [blame] | 206 | func getPacketInGemPort(key string) (*kvstore.KVPair, error) { |
| 207 | //parse interface, onu, uni, vlan, priority values |
| 208 | arr := getParamsFromPacketInKey(key) |
| 209 | |
| 210 | if len(arr) < 5 { |
| 211 | return nil, errors.New("key didn't find") |
| 212 | } |
| 213 | if arr[0] == "1" && arr[1] == "1" && arr[2] == "3" && arr[3] == "0" && arr[4] == "0" { |
| 214 | str, _ := json.Marshal(3) |
| 215 | return kvstore.NewKVPair(key, str, "mock", 3000, 1), nil |
| 216 | } |
| 217 | if arr[0] == "2" && arr[1] == "2" && arr[2] == "4" && arr[3] == "549" && arr[4] == "0" { |
| 218 | str, _ := json.Marshal(4) |
| 219 | return kvstore.NewKVPair(key, str, "mock", 3000, 1), nil |
| 220 | } |
| 221 | if arr[0] == "1" && arr[1] == "2" && arr[2] == "2" && arr[3] == "48" && arr[4] == "7" { |
| 222 | str, _ := json.Marshal(2) |
| 223 | return kvstore.NewKVPair(key, str, "mock", 3000, 1), nil |
| 224 | } |
| 225 | return nil, errors.New("key didn't find") |
| 226 | } |
| 227 | |
Joey Armstrong | 3f0e242 | 2023-07-05 18:25:41 -0400 | [diff] [blame] | 228 | // getParamsFromPacketInKey parse packetIn key that is in the format of "onu_packetin/{1,1,1,1,2}" |
Esin Karaman | 7fb80c2 | 2020-07-16 14:23:33 +0000 | [diff] [blame] | 229 | func getParamsFromPacketInKey(key string) []string { |
| 230 | //return intfID, onuID, uniID, vlanID, priority |
| 231 | firstIndex := strings.Index(key, "{") |
| 232 | lastIndex := strings.Index(key, "}") |
| 233 | if firstIndex == -1 && lastIndex == -1 { |
| 234 | return []string{} |
| 235 | } |
| 236 | arr := strings.Split(key[firstIndex+1:lastIndex], ",") |
| 237 | if len(arr) < 5 { |
| 238 | return []string{} |
| 239 | } |
| 240 | return arr |
| 241 | } |
| 242 | |
kdarapu | 3248f9a | 2019-10-03 13:54:52 +0530 | [diff] [blame] | 243 | // Put mock function implementation for KVClient |
npujar | ec5762e | 2020-01-01 14:08:48 +0530 | [diff] [blame] | 244 | func (kvclient *MockKVClient) Put(ctx context.Context, key string, value interface{}) error { |
kdarapu | 3248f9a | 2019-10-03 13:54:52 +0530 | [diff] [blame] | 245 | if key != "" { |
kdarapu | 3248f9a | 2019-10-03 13:54:52 +0530 | [diff] [blame] | 246 | return nil |
| 247 | } |
| 248 | return errors.New("key didn't find") |
| 249 | } |
| 250 | |
| 251 | // Delete mock function implementation for KVClient |
npujar | ec5762e | 2020-01-01 14:08:48 +0530 | [diff] [blame] | 252 | func (kvclient *MockKVClient) Delete(ctx context.Context, key string) error { |
kdarapu | 3248f9a | 2019-10-03 13:54:52 +0530 | [diff] [blame] | 253 | if key == "" { |
| 254 | return errors.New("key didn't find") |
| 255 | } |
| 256 | return nil |
| 257 | } |
| 258 | |
serkant.uluderya | 7b8211e | 2021-02-24 16:39:18 +0300 | [diff] [blame] | 259 | // DeleteWithPrefix mock function implementation for KVClient |
| 260 | func (kvclient *MockKVClient) DeleteWithPrefix(ctx context.Context, prefixKey string) error { |
| 261 | if prefixKey == "" { |
| 262 | return errors.New("key didn't find") |
| 263 | } |
| 264 | return nil |
| 265 | } |
| 266 | |
kdarapu | 3248f9a | 2019-10-03 13:54:52 +0530 | [diff] [blame] | 267 | // Reserve mock function implementation for KVClient |
Neha Sharma | cc65696 | 2020-04-14 14:26:11 +0000 | [diff] [blame] | 268 | func (kvclient *MockKVClient) Reserve(ctx context.Context, key string, value interface{}, ttl time.Duration) (interface{}, error) { |
kdarapu | 3248f9a | 2019-10-03 13:54:52 +0530 | [diff] [blame] | 269 | if key != "" { |
| 270 | maps := make(map[string]*kvstore.KVPair) |
| 271 | maps[key] = &kvstore.KVPair{Key: key} |
| 272 | return maps[key], nil |
| 273 | } |
| 274 | return nil, errors.New("key didn't find") |
| 275 | } |
| 276 | |
| 277 | // ReleaseReservation mock function implementation for KVClient |
npujar | ec5762e | 2020-01-01 14:08:48 +0530 | [diff] [blame] | 278 | func (kvclient *MockKVClient) ReleaseReservation(ctx context.Context, key string) error { |
kdarapu | 3248f9a | 2019-10-03 13:54:52 +0530 | [diff] [blame] | 279 | // return nil |
| 280 | if key == "" { |
| 281 | return errors.New("key didn't find") |
| 282 | } |
| 283 | return nil |
| 284 | } |
| 285 | |
| 286 | // ReleaseAllReservations mock function implementation for KVClient |
npujar | ec5762e | 2020-01-01 14:08:48 +0530 | [diff] [blame] | 287 | func (kvclient *MockKVClient) ReleaseAllReservations(ctx context.Context) error { |
kdarapu | 3248f9a | 2019-10-03 13:54:52 +0530 | [diff] [blame] | 288 | return nil |
| 289 | } |
| 290 | |
| 291 | // RenewReservation mock function implementation for KVClient |
npujar | ec5762e | 2020-01-01 14:08:48 +0530 | [diff] [blame] | 292 | func (kvclient *MockKVClient) RenewReservation(ctx context.Context, key string) error { |
kdarapu | 3248f9a | 2019-10-03 13:54:52 +0530 | [diff] [blame] | 293 | // return nil |
| 294 | if key == "" { |
| 295 | return errors.New("key didn't find") |
| 296 | } |
| 297 | return nil |
| 298 | } |
| 299 | |
| 300 | // Watch mock function implementation for KVClient |
Scott Baker | e701b86 | 2020-02-20 16:19:16 -0800 | [diff] [blame] | 301 | func (kvclient *MockKVClient) Watch(ctx context.Context, key string, withPrefix bool) chan *kvstore.Event { |
kdarapu | 3248f9a | 2019-10-03 13:54:52 +0530 | [diff] [blame] | 302 | return nil |
| 303 | // if key == "" { |
| 304 | // return nil |
| 305 | // } |
| 306 | // return &kvstore.Event{EventType: 1, Key: key} |
| 307 | } |
| 308 | |
| 309 | // AcquireLock mock function implementation for KVClient |
Neha Sharma | cc65696 | 2020-04-14 14:26:11 +0000 | [diff] [blame] | 310 | func (kvclient *MockKVClient) AcquireLock(ctx context.Context, lockName string, timeout time.Duration) error { |
kdarapu | 3248f9a | 2019-10-03 13:54:52 +0530 | [diff] [blame] | 311 | return nil |
| 312 | } |
| 313 | |
| 314 | // ReleaseLock mock function implementation for KVClient |
| 315 | func (kvclient *MockKVClient) ReleaseLock(lockName string) error { |
| 316 | return nil |
| 317 | } |
| 318 | |
| 319 | // IsConnectionUp mock function implementation for KVClient |
Matteo Scandolo | 945e401 | 2019-12-12 14:16:11 -0800 | [diff] [blame] | 320 | func (kvclient *MockKVClient) IsConnectionUp(ctx context.Context) bool { |
| 321 | // timeout in second |
npujar | ec5762e | 2020-01-01 14:08:48 +0530 | [diff] [blame] | 322 | t, _ := ctx.Deadline() |
Kent Hagerman | e6ff101 | 2020-07-14 15:07:53 -0400 | [diff] [blame] | 323 | return t.Second()-time.Now().Second() >= 1 |
kdarapu | 3248f9a | 2019-10-03 13:54:52 +0530 | [diff] [blame] | 324 | } |
| 325 | |
| 326 | // CloseWatch mock function implementation for KVClient |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 327 | func (kvclient *MockKVClient) CloseWatch(ctx context.Context, key string, ch chan *kvstore.Event) { |
kdarapu | 3248f9a | 2019-10-03 13:54:52 +0530 | [diff] [blame] | 328 | } |
| 329 | |
| 330 | // Close mock function implementation for KVClient |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 331 | func (kvclient *MockKVClient) Close(ctx context.Context) { |
kdarapu | 3248f9a | 2019-10-03 13:54:52 +0530 | [diff] [blame] | 332 | } |