VOL-1577 - General cleanup (gofmt, go vet, go test, dep check)
Change-Id: I536b2746b8bd266f3e75aeccc65bfe7468f1b44a
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()