VOL-1577 - General cleanup (gofmt, go vet, go test, dep check)

Change-Id: I536b2746b8bd266f3e75aeccc65bfe7468f1b44a
diff --git a/tests/afrouter/suites/test2/test2.go b/tests/afrouter/suites/test2/test2.go
index 9f80d37..258cb64 100644
--- a/tests/afrouter/suites/test2/test2.go
+++ b/tests/afrouter/suites/test2/test2.go
@@ -1,3 +1,5 @@
+// +build integration
+
 /*
  * Copyright 2018-present Open Networking Foundation
 
diff --git a/tests/afrouter/suites/test3/test3.go b/tests/afrouter/suites/test3/test3.go
index 4c546ba..2fb561c 100644
--- a/tests/afrouter/suites/test3/test3.go
+++ b/tests/afrouter/suites/test3/test3.go
@@ -1,3 +1,5 @@
+// +build integration
+
 /*
  * Copyright 2018-present Open Networking Foundation
 
diff --git a/tests/afrouter/tester.go b/tests/afrouter/tester.go
index f3ba2aa..94972ed 100644
--- a/tests/afrouter/tester.go
+++ b/tests/afrouter/tester.go
@@ -1,3 +1,5 @@
+// +build integration
+
 /*
  * Copyright 2018-present Open Networking Foundation
 
diff --git a/tests/afrouter/tester/main.go b/tests/afrouter/tester/main.go
index 8190fe6..1037de0 100644
--- a/tests/afrouter/tester/main.go
+++ b/tests/afrouter/tester/main.go
@@ -1,3 +1,5 @@
+// +build integration
+
 /*
  * Copyright 2018-present Open Networking Foundation
 
@@ -26,9 +28,9 @@
 func main() {
 	// Setup logging
 	/*
-	if _, err := log.SetDefaultLogger(log.JSON, 0, nil); err != nil {
-		log.With(log.Fields{"error": err}).Fatal("Cannot setup logging")
-	}
+		if _, err := log.SetDefaultLogger(log.JSON, 0, nil); err != nil {
+			log.With(log.Fields{"error": err}).Fatal("Cannot setup logging")
+		}
 	*/
 
 	defer log.CleanUp()
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 47e4472..4eb5d1c 100644
--- a/tests/core/api/grpc_nbi_api_handler_client_test.go
+++ b/tests/core/api/grpc_nbi_api_handler_client_test.go
@@ -1,3 +1,5 @@
+// +build integration
+
 /*
  * Copyright 2018-present Open Networking Foundation
 
@@ -13,13 +15,14 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package api
 
 import (
 	"context"
 	"fmt"
-	com "github.com/opencord/voltha-go/adapters/common"
 	"github.com/golang/protobuf/ptypes/empty"
+	com "github.com/opencord/voltha-go/adapters/common"
 	"github.com/opencord/voltha-go/common/log"
 	"github.com/opencord/voltha-protos/go/common"
 	"github.com/opencord/voltha-protos/go/openflow_13"
@@ -121,7 +124,7 @@
 func startKafka() {
 	fmt.Println("Starting Kafka and Etcd ...")
 	command := "docker-compose"
-	cmd := exec.Command(command, "-f", "../../compose/docker-compose-zk-kafka-test.yml", "up", "-d")
+	cmd := exec.Command(command, "-f", "../../../compose/docker-compose-zk-kafka-test.yml", "up", "-d")
 	if err := cmd.Run(); err != nil {
 		log.Fatal(err)
 	}
@@ -130,7 +133,7 @@
 func startEtcd() {
 	fmt.Println("Starting Etcd ...")
 	command := "docker-compose"
-	cmd := exec.Command(command, "-f", "../../compose/docker-compose-etcd.yml", "up", "-d")
+	cmd := exec.Command(command, "-f", "../../../compose/docker-compose-etcd.yml", "up", "-d")
 	if err := cmd.Run(); err != nil {
 		log.Fatal(err)
 	}
@@ -139,7 +142,7 @@
 func stopKafka() {
 	fmt.Println("Stopping Kafka and Etcd ...")
 	command := "docker-compose"
-	cmd := exec.Command(command, "-f", "../../compose/docker-compose-zk-kafka-test.yml", "down")
+	cmd := exec.Command(command, "-f", "../../../compose/docker-compose-zk-kafka-test.yml", "down")
 	if err := cmd.Run(); err != nil {
 		// ignore error - as this is mostly due network being left behind as its being used by other
 		// containers
@@ -150,7 +153,7 @@
 func stopEtcd() {
 	fmt.Println("Stopping Etcd ...")
 	command := "docker-compose"
-	cmd := exec.Command(command, "-f", "../../compose/docker-compose-etcd.yml", "down")
+	cmd := exec.Command(command, "-f", "../../../compose/docker-compose-etcd.yml", "down")
 	if err := cmd.Run(); err != nil {
 		// ignore error - as this is mostly due network being left behind as its being used by other
 		// containers
@@ -161,7 +164,7 @@
 func startCore() {
 	fmt.Println("Starting voltha core ...")
 	command := "docker-compose"
-	cmd := exec.Command(command, "-f", "../../compose/rw_core.yml", "up", "-d")
+	cmd := exec.Command(command, "-f", "../../../compose/rw_core.yml", "up", "-d")
 	if err := cmd.Run(); err != nil {
 		log.Fatal(err)
 	}
@@ -170,7 +173,7 @@
 func stopCore() {
 	fmt.Println("Stopping voltha core ...")
 	command := "docker-compose"
-	cmd := exec.Command(command, "-f", "../../compose/rw_core.yml", "down")
+	cmd := exec.Command(command, "-f", "../../../compose/rw_core.yml", "down")
 	if err := cmd.Run(); err != nil {
 		// ignore error - as this is mostly due network being left behind as its being used by other
 		// containers
@@ -181,7 +184,7 @@
 func startSimulatedOLTAndONUAdapters() {
 	fmt.Println("Starting simulated OLT and ONU adapters ...")
 	command := "docker-compose"
-	cmd := exec.Command(command, "-f", "../../compose/adapters-simulated.yml", "up", "-d")
+	cmd := exec.Command(command, "-f", "../../../compose/adapters-simulated.yml", "up", "-d")
 	if err := cmd.Run(); err != nil {
 		log.Fatal(err)
 	}
@@ -190,7 +193,7 @@
 func stopSimulatedOLTAndONUAdapters() {
 	fmt.Println("Stopping simulated OLT and ONU adapters ...")
 	command := "docker-compose"
-	cmd := exec.Command(command, "-f", "../../compose/adapters-simulated.yml", "down")
+	cmd := exec.Command(command, "-f", "../../../compose/adapters-simulated.yml", "down")
 	if err := cmd.Run(); err != nil {
 		// ignore error - as this is mostly due network being left behind as its being used by other
 		// containers
@@ -198,7 +201,6 @@
 	}
 }
 
-
 func TestListDeviceIds(t *testing.T) {
 	fmt.Println("Testing list Devices Ids ...")
 	//0. Start kafka and Ectd
@@ -335,7 +337,7 @@
 	for i := 0; i < numberOfOLTDevices; i++ {
 		ctx := context.Background()
 		randomMacAddress := strings.ToUpper(com.GetRandomMacAddress())
-		device := &voltha.Device{Type: "simulated_olt", MacAddress:randomMacAddress}
+		device := &voltha.Device{Type: "simulated_olt", MacAddress: randomMacAddress}
 		response, err := stub.CreateDevice(ctx, device)
 		log.Infow("response", log.Fields{"res": response, "error": err})
 		assert.Nil(t, err)
@@ -345,7 +347,7 @@
 	//4. Enable all the devices
 	for id, _ := range devices {
 		ctx := context.Background()
-		response, err := stub.EnableDevice(ctx, &common.ID{Id:id})
+		response, err := stub.EnableDevice(ctx, &common.ID{Id: id})
 		log.Infow("response", log.Fields{"res": response, "error": err})
 		assert.Nil(t, err)
 	}
@@ -366,7 +368,7 @@
 	log.Infow("response", log.Fields{"res": response, "error": err})
 	assert.Nil(t, err)
 	assert.Equal(t, len(devices)*2, len(response.Items))
-	for _, d := range (response.Items) {
+	for _, d := range response.Items {
 		devices[d.Id] = d
 		assert.Equal(t, d.AdminState, voltha.AdminState_ENABLED)
 	}
@@ -377,7 +379,7 @@
 	log.Infow("response", log.Fields{"res": response, "error": lerr})
 	assert.Nil(t, lerr)
 	assert.Equal(t, numberOfOLTDevices, len(lresponse.Items))
-	for _, ld := range (lresponse.Items) {
+	for _, ld := range lresponse.Items {
 		logicalDevices[ld.Id] = ld
 		// Ensure each logical device have two ports
 		assert.Equal(t, 2, len(ld.Ports))
@@ -387,7 +389,7 @@
 	for id, d := range devices {
 		ctx := context.Background()
 		if d.Type == "simulated_onu" {
-			response, err := stub.DisableDevice(ctx, &common.ID{Id:id})
+			response, err := stub.DisableDevice(ctx, &common.ID{Id: id})
 			log.Infow("response", log.Fields{"res": response, "error": err})
 			assert.Nil(t, err)
 		}
@@ -401,7 +403,7 @@
 	log.Infow("response", log.Fields{"res": response, "error": err})
 	assert.Nil(t, err)
 	assert.Equal(t, len(devices), len(response.Items))
-	for _, d := range (response.Items) {
+	for _, d := range response.Items {
 		if d.Type == "simulated_onu" {
 			assert.Equal(t, d.AdminState, voltha.AdminState_DISABLED)
 			devices[d.Id] = d
@@ -415,7 +417,7 @@
 	log.Infow("response", log.Fields{"res": response, "error": lerr})
 	assert.Nil(t, lerr)
 	assert.Equal(t, numberOfOLTDevices, len(lresponse.Items))
-	for _, ld := range (lresponse.Items) {
+	for _, ld := range lresponse.Items {
 		logicalDevices[ld.Id] = ld
 		// Ensure each logical device have one port - only olt port
 		assert.Equal(t, 1, len(ld.Ports))
@@ -425,7 +427,7 @@
 	for id, d := range devices {
 		ctx := context.Background()
 		if d.Type == "simulated_onu" {
-			response, err := stub.EnableDevice(ctx, &common.ID{Id:id})
+			response, err := stub.EnableDevice(ctx, &common.ID{Id: id})
 			log.Infow("response", log.Fields{"res": response, "error": err})
 			assert.Nil(t, err)
 		}
@@ -439,7 +441,7 @@
 	log.Infow("response", log.Fields{"res": response, "error": err})
 	assert.Nil(t, err)
 	assert.Equal(t, len(devices), len(response.Items))
-	for _, d := range (response.Items) {
+	for _, d := range response.Items {
 		assert.Equal(t, d.AdminState, voltha.AdminState_ENABLED)
 		devices[d.Id] = d
 	}
@@ -474,7 +476,6 @@
 	//stopEtcd()
 }
 
-
 func TestGetDevice(t *testing.T) {
 	var id common.ID
 	id.Id = "anyid"
diff --git a/tests/core/concurrency/core_concurrency_test.go b/tests/core/concurrency/core_concurrency_test.go
index 42f5de0..5fbda49 100644
--- a/tests/core/concurrency/core_concurrency_test.go
+++ b/tests/core/concurrency/core_concurrency_test.go
@@ -1,3 +1,5 @@
+// +build integration
+
 /*
  * Copyright 2018-present Open Networking Foundation
 
@@ -62,7 +64,7 @@
 	devices = make(map[string]*voltha.Device)
 }
 
-func connectToCore(port int) (voltha.VolthaServiceClient, error)  {
+func connectToCore(port int) (voltha.VolthaServiceClient, error) {
 	grpcHostIP := os.Getenv("DOCKER_HOST_IP")
 	grpcHost := fmt.Sprintf("%s:%d", grpcHostIP, port)
 	conn, err := grpc.Dial(grpcHost, grpc.WithInsecure())
@@ -192,8 +194,7 @@
 	}
 }
 
-
-func sendCreateDeviceRequest(ctx context.Context, stub voltha.VolthaServiceClient, device *voltha.Device, ch chan interface{} ) {
+func sendCreateDeviceRequest(ctx context.Context, stub voltha.VolthaServiceClient, device *voltha.Device, ch chan interface{}) {
 	fmt.Println("Sending  create device ...")
 	if response, err := stub.CreateDevice(ctx, device); err != nil {
 		ch <- err
@@ -202,9 +203,9 @@
 	}
 }
 
-func sendEnableDeviceRequest(ctx context.Context, stub voltha.VolthaServiceClient, deviceId string, ch chan interface{} ) {
+func sendEnableDeviceRequest(ctx context.Context, stub voltha.VolthaServiceClient, deviceId string, ch chan interface{}) {
 	fmt.Println("Sending enable device ...")
-	if response, err := stub.EnableDevice(ctx, &common.ID{Id:deviceId}); err != nil {
+	if response, err := stub.EnableDevice(ctx, &common.ID{Id: deviceId}); err != nil {
 		ch <- err
 	} else {
 		ch <- response
@@ -253,7 +254,7 @@
 	ui := uuid.New()
 	ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(volthaSerialNumberKey, ui.String()))
 	randomMacAddress := strings.ToUpper(com.GetRandomMacAddress())
-	device := &voltha.Device{Type: "simulated_olt", MacAddress:randomMacAddress}
+	device := &voltha.Device{Type: "simulated_olt", MacAddress: randomMacAddress}
 	ch := make(chan interface{})
 	defer close(ch)
 	requestNum := 0
@@ -296,7 +297,7 @@
 			requestNum := 0
 			for _, stub := range stubs {
 				go sendEnableDeviceRequest(ctx, stub, deviceId, ch)
-				requestNum +=1
+				requestNum += 1
 			}
 			receivedResponse := 0
 			var err error
@@ -308,7 +309,7 @@
 				if !ok {
 				} else if er, ok := res.(error); ok {
 					err = er
-				} else if _ , ok := res.(*empty.Empty); ok {
+				} else if _, ok := res.(*empty.Empty); ok {
 					validResponseReceived = true
 				}
 				if receivedResponse == requestNum {
@@ -324,19 +325,22 @@
 	return nil
 }
 
-
 func TestConcurrentRequests(t *testing.T) {
 	fmt.Println("Testing Concurrent requests ...")
 
 	////0. Start kafka and Ectd
-	//startKafka()
-	//startEtcd()
+	startKafka()
+	defer stopKafka()
+	startEtcd()
+	defer stopKafka()
 	//
 	////1. Start the core
-	//startCores()
+	startCores()
+	defer stopCores()
 	//
 	////2. Start the simulated adapters
-	//startSimulatedOLTAndONUAdapters()
+	startSimulatedOLTAndONUAdapters()
+	defer stopSimulatedOLTAndONUAdapters()
 	//
 	//// Wait until the core and adapters sync up
 	//time.Sleep(10 * time.Second)
@@ -364,7 +368,6 @@
 	//stopEtcd()
 }
 
-
 func shutdown() {
 	for _, conn := range conns {
 		conn.Close()
diff --git a/tests/kafka/kafka_client_test.go b/tests/kafka/kafka_client_test.go
index b4fc0cf..f6eadff 100644
--- a/tests/kafka/kafka_client_test.go
+++ b/tests/kafka/kafka_client_test.go
@@ -1,3 +1,5 @@
+// +build integration
+
 /*
  * Copyright 2018-present Open Networking Foundation
 
diff --git a/tests/kafka/kafka_inter_container_messaging_test.go b/tests/kafka/kafka_inter_container_messaging_test.go
index d6a8e8b..6a6dbc2 100644
--- a/tests/kafka/kafka_inter_container_messaging_test.go
+++ b/tests/kafka/kafka_inter_container_messaging_test.go
@@ -1,3 +1,5 @@
+// +build integration
+
 /*
  * Copyright 2018-present Open Networking Foundation
 
@@ -21,9 +23,9 @@
 	"github.com/google/uuid"
 	"github.com/opencord/voltha-go/common/log"
 	kk "github.com/opencord/voltha-go/kafka"
+	rhp "github.com/opencord/voltha-go/rw_core/core"
 	ic "github.com/opencord/voltha-protos/go/inter_container"
 	"github.com/opencord/voltha-protos/go/voltha"
-	rhp "github.com/opencord/voltha-go/rw_core/core"
 	"github.com/stretchr/testify/assert"
 	"os"
 	"testing"
@@ -34,6 +36,10 @@
 Prerequite:  Start the kafka/zookeeper containers.
 */
 
