Skip to content

Commit

Permalink
dp, tests: rename the test variables
Browse files Browse the repository at this point in the history
Signed-off-by: Miguel Duarte Barroso <[email protected]>
  • Loading branch information
maiqueb committed May 19, 2021
1 parent 127ae67 commit f0cd8d6
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions pkg/deviceplugin/plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,30 +57,30 @@ func (s *ListAndWatchServerSendSpy) SetTrailer(m metadata.MD) {
}

var _ = Describe("Macvtap", func() {
var masterIfaceName string
var masterIface netlink.Link
var lowerDeviceIfaceName string
var lowerDeviceIface netlink.Link
var testNs ns.NetNS

BeforeEach(func() {
var err error
testNs, err = testutils.NewNS()
Expect(err).NotTo(HaveOccurred())

masterIfaceName = fmt.Sprintf("master%d", rand.Intn(100))
masterIface = &netlink.Dummy{
lowerDeviceIfaceName = fmt.Sprintf("lowerdev%d", rand.Intn(100))
lowerDeviceIface = &netlink.Dummy{
LinkAttrs: netlink.LinkAttrs{
Name: masterIfaceName,
Name: lowerDeviceIfaceName,
Namespace: netlink.NsFd(int(testNs.Fd())),
},
}

err = netlink.LinkAdd(masterIface)
err = netlink.LinkAdd(lowerDeviceIface)
Expect(err).NotTo(HaveOccurred())
})

AfterEach(func() {
testNs.Do(func(ns ns.NetNS) error {
netlink.LinkDel(masterIface)
netlink.LinkDel(lowerDeviceIface)
return nil
})
})
Expand All @@ -90,7 +90,7 @@ var _ = Describe("Macvtap", func() {
var sendSpy *ListAndWatchServerSendSpy

BeforeEach(func() {
mvdp = NewMacvtapDevicePlugin(masterIfaceName, masterIfaceName, "bridge", 0, testNs.Path())
mvdp = NewMacvtapDevicePlugin(lowerDeviceIfaceName, lowerDeviceIfaceName, "bridge", 0, testNs.Path())
sendSpy = &ListAndWatchServerSendSpy{}
go func() {
err := mvdp.ListAndWatch(nil, sendSpy)
Expand All @@ -103,7 +103,7 @@ var _ = Describe("Macvtap", func() {
})

It("should allocate a new device upon request", func() {
ifaceName := masterIfaceName + "Mvp99"
ifaceName := lowerDeviceIfaceName + "Mvp99"
req := &pluginapi.AllocateRequest{
ContainerRequests: []*pluginapi.ContainerAllocateRequest{
{
Expand Down Expand Up @@ -132,7 +132,7 @@ var _ = Describe("Macvtap", func() {
Expect(dev.HostPath).To(Equal(dev.ContainerPath))
})

Context("when master device does not exist", func() {
Context("when lower device does not exist", func() {
It("should not advertise devices", func() {
By("first advertising healthy devices", func() {
Eventually(func() int {
Expand All @@ -142,9 +142,9 @@ var _ = Describe("Macvtap", func() {
Expect(sendSpy.last.Devices).To(HaveLen(100))
})

By("then deleting the master device", func() {
By("then deleting the lower device", func() {
err := testNs.Do(func(ns ns.NetNS) error {
return util.LinkDelete(masterIfaceName)
return util.LinkDelete(lowerDeviceIfaceName)
})
Expect(err).NotTo(HaveOccurred())
})
Expand Down Expand Up @@ -183,10 +183,10 @@ var _ = Describe("Macvtap", func() {
resourceName := "dataplane"
mode := "vepa"
capacity := 30
config := `[{"name":"%s","master":"%s","mode":"%s","capacity":%d}]`
config := `[{"name":"%s","lowerDevice":"%s","mode":"%s","capacity":%d}]`

BeforeEach(func() {
config = fmt.Sprintf(config, resourceName, masterIfaceName, mode, capacity)
config = fmt.Sprintf(config, resourceName, lowerDeviceIfaceName, mode, capacity)
os.Setenv(ConfigEnvironmentVariable, config)
})

Expand All @@ -200,7 +200,7 @@ var _ = Describe("Macvtap", func() {

plugin := lister.NewPlugin(resourceName)
Expect(plugin.(*macvtapDevicePlugin).Name).To(Equal(resourceName))
Expect(plugin.(*macvtapDevicePlugin).Master).To(Equal(masterIfaceName))
Expect(plugin.(*macvtapDevicePlugin).LowerDevice).To(Equal(lowerDeviceIfaceName))
Expect(plugin.(*macvtapDevicePlugin).Mode).To(Equal(mode))
Expect(plugin.(*macvtapDevicePlugin).Capacity).To(Equal(capacity))
})
Expand Down Expand Up @@ -238,7 +238,7 @@ var _ = Describe("Macvtap", func() {

plugin := lister.NewPlugin(parentName)
Expect(plugin.(*macvtapDevicePlugin).Name).To(Equal(parentName))
Expect(plugin.(*macvtapDevicePlugin).Master).To(Equal(parentName))
Expect(plugin.(*macvtapDevicePlugin).LowerDevice).To(Equal(parentName))
Expect(plugin.(*macvtapDevicePlugin).Mode).To(Equal(DefaultMode))
Expect(plugin.(*macvtapDevicePlugin).Capacity).To(Equal(DefaultCapacity))
})
Expand Down

0 comments on commit f0cd8d6

Please sign in to comment.