VOL-2180 code changes for context addition
Integrating InterContainerProxy interface changes
Change-Id: Ia20c5ac3093b7845acf80cce801ec0c1d90c125f
diff --git a/mocks/mockKVClient.go b/mocks/mockKVClient.go
index 7d12cac..90a9742 100644
--- a/mocks/mockKVClient.go
+++ b/mocks/mockKVClient.go
@@ -18,10 +18,12 @@
package mocks
import (
+ "context"
"encoding/json"
"errors"
"strconv"
"strings"
+ "time"
"github.com/opencord/voltha-lib-go/v3/pkg/log"
"github.com/opencord/voltha-openolt-adapter/adaptercore/resourcemanager"
@@ -57,7 +59,7 @@
}
// List mock function implementation for KVClient
-func (kvclient *MockKVClient) List(key string, timeout int) (map[string]*kvstore.KVPair, error) {
+func (kvclient *MockKVClient) List(ctx context.Context, key string) (map[string]*kvstore.KVPair, error) {
if key != "" {
maps := make(map[string]*kvstore.KVPair)
maps[key] = &kvstore.KVPair{Key: key}
@@ -67,7 +69,7 @@
}
// Get mock function implementation for KVClient
-func (kvclient *MockKVClient) Get(key string, timeout int) (*kvstore.KVPair, error) {
+func (kvclient *MockKVClient) Get(ctx context.Context, key string) (*kvstore.KVPair, error) {
log.Debugw("Warning Warning Warning: Get of MockKVClient called", log.Fields{"key": key})
if key != "" {
log.Debug("Warning Key Not Blank")
@@ -170,7 +172,7 @@
}
// Put mock function implementation for KVClient
-func (kvclient *MockKVClient) Put(key string, value interface{}, timeout int) error {
+func (kvclient *MockKVClient) Put(ctx context.Context, key string, value interface{}) error {
if key != "" {
return nil
@@ -179,7 +181,7 @@
}
// Delete mock function implementation for KVClient
-func (kvclient *MockKVClient) Delete(key string, timeout int) error {
+func (kvclient *MockKVClient) Delete(ctx context.Context, key string) error {
if key == "" {
return errors.New("key didn't find")
}
@@ -187,7 +189,7 @@
}
// Reserve mock function implementation for KVClient
-func (kvclient *MockKVClient) Reserve(key string, value interface{}, ttl int64) (interface{}, error) {
+func (kvclient *MockKVClient) Reserve(ctx context.Context, key string, value interface{}, ttl int64) (interface{}, error) {
if key != "" {
maps := make(map[string]*kvstore.KVPair)
maps[key] = &kvstore.KVPair{Key: key}
@@ -197,7 +199,7 @@
}
// ReleaseReservation mock function implementation for KVClient
-func (kvclient *MockKVClient) ReleaseReservation(key string) error {
+func (kvclient *MockKVClient) ReleaseReservation(ctx context.Context, key string) error {
// return nil
if key == "" {
return errors.New("key didn't find")
@@ -206,12 +208,12 @@
}
// ReleaseAllReservations mock function implementation for KVClient
-func (kvclient *MockKVClient) ReleaseAllReservations() error {
+func (kvclient *MockKVClient) ReleaseAllReservations(ctx context.Context) error {
return nil
}
// RenewReservation mock function implementation for KVClient
-func (kvclient *MockKVClient) RenewReservation(key string) error {
+func (kvclient *MockKVClient) RenewReservation(ctx context.Context, key string) error {
// return nil
if key == "" {
return errors.New("key didn't find")
@@ -220,7 +222,7 @@
}
// Watch mock function implementation for KVClient
-func (kvclient *MockKVClient) Watch(key string) chan *kvstore.Event {
+func (kvclient *MockKVClient) Watch(ctx context.Context, key string) chan *kvstore.Event {
return nil
// if key == "" {
// return nil
@@ -229,7 +231,7 @@
}
// AcquireLock mock function implementation for KVClient
-func (kvclient *MockKVClient) AcquireLock(lockName string, timeout int) error {
+func (kvclient *MockKVClient) AcquireLock(ctx context.Context, lockName string, timeout int) error {
return nil
}
@@ -239,8 +241,9 @@
}
// IsConnectionUp mock function implementation for KVClient
-func (kvclient *MockKVClient) IsConnectionUp(timeout int) bool { // timeout in second
- if timeout < 1 {
+func (kvclient *MockKVClient) IsConnectionUp(ctx context.Context) bool { // timeout in second
+ t, _ := ctx.Deadline()
+ if t.Second()-time.Now().Second() < 1 {
return false
}
return true