[VOL-5374] - Upgrade go version to v1.23
Change-Id: I86c21c482e61b358023119620b87032f2ea04c6d
Signed-off-by: Akash Reddy Kankanala <akash.kankanala@radisys.com>
[VOL-5374] - Upgrade go version to v1.23
Change-Id: Ie653d5c992aa3ff6624916d65009e2efbe0ed3f5
Signed-off-by: Akash Reddy Kankanala <akash.kankanala@radisys.com>
diff --git a/rw_core/test/core_nbi_handler_multi_test.go b/rw_core/test/core_nbi_handler_multi_test.go
index f823f0f..471bc2e 100755
--- a/rw_core/test/core_nbi_handler_multi_test.go
+++ b/rw_core/test/core_nbi_handler_multi_test.go
@@ -141,7 +141,7 @@
return test
}
-func (nb *NBTest) startGRPCCore(ctx context.Context, t *testing.T) (coreEndpoint, nbiEndpoint string) {
+func (nb *NBTest) startGRPCCore(ctx context.Context) (coreEndpoint, nbiEndpoint string) {
// Setup the configs
cfg := &config.RWCoreFlags{}
cfg.ParseCommandArguments([]string{})
@@ -511,9 +511,7 @@
// Create a logical device monitor will automatically send trap and eapol flows to the devices being enables
var wg sync.WaitGroup
wg.Add(1)
- subCtx, cancel := context.WithCancel(context.Background())
- defer cancel()
- go nb.monitorLogicalDevices(subCtx, t, nbi, 1, nb.numONUPerOLT, &wg, false, false, oltDevice.Id, eventCh)
+ go nb.monitorLogicalDevices(t, nbi, 1, nb.numONUPerOLT, &wg, false, false, oltDevice.Id, eventCh)
// Wait for the logical device to be in the ready state
var vldFunction = func(ports []*voltha.LogicalPort) bool {
@@ -781,7 +779,7 @@
return oltDevice, err
}
-func (nb *NBTest) testEnableDeviceFailed(t *testing.T, nbi voltha.VolthaServiceClient, oltDeviceType string) {
+func (nb *NBTest) testEnableDeviceFailed(t *testing.T, nbi voltha.VolthaServiceClient) {
//Create a device that has no adapter registered
macAddress := getRandomMacAddress()
oltDeviceNoAdapter, err := nbi.CreateDevice(getContext(), &voltha.Device{Type: "noAdapterRegistered", MacAddress: macAddress})
@@ -816,9 +814,7 @@
//Create a logical device monitor will automatically send trap and eapol flows to the devices being enables
var wg sync.WaitGroup
wg.Add(1)
- subCtx, cancel := context.WithCancel(context.Background())
- defer cancel()
- go nb.monitorLogicalDevices(subCtx, t, nbi, 1, nb.numONUPerOLT, &wg, false, false, oltDevice.Id, eventCh)
+ go nb.monitorLogicalDevices(t, nbi, 1, nb.numONUPerOLT, &wg, false, false, oltDevice.Id, eventCh)
// Wait for the logical device to be in the ready state
var vldFunction = func(ports []*voltha.LogicalPort) bool {
@@ -1339,7 +1335,7 @@
assert.Nil(t, err)
}
-func (nb *NBTest) sendTrapFlows(t *testing.T, nbi voltha.VolthaServiceClient, logicalDeviceID string, ports []*voltha.LogicalPort, meterID uint64, startingVlan int) (numNNIPorts, numUNIPorts int) {
+func (nb *NBTest) sendTrapFlows(t *testing.T, nbi voltha.VolthaServiceClient, logicalDeviceID string, ports []*voltha.LogicalPort) (numNNIPorts, numUNIPorts int) {
// Send flows for the parent device
var nniPorts []*voltha.LogicalPort
var uniPorts []*voltha.LogicalPort
@@ -1526,7 +1522,6 @@
}
func (nb *NBTest) monitorLogicalDevices(
- ctx context.Context,
t *testing.T,
nbi voltha.VolthaServiceClient,
numNNIPorts int,
@@ -1615,7 +1610,7 @@
// Send initial set of Trap flows
startingVlan := 4091
- nb.sendTrapFlows(t, nbi, logicalDeviceID, ports.Items, uint64(meterID), startingVlan)
+ nb.sendTrapFlows(t, nbi, logicalDeviceID, ports.Items)
//Listen for port events
processedNniLogicalPorts := 0
@@ -1689,9 +1684,7 @@
// Create a logical device monitor will automatically send trap and eapol flows to the devices being enables
var wg sync.WaitGroup
wg.Add(1)
- subCtx, cancel := context.WithCancel(context.Background())
- defer cancel()
- go nb.monitorLogicalDevices(subCtx, t, nbi, 1, nb.numONUPerOLT, &wg, true, false, oltDevice.Id, eventCh)
+ go nb.monitorLogicalDevices(t, nbi, 1, nb.numONUPerOLT, &wg, true, false, oltDevice.Id, eventCh)
// Wait for the logical device to be in the ready state
var vldFunction = func(ports []*voltha.LogicalPort) bool {
@@ -1946,7 +1939,7 @@
nb.testDeleteDeviceFailure(t, nbi, oltDeviceType)
////Test failed enable device
- nb.testEnableDeviceFailed(t, nbi, oltDeviceType)
+ nb.testEnableDeviceFailed(t, nbi)
//Test Enable a device
nb.testEnableDevice(t, nbi, oltDeviceType)
@@ -2008,7 +2001,7 @@
func setUpCore(ctx context.Context, t *testing.T, nb *NBTest) (voltha.VolthaServiceClient, string) {
// Start the Core
- coreAPIEndpoint, nbiEndpoint := nb.startGRPCCore(ctx, t)
+ coreAPIEndpoint, nbiEndpoint := nb.startGRPCCore(ctx)
// Wait until the core is ready
start := time.Now()
diff --git a/rw_core/test/utils.go b/rw_core/test/utils.go
index dfd28da..db1b28b 100644
--- a/rw_core/test/utils.go
+++ b/rw_core/test/utils.go
@@ -20,18 +20,17 @@
import (
"bufio"
"context"
+ "crypto/rand"
"encoding/json"
"fmt"
+ "io"
"os"
"path/filepath"
"strings"
"testing"
- "time"
ca "github.com/opencord/voltha-protos/v5/go/core_adapter"
- "math/rand"
-
"github.com/opencord/voltha-go/rw_core/config"
cm "github.com/opencord/voltha-go/rw_core/mocks"
"github.com/opencord/voltha-lib-go/v7/pkg/db/kvstore"
@@ -51,11 +50,11 @@
)
type AdapterInfo struct {
- TotalReplica int32
Vendor string
DeviceType string
ChildDeviceType string
ChildVendor string
+ TotalReplica int32
}
// prettyPrintDeviceUpdateLog is used just for debugging and exploring the Core logs
@@ -100,16 +99,14 @@
if err := json.Unmarshal([]byte(input), &logEntry); err != nil {
logger.Fatal(context.Background(), err)
}
- fmt.Println(
- fmt.Sprintf(
- "%s\t%s\t%s\t%-30.30q\t%-16.16s\t%-25.25s\t%s",
- logEntry.Ts,
- logEntry.DeviceID,
- logEntry.Status,
- logEntry.RPC,
- logEntry.RequestedBy,
- logEntry.StateChange,
- logEntry.Description))
+ fmt.Printf("%s\t%s\t%s\t%-30.30q\t%-16.16s\t%-25.25s\t%s",
+ logEntry.Ts,
+ logEntry.DeviceID,
+ logEntry.Status,
+ logEntry.RPC,
+ logEntry.RequestedBy,
+ logEntry.StateChange,
+ logEntry.Description)
}
}
@@ -317,13 +314,14 @@
// getRandomMacAddress returns a random mac address
func getRandomMacAddress() string {
- rand.Seed(time.Now().UnixNano() / int64(rand.Intn(255)+1))
+ mac := make([]byte, 6)
+ if _, err := io.ReadFull(rand.Reader, mac); err != nil {
+ fmt.Println("Error", err)
+ }
+
+ // Ensure the locally administered bit is set and the unicast bit is cleared
+ mac[0] = (mac[0] & 0xfe) | 0x02
+
return fmt.Sprintf("%02x:%02x:%02x:%02x:%02x:%02x",
- rand.Intn(255),
- rand.Intn(255),
- rand.Intn(255),
- rand.Intn(255),
- rand.Intn(255),
- rand.Intn(255),
- )
+ mac[0], mac[1], mac[2], mac[3], mac[4], mac[5])
}