[VOL-4442] grpc streaming connection monitoring
Change-Id: Ifc904d3d146696937cf5e4e7427fbb4d5ff45da0
diff --git a/pkg/grpc/utils_test.go b/pkg/grpc/utils_test.go
index 55ffdf8..a9cf7ff 100644
--- a/pkg/grpc/utils_test.go
+++ b/pkg/grpc/utils_test.go
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package grpc
+package grpc_test
import (
"context"
@@ -21,6 +21,7 @@
"testing"
"time"
+ vgrpc "github.com/opencord/voltha-lib-go/v7/pkg/grpc"
"github.com/stretchr/testify/assert"
)
@@ -28,7 +29,7 @@
initTime := 1 * time.Millisecond
maxTime := 500 * time.Millisecond
maxElapsedTime := 0 * time.Millisecond
- backoff := NewBackoff(initTime, maxTime, maxElapsedTime)
+ backoff := vgrpc.NewBackoff(initTime, maxTime, maxElapsedTime)
ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond)
defer cancel()
err := backoff.Backoff(ctx)
@@ -39,7 +40,7 @@
initTime := 10 * time.Millisecond
maxTime := 50 * time.Millisecond
maxElapsedTime := 500 * time.Millisecond
- b := NewBackoff(initTime, maxTime, maxElapsedTime)
+ b := vgrpc.NewBackoff(initTime, maxTime, maxElapsedTime)
start := time.Now()
loop:
for {
@@ -55,7 +56,7 @@
initTime := 100 * time.Millisecond
maxTime := 500 * time.Millisecond
maxElapsedTime := 0 * time.Millisecond
- backoff := NewBackoff(initTime, maxTime, maxElapsedTime)
+ backoff := vgrpc.NewBackoff(initTime, maxTime, maxElapsedTime)
ctx, cancel := context.WithTimeout(context.Background(), 2000*time.Millisecond)
defer cancel()
previous := time.Duration(0)
@@ -75,7 +76,7 @@
initTime := 1000 * time.Millisecond
maxTime := 1100 * time.Millisecond
maxElapsedTime := 0 * time.Millisecond
- backoff := NewBackoff(initTime, maxTime, maxElapsedTime)
+ backoff := vgrpc.NewBackoff(initTime, maxTime, maxElapsedTime)
ctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)
defer cancel()
err := backoff.Backoff(ctx)
@@ -86,18 +87,18 @@
func TestSetFromEnvVariable(t *testing.T) {
// 1. Test with unsupported type
var valInt int
- err := SetFromEnvVariable("MY-KEY", valInt)
+ err := vgrpc.SetFromEnvVariable("MY-KEY", valInt)
assert.NotNil(t, err)
//2. Test with supported type but no env variable present
var valDuration time.Duration
- err = SetFromEnvVariable("MY-KEY", &valDuration)
+ err = vgrpc.SetFromEnvVariable("MY-KEY", &valDuration)
assert.Nil(t, err)
//3. Test with supported type and env variable present
err = os.Setenv("MY-KEY", "10s")
assert.Nil(t, err)
- err = SetFromEnvVariable("MY-KEY", &valDuration)
+ err = vgrpc.SetFromEnvVariable("MY-KEY", &valDuration)
assert.Nil(t, err)
assert.Equal(t, 10*time.Second, valDuration)
}