+const (
+	TEST_RPC_KEY = ""
+)
+
 var coreKafkaProxy *kk.InterContainerProxy
 var adapterKafkaProxy *kk.InterContainerProxy
 var kafkaPartitionClient kk.Client
@@ -170,7 +176,7 @@
 	rpc := "IncorrectAPI"
 	topic := kk.Topic{Name: "Core"}
 	start := time.Now()
-	status, result := adapterKafkaProxy.InvokeRPC(nil, rpc, &topic, &topic, true, args...)
+	status, result := adapterKafkaProxy.InvokeRPC(nil, rpc, &topic, &topic, true, TEST_RPC_KEY, args...)
 	elapsed := time.Since(start)
 	log.Infow("Result", log.Fields{"status": status, "result": result, "time": elapsed})
 	assert.Equal(t, status, false)
@@ -193,7 +199,7 @@
 	rpc := "GetDevice"
 	topic := kk.Topic{Name: "Core"}
 	start := time.Now()
-	status, result := adapterKafkaProxy.InvokeRPC(nil, rpc, &topic, &topic, true, args...)
+	status, result := adapterKafkaProxy.InvokeRPC(nil, rpc, &topic, &topic, true, TEST_RPC_KEY, args...)
 	elapsed := time.Since(start)
 	log.Infow("Result", log.Fields{"status": status, "result": result, "time": elapsed})
 	assert.Equal(t, status, false)
