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