VOL-1900 lint warning fixes tests

Change-Id: Ic309e11913134cf559fd80cefcf5ded815bb52dc
diff --git a/tests/core/api/grpc_nbi_api_handler_client_test.go b/tests/core/api/grpc_nbi_api_handler_client_test.go
index 148b664..17ad4b9 100644
--- a/tests/core/api/grpc_nbi_api_handler_client_test.go
+++ b/tests/core/api/grpc_nbi_api_handler_client_test.go
@@ -21,6 +21,12 @@
 import (
 	"context"
 	"fmt"
+	"os"
+	"os/exec"
+	"strings"
+	"testing"
+	"time"
+
 	"github.com/golang/protobuf/ptypes/empty"
 	com "github.com/opencord/voltha-lib-go/v2/pkg/adapters/common"
 	"github.com/opencord/voltha-lib-go/v2/pkg/log"
@@ -32,11 +38,6 @@
 	"google.golang.org/grpc/codes"
 	"google.golang.org/grpc/metadata"
 	"google.golang.org/grpc/status"
-	"os"
-	"os/exec"
-	"strings"
-	"testing"
-	"time"
 )
 
 var conn *grpc.ClientConn
diff --git a/tests/core/concurrency/core_concurrency_test.go b/tests/core/concurrency/core_concurrency_test.go
index 4f1e4da..c9ca8f1 100644
--- a/tests/core/concurrency/core_concurrency_test.go
+++ b/tests/core/concurrency/core_concurrency_test.go
@@ -21,6 +21,11 @@
 	"context"
 	"errors"
 	"fmt"
+	"os"
+	"os/exec"
+	"strings"
+	"testing"
+
 	"github.com/golang/protobuf/ptypes/empty"
 	"github.com/google/uuid"
 	com "github.com/opencord/voltha-lib-go/v2/pkg/adapters/common"
@@ -30,10 +35,6 @@
 	"github.com/stretchr/testify/assert"
 	"google.golang.org/grpc"
 	"google.golang.org/grpc/metadata"
-	"os"
-	"os/exec"
-	"strings"
-	"testing"
 )
 
 var conns []*grpc.ClientConn