@@ -220,7 +226,7 @@
 	ctx, cancel := context.WithTimeout(context.Background(), timeout)
 	defer cancel()
 	start := time.Now()
-	status, result := adapterKafkaProxy.InvokeRPC(ctx, rpc, &topic, &topic, true, args...)
+	status, result := adapterKafkaProxy.InvokeRPC(ctx, rpc, &topic, &topic, true, TEST_RPC_KEY, args...)
 	elapsed := time.Since(start)
 	log.Infow("Result", log.Fields{"status": status, "result": result, "time": elapsed})
 	assert.Equal(t, status, true)
@@ -245,7 +251,7 @@
 	ctx, cancel := context.WithTimeout(context.Background(), timeout)
 	defer cancel()
 	start := time.Now()
-	status, result := adapterKafkaProxy.InvokeRPC(ctx, rpc, &topic, &topic, true, args...)
+	status, result := adapterKafkaProxy.InvokeRPC(ctx, rpc, &topic, &topic, true, TEST_RPC_KEY, args...)
 	elapsed := time.Since(start)
 	log.Infow("Result", log.Fields{"status": status, "result": result, "time": elapsed})
 	assert.Equal(t, status, false)
@@ -268,7 +274,7 @@
 	topic := kk.Topic{Name: "Core"}
 	expectedResponse := &voltha.Device{Id: trnsId}
 	start := time.Now()
