vgc unit tests part 2
Change-Id: Iec7e27c73f90b5d40d36b52a4b71e97cf166798c
diff --git a/internal/pkg/application/application_test.go b/internal/pkg/application/application_test.go
index ca2e2b9..7670e3b 100644
--- a/internal/pkg/application/application_test.go
+++ b/internal/pkg/application/application_test.go
@@ -34,6 +34,8 @@
"go.uber.org/atomic"
)
+var test_data = "1234"
+
func TestVoltApplication_RestoreNbDeviceFromDb(t *testing.T) {
type args struct {
cntx context.Context
@@ -424,7 +426,7 @@
}
macAdd, _ := net.ParseMAC("ff:ff:ff:ff:ff:ff")
macPort := map[string]string{}
- macPort[macAdd.String()] = "1234"
+ macPort[macAdd.String()] = test_data
tests := []struct {
name string
args args
@@ -433,7 +435,7 @@
name: "Positive_Case_UpdateMacInPortMap",
args: args{
macAddr: macAdd,
- port: "1234",
+ port: test_data,
},
},
}
@@ -453,7 +455,7 @@
}
macAdd, _ := net.ParseMAC("ff:ff:ff:ff:ff:ff")
macPort := map[string]string{}
- macPort[macAdd.String()] = "1234"
+ macPort[macAdd.String()] = test_data
tests := []struct {
name string
args args
@@ -464,7 +466,7 @@
args: args{
macAddr: macAdd,
},
- want: "1234",
+ want: test_data,
},
}
for _, tt := range tests {
@@ -2375,3 +2377,323 @@
})
}
}
+
+func TestVoltApplication_GetDeviceFromPort(t *testing.T) {
+ type args struct {
+ port string
+ }
+ voltDev := &VoltDevice{
+ Name: "SDX6320031",
+ SerialNum: "SDX6320031",
+ NniDhcpTrapVid: 123,
+ NniPort: "16777216",
+ SouthBoundID: "49686e2d-618f-4e8e-bca0-442ab850a63a",
+ Ports: sync.Map{},
+ }
+ voltPort := &VoltPort{
+ Name: "16777216",
+ Device: "SDX6320031",
+ ID: 16777216,
+ State: PortStateDown,
+ ChannelPerSubAlarmRaised: false,
+ Type: VoltPortTypeNni,
+ }
+ tests := []struct {
+ name string
+ args args
+ want *VoltDevice
+ wantErr bool
+ }{
+ {
+ name: "Positive_Case_GetDeviceFromPort",
+ args: args{
+ port: "16777216",
+ },
+ want: voltDev,
+ wantErr: false,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ va := &VoltApplication{
+ DevicesDisc: sync.Map{},
+ PortsDisc: sync.Map{},
+ }
+ va.PortsDisc.Store("16777216", voltPort)
+ va.DevicesDisc.Store("SDX6320031", voltDev)
+ got, err := va.GetDeviceFromPort(tt.args.port)
+ if (err != nil) != tt.wantErr {
+ t.Errorf("VoltApplication.GetDeviceFromPort() error = %v, wantErr %v", err, tt.wantErr)
+ return
+ }
+ if !reflect.DeepEqual(got, tt.want) {
+ t.Errorf("VoltApplication.GetDeviceFromPort() = %v, want %v", got, tt.want)
+ }
+ })
+ }
+}
+
+func TestVoltApplication_GetPortID(t *testing.T) {
+ type args struct {
+ port string
+ }
+ voltPort := &VoltPort{
+ Name: "16777216",
+ Device: "SDX6320031",
+ ID: 16777216,
+ State: PortStateDown,
+ ChannelPerSubAlarmRaised: false,
+ Type: VoltPortTypeNni,
+ }
+ tests := []struct {
+ name string
+ args args
+ want uint32
+ wantErr bool
+ }{
+ {
+ name: "Positive_Case_GetPortID",
+ args: args{
+ port: "16777216",
+ },
+ want: 16777216,
+ wantErr: false,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ va := &VoltApplication{
+ PortsDisc: sync.Map{},
+ }
+ va.PortsDisc.Store("16777216", voltPort)
+ got, err := va.GetPortID(tt.args.port)
+ if (err != nil) != tt.wantErr {
+ t.Errorf("VoltApplication.GetPortID() error = %v, wantErr %v", err, tt.wantErr)
+ return
+ }
+ if got != tt.want {
+ t.Errorf("VoltApplication.GetPortID() = %v, want %v", got, tt.want)
+ }
+ })
+ }
+}
+
+func TestVoltApplication_GetPortName(t *testing.T) {
+ type args struct {
+ port uint32
+ }
+ voltPort := &VoltPort{
+ Name: "16777216",
+ Device: "SDX6320031",
+ ID: 16777216,
+ State: PortStateDown,
+ ChannelPerSubAlarmRaised: false,
+ Type: VoltPortTypeNni,
+ }
+ tests := []struct {
+ name string
+ args args
+ want string
+ wantErr bool
+ }{
+ {
+ name: "Positive_Case_GetPortID",
+ args: args{
+ port: 16777216,
+ },
+ want: "16777216",
+ wantErr: false,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ va := &VoltApplication{
+ PortsDisc: sync.Map{},
+ }
+ va.PortsDisc.Store("16777216", voltPort)
+ got, err := va.GetPortName(tt.args.port)
+ if (err != nil) != tt.wantErr {
+ t.Errorf("VoltApplication.GetPortName() error = %v, wantErr %v", err, tt.wantErr)
+ return
+ }
+ if got != tt.want {
+ t.Errorf("VoltApplication.GetPortName() = %v, want %v", got, tt.want)
+ }
+ })
+ }
+}
+
+func TestVoltApplication_PortUpInd(t *testing.T) {
+ type args struct {
+ cntx context.Context
+ device string
+ port string
+ }
+ voltDev := &VoltDevice{
+ Name: "SDX6320031",
+ SerialNum: "SDX6320031",
+ NniDhcpTrapVid: 123,
+ NniPort: "16777472",
+ SouthBoundID: "49686e2d-618f-4e8e-bca0-442ab850a63a",
+ Ports: sync.Map{},
+ VpvsBySvlan: util.NewConcurrentMap(),
+ }
+ voltPort := &VoltPort{
+ Name: "16777472",
+ Device: "SDX6320031",
+ ID: 16777472,
+ State: PortStateUp,
+ ChannelPerSubAlarmRaised: false,
+ Type: VoltPortTypeNni,
+ }
+ voltServ := &VoltService{
+ VoltServiceOper: VoltServiceOper{
+ Device: "SDX6320031",
+ },
+ VoltServiceCfg: VoltServiceCfg{
+ IsActivated: true,
+ },
+ }
+ voltPortVnets := make([]*VoltPortVnet, 0)
+ voltPortVnet := &VoltPortVnet{
+ Device: "SDX6320031",
+ Port: "16777472",
+ DeleteInProgress: false,
+ services: sync.Map{},
+ SVlan: 4096,
+ CVlan: 2310,
+ UniVlan: 4096,
+ SVlanTpid: 65,
+ servicesCount: atomic.NewUint64(1),
+ }
+ voltPortVnets = append(voltPortVnets, voltPortVnet)
+
+ tests := []struct {
+ name string
+ args args
+ }{
+ {
+ name: "Positive_Case_PortUpInd",
+ args: args{
+ cntx: context.Background(),
+ port: "16777472",
+ device: "SDX6320031",
+ },
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ va := &VoltApplication{
+ DevicesDisc: sync.Map{},
+ VnetsByPort: sync.Map{},
+ }
+ va.DevicesDisc.Store("SDX6320031", voltDev)
+ voltDev.Ports.Store("16777472", voltPort)
+ va.VnetsByPort.Store("16777472", voltPortVnets)
+ voltPortVnet.services.Store("SDX6320031-1_SDX6320031-1-4096-2310-4096-65", voltServ)
+ voltapp := GetApplication()
+ voltapp.DevicesDisc.Store("SDX6320031", voltDev)
+ dbintf := mocks.NewMockDBIntf(gomock.NewController(t))
+ db = dbintf
+ dbintf.EXPECT().PutVpv(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).AnyTimes()
+ va.PortUpInd(tt.args.cntx, tt.args.device, tt.args.port)
+ })
+ }
+}
+
+func TestVoltApplication_PortDownInd(t *testing.T) {
+ type args struct {
+ cntx context.Context
+ device string
+ port string
+ }
+ voltDev := &VoltDevice{
+ Name: "SDX6320031",
+ SerialNum: "SDX6320031",
+ NniDhcpTrapVid: 123,
+ NniPort: "16777472",
+ SouthBoundID: "49686e2d-618f-4e8e-bca0-442ab850a63a",
+ Ports: sync.Map{},
+ VpvsBySvlan: util.NewConcurrentMap(),
+ }
+ voltPort := &VoltPort{
+ Name: "16777472",
+ Device: "SDX6320031",
+ ID: 16777472,
+ State: PortStateDown,
+ ChannelPerSubAlarmRaised: false,
+ Type: VoltPortTypeNni,
+ }
+ voltPortVnets := make([]*VoltPortVnet, 0)
+ voltPortVnet := &VoltPortVnet{
+ Device: "SDX6320031",
+ Port: "16777472",
+ DeleteInProgress: false,
+ services: sync.Map{},
+ SVlan: 4096,
+ CVlan: 2310,
+ UniVlan: 4096,
+ SVlanTpid: 65,
+ servicesCount: atomic.NewUint64(1),
+ }
+ voltPortVnets = append(voltPortVnets, voltPortVnet)
+ tests := []struct {
+ name string
+ args args
+ }{
+ {
+ name: "Positive_Case_PortDownInd",
+ args: args{
+ cntx: context.Background(),
+ port: "16777472",
+ device: "SDX6320031",
+ },
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ va := &VoltApplication{}
+ va.DevicesDisc.Store("SDX6320031", voltDev)
+ voltDev.Ports.Store("16777472", voltPort)
+ va.VnetsByPort.Store("16777472", voltPortVnets)
+ voltApp := GetApplication()
+ voltApp.DevicesDisc.Store("SDX6320031", voltDev)
+ va.PortDownInd(tt.args.cntx, tt.args.device, tt.args.port)
+ })
+ }
+}
+
+func TestVoltApplication_UpdateDeviceSerialNumberList(t *testing.T) {
+ type args struct {
+ oldOltSlNo string
+ newOltSlNo string
+ }
+ voltDev := &VoltDevice{
+ Name: "49686e2d-618f-4e8e-bca0",
+ SerialNum: "SDX6320031",
+ NniDhcpTrapVid: 123,
+ NniPort: "16777472",
+ SouthBoundID: "49686e2d-618f-4e8e-bca0-442ab850a63a",
+ Ports: sync.Map{},
+ VpvsBySvlan: util.NewConcurrentMap(),
+ }
+ tests := []struct {
+ name string
+ args args
+ }{
+ {
+ name: "Positive_Case_UpdateDeviceSerialNumberList",
+ args: args{
+ oldOltSlNo: "SDX6320030",
+ newOltSlNo: "SDX6320031",
+ },
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ va := &VoltApplication{}
+ va.DevicesDisc.Store("SDX6320031", voltDev)
+ va.UpdateDeviceSerialNumberList(tt.args.oldOltSlNo, tt.args.newOltSlNo)
+ })
+ }
+}
diff --git a/internal/pkg/application/pppoeia_test.go b/internal/pkg/application/pppoeia_test.go
new file mode 100644
index 0000000..45b76fa
--- /dev/null
+++ b/internal/pkg/application/pppoeia_test.go
@@ -0,0 +1,266 @@
+/*
+* Copyright 2022-present Open Networking Foundation
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+ */
+
+package application
+
+import (
+ "context"
+ "net"
+ "sync"
+ "testing"
+ cntlr "voltha-go-controller/internal/pkg/controller"
+ "voltha-go-controller/internal/pkg/of"
+ "voltha-go-controller/internal/test/mocks"
+
+ "github.com/golang/mock/gomock"
+ "github.com/google/gopacket"
+ "github.com/google/gopacket/layers"
+ "github.com/stretchr/testify/assert"
+)
+
+var eth = &layers.Ethernet{
+ SrcMAC: layers.EthernetBroadcast,
+ DstMAC: layers.EthernetBroadcast,
+ EthernetType: layers.EthernetTypeARP,
+ Length: uint16(1),
+}
+var dot1Q = &layers.Dot1Q{
+ Priority: uint8(1),
+ DropEligible: true,
+ Type: layers.EthernetTypeARP,
+}
+var LayerTypeDot2Q = []gopacket.Layer{
+ dot1Q,
+}
+
+func TestPppoeIaPacketTask_Start(t *testing.T) {
+ type args struct {
+ ctx context.Context
+ taskID uint8
+ }
+ tests := []struct {
+ name string
+ args args
+ wantErr bool
+ }{
+ {
+ name: "PppoeIaPacketTask_Start",
+ args: args{
+ ctx: context.Background(),
+ taskID: EtherType8100,
+ },
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ pppoe := &layers.PPPoE{
+ Version: uint8(1),
+ }
+ pkt := mocks.NewMockPacket(gomock.NewController(t))
+ var dpt = &PppoeIaPacketTask{
+ pkt: pkt,
+ }
+ pkt.EXPECT().Layer(layers.LayerTypePPPoE).Return(pppoe).Times(2)
+ pkt.EXPECT().Layer(layers.LayerTypeEthernet).Return(eth).Times(1)
+ pkt.EXPECT().Layer(layers.LayerTypeDot1Q).Return(dot1Q).Times(1)
+ pkt.EXPECT().Layers().Return(LayerTypeDot2Q).Times(1)
+ err := dpt.Start(tt.args.ctx, tt.args.taskID)
+ assert.Nil(t, err)
+ })
+ }
+}
+
+func TestVoltApplication_ProcessPPPoEIaPacket(t *testing.T) {
+ type args struct {
+ cntx context.Context
+ device string
+ port string
+ pkt gopacket.Packet
+ }
+ pkt := mocks.NewMockPacket(gomock.NewController(t))
+ tests := []struct {
+ name string
+ args args
+ }{
+ {
+ name: "ProcessPPPoEIaPacket_ProcessUsPppoeIaPacket",
+ args: args{
+ cntx: context.Background(),
+ device: test_device,
+ port: "test_port",
+ pkt: pkt,
+ },
+ },
+ {
+ name: "pppoel_nil",
+ args: args{
+ cntx: context.Background(),
+ device: test_device,
+ port: "test_port",
+ pkt: pkt,
+ },
+ },
+ {
+ name: "pppoel_invalidType",
+ args: args{
+ cntx: context.Background(),
+ device: test_device,
+ port: "test_port",
+ pkt: pkt,
+ },
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ va := &VoltApplication{}
+ // dot1Q := &layers.Dot1Q{
+ // Priority: uint8(1),
+ // DropEligible: true,
+ // Type: layers.EthernetTypeARP,
+ // }
+ // LayerTypeDot2Q := []gopacket.Layer{
+ // dot1Q,
+ // }
+ ga := GetApplication()
+ switch tt.name {
+ case "ProcessPPPoEIaPacket_ProcessUsPppoeIaPacket":
+ ga.DevicesDisc.Store(test_device, voltDevice)
+ pkt.EXPECT().Layer(layers.LayerTypePPPoE).Return(&layers.PPPoE{
+ Version: uint8(1),
+ }).Times(1)
+ pkt.EXPECT().Layers().Return(LayerTypeDot2Q).Times(2)
+ va.ProcessPPPoEIaPacket(tt.args.cntx, tt.args.device, tt.args.port, tt.args.pkt)
+ case "pppoel_nil":
+ pkt.EXPECT().Layer(layers.LayerTypePPPoE).Return(nil).Times(1)
+ va.ProcessPPPoEIaPacket(tt.args.cntx, tt.args.device, tt.args.port, tt.args.pkt)
+ case "pppoel_invalidType":
+ pkt.EXPECT().Layer(layers.LayerTypePPPoE).Return(&layers.ARP{}).Times(1)
+ va.ProcessPPPoEIaPacket(tt.args.cntx, tt.args.device, tt.args.port, tt.args.pkt)
+ }
+ })
+ }
+}
+
+func TestVoltApplication_ProcessUsPppoeIaPacket(t *testing.T) {
+ type args struct {
+ cntx context.Context
+ device string
+ port string
+ pkt gopacket.Packet
+ }
+ pkt := mocks.NewMockPacket(gomock.NewController(t))
+ tests := []struct {
+ name string
+ args args
+ }{
+ {
+ name: "VoltApplication_ProcessUsPppoeIaPacket",
+ args: args{
+ cntx: context.Background(),
+ device: test_device,
+ port: "test_port",
+ pkt: pkt,
+ },
+ },
+ }
+ macAdd, _ := net.ParseMAC("ff:ff:ff:ff:ff:ff")
+ macPort := map[string]string{}
+ macPort[macAdd.String()] = test_data
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ va := &VoltApplication{
+ macPortMap: macPort,
+ VnetsByPort: sync.Map{},
+ DevicesDisc: sync.Map{},
+ }
+ voltServ := &VoltService{
+ VoltServiceOper: VoltServiceOper{
+ Device: "SDX6320031",
+ },
+ VoltServiceCfg: VoltServiceCfg{
+ IsActivated: true,
+ Pbits: []of.PbitType{PbitMatchAll},
+ },
+ }
+ switch tt.name {
+ case "VoltApplication_ProcessUsPppoeIaPacket":
+ va.DevicesDisc.Store(test_device, voltDevice)
+ pkt.EXPECT().Layers().Return(LayerTypeDot2Q).Times(3)
+ voltPortVnet1[0].SVlan = 0
+ voltDevice.NniPort = "1"
+ va.VnetsByPort.Store("test_port", voltPortVnet1)
+ voltPortVnet1[0].PppoeIa = true
+ voltPortVnet1[0].AllowTransparent = true
+ voltPortVnet1[0].Port = test_data
+ pendingDeleteFlow := map[string]bool{}
+ pendingDeleteFlow["test_cookie"] = true
+ voltPortVnet1[0].PendingDeleteFlow = pendingDeleteFlow
+ dbintf := mocks.NewMockDBIntf(gomock.NewController(t))
+ db = dbintf
+ eth.SrcMAC = layers.EthernetBroadcast
+ dbintf.EXPECT().PutVpv(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1)
+ voltPortVnet1[0].services.Store("SDX6320031-1_SDX6320031-1-4096-2310-4096-65", voltServ)
+ pkt.EXPECT().Layer(layers.LayerTypeEthernet).Return(eth).Times(2)
+ pkt.EXPECT().Layer(layers.LayerTypePPPoE).Return(&layers.PPPoE{
+ Version: uint8(1),
+ Code: layers.PPPoECodePADI,
+ }).Times(1)
+ pkt.EXPECT().Layer(layers.LayerTypeDot1Q).Return(dot1Q).Times(1)
+ _ = cntlr.NewController(context.Background(), mocks.NewMockApp(gomock.NewController(t)))
+ va.ProcessUsPppoeIaPacket(tt.args.cntx, tt.args.device, tt.args.port, tt.args.pkt)
+ }
+ })
+ }
+}
+
+func TestVoltApplication_ProcessDsPppoeIaPacket(t *testing.T) {
+ type args struct {
+ cntx context.Context
+ device string
+ port string
+ pkt gopacket.Packet
+ }
+ pkt := mocks.NewMockPacket(gomock.NewController(t))
+ tests := []struct {
+ name string
+ args args
+ }{
+ {
+ name: "VoltApplication_ProcessDsPppoeIaPacket",
+ args: args{
+ cntx: context.Background(),
+ device: test_device,
+ port: "test_port",
+ pkt: pkt,
+ },
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ va := &VoltApplication{}
+ pkt.EXPECT().Layer(layers.LayerTypeEthernet).Return(eth).Times(1)
+ pkt.EXPECT().Layer(layers.LayerTypePPPoE).Return(&layers.PPPoE{
+ Version: uint8(1),
+ Code: layers.PPPoECodePADI,
+ }).Times(1)
+ pkt.EXPECT().Layer(layers.LayerTypeDot1Q).Return(dot1Q).Times(1)
+ pkt.EXPECT().Layers().Return(LayerTypeDot2Q).Times(3)
+ dbintf := mocks.NewMockDBIntf(gomock.NewController(t))
+ db = dbintf
+ dbintf.EXPECT().PutVpv(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1)
+ va.ProcessDsPppoeIaPacket(tt.args.cntx, tt.args.device, tt.args.port, tt.args.pkt)
+ })
+ }
+}
diff --git a/internal/pkg/application/service_test.go b/internal/pkg/application/service_test.go
index b9c458b..c687e55 100644
--- a/internal/pkg/application/service_test.go
+++ b/internal/pkg/application/service_test.go
@@ -19,6 +19,8 @@
"context"
"encoding/json"
"errors"
+ "net"
+ "reflect"
"sync"
"testing"
"voltha-go-controller/internal/pkg/controller"
@@ -48,8 +50,9 @@
}
var voltMeter = &VoltMeter{
- Name: "test_volt_meter",
- Version: "test_version",
+ Name: "test_volt_meter",
+ Version: "test_version",
+ AssociatedServices: 3,
}
var voltVnet = &VoltVnet{
@@ -74,6 +77,26 @@
State: cntlr.DeviceStateDOWN,
}
+var voltDevice2 = &VoltDevice{
+ Name: "test_name",
+ State: controller.DeviceStateUP,
+ FlowAddEventMap: util.NewConcurrentMap(),
+ FlowDelEventMap: util.NewConcurrentMap(),
+ SerialNum: "test_serial_number",
+ MigratingServices: util.NewConcurrentMap(),
+}
+
+var voltService2 = &VoltService{
+ Version: "test_version",
+ VoltServiceCfg: VoltServiceCfg{
+ VnetID: "test_vnet_id",
+ Port: "test_port",
+ SVlan: of.VlanAny,
+ CVlan: of.VlanAny,
+ UniVlan: of.VlanAny,
+ },
+}
+
var GetDeviceFromPort_error = "GetDeviceFromPort_error"
func TestVoltApplication_RestoreSvcsFromDb(t *testing.T) {
@@ -105,7 +128,7 @@
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
- voltService := &VoltService{
+ voltService4 := &VoltService{
VoltServiceOper: VoltServiceOper{
Device: "SDX6320031",
ForceDelete: true,
@@ -116,7 +139,7 @@
},
}
serviceToDelete := map[string]bool{}
- serviceToDelete[voltService.VoltServiceCfg.Name] = true
+ serviceToDelete[voltService4.VoltServiceCfg.Name] = true
va := &VoltApplication{
ServicesToDelete: serviceToDelete,
}
@@ -125,7 +148,7 @@
switch tt.name {
case "VoltApplication_RestoreSvcsFromDb":
- b, err := json.Marshal(voltService)
+ b, err := json.Marshal(voltService4)
if err != nil {
panic(err)
}
@@ -441,6 +464,19 @@
serviceMigration: true,
},
},
+ {
+ name: "GetMeterByID_not_nil",
+ args: args{
+ cntx: context.Background(),
+ name: "test_name",
+ forceDelete: true,
+ newSvc: &VoltServiceCfg{
+ Name: "vs_cfg_name",
+ Port: "test_port",
+ },
+ serviceMigration: true,
+ },
+ },
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
@@ -448,7 +484,7 @@
ServiceByName: sync.Map{},
VnetsByPort: sync.Map{},
}
- voltService := &VoltService{
+ voltService3 := &VoltService{
Version: "test_version",
VoltServiceCfg: VoltServiceCfg{
Port: "4096-4096-4096",
@@ -457,13 +493,30 @@
UniVlan: of.VlanAny,
},
}
- va.ServiceByName.Store(tt.args.name, voltService)
- va.VnetsByPort.Store("4096-4096-4096", voltPortVnet1)
- dbintf := mocks.NewMockDBIntf(gomock.NewController(t))
- db = dbintf
- dbintf.EXPECT().DelService(gomock.Any(), gomock.Any()).AnyTimes()
- dbintf.EXPECT().PutService(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).AnyTimes()
- va.DelService(tt.args.cntx, tt.args.name, tt.args.forceDelete, tt.args.newSvc, tt.args.serviceMigration)
+ switch tt.name {
+ case "VoltApplication_DelService":
+ va.ServiceByName.Store(tt.args.name, voltService3)
+ va.VnetsByPort.Store("4096-4096-4096", voltPortVnet1)
+ dbintf := mocks.NewMockDBIntf(gomock.NewController(t))
+ db = dbintf
+ dbintf.EXPECT().DelService(gomock.Any(), gomock.Any()).AnyTimes()
+ dbintf.EXPECT().PutService(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).AnyTimes()
+ va.DelService(tt.args.cntx, tt.args.name, tt.args.forceDelete, tt.args.newSvc, tt.args.serviceMigration)
+ case "GetMeterByID_not_nil":
+ va.ServiceByName.Store(tt.args.name, voltService3)
+ va.VnetsByPort.Store("4096-4096-4096", voltPortVnet1)
+ voltService3.AggDsMeterID = uint32(1)
+ voltService3.DsMeterID = uint32(1)
+ voltService3.UsMeterID = uint32(2)
+ va.MeterMgr.MetersByID.Store(voltService3.AggDsMeterID, voltMeter)
+ va.MeterMgr.MetersByID.Store(voltService3.DsMeterID, voltMeter)
+ va.MeterMgr.MetersByID.Store(voltService3.UsMeterID, voltMeter)
+ dbintf := mocks.NewMockDBIntf(gomock.NewController(t))
+ db = dbintf
+ dbintf.EXPECT().DelService(gomock.Any(), gomock.Any()).AnyTimes()
+ dbintf.EXPECT().PutService(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).AnyTimes()
+ va.DelService(tt.args.cntx, tt.args.name, tt.args.forceDelete, tt.args.newSvc, tt.args.serviceMigration)
+ }
})
}
}
@@ -910,7 +963,7 @@
name: "VoltApplication_ActivateService",
args: args{
cntx: context.Background(),
- deviceID: "test_name",
+ deviceID: DeviceAny,
portNo: "test_port",
sVlan: of.VlanNone,
cVlan: of.VlanAny,
@@ -939,6 +992,28 @@
tpID: AnyVlan,
},
},
+ {
+ name: "deviceID != device.Name",
+ args: args{
+ cntx: context.Background(),
+ deviceID: "test_name1",
+ portNo: "test_port",
+ sVlan: of.VlanNone,
+ cVlan: of.VlanAny,
+ tpID: AnyVlan,
+ },
+ },
+ {
+ name: "sVlan != of.VlanNone && sVlan != vs.SVlan",
+ args: args{
+ cntx: context.Background(),
+ deviceID: "test_name",
+ portNo: "test_port",
+ sVlan: 1,
+ cVlan: of.VlanAny,
+ tpID: AnyVlan,
+ },
+ },
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
@@ -992,6 +1067,31 @@
case GetDeviceFromPort_error:
err := va.ActivateService(tt.args.cntx, tt.args.deviceID, tt.args.portNo, tt.args.sVlan, tt.args.cVlan, tt.args.tpID)
assert.NotNil(t, err)
+ case "deviceID != device.Name":
+ var voltPortTest1 = &VoltPort{
+ Name: "test_name",
+ State: PortStateUp,
+ Device: test_device,
+ }
+ var voltDevice_test = &VoltDevice{
+ Name: "",
+ State: controller.DeviceStateUP,
+ FlowAddEventMap: util.NewConcurrentMap(),
+ FlowDelEventMap: util.NewConcurrentMap(),
+ SerialNum: "test_serial_number",
+ }
+ va.PortsDisc.Store("test_port", voltPortTest1)
+ va.DevicesDisc.Store(test_device, voltDevice_test)
+ err := va.ActivateService(tt.args.cntx, tt.args.deviceID, tt.args.portNo, tt.args.sVlan, tt.args.cVlan, tt.args.tpID)
+ assert.NotNil(t, err)
+ case "sVlan != of.VlanNone && sVlan != vs.SVlan":
+ voltPortTest.Device = test_device
+ va.PortsDisc.Store("test_port", voltPortTest)
+ va.DevicesDisc.Store(test_device, voltDevice)
+ va.ServiceByName.Store("test_name", voltServiceTest)
+ if err := va.ActivateService(tt.args.cntx, tt.args.deviceID, tt.args.portNo, tt.args.sVlan, tt.args.cVlan, tt.args.tpID); (err != nil) != tt.wantErr {
+ t.Errorf("VoltApplication.ActivateService() error = %v, wantErr %v", err, tt.wantErr)
+ }
}
})
}
@@ -1522,6 +1622,16 @@
},
want: false,
},
+ {
+ name: "nvs.IsOption82Enabled != evs.IsOption82Enabled",
+ args: args{
+ evs: &VoltServiceCfg{
+ IsOption82Enabled: true,
+ },
+ nvs: &VoltServiceCfg{},
+ },
+ want: false,
+ },
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
@@ -1542,7 +1652,8 @@
"nvs.AllowTransparent != evs.AllowTransparent",
"nvs.EnableMulticastKPI != evs.EnableMulticastKPI", "nvs.DataRateAttr != evs.DataRateAttr",
"nvs.MinDataRateUs != evs.MinDataRateUs", "nvs.MinDataRateDs != evs.MinDataRateDs",
- "nvs.MaxDataRateUs != evs.MaxDataRateUs", "nvs.MaxDataRateDs != evs.MaxDataRateDs":
+ "nvs.MaxDataRateUs != evs.MaxDataRateUs", "nvs.MaxDataRateDs != evs.MaxDataRateDs",
+ "nvs.IsOption82Enabled != evs.IsOption82Enabled":
if got := va.DeepEqualServicecfg(tt.args.evs, tt.args.nvs); got != tt.want {
t.Errorf("VoltApplication.DeepEqualServicecfg() = %v, want %v", got, tt.want)
}
@@ -1550,3 +1661,1414 @@
})
}
}
+
+func Test_forceUpdateAllServices(t *testing.T) {
+ type args struct {
+ cntx context.Context
+ msr *MigrateServicesRequest
+ }
+ servicesList := map[string]bool{}
+ servicesList[test_device] = true
+ tests := []struct {
+ name string
+ args args
+ }{
+ {
+ name: "forceUpdateAllServices",
+ args: args{
+ cntx: context.Background(),
+ msr: &MigrateServicesRequest{
+ ID: "test_id",
+ ServicesList: servicesList,
+ DeviceID: test_device,
+ },
+ },
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ ga := GetApplication()
+ dbintf := mocks.NewMockDBIntf(gomock.NewController(t))
+ db = dbintf
+ dbintf.EXPECT().DelMigrateServicesReq(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).AnyTimes()
+ ga.ServiceByName.Store(test_device, voltService2)
+ voltService2.VoltServiceOper.Metadata = &MigrateServiceMetadata{
+ NewVnetID: "test_new_vnet_id",
+ RequestID: "test_request_id",
+ }
+ newConcurrentMap := util.NewConcurrentMap()
+ ga.DevicesDisc.Store(test_device, voltDevice2)
+ voltDevice2.MigratingServices.Set("test_vnet_id", newConcurrentMap)
+ migrateServicesRequest := &MigrateServicesRequest{
+ ID: "test_id",
+ ServicesList: servicesList,
+ }
+ newConcurrentMap.Set("test_request_id", migrateServicesRequest)
+ dbintf.EXPECT().PutMigrateServicesReq(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).AnyTimes()
+ forceUpdateAllServices(tt.args.cntx, tt.args.msr)
+ })
+ }
+}
+
+func TestVoltService_updateVnetProfile(t *testing.T) {
+ type args struct {
+ cntx context.Context
+ deviceID string
+ }
+ tests := []struct {
+ name string
+ args args
+ }{
+ {
+ name: "DeleteInProgress_true",
+ args: args{
+ cntx: context.Background(),
+ deviceID: test_device,
+ },
+ },
+ {
+ name: "metadata_nil",
+ args: args{
+ cntx: context.Background(),
+ deviceID: test_device,
+ },
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ switch tt.name {
+ case "DeleteInProgress_true":
+ vs := &VoltService{
+ VoltServiceOper: VoltServiceOper{
+ DeleteInProgress: true,
+ },
+ }
+ vs.updateVnetProfile(tt.args.cntx, tt.args.deviceID)
+ case "metadata_nil":
+ vs := &VoltService{
+ VoltServiceOper: VoltServiceOper{
+ Metadata: &MigrateServiceMetadata{},
+ },
+ }
+ vs.updateVnetProfile(tt.args.cntx, tt.args.deviceID)
+ }
+ })
+ }
+}
+
+func TestMigrateServicesRequest_serviceMigrated(t *testing.T) {
+ type args struct {
+ cntx context.Context
+ serviceName string
+ }
+ tests := []struct {
+ name string
+ args args
+ }{
+ {
+ name: "ServicesList_nil",
+ args: args{
+ cntx: context.Background(),
+ serviceName: "test_service_name",
+ },
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ msr := &MigrateServicesRequest{
+ ServicesList: map[string]bool{},
+ }
+ dbintf := mocks.NewMockDBIntf(gomock.NewController(t))
+ db = dbintf
+ dbintf.EXPECT().DelMigrateServicesReq(gomock.All(), gomock.Any(), gomock.Any()).Return(nil).Times(1)
+ msr.serviceMigrated(tt.args.cntx, tt.args.serviceName)
+ })
+ }
+}
+
+func TestVoltApplication_TriggerPendingMigrateServicesReq(t *testing.T) {
+ type args struct {
+ cntx context.Context
+ device string
+ }
+ tests := []struct {
+ name string
+ args args
+ }{
+ {
+ name: "VoltApplication_TriggerPendingMigrateServicesReq",
+ args: args{
+ cntx: context.Background(),
+ device: test_device,
+ },
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ va := &VoltApplication{
+ ServiceByName: sync.Map{},
+ }
+ migrateServicesRequest := &MigrateServicesRequest{
+ ID: "test_id",
+ OldVnetID: "test_vnet_id",
+ DeviceID: test_device,
+ }
+ b, err := json.Marshal(migrateServicesRequest)
+ if err != nil {
+ panic(err)
+ }
+ kvpair := map[string]*kvstore.KVPair{}
+ kvpair["test_device_id"] = &kvstore.KVPair{
+ Key: "test_device_id",
+ Value: b,
+ }
+
+ dbintf := mocks.NewMockDBIntf(gomock.NewController(t))
+ db = dbintf
+ ga := GetApplication()
+ ga.DevicesDisc.Store(test_device, voltDevice2)
+ newConcurrentMap := util.NewConcurrentMap()
+ voltDevice2.MigratingServices.Set("test_vnet_id", newConcurrentMap)
+ dbintf.EXPECT().GetAllMigrateServicesReq(gomock.Any(), gomock.Any()).Return(kvpair, nil).AnyTimes()
+ va.TriggerPendingMigrateServicesReq(tt.args.cntx, tt.args.device)
+ })
+ }
+}
+
+func TestVoltApplication_FetchAndProcessAllMigrateServicesReq(t *testing.T) {
+ type args struct {
+ cntx context.Context
+ device string
+ msrAction func(context.Context, *MigrateServicesRequest)
+ }
+ tests := []struct {
+ name string
+ args args
+ }{
+ {
+ name: "invalid_value_type",
+ args: args{
+ cntx: context.Background(),
+ device: test_device,
+ msrAction: func(ctx context.Context, msr *MigrateServicesRequest) {},
+ },
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ va := &VoltApplication{
+ DevicesDisc: sync.Map{},
+ }
+ dbintf := mocks.NewMockDBIntf(gomock.NewController(t))
+ db = dbintf
+ kvpair := map[string]*kvstore.KVPair{}
+ kvpair["test_device_id"] = &kvstore.KVPair{
+ Key: "test_device_id",
+ Value: "invalid_value",
+ }
+ dbintf.EXPECT().GetAllMigrateServicesReq(gomock.Any(), gomock.Any()).Return(kvpair, nil).AnyTimes()
+ va.FetchAndProcessAllMigrateServicesReq(tt.args.cntx, tt.args.device, tt.args.msrAction)
+ })
+ }
+}
+
+func TestVoltApplication_createMigrateServicesFromString(t *testing.T) {
+ type args struct {
+ b []byte
+ }
+ tests := []struct {
+ name string
+ args args
+ }{
+ {
+ name: "Unmarshal_error",
+ args: args{
+ b: []byte{},
+ },
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ va := &VoltApplication{
+ vendorID: test_device,
+ }
+ got := va.createMigrateServicesFromString(tt.args.b)
+ assert.NotNil(t, got)
+ })
+ }
+}
+
+func TestVoltApplication_getMigrateServicesRequest(t *testing.T) {
+ type args struct {
+ deviceID string
+ oldVnetID string
+ requestID string
+ }
+ tests := []struct {
+ name string
+ args args
+ want *MigrateServicesRequest
+ }{
+ {
+ name: "GetDevice_nil",
+ args: args{
+ deviceID: test_device,
+ },
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ va := &VoltApplication{
+ vendorID: "vendorID",
+ }
+ if got := va.getMigrateServicesRequest(tt.args.deviceID, tt.args.oldVnetID, tt.args.requestID); !reflect.DeepEqual(got, tt.want) {
+ t.Errorf("VoltApplication.getMigrateServicesRequest() = %v, want %v", got, tt.want)
+ }
+ })
+ }
+}
+
+func TestVoltDevice_AddMigratingServices(t *testing.T) {
+ type args struct {
+ msr *MigrateServicesRequest
+ }
+ tests := []struct {
+ name string
+ args args
+ }{
+ {
+ name: "MigratingServices_Get_nil",
+ args: args{
+ msr: &MigrateServicesRequest{
+ ID: "test_id",
+ },
+ },
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ d := &VoltDevice{
+ MigratingServices: util.NewConcurrentMap(),
+ }
+ d.AddMigratingServices(tt.args.msr)
+ })
+ }
+}
+
+func TestMigrateServicesRequest_ProcessMigrateServicesProfRequest(t *testing.T) {
+ type args struct {
+ cntx context.Context
+ }
+ tests := []struct {
+ name string
+ args args
+ }{
+ {
+ name: "ServicesList_true",
+ args: args{
+ cntx: context.Background(),
+ },
+ },
+ {
+ name: "ServicesList_false",
+ args: args{
+ cntx: context.Background(),
+ },
+ },
+ {
+ name: "GetVnetByPort_nil",
+ args: args{
+ cntx: context.Background(),
+ },
+ },
+ {
+ name: "UsHSIAFlowsApplied_true",
+ args: args{
+ cntx: context.Background(),
+ },
+ },
+ {
+ name: "ServiceByName_nil",
+ args: args{
+ cntx: context.Background(),
+ },
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ dbintf := mocks.NewMockDBIntf(gomock.NewController(t))
+ db = dbintf
+ switch tt.name {
+ case "ServicesList_true":
+ servicesList := map[string]bool{}
+ servicesList[test_device] = true
+ msr := &MigrateServicesRequest{
+ ServicesList: servicesList,
+ }
+ dbintf.EXPECT().DelMigrateServicesReq(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).AnyTimes()
+ msr.ProcessMigrateServicesProfRequest(tt.args.cntx)
+ case "ServicesList_false":
+ servicesList := map[string]bool{}
+ servicesList[test_device] = false
+ msr := &MigrateServicesRequest{
+ ServicesList: servicesList,
+ }
+ ga := GetApplication()
+ ga.ServiceByName.Store(test_device, voltService2)
+ ga.VnetsByPort.Store("test_port", voltPortVnet1)
+ msr.ProcessMigrateServicesProfRequest(tt.args.cntx)
+ case "GetVnetByPort_nil":
+ servicesList := map[string]bool{}
+ servicesList[test_device] = false
+ msr := &MigrateServicesRequest{
+ ServicesList: servicesList,
+ }
+ ga := GetApplication()
+ var voltService1 = &VoltService{
+ Version: "test_version",
+ VoltServiceCfg: VoltServiceCfg{
+ VnetID: "test_vnet_id",
+ SVlan: of.VlanAny,
+ CVlan: of.VlanAny,
+ UniVlan: of.VlanAny,
+ },
+ }
+ ga.ServiceByName.Store(test_device, voltService1)
+ ga.VnetsByPort.Store("test_port1", nil)
+ msr.ProcessMigrateServicesProfRequest(tt.args.cntx)
+ case "UsHSIAFlowsApplied_true":
+ servicesList := map[string]bool{}
+ servicesList[test_device] = false
+ msr := &MigrateServicesRequest{
+ ServicesList: servicesList,
+ }
+ ga := GetApplication()
+ voltService2.UsHSIAFlowsApplied = true
+ ga.ServiceByName.Store(test_device, voltService2)
+ ga.VnetsByPort.Store("test_port", voltPortVnet1)
+ dbintf.EXPECT().PutVpv(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).AnyTimes()
+ dbintf.EXPECT().PutService(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).AnyTimes()
+ msr.ProcessMigrateServicesProfRequest(tt.args.cntx)
+ case "ServiceByName_nil":
+ servicesList := map[string]bool{}
+ servicesList[""] = false
+ msr := &MigrateServicesRequest{
+ ServicesList: servicesList,
+ }
+ msr.ProcessMigrateServicesProfRequest(tt.args.cntx)
+ }
+ })
+ }
+}
+
+func TestVoltApplication_MigrateServices(t *testing.T) {
+ type args struct {
+ cntx context.Context
+ serialNum string
+ reqID string
+ oldVnetID string
+ newVnetID string
+ serviceList []string
+ }
+ tests := []struct {
+ name string
+ args args
+ wantErr bool
+ }{
+ {
+ name: "VoltApplication_MigrateServices",
+ args: args{
+ cntx: context.Background(),
+ serialNum: "test_serial_number",
+ reqID: "test_reqid",
+ oldVnetID: "test_old_vnet_id",
+ newVnetID: "test_new_vnet_id",
+ serviceList: []string{"test_service_list_1", "test_service_list_2"},
+ },
+ },
+ {
+ name: "Old Vnet Id not found",
+ args: args{
+ cntx: context.Background(),
+ serialNum: "test_serial_number",
+ reqID: "test_reqid",
+ oldVnetID: "",
+ newVnetID: "test_new_vnet_id",
+ serviceList: []string{"test_service_list_1", "test_service_list_2"},
+ },
+ },
+ {
+ name: "New Vnet Id not found",
+ args: args{
+ cntx: context.Background(),
+ serialNum: "test_serial_number",
+ reqID: "test_reqid",
+ oldVnetID: "test_old_vnet_id",
+ newVnetID: "",
+ serviceList: []string{"test_service_list_1", "test_service_list_2"},
+ },
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ va := &VoltApplication{
+ VnetsByName: sync.Map{},
+ }
+ voltVnet2 := &VoltVnet{
+ Version: "v3",
+ VnetConfig: VnetConfig{
+ Name: "2310-4096-4096",
+ VnetType: "Encapsulation",
+ SVlan: 2310,
+ CVlan: 4096,
+ UniVlan: 4096,
+ SVlanTpid: 33024,
+ },
+ VnetOper: VnetOper{
+ PendingDeviceToDelete: "SDX63200313",
+ },
+ }
+ switch tt.name {
+ case "VoltApplication_MigrateServices":
+ va.VnetsByName.Store("test_old_vnet_id", voltVnet2)
+ va.VnetsByName.Store("test_new_vnet_id", voltVnet2)
+ va.DevicesDisc.Store(test_device, voltDevice2)
+ dbintf := mocks.NewMockDBIntf(gomock.NewController(t))
+ db = dbintf
+ dbintf.EXPECT().PutMigrateServicesReq(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).AnyTimes()
+ if err := va.MigrateServices(tt.args.cntx, tt.args.serialNum, tt.args.reqID, tt.args.oldVnetID, tt.args.newVnetID, tt.args.serviceList); (err != nil) != tt.wantErr {
+ t.Errorf("VoltApplication.MigrateServices() error = %v, wantErr %v", err, tt.wantErr)
+ }
+ case "Old Vnet Id not found":
+ va.VnetsByName.Store("test_old_vnet_id", voltVnet2)
+ err := va.MigrateServices(tt.args.cntx, tt.args.serialNum, tt.args.reqID, tt.args.oldVnetID, tt.args.newVnetID, tt.args.serviceList)
+ assert.NotNil(t, err)
+ case "New Vnet Id not found":
+ va.VnetsByName.Store("test_old_vnet_id", voltVnet2)
+ va.VnetsByName.Store("test_new_vnet_id", voltVnet2)
+ err := va.MigrateServices(tt.args.cntx, tt.args.serialNum, tt.args.reqID, tt.args.oldVnetID, tt.args.newVnetID, tt.args.serviceList)
+ assert.NotNil(t, err)
+ }
+ })
+ }
+}
+
+func TestMigrateServicesRequest_WriteToDB(t *testing.T) {
+ type args struct {
+ cntx context.Context
+ }
+ tests := []struct {
+ name string
+ args args
+ }{
+ {
+ name: "PutMigrateServicesReq_error",
+ args: args{
+ cntx: context.Background(),
+ },
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ msr := &MigrateServicesRequest{
+ ID: test_device,
+ }
+ dbintf := mocks.NewMockDBIntf(gomock.NewController(t))
+ db = dbintf
+ dbintf.EXPECT().PutMigrateServicesReq(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(errors.New("error")).Times(1)
+ msr.WriteToDB(tt.args.cntx)
+ })
+ }
+}
+
+func TestVoltService_MatchesVlans(t *testing.T) {
+ type args struct {
+ vlans []of.VlanType
+ }
+ tests := []struct {
+ name string
+ args args
+ want bool
+ }{
+ {
+ name: "vlans_nil",
+ args: args{
+ vlans: []of.VlanType{},
+ },
+ want: false,
+ },
+ {
+ name: "MatchesVlans",
+ args: args{
+ vlans: []of.VlanType{
+ of.VlanAny,
+ },
+ },
+ want: true,
+ },
+ {
+ name: "vlans[0] != vs.CVlan",
+ args: args{
+ vlans: []of.VlanType{
+ of.VlanNone,
+ },
+ },
+ want: false,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ vs := &VoltService{
+ VoltServiceCfg: VoltServiceCfg{CVlan: of.VlanAny},
+ }
+ switch tt.name {
+ case "vlans_nil", "MatchesVlans", "vlans[0] != vs.CVlan":
+ if got := vs.MatchesVlans(tt.args.vlans); got != tt.want {
+ t.Errorf("VoltService.MatchesVlans() = %v, want %v", got, tt.want)
+ }
+ }
+ })
+ }
+}
+
+func TestVoltService_MatchesPbits(t *testing.T) {
+ type args struct {
+ pbits []of.PbitType
+ }
+ tests := []struct {
+ name string
+ args args
+ want bool
+ }{
+ {
+ name: "VoltService_MatchesPbits",
+ args: args{
+ pbits: []of.PbitType{
+ of.PbitMatchAll,
+ },
+ },
+ want: true,
+ },
+ {
+ name: "PbitType_nil",
+ args: args{
+ pbits: []of.PbitType{},
+ },
+ want: false,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ vs := &VoltService{
+ VoltServiceCfg: VoltServiceCfg{
+ Pbits: []of.PbitType{
+ of.PbitMatchAll,
+ },
+ },
+ }
+ switch tt.name {
+ case "VoltService_MatchesPbits", "PbitType_nil":
+ if got := vs.MatchesPbits(tt.args.pbits); got != tt.want {
+ t.Errorf("VoltService.MatchesPbits() = %v, want %v", got, tt.want)
+ }
+ }
+ })
+ }
+}
+
+func TestVoltApplication_DelServiceWithPrefix(t *testing.T) {
+ type args struct {
+ cntx context.Context
+ prefix string
+ }
+ tests := []struct {
+ name string
+ args args
+ }{
+ {
+ name: "VoltApplication_DelServiceWithPrefix",
+ args: args{
+ cntx: context.Background(),
+ prefix: test_device,
+ },
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ va := &VoltApplication{
+ VnetsBySvlan: util.NewConcurrentMap(),
+ }
+ va.ServiceByName.Store(test_device, voltService)
+ va.VnetsByName.Store("0-0-0", voltVnet)
+ dbintf := mocks.NewMockDBIntf(gomock.NewController(t))
+ db = dbintf
+ dbintf.EXPECT().PutVnet(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1)
+ cuncurrentMap := &util.ConcurrentMap{
+ Count: atomic.NewUint64(0),
+ }
+ va.VnetsBySvlan.Set(of.VlanAny, cuncurrentMap)
+ dbintf.EXPECT().DelVnet(gomock.Any(), gomock.Any()).Return(nil).Times(1)
+ va.DelServiceWithPrefix(tt.args.cntx, tt.args.prefix)
+ })
+ }
+}
+
+func TestVoltService_FlowInstallFailure(t *testing.T) {
+ type args struct {
+ cookie string
+ errorCode uint32
+ errReason string
+ }
+ tests := []struct {
+ name string
+ args args
+ }{
+ {
+ name: "VoltService_FlowInstallFailure",
+ args: args{
+ cookie: "test_cookie",
+ errorCode: uint32(1),
+ errReason: "err_reason",
+ },
+ },
+ {
+ name: "PendingFlows[cookie]_false",
+ args: args{
+ cookie: "test_cookie",
+ errorCode: uint32(1),
+ errReason: "err_reason",
+ },
+ },
+ }
+ pendingFlows := map[string]bool{}
+ pendingFlows["test_cookie"] = true
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ vs := &VoltService{
+ VoltServiceOper: VoltServiceOper{},
+ }
+ switch tt.name {
+ case "VoltService_FlowInstallFailure":
+ vs.PendingFlows = pendingFlows
+ vs.FlowInstallFailure(tt.args.cookie, tt.args.errorCode, tt.args.errReason)
+ case "PendingFlows[cookie]_false":
+ vs.FlowInstallFailure(tt.args.cookie, tt.args.errorCode, tt.args.errReason)
+ }
+ })
+ }
+}
+
+func TestVoltService_FlowRemoveSuccess(t *testing.T) {
+ type args struct {
+ cntx context.Context
+ cookie string
+ }
+ tests := []struct {
+ name string
+ args args
+ }{
+ {
+ name: "GetDevice != nil",
+ args: args{
+ cntx: context.Background(),
+ cookie: "test_cookie",
+ },
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ vs := &VoltService{
+ VoltServiceOper: VoltServiceOper{
+ Device: test_device,
+ },
+ }
+ ga := GetApplication()
+ ga.DevicesDisc.Store(test_device, voltDevice2)
+ voltDevice2.State = controller.DeviceStateUP
+ dbintf := mocks.NewMockDBIntf(gomock.NewController(t))
+ db = dbintf
+ dbintf.EXPECT().PutService(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).AnyTimes()
+ vs.FlowRemoveSuccess(tt.args.cntx, tt.args.cookie)
+ })
+ }
+}
+
+func TestVoltService_setDSMatchActionVlanT0(t *testing.T) {
+ type args struct {
+ flow *of.VoltSubFlow
+ }
+ tests := []struct {
+ name string
+ args args
+ wantErr bool
+ }{
+ {
+ name: "VlanControl: ONUCVlanOLTSVlan",
+ args: args{
+ flow: &of.VoltSubFlow{
+ ErrorReason: "test_error_reason",
+ Cookie: uint64(1),
+ OldCookie: uint64(2),
+ TableID: uint32(3),
+ Priority: uint32(4),
+ State: uint8(5),
+ },
+ },
+ },
+ {
+ name: "VlanControl: OLTCVlanOLTSVlan",
+ args: args{
+ flow: &of.VoltSubFlow{
+ ErrorReason: "test_error_reason",
+ Cookie: uint64(1),
+ OldCookie: uint64(2),
+ TableID: uint32(3),
+ Priority: uint32(4),
+ State: uint8(5),
+ },
+ },
+ },
+ {
+ name: "VlanControl: ONUCVlan",
+ args: args{
+ flow: &of.VoltSubFlow{
+ ErrorReason: "test_error_reason",
+ Cookie: uint64(1),
+ OldCookie: uint64(2),
+ TableID: uint32(3),
+ Priority: uint32(4),
+ State: uint8(5),
+ },
+ },
+ },
+ {
+ name: "VlanControl: OLTSVlan",
+ args: args{
+ flow: &of.VoltSubFlow{
+ ErrorReason: "test_error_reason",
+ Cookie: uint64(1),
+ OldCookie: uint64(2),
+ TableID: uint32(3),
+ Priority: uint32(4),
+ State: uint8(5),
+ },
+ },
+ },
+ {
+ name: "VlanControl: OLTSVlan && UniVlan != of.VlanAny",
+ args: args{
+ flow: &of.VoltSubFlow{
+ ErrorReason: "test_error_reason",
+ Cookie: uint64(1),
+ OldCookie: uint64(2),
+ TableID: uint32(3),
+ Priority: uint32(4),
+ State: uint8(5),
+ },
+ },
+ },
+ {
+ name: "invalid VlanControl",
+ args: args{
+ flow: &of.VoltSubFlow{
+ ErrorReason: "test_error_reason",
+ Cookie: uint64(1),
+ OldCookie: uint64(2),
+ TableID: uint32(3),
+ Priority: uint32(4),
+ State: uint8(5),
+ },
+ },
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ vs := &VoltService{
+ VoltServiceCfg: VoltServiceCfg{
+ SVlan: of.VlanAny,
+ UniVlan: of.VlanAny,
+ VlanControl: ONUCVlanOLTSVlan,
+ },
+ }
+ switch tt.name {
+ case "VlanControl: ONUCVlanOLTSVlan":
+ vs.VlanControl = ONUCVlanOLTSVlan
+ if err := vs.setDSMatchActionVlanT0(tt.args.flow); (err != nil) != tt.wantErr {
+ t.Errorf("VoltService.setDSMatchActionVlanT0() error = %v, wantErr %v", err, tt.wantErr)
+ }
+ case "VlanControl: OLTCVlanOLTSVlan":
+ vs.VlanControl = OLTCVlanOLTSVlan
+ if err := vs.setDSMatchActionVlanT0(tt.args.flow); (err != nil) != tt.wantErr {
+ t.Errorf("VoltService.setDSMatchActionVlanT0() error = %v, wantErr %v", err, tt.wantErr)
+ }
+ case "VlanControl: ONUCVlan":
+ vs.VlanControl = ONUCVlan
+ if err := vs.setDSMatchActionVlanT0(tt.args.flow); (err != nil) != tt.wantErr {
+ t.Errorf("VoltService.setDSMatchActionVlanT0() error = %v, wantErr %v", err, tt.wantErr)
+ }
+ case "VlanControl: OLTSVlan":
+ vs.VlanControl = OLTSVlan
+ vs.UniVlan = vs.CVlan
+ if err := vs.setDSMatchActionVlanT0(tt.args.flow); (err != nil) != tt.wantErr {
+ t.Errorf("VoltService.setDSMatchActionVlanT0() error = %v, wantErr %v", err, tt.wantErr)
+ }
+ case "VlanControl: OLTSVlan && UniVlan != of.VlanAny":
+ vs.VlanControl = OLTSVlan
+ if err := vs.setDSMatchActionVlanT0(tt.args.flow); (err != nil) != tt.wantErr {
+ t.Errorf("VoltService.setDSMatchActionVlanT0() error = %v, wantErr %v", err, tt.wantErr)
+ }
+ case "invalid VlanControl":
+ vs.VlanControl = 5
+ err := vs.setDSMatchActionVlanT0(tt.args.flow)
+ assert.NotNil(t, err)
+ }
+ })
+ }
+}
+
+func TestVoltService_setUSMatchActionVlanT1(t *testing.T) {
+ type args struct {
+ flow *of.VoltSubFlow
+ }
+ tests := []struct {
+ name string
+ args args
+ wantErr bool
+ }{
+ {
+ name: "VlanControl: ONUCVlanOLTSVlan",
+ args: args{
+ flow: &of.VoltSubFlow{
+ ErrorReason: "test_error_reason",
+ Cookie: uint64(1),
+ OldCookie: uint64(2),
+ TableID: uint32(3),
+ Priority: uint32(4),
+ State: uint8(5),
+ },
+ },
+ },
+ {
+ name: "VlanControl: OLTCVlanOLTSVlan",
+ args: args{
+ flow: &of.VoltSubFlow{
+ ErrorReason: "test_error_reason",
+ Cookie: uint64(1),
+ OldCookie: uint64(2),
+ TableID: uint32(3),
+ Priority: uint32(4),
+ State: uint8(5),
+ },
+ },
+ },
+ {
+ name: "VlanControl: ONUCVlan",
+ args: args{
+ flow: &of.VoltSubFlow{
+ ErrorReason: "test_error_reason",
+ Cookie: uint64(1),
+ OldCookie: uint64(2),
+ TableID: uint32(3),
+ Priority: uint32(4),
+ State: uint8(5),
+ },
+ },
+ },
+ {
+ name: "VlanControl: OLTSVlan",
+ args: args{
+ flow: &of.VoltSubFlow{
+ ErrorReason: "test_error_reason",
+ Cookie: uint64(1),
+ OldCookie: uint64(2),
+ TableID: uint32(3),
+ Priority: uint32(4),
+ State: uint8(5),
+ },
+ },
+ },
+ {
+ name: "VlanControl: OLTSVlan vs.UniVlan != of.VlanAny && vs.UniVlan != of.VlanNone",
+ args: args{
+ flow: &of.VoltSubFlow{
+ ErrorReason: "test_error_reason",
+ Cookie: uint64(1),
+ OldCookie: uint64(2),
+ TableID: uint32(3),
+ Priority: uint32(4),
+ State: uint8(5),
+ },
+ },
+ },
+ {
+ name: "VlanControl: OLTSVlan vs.UniVlan == of.VlanNone",
+ args: args{
+ flow: &of.VoltSubFlow{
+ ErrorReason: "test_error_reason",
+ Cookie: uint64(1),
+ OldCookie: uint64(2),
+ TableID: uint32(3),
+ Priority: uint32(4),
+ State: uint8(5),
+ },
+ },
+ },
+ {
+ name: "VlanControl: default",
+ args: args{
+ flow: &of.VoltSubFlow{
+ ErrorReason: "test_error_reason",
+ Cookie: uint64(1),
+ OldCookie: uint64(2),
+ TableID: uint32(3),
+ Priority: uint32(4),
+ State: uint8(5),
+ },
+ },
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ vs := &VoltService{
+ VoltServiceCfg: VoltServiceCfg{
+ SVlan: of.VlanAny,
+ UniVlan: of.VlanAny,
+ VlanControl: ONUCVlanOLTSVlan,
+ },
+ }
+ switch tt.name {
+ case "VlanControl: ONUCVlanOLTSVlan":
+ vs.VlanControl = ONUCVlanOLTSVlan
+ if err := vs.setUSMatchActionVlanT1(tt.args.flow); (err != nil) != tt.wantErr {
+ t.Errorf("VoltService.setDSMatchActionVlanT0() error = %v, wantErr %v", err, tt.wantErr)
+ }
+ case "VlanControl: OLTCVlanOLTSVlan":
+ vs.VlanControl = OLTCVlanOLTSVlan
+ if err := vs.setUSMatchActionVlanT1(tt.args.flow); (err != nil) != tt.wantErr {
+ t.Errorf("VoltService.setDSMatchActionVlanT0() error = %v, wantErr %v", err, tt.wantErr)
+ }
+ case "VlanControl: ONUCVlan":
+ vs.VlanControl = ONUCVlan
+ if err := vs.setUSMatchActionVlanT1(tt.args.flow); (err != nil) != tt.wantErr {
+ t.Errorf("VoltService.setDSMatchActionVlanT0() error = %v, wantErr %v", err, tt.wantErr)
+ }
+ case "VlanControl: OLTSVlan":
+ vs.VlanControl = OLTSVlan
+ if err := vs.setUSMatchActionVlanT1(tt.args.flow); (err != nil) != tt.wantErr {
+ t.Errorf("VoltService.setDSMatchActionVlanT0() error = %v, wantErr %v", err, tt.wantErr)
+ }
+ case "VlanControl: OLTSVlan vs.UniVlan != of.VlanAny && vs.UniVlan != of.VlanNone":
+ vs.VlanControl = OLTSVlan
+ vs.UniVlan = vs.CVlan
+ if err := vs.setUSMatchActionVlanT1(tt.args.flow); (err != nil) != tt.wantErr {
+ t.Errorf("VoltService.setDSMatchActionVlanT0() error = %v, wantErr %v", err, tt.wantErr)
+ }
+ case "VlanControl: OLTSVlan vs.UniVlan == of.VlanNone":
+ vs.VlanControl = OLTSVlan
+ vs.UniVlan = of.VlanNone
+ if err := vs.setUSMatchActionVlanT1(tt.args.flow); (err != nil) != tt.wantErr {
+ t.Errorf("VoltService.setDSMatchActionVlanT0() error = %v, wantErr %v", err, tt.wantErr)
+ }
+ case "VlanControl: default":
+ vs.VlanControl = 6
+ err := vs.setUSMatchActionVlanT1(tt.args.flow)
+ assert.NotNil(t, err)
+ }
+ })
+ }
+}
+
+func TestVoltService_setUSMatchActionVlanT0(t *testing.T) {
+ type args struct {
+ flow *of.VoltSubFlow
+ }
+ tests := []struct {
+ name string
+ args args
+ wantErr bool
+ }{
+ {
+ name: "vs.VlanControl: ONUCVlanOLTSVlan",
+ args: args{
+ flow: &of.VoltSubFlow{
+ ErrorReason: "test_error_reason",
+ Cookie: uint64(1),
+ OldCookie: uint64(2),
+ TableID: uint32(3),
+ Priority: uint32(4),
+ State: uint8(5),
+ },
+ },
+ },
+ {
+ name: "vs.VlanControl: ONUCVlanOLTSVlan vs.UniVlan == of.VlanNone",
+ args: args{
+ flow: &of.VoltSubFlow{
+ ErrorReason: "test_error_reason",
+ Cookie: uint64(1),
+ OldCookie: uint64(2),
+ TableID: uint32(3),
+ Priority: uint32(4),
+ State: uint8(5),
+ },
+ },
+ },
+ {
+ name: "vs.VlanControl: OLTCVlanOLTSVlan",
+ args: args{
+ flow: &of.VoltSubFlow{
+ ErrorReason: "test_error_reason",
+ Cookie: uint64(1),
+ OldCookie: uint64(2),
+ TableID: uint32(3),
+ Priority: uint32(4),
+ State: uint8(5),
+ },
+ },
+ },
+ {
+ name: "vs.VlanControl: ONUCVlan",
+ args: args{
+ flow: &of.VoltSubFlow{
+ ErrorReason: "test_error_reason",
+ Cookie: uint64(1),
+ OldCookie: uint64(2),
+ TableID: uint32(3),
+ Priority: uint32(4),
+ State: uint8(5),
+ },
+ },
+ },
+ {
+ name: "vs.VlanControl: ONUCVlan vs.UniVlan == of.VlanNone",
+ args: args{
+ flow: &of.VoltSubFlow{
+ ErrorReason: "test_error_reason",
+ Cookie: uint64(1),
+ OldCookie: uint64(2),
+ TableID: uint32(3),
+ Priority: uint32(4),
+ State: uint8(5),
+ },
+ },
+ },
+ {
+ name: "vs.VlanControl: OLTSVlan",
+ args: args{
+ flow: &of.VoltSubFlow{
+ ErrorReason: "test_error_reason",
+ Cookie: uint64(1),
+ OldCookie: uint64(2),
+ TableID: uint32(3),
+ Priority: uint32(4),
+ State: uint8(5),
+ },
+ },
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ vs := &VoltService{}
+ switch tt.name {
+ case "vs.VlanControl: ONUCVlanOLTSVlan":
+ vs.VlanControl = ONUCVlanOLTSVlan
+ if err := vs.setUSMatchActionVlanT0(tt.args.flow); (err != nil) != tt.wantErr {
+ t.Errorf("VoltService.setUSMatchActionVlanT0() error = %v, wantErr %v", err, tt.wantErr)
+ }
+ case "vs.VlanControl: ONUCVlanOLTSVlan vs.UniVlan == of.VlanNone":
+ vs.VlanControl = ONUCVlanOLTSVlan
+ vs.UniVlan = of.VlanNone
+ if err := vs.setUSMatchActionVlanT0(tt.args.flow); (err != nil) != tt.wantErr {
+ t.Errorf("VoltService.setUSMatchActionVlanT0() error = %v, wantErr %v", err, tt.wantErr)
+ }
+ case "vs.VlanControl: OLTCVlanOLTSVlan":
+ vs.VlanControl = OLTCVlanOLTSVlan
+ if err := vs.setUSMatchActionVlanT0(tt.args.flow); (err != nil) != tt.wantErr {
+ t.Errorf("VoltService.setUSMatchActionVlanT0() error = %v, wantErr %v", err, tt.wantErr)
+ }
+ case "vs.VlanControl: ONUCVlan":
+ vs.VlanControl = ONUCVlan
+ if err := vs.setUSMatchActionVlanT0(tt.args.flow); (err != nil) != tt.wantErr {
+ t.Errorf("VoltService.setUSMatchActionVlanT0() error = %v, wantErr %v", err, tt.wantErr)
+ }
+ case "vs.VlanControl: ONUCVlan vs.UniVlan == of.VlanNone":
+ vs.VlanControl = ONUCVlan
+ vs.UniVlan = of.VlanNone
+ if err := vs.setUSMatchActionVlanT0(tt.args.flow); (err != nil) != tt.wantErr {
+ t.Errorf("VoltService.setUSMatchActionVlanT0() error = %v, wantErr %v", err, tt.wantErr)
+ }
+ case "vs.VlanControl: OLTSVlan":
+ vs.VlanControl = OLTSVlan
+ if err := vs.setUSMatchActionVlanT0(tt.args.flow); (err != nil) != tt.wantErr {
+ t.Errorf("VoltService.setUSMatchActionVlanT0() error = %v, wantErr %v", err, tt.wantErr)
+ }
+ }
+ })
+ }
+}
+
+func TestVoltService_setDSMatchActionVlanT1(t *testing.T) {
+ type args struct {
+ flow *of.VoltSubFlow
+ }
+ tests := []struct {
+ name string
+ args args
+ wantErr bool
+ }{
+ {
+ name: "vs.VlanControl: ONUCVlanOLTSVlan",
+ args: args{
+ flow: &of.VoltSubFlow{
+ ErrorReason: "test_error_reason",
+ Cookie: uint64(1),
+ OldCookie: uint64(2),
+ TableID: uint32(3),
+ Priority: uint32(4),
+ State: uint8(5),
+ },
+ },
+ },
+ {
+ name: "vs.VlanControl: ONUCVlanOLTSVlan vs.UniVlan == of.VlanNone",
+ args: args{
+ flow: &of.VoltSubFlow{
+ ErrorReason: "test_error_reason",
+ Cookie: uint64(1),
+ OldCookie: uint64(2),
+ TableID: uint32(3),
+ Priority: uint32(4),
+ State: uint8(5),
+ },
+ },
+ },
+ {
+ name: "vs.VlanControl: OLTCVlanOLTSVlan",
+ args: args{
+ flow: &of.VoltSubFlow{
+ ErrorReason: "test_error_reason",
+ Cookie: uint64(1),
+ OldCookie: uint64(2),
+ TableID: uint32(3),
+ Priority: uint32(4),
+ State: uint8(5),
+ },
+ },
+ },
+ {
+ name: "vs.VlanControl: ONUCVlan",
+ args: args{
+ flow: &of.VoltSubFlow{
+ ErrorReason: "test_error_reason",
+ Cookie: uint64(1),
+ OldCookie: uint64(2),
+ TableID: uint32(3),
+ Priority: uint32(4),
+ State: uint8(5),
+ },
+ },
+ },
+ {
+ name: "vs.VlanControl: ONUCVlan vs.UniVlan == of.VlanNone",
+ args: args{
+ flow: &of.VoltSubFlow{
+ ErrorReason: "test_error_reason",
+ Cookie: uint64(1),
+ OldCookie: uint64(2),
+ TableID: uint32(3),
+ Priority: uint32(4),
+ State: uint8(5),
+ },
+ },
+ },
+ {
+ name: "vs.VlanControl: OLTSVlan",
+ args: args{
+ flow: &of.VoltSubFlow{
+ ErrorReason: "test_error_reason",
+ Cookie: uint64(1),
+ OldCookie: uint64(2),
+ TableID: uint32(3),
+ Priority: uint32(4),
+ State: uint8(5),
+ },
+ },
+ },
+ {
+ name: "vs.VlanControl: default",
+ args: args{
+ flow: &of.VoltSubFlow{
+ ErrorReason: "test_error_reason",
+ Cookie: uint64(1),
+ OldCookie: uint64(2),
+ TableID: uint32(3),
+ Priority: uint32(4),
+ State: uint8(5),
+ },
+ },
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ vs := &VoltService{}
+ switch tt.name {
+ case "vs.VlanControl: ONUCVlanOLTSVlan":
+ vs.VlanControl = ONUCVlanOLTSVlan
+ if err := vs.setDSMatchActionVlanT1(tt.args.flow); (err != nil) != tt.wantErr {
+ t.Errorf("VoltService.setDSMatchActionVlanT1() error = %v, wantErr %v", err, tt.wantErr)
+ }
+ case "vs.VlanControl: ONUCVlanOLTSVlan vs.UniVlan == of.VlanNone":
+ vs.VlanControl = ONUCVlanOLTSVlan
+ vs.UniVlan = of.VlanNone
+ if err := vs.setDSMatchActionVlanT1(tt.args.flow); (err != nil) != tt.wantErr {
+ t.Errorf("VoltService.setDSMatchActionVlanT1() error = %v, wantErr %v", err, tt.wantErr)
+ }
+ case "vs.VlanControl: OLTCVlanOLTSVlan":
+ vs.VlanControl = OLTCVlanOLTSVlan
+ if err := vs.setDSMatchActionVlanT1(tt.args.flow); (err != nil) != tt.wantErr {
+ t.Errorf("VoltService.setDSMatchActionVlanT1() error = %v, wantErr %v", err, tt.wantErr)
+ }
+ case "vs.VlanControl: ONUCVlan":
+ vs.VlanControl = ONUCVlan
+ if err := vs.setDSMatchActionVlanT1(tt.args.flow); (err != nil) != tt.wantErr {
+ t.Errorf("VoltService.setDSMatchActionVlanT1() error = %v, wantErr %v", err, tt.wantErr)
+ }
+ case "vs.VlanControl: ONUCVlan vs.UniVlan == of.VlanNone":
+ vs.VlanControl = ONUCVlan
+ vs.UniVlan = of.VlanNone
+ if err := vs.setDSMatchActionVlanT1(tt.args.flow); (err != nil) != tt.wantErr {
+ t.Errorf("VoltService.setDSMatchActionVlanT1() error = %v, wantErr %v", err, tt.wantErr)
+ }
+ case "vs.VlanControl: OLTSVlan":
+ vs.VlanControl = OLTSVlan
+ if err := vs.setDSMatchActionVlanT1(tt.args.flow); (err != nil) != tt.wantErr {
+ t.Errorf("VoltService.setDSMatchActionVlanT1() error = %v, wantErr %v", err, tt.wantErr)
+ }
+ case "vs.VlanControl: default":
+ vs.VlanControl = 6
+ err := vs.setDSMatchActionVlanT1(tt.args.flow)
+ assert.NotNil(t, err)
+ }
+ })
+ }
+}
+
+func TestVoltService_SetIpv6Addr(t *testing.T) {
+ type args struct {
+ addr net.IP
+ }
+ tests := []struct {
+ name string
+ args args
+ }{
+ {
+ name: "SetIpv6Addr",
+ args: args{
+ addr: AllSystemsMulticastGroupIP,
+ },
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ vs := &VoltService{}
+ vs.SetIpv6Addr(tt.args.addr)
+ })
+ }
+}
+
+func TestVoltService_SetIpv4Addr(t *testing.T) {
+ type args struct {
+ addr net.IP
+ }
+ tests := []struct {
+ name string
+ args args
+ }{
+ {
+ name: "VoltService_SetIpv4Addr",
+ args: args{
+ addr: AllSystemsMulticastGroupIP,
+ },
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ vs := &VoltService{}
+ vs.SetIpv4Addr(tt.args.addr)
+ })
+ }
+}
+
+func TestVoltService_SetMacAddr(t *testing.T) {
+ type args struct {
+ addr net.HardwareAddr
+ }
+ tests := []struct {
+ name string
+ args args
+ }{
+ {
+ name: "VoltService_SetMacAddr",
+ args: args{
+ addr: BroadcastMAC,
+ },
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ vs := &VoltService{}
+ vs.SetMacAddr(tt.args.addr)
+ })
+ }
+}
+
+func TestVoltService_GetCircuitID(t *testing.T) {
+ tests := []struct {
+ name string
+ want []byte
+ }{
+ {
+ name: "VoltService_GetCircuitID",
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ vs := &VoltService{}
+ _ = vs.GetCircuitID()
+ })
+ }
+}
+
+func TestVoltService_GetRemoteID(t *testing.T) {
+ tests := []struct {
+ name string
+ want []byte
+ }{
+ {
+ name: "VoltService_GetRemoteID",
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ vs := &VoltService{}
+ _ = vs.GetRemoteID()
+ })
+ }
+}
+
+func TestVoltService_IPAssigned(t *testing.T) {
+ tests := []struct {
+ name string
+ want bool
+ }{
+ {
+ name: "VoltService_IPAssigned",
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ vs := &VoltService{}
+ _ = vs.IPAssigned()
+ })
+ }
+}
diff --git a/internal/test/mocks/mock_packet.go b/internal/test/mocks/mock_packet.go
new file mode 100644
index 0000000..3076ee5
--- /dev/null
+++ b/internal/test/mocks/mock_packet.go
@@ -0,0 +1,333 @@
+/*
+* Copyright 2022-present Open Networking Foundation
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+ */
+
+// Code generated by MockGen. DO NOT EDIT.
+// Source: /home/vinod/go/src/gerrit.opencord.org/voltha-go-controller/vendor/github.com/google/gopacket/packet.go
+
+// Package mock_gopacket is a generated GoMock package.
+package mocks
+
+import (
+ reflect "reflect"
+
+ gomock "github.com/golang/mock/gomock"
+ gopacket "github.com/google/gopacket"
+)
+
+// MockPacket is a mock of Packet interface.
+type MockPacket struct {
+ ctrl *gomock.Controller
+ recorder *MockPacketMockRecorder
+}
+
+// MockPacketMockRecorder is the mock recorder for MockPacket.
+type MockPacketMockRecorder struct {
+ mock *MockPacket
+}
+
+// NewMockPacket creates a new mock instance.
+func NewMockPacket(ctrl *gomock.Controller) *MockPacket {
+ mock := &MockPacket{ctrl: ctrl}
+ mock.recorder = &MockPacketMockRecorder{mock}
+ return mock
+}
+
+// EXPECT returns an object that allows the caller to indicate expected use.
+func (m *MockPacket) EXPECT() *MockPacketMockRecorder {
+ return m.recorder
+}
+
+// ApplicationLayer mocks base method.
+func (m *MockPacket) ApplicationLayer() gopacket.ApplicationLayer {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "ApplicationLayer")
+ ret0, _ := ret[0].(gopacket.ApplicationLayer)
+ return ret0
+}
+
+// ApplicationLayer indicates an expected call of ApplicationLayer.
+func (mr *MockPacketMockRecorder) ApplicationLayer() *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ApplicationLayer", reflect.TypeOf((*MockPacket)(nil).ApplicationLayer))
+}
+
+// Data mocks base method.
+func (m *MockPacket) Data() []byte {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "Data")
+ ret0, _ := ret[0].([]byte)
+ return ret0
+}
+
+// Data indicates an expected call of Data.
+func (mr *MockPacketMockRecorder) Data() *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Data", reflect.TypeOf((*MockPacket)(nil).Data))
+}
+
+// Dump mocks base method.
+func (m *MockPacket) Dump() string {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "Dump")
+ ret0, _ := ret[0].(string)
+ return ret0
+}
+
+// Dump indicates an expected call of Dump.
+func (mr *MockPacketMockRecorder) Dump() *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Dump", reflect.TypeOf((*MockPacket)(nil).Dump))
+}
+
+// ErrorLayer mocks base method.
+func (m *MockPacket) ErrorLayer() gopacket.ErrorLayer {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "ErrorLayer")
+ ret0, _ := ret[0].(gopacket.ErrorLayer)
+ return ret0
+}
+
+// ErrorLayer indicates an expected call of ErrorLayer.
+func (mr *MockPacketMockRecorder) ErrorLayer() *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ErrorLayer", reflect.TypeOf((*MockPacket)(nil).ErrorLayer))
+}
+
+// Layer mocks base method.
+func (m *MockPacket) Layer(arg0 gopacket.LayerType) gopacket.Layer {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "Layer", arg0)
+ ret0, _ := ret[0].(gopacket.Layer)
+ return ret0
+}
+
+// Layer indicates an expected call of Layer.
+func (mr *MockPacketMockRecorder) Layer(arg0 interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Layer", reflect.TypeOf((*MockPacket)(nil).Layer), arg0)
+}
+
+// LayerClass mocks base method.
+func (m *MockPacket) LayerClass(arg0 gopacket.LayerClass) gopacket.Layer {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "LayerClass", arg0)
+ ret0, _ := ret[0].(gopacket.Layer)
+ return ret0
+}
+
+// LayerClass indicates an expected call of LayerClass.
+func (mr *MockPacketMockRecorder) LayerClass(arg0 interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LayerClass", reflect.TypeOf((*MockPacket)(nil).LayerClass), arg0)
+}
+
+// Layers mocks base method.
+func (m *MockPacket) Layers() []gopacket.Layer {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "Layers")
+ ret0, _ := ret[0].([]gopacket.Layer)
+ return ret0
+}
+
+// Layers indicates an expected call of Layers.
+func (mr *MockPacketMockRecorder) Layers() *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Layers", reflect.TypeOf((*MockPacket)(nil).Layers))
+}
+
+// LinkLayer mocks base method.
+func (m *MockPacket) LinkLayer() gopacket.LinkLayer {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "LinkLayer")
+ ret0, _ := ret[0].(gopacket.LinkLayer)
+ return ret0
+}
+
+// LinkLayer indicates an expected call of LinkLayer.
+func (mr *MockPacketMockRecorder) LinkLayer() *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LinkLayer", reflect.TypeOf((*MockPacket)(nil).LinkLayer))
+}
+
+// Metadata mocks base method.
+func (m *MockPacket) Metadata() *gopacket.PacketMetadata {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "Metadata")
+ ret0, _ := ret[0].(*gopacket.PacketMetadata)
+ return ret0
+}
+
+// Metadata indicates an expected call of Metadata.
+func (mr *MockPacketMockRecorder) Metadata() *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Metadata", reflect.TypeOf((*MockPacket)(nil).Metadata))
+}
+
+// NetworkLayer mocks base method.
+func (m *MockPacket) NetworkLayer() gopacket.NetworkLayer {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "NetworkLayer")
+ ret0, _ := ret[0].(gopacket.NetworkLayer)
+ return ret0
+}
+
+// NetworkLayer indicates an expected call of NetworkLayer.
+func (mr *MockPacketMockRecorder) NetworkLayer() *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NetworkLayer", reflect.TypeOf((*MockPacket)(nil).NetworkLayer))
+}
+
+// String mocks base method.
+func (m *MockPacket) String() string {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "String")
+ ret0, _ := ret[0].(string)
+ return ret0
+}
+
+// String indicates an expected call of String.
+func (mr *MockPacketMockRecorder) String() *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "String", reflect.TypeOf((*MockPacket)(nil).String))
+}
+
+// TransportLayer mocks base method.
+func (m *MockPacket) TransportLayer() gopacket.TransportLayer {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "TransportLayer")
+ ret0, _ := ret[0].(gopacket.TransportLayer)
+ return ret0
+}
+
+// TransportLayer indicates an expected call of TransportLayer.
+func (mr *MockPacketMockRecorder) TransportLayer() *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TransportLayer", reflect.TypeOf((*MockPacket)(nil).TransportLayer))
+}
+
+// MockDumper is a mock of Dumper interface.
+type MockDumper struct {
+ ctrl *gomock.Controller
+ recorder *MockDumperMockRecorder
+}
+
+// MockDumperMockRecorder is the mock recorder for MockDumper.
+type MockDumperMockRecorder struct {
+ mock *MockDumper
+}
+
+// NewMockDumper creates a new mock instance.
+func NewMockDumper(ctrl *gomock.Controller) *MockDumper {
+ mock := &MockDumper{ctrl: ctrl}
+ mock.recorder = &MockDumperMockRecorder{mock}
+ return mock
+}
+
+// EXPECT returns an object that allows the caller to indicate expected use.
+func (m *MockDumper) EXPECT() *MockDumperMockRecorder {
+ return m.recorder
+}
+
+// Dump mocks base method.
+func (m *MockDumper) Dump() string {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "Dump")
+ ret0, _ := ret[0].(string)
+ return ret0
+}
+
+// Dump indicates an expected call of Dump.
+func (mr *MockDumperMockRecorder) Dump() *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Dump", reflect.TypeOf((*MockDumper)(nil).Dump))
+}
+
+// MockPacketDataSource is a mock of PacketDataSource interface.
+type MockPacketDataSource struct {
+ ctrl *gomock.Controller
+ recorder *MockPacketDataSourceMockRecorder
+}
+
+// MockPacketDataSourceMockRecorder is the mock recorder for MockPacketDataSource.
+type MockPacketDataSourceMockRecorder struct {
+ mock *MockPacketDataSource
+}
+
+// NewMockPacketDataSource creates a new mock instance.
+func NewMockPacketDataSource(ctrl *gomock.Controller) *MockPacketDataSource {
+ mock := &MockPacketDataSource{ctrl: ctrl}
+ mock.recorder = &MockPacketDataSourceMockRecorder{mock}
+ return mock
+}
+
+// EXPECT returns an object that allows the caller to indicate expected use.
+func (m *MockPacketDataSource) EXPECT() *MockPacketDataSourceMockRecorder {
+ return m.recorder
+}
+
+// ReadPacketData mocks base method.
+func (m *MockPacketDataSource) ReadPacketData() ([]byte, gopacket.CaptureInfo, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "ReadPacketData")
+ ret0, _ := ret[0].([]byte)
+ ret1, _ := ret[1].(gopacket.CaptureInfo)
+ ret2, _ := ret[2].(error)
+ return ret0, ret1, ret2
+}
+
+// ReadPacketData indicates an expected call of ReadPacketData.
+func (mr *MockPacketDataSourceMockRecorder) ReadPacketData() *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReadPacketData", reflect.TypeOf((*MockPacketDataSource)(nil).ReadPacketData))
+}
+
+// MockZeroCopyPacketDataSource is a mock of ZeroCopyPacketDataSource interface.
+type MockZeroCopyPacketDataSource struct {
+ ctrl *gomock.Controller
+ recorder *MockZeroCopyPacketDataSourceMockRecorder
+}
+
+// MockZeroCopyPacketDataSourceMockRecorder is the mock recorder for MockZeroCopyPacketDataSource.
+type MockZeroCopyPacketDataSourceMockRecorder struct {
+ mock *MockZeroCopyPacketDataSource
+}
+
+// NewMockZeroCopyPacketDataSource creates a new mock instance.
+func NewMockZeroCopyPacketDataSource(ctrl *gomock.Controller) *MockZeroCopyPacketDataSource {
+ mock := &MockZeroCopyPacketDataSource{ctrl: ctrl}
+ mock.recorder = &MockZeroCopyPacketDataSourceMockRecorder{mock}
+ return mock
+}
+
+// EXPECT returns an object that allows the caller to indicate expected use.
+func (m *MockZeroCopyPacketDataSource) EXPECT() *MockZeroCopyPacketDataSourceMockRecorder {
+ return m.recorder
+}
+
+// ZeroCopyReadPacketData mocks base method.
+func (m *MockZeroCopyPacketDataSource) ZeroCopyReadPacketData() ([]byte, gopacket.CaptureInfo, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "ZeroCopyReadPacketData")
+ ret0, _ := ret[0].([]byte)
+ ret1, _ := ret[1].(gopacket.CaptureInfo)
+ ret2, _ := ret[2].(error)
+ return ret0, ret1, ret2
+}
+
+// ZeroCopyReadPacketData indicates an expected call of ZeroCopyReadPacketData.
+func (mr *MockZeroCopyPacketDataSourceMockRecorder) ZeroCopyReadPacketData() *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ZeroCopyReadPacketData", reflect.TypeOf((*MockZeroCopyPacketDataSource)(nil).ZeroCopyReadPacketData))
+}
diff --git a/internal/test/mocks/mock_task_info.go b/internal/test/mocks/mock_task_info.go
new file mode 100644
index 0000000..5f8ba92
--- /dev/null
+++ b/internal/test/mocks/mock_task_info.go
@@ -0,0 +1,118 @@
+/*
+* Copyright 2022-present Open Networking Foundation
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+ */
+
+// Code generated by MockGen. DO NOT EDIT.
+// Source: /home/vinod/go/src/gerrit.opencord.org/voltha-go-controller/internal/pkg/tasks/task_intf.go
+
+// Package mock_tasks is a generated GoMock package.
+package mocks
+
+import (
+ context "context"
+ reflect "reflect"
+
+ gomock "github.com/golang/mock/gomock"
+)
+
+// MockTask is a mock of Task interface.
+type MockTask struct {
+ ctrl *gomock.Controller
+ recorder *MockTaskMockRecorder
+}
+
+// MockTaskMockRecorder is the mock recorder for MockTask.
+type MockTaskMockRecorder struct {
+ mock *MockTask
+}
+
+// NewMockTask creates a new mock instance.
+func NewMockTask(ctrl *gomock.Controller) *MockTask {
+ mock := &MockTask{ctrl: ctrl}
+ mock.recorder = &MockTaskMockRecorder{mock}
+ return mock
+}
+
+// EXPECT returns an object that allows the caller to indicate expected use.
+func (m *MockTask) EXPECT() *MockTaskMockRecorder {
+ return m.recorder
+}
+
+// Name mocks base method.
+func (m *MockTask) Name() string {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "Name")
+ ret0, _ := ret[0].(string)
+ return ret0
+}
+
+// Name indicates an expected call of Name.
+func (mr *MockTaskMockRecorder) Name() *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Name", reflect.TypeOf((*MockTask)(nil).Name))
+}
+
+// Start mocks base method.
+func (m *MockTask) Start(arg0 context.Context, arg1 uint8) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "Start", arg0, arg1)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// Start indicates an expected call of Start.
+func (mr *MockTaskMockRecorder) Start(arg0, arg1 interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Start", reflect.TypeOf((*MockTask)(nil).Start), arg0, arg1)
+}
+
+// Stop mocks base method.
+func (m *MockTask) Stop() {
+ m.ctrl.T.Helper()
+ m.ctrl.Call(m, "Stop")
+}
+
+// Stop indicates an expected call of Stop.
+func (mr *MockTaskMockRecorder) Stop() *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Stop", reflect.TypeOf((*MockTask)(nil).Stop))
+}
+
+// TaskID mocks base method.
+func (m *MockTask) TaskID() uint8 {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "TaskID")
+ ret0, _ := ret[0].(uint8)
+ return ret0
+}
+
+// TaskID indicates an expected call of TaskID.
+func (mr *MockTaskMockRecorder) TaskID() *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TaskID", reflect.TypeOf((*MockTask)(nil).TaskID))
+}
+
+// Timestamp mocks base method.
+func (m *MockTask) Timestamp() string {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "Timestamp")
+ ret0, _ := ret[0].(string)
+ return ret0
+}
+
+// Timestamp indicates an expected call of Timestamp.
+func (mr *MockTaskMockRecorder) Timestamp() *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Timestamp", reflect.TypeOf((*MockTask)(nil).Timestamp))
+}