diff --git a/tests/kafka/kafka_client_test.go b/tests/kafka/kafka_client_test.go
index 0c3f657..7309840 100644
--- a/tests/kafka/kafka_client_test.go
+++ b/tests/kafka/kafka_client_test.go
@@ -19,6 +19,10 @@
 
 import (
 	"fmt"
+	"os"
+	"testing"
+	"time"
+
 	"github.com/golang/protobuf/ptypes"
 	"github.com/golang/protobuf/ptypes/any"
 	"github.com/google/uuid"
@@ -26,9 +30,6 @@
 	"github.com/opencord/voltha-lib-go/v2/pkg/log"
 	ic "github.com/opencord/voltha-protos/v2/go/inter_container"
 	"github.com/stretchr/testify/assert"
-	"os"
-	"testing"
-	"time"
 )
 
 /*
diff --git a/tests/utils/test_utils.go b/tests/utils/test_utils.go
index a0ebe56..c461f7e 100644
--- a/tests/utils/test_utils.go
+++ b/tests/utils/test_utils.go
@@ -15,6 +15,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package core
 
 import (
@@ -27,17 +28,20 @@
 	"github.com/golang/protobuf/ptypes/empty"
 	"github.com/google/uuid"
 	com "github.com/opencord/voltha-lib-go/v2/pkg/adapters/common"
+	"github.com/opencord/voltha-lib-go/v2/pkg/log"
 	"github.com/opencord/voltha-protos/v2/go/common"
 	ofp "github.com/opencord/voltha-protos/v2/go/openflow_13"
 	"github.com/opencord/voltha-protos/v2/go/voltha"
+
 	"google.golang.org/grpc"
 	"google.golang.org/grpc/codes"
 	"google.golang.org/grpc/metadata"
 	"google.golang.org/grpc/status"
 )
 
+// constant represents voltha serial number
 const (
-	VOLTHA_SERIAL_NUMBER_KEY = "voltha_serial_number"
+	VolthaSerialNumberKey = "voltha_serial_number"
 )
 
 func startKafka(composePath string) error {
@@ -128,24 +132,11 @@
 	return nil
 }
 
+// ListLogicalDevices lists all logical devices managed by the Voltha cluster
 func ListLogicalDevices(stub voltha.VolthaServiceClient) (*voltha.LogicalDevices, error) {
 	ui := uuid.New()
-	ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(VOLTHA_SERIAL_NUMBER_KEY, ui.String()))
-	if response, err := stub.ListLogicalDevices(ctx, &empty.Empty{}); err != nil {
-		return nil, err
-	} else {
-		return response, nil
-	}
-}
-
-func getNumUniPort(ld *voltha.LogicalDevice) int {
-	num := 0
-	for _, port := range ld.Ports {
-		if !port.RootPort {
-			num += 1
-		}
-	}
-	return num
+	ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(VolthaSerialNumberKey, ui.String()))
+	return stub.ListLogicalDevices(ctx, &empty.Empty{})
 }
 
 func sendCreateDeviceRequest(ctx context.Context, stub voltha.VolthaServiceClient, device *voltha.Device, ch chan interface{}) {
@@ -164,24 +155,8 @@
 	}
 }
 
-func sendEnableDeviceRequest(ctx context.Context, stub voltha.VolthaServiceClient, deviceId string, ch chan interface{}) {
-	if response, err := stub.EnableDevice(ctx, &common.ID{Id: deviceId}); err != nil {
-		ch <- err
-	} else {
-		ch <- response
-	}
-}
-
-func sendDisableDeviceRequest(ctx context.Context, stub voltha.VolthaServiceClient, deviceId string, ch chan interface{}) {
-	if response, err := stub.DisableDevice(ctx, &common.ID{Id: deviceId}); err != nil {
-		ch <- err
-	} else {
-		ch <- response
-	}
-}
-
-func sendDeleteDeviceRequest(ctx context.Context, stub voltha.VolthaServiceClient, deviceId string, ch chan interface{}) {
-	if response, err := stub.DeleteDevice(ctx, &common.ID{Id: deviceId}); err != nil {
+func sendEnableDeviceRequest(ctx context.Context, stub voltha.VolthaServiceClient, deviceID string, ch chan interface{}) {
+	if response, err := stub.EnableDevice(ctx, &common.ID{Id: deviceID}); err != nil {
 		ch <- err
 	} else {
 		ch <- response
@@ -189,21 +164,14 @@
 }
 
 func getDevices(ctx context.Context, stub voltha.VolthaServiceClient) (*voltha.Devices, error) {
-	if response, err := stub.ListDevices(ctx, &empty.Empty{}); err != nil {
-		return nil, err
-	} else {
-		return response, nil
-	}
+	return stub.ListDevices(ctx, &empty.Empty{})
 }
 
 func getLogicalDevices(ctx context.Context, stub voltha.VolthaServiceClient) (*voltha.LogicalDevices, error) {
-	if response, err := stub.ListLogicalDevices(ctx, &empty.Empty{}); err != nil {
-		return nil, err
-	} else {
-		return response, nil
-	}
+	return stub.ListLogicalDevices(ctx, &empty.Empty{})
 }
 
+// IsFlowPresent returns true if flow is present
 func IsFlowPresent(lookingFor *voltha.OfpFlowStats, flows []*voltha.OfpFlowStats) bool {
 	for _, f := range flows {
 		if f.String() == lookingFor.String() {
@@ -213,14 +181,11 @@
 	return false
 }
 
+// ListDevices lists all physical devices controlled by the Voltha cluster
 func ListDevices(stub voltha.VolthaServiceClient) (*voltha.Devices, error) {
 	ui := uuid.New()
-	ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(VOLTHA_SERIAL_NUMBER_KEY, ui.String()))
-	if devices, err := getDevices(ctx, stub); err == nil {
-		return devices, nil
-	} else {
-		return nil, err
-	}
+	ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(VolthaSerialNumberKey, ui.String()))
+	return getDevices(ctx, stub)
 }
 
 func sendFlow(ctx context.Context, stub voltha.VolthaServiceClient, flow *ofp.FlowTableUpdate, ch chan interface{}) {
@@ -231,20 +196,23 @@
 	}
 }
 
+// SetLogLevel sets log level to the given level
 func SetLogLevel(stub voltha.VolthaServiceClient, l voltha.Logging) error {
 	ui := uuid.New()
-	ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(VOLTHA_SERIAL_NUMBER_KEY, ui.String()))
+	ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(VolthaSerialNumberKey, ui.String()))
 	_, err := stub.UpdateLogLevel(ctx, &l)
 	return err
 }
 
+// SetAllLogLevel sets log level of all service to the given level
 func SetAllLogLevel(stub voltha.VolthaServiceClient, l voltha.Logging) error {
 	ui := uuid.New()
-	ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(VOLTHA_SERIAL_NUMBER_KEY, ui.String()))
+	ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(VolthaSerialNumberKey, ui.String()))
 	_, err := stub.UpdateLogLevel(ctx, &l)
 	return err
 }
 
+// SetupGrpcConnectionToCore sets up client connection to an RPC server.
 func SetupGrpcConnectionToCore(grpcHostIP string, grpcPort int) (voltha.VolthaServiceClient, error) {
 	grpcHost := fmt.Sprintf("%s:%d", grpcHostIP, grpcPort)
 	fmt.Println("Connecting to voltha using:", grpcHost)
@@ -255,9 +223,10 @@
 	return voltha.NewVolthaServiceClient(conn), nil
 }
 
+// VerifyLogicalDevices verifies all logical devices managed by the Voltha cluster
 func VerifyLogicalDevices(stub voltha.VolthaServiceClient, parentDevice *voltha.Device, numONUsPerOLT int) (*voltha.LogicalDevices, error) {
 	ui := uuid.New()
-	ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(VOLTHA_SERIAL_NUMBER_KEY, ui.String()))
+	ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(VolthaSerialNumberKey, ui.String()))
 	retrievedLogicalDevices, err := getLogicalDevices(ctx, stub)
 	if err != nil {
 		return nil, err
@@ -300,9 +269,10 @@
 	return retrievedLogicalDevices, nil
 }
 
+// VerifyDevices verifies all physical devices controlled by the Voltha cluster
 func VerifyDevices(stub voltha.VolthaServiceClient, numONUsPerOLT int) error {
 	ui := uuid.New()
-	ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(VOLTHA_SERIAL_NUMBER_KEY, ui.String()))
+	ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(VolthaSerialNumberKey, ui.String()))
 	retrievedDevices, err := getDevices(ctx, stub)
 	if err != nil {
 		return err
@@ -381,10 +351,11 @@
 	return true
 }
 
+// WaitForAdapterRegistration waits on channel for response of list adapters
 func WaitForAdapterRegistration(stub voltha.VolthaServiceClient, requiredAdapterNames []string, timeout int) (*voltha.Adapters, error) {
 	fmt.Println("Waiting for adapter registration ...")
 	ui := uuid.New()
-	ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(VOLTHA_SERIAL_NUMBER_KEY, ui.String()))
+	ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(VolthaSerialNumberKey, ui.String()))
 	ch := make(chan interface{})
 	defer close(ch)
 	for {
@@ -408,9 +379,10 @@
 	}
 }
 
+// PreProvisionDevice pre-provisions a new physical device
 func PreProvisionDevice(stub voltha.VolthaServiceClient) (*voltha.Device, error) {
 	ui := uuid.New()
-	ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(VOLTHA_SERIAL_NUMBER_KEY, ui.String()))
+	ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(VolthaSerialNumberKey, ui.String()))
 	randomMacAddress := strings.ToUpper(com.GetRandomMacAddress())
 	device := &voltha.Device{Type: "simulated_olt", MacAddress: randomMacAddress}
 	ch := make(chan interface{})
@@ -427,10 +399,13 @@
 	return nil, status.Errorf(codes.Unknown, "cannot provision device:{%v}", device)
 }
 
+// EnableDevice - if the device was in pre-provisioned state then it
+// will transition to ENABLED state.  If it was is DISABLED state then it
+// will transition to ENABLED state as well.
 func EnableDevice(stub voltha.VolthaServiceClient, device *voltha.Device, numONUs int) error {
 	if device.AdminState == voltha.AdminState_PREPROVISIONED {
 		ui := uuid.New()
-		ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(VOLTHA_SERIAL_NUMBER_KEY, ui.String()))
+		ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(VolthaSerialNumberKey, ui.String()))
 		ch := make(chan interface{})
 		defer close(ch)
 		go sendEnableDeviceRequest(ctx, stub, device.Id, ch)
@@ -446,9 +421,10 @@
 	return status.Errorf(codes.Unknown, "cannot enable device:{%s}", device.Id)
 }
 
+// UpdateFlow updates flow table for logical device
 func UpdateFlow(stub voltha.VolthaServiceClient, flow *ofp.FlowTableUpdate) error {
 	ui := uuid.New()
-	ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(VOLTHA_SERIAL_NUMBER_KEY, ui.String()))
+	ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(VolthaSerialNumberKey, ui.String()))
 	ch := make(chan interface{})
 	defer close(ch)
 	go sendFlow(ctx, stub, flow, ch)
@@ -463,6 +439,7 @@
 	return status.Errorf(codes.Unknown, "cannot add flow:{%v}", flow)
 }
 
+// StartSimulatedEnv starts kafka, etcd, olt, onu adapters, core
 func StartSimulatedEnv(composePath string) error {
 	fmt.Println("Starting simulated environment ...")
 	// Start kafka and Etcd
@@ -490,10 +467,23 @@
 	return nil
 }
 
+// StopSimulatedEnv stops kafka, etcd, olt, onu adapters, core
 func StopSimulatedEnv(composePath string) error {
-	stopSimulatedOLTAndONUAdapters(composePath)
-	stopCore(composePath)
-	stopKafka(composePath)
-	stopEtcd(composePath)
+	err := stopSimulatedOLTAndONUAdapters(composePath)
+	if err != nil {
+		log.Errorw("unable-to-stop-simulated-olt-onu-adapters", log.Fields{"error": err})
+	}
+	err = stopCore(composePath)
+	if err != nil {
+		log.Errorw("unable-to-stop-core", log.Fields{"error": err})
+	}
+	err = stopKafka(composePath)
+	if err != nil {
+		log.Errorw("unable-to-stop-kafka", log.Fields{"error": err})
+	}
+	err = stopEtcd(composePath)
+	if err != nil {
+		log.Errorw("unable-to-stop-etcd", log.Fields{"error": err})
+	}
 	return nil
 }