-	status, result := adapterKafkaProxy.InvokeRPC(nil, rpc, &topic, &topic, true, args...)
+	status, result := adapterKafkaProxy.InvokeRPC(nil, rpc, &topic, &topic, true, TEST_RPC_KEY, args...)
 	elapsed := time.Since(start)
 	log.Infow("Result", log.Fields{"status": status, "result": result, "time": elapsed})
 	assert.Equal(t, status, true)
@@ -291,7 +297,7 @@
 	topic := kk.Topic{Name: "Core"}
 	expectedResponse := &voltha.Device{Id: trnsId}
 	start := time.Now()
-	status, result := adapterKafkaProxy.InvokeRPC(nil, rpc, &topic, &topic, true, args...)
+	status, result := adapterKafkaProxy.InvokeRPC(nil, rpc, &topic, &topic, true, TEST_RPC_KEY, args...)
 	elapsed := time.Since(start)
 	log.Infow("Result", log.Fields{"status": status, "result": result, "time": elapsed})
 	assert.Equal(t, status, true)
@@ -318,7 +324,7 @@
 	rpc := "GetPorts"
 	topic := kk.Topic{Name: "Core"}
 	start := time.Now()
-	status, result := adapterKafkaProxy.InvokeRPC(nil, rpc, &topic, &topic, true, args...)
+	status, result := adapterKafkaProxy.InvokeRPC(nil, rpc, &topic, &topic, true, TEST_RPC_KEY, args...)
 	elapsed := time.Since(start)
 	log.Infow("Result", log.Fields{"status": status, "result": result, "time": elapsed})
 	assert.Equal(t, status, true)
