[VOL-4290] Voltha go library updates for gRPC migration

Change-Id: I1aa2774beb6b7ed7419bc45aeb53fcae8a8ecda0
diff --git a/pkg/grpc/common_test.go b/pkg/grpc/common_test.go
index 7760c33..7a5f394 100644
--- a/pkg/grpc/common_test.go
+++ b/pkg/grpc/common_test.go
@@ -16,7 +16,10 @@
 package grpc
 
 import (
-	"github.com/opencord/voltha-lib-go/v6/pkg/log"
+	"fmt"
+	"time"
+
+	"github.com/opencord/voltha-lib-go/v7/pkg/log"
 )
 
 const (
@@ -30,15 +33,44 @@
 	 * useful.
 	 */
 
-	VOLTHA_LOGLEVEL = log.FatalLevel
+	volthaTestLogLevel = log.FatalLevel
+	retryInterval      = 50 * time.Millisecond
 )
 
+type isConditionSatisfied func() bool
+
 // Unit test initialization. This init() function handles all unit tests in
 // the current directory.
 func init() {
 	// Logger must be configured or bad things happen
-	_, err := log.SetDefaultLogger(log.JSON, VOLTHA_LOGLEVEL, log.Fields{"instanceId": 1})
+	_, err := log.SetDefaultLogger(log.JSON, volthaTestLogLevel, log.Fields{"instanceId": 1})
 	if err != nil {
 		panic(err)
 	}
 }
+
+func waitUntilCondition(timeout time.Duration, verificationFunction isConditionSatisfied) error {
+	ch := make(chan int, 1)
+	done := false
+	go func() {
+		for {
+			if verificationFunction() {
+				ch <- 1
+				break
+			}
+			if done {
+				break
+			}
+			time.Sleep(retryInterval)
+		}
+	}()
+	timer := time.NewTimer(timeout)
+	defer timer.Stop()
+	select {
+	case <-ch:
+		return nil
+	case <-timer.C:
+		done = true
+		return fmt.Errorf("timeout-waiting-for-condition")
+	}
+}