@@ -341,7 +347,7 @@
 	rpc := "GetPorts"
 	topic := kk.Topic{Name: "Core"}
 	start := time.Now()
-	status, result := adapterKafkaProxy.InvokeRPC(nil, rpc, &topic, &topic, true, args...)
+	status, result := adapterKafkaProxy.InvokeRPC(nil, rpc, &topic, &topic, true, TEST_RPC_KEY, args...)
 	elapsed := time.Since(start)
 	log.Infow("Result", log.Fields{"status": status, "result": result, "time": elapsed})
 	assert.Equal(t, status, false)
@@ -385,7 +391,7 @@
 	rpc := "ChildDeviceDetected"
 	topic := kk.Topic{Name: "Core"}
 	start := time.Now()
-	status, result := adapterKafkaProxy.InvokeRPC(nil, rpc, &topic, &topic, true, args...)
+	status, result := adapterKafkaProxy.InvokeRPC(nil, rpc, &topic, &topic, true, TEST_RPC_KEY, args...)
 	elapsed := time.Since(start)
 	log.Infow("Result", log.Fields{"status": status, "result": result, "time": elapsed})
 	assert.Equal(t, status, true)
@@ -424,7 +430,7 @@
 	rpc := "ChildDeviceDetected"
 	topic := kk.Topic{Name: "Core"}
 	start := time.Now()
-	status, result := adapterKafkaProxy.InvokeRPC(nil, rpc, &topic, &topic, false, args...)
+	status, result := adapterKafkaProxy.InvokeRPC(nil, rpc, &topic, &topic, false, TEST_RPC_KEY, args...)
 	elapsed := time.Since(start)
 	log.Infow("Result", log.Fields{"status": status, "result": result, "time": elapsed})
 	assert.Equal(t, status, true)
@@ -453,7 +459,7 @@
 	rpc := "ChildDeviceDetected"
 	topic := kk.Topic{Name: "Core"}
 	start := time.Now()
-	status, result := adapterKafkaProxy.InvokeRPC(nil, rpc, &topic, &topic, true, args...)
+	status, result := adapterKafkaProxy.InvokeRPC(nil, rpc, &topic, &topic, true, TEST_RPC_KEY, args...)
 	elapsed := time.Since(start)
 	log.Infow("Result", log.Fields{"status": status, "result": result, "time": elapsed})
 	assert.Equal(t, status, false)
@@ -487,7 +493,7 @@
 	rpc := "DeviceStateUpdate"
 	topic := kk.Topic{Name: "Core"}
 	start := time.Now()
-	status, result := adapterKafkaProxy.InvokeRPC(nil, rpc, &topic, &topic, true, args...)
+	status, result := adapterKafkaProxy.InvokeRPC(nil, rpc, &topic, &topic, true, TEST_RPC_KEY, args...)
 	elapsed := time.Since(start)
 	log.Infow("Result", log.Fields{"status": status, "result": result, "time": elapsed})
 	assert.Equal(t, status, true)