Update tests to utilize ginkgo/v2

This commit updates the import of ginkgo to v2 in
all of the tests.

Signed-off-by: liornoy <lnoy@redhat.com>
Co-authored-by: Sascha Grunert <sgrunert@redhat.com>
This commit is contained in:
liornoy 2023-01-18 12:30:11 +02:00
parent 23c2134110
commit 2d1005ec02
No known key found for this signature in database
GPG Key ID: 8677C8CEE85F49DA
73 changed files with 107 additions and 99 deletions

View File

@ -28,7 +28,7 @@ import (
"strings" "strings"
"time" "time"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"github.com/onsi/gomega/gbytes" "github.com/onsi/gomega/gbytes"
"github.com/onsi/gomega/gexec" "github.com/onsi/gomega/gexec"

View File

@ -17,7 +17,7 @@ import (
"strings" "strings"
"testing" "testing"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"github.com/onsi/gomega/gexec" "github.com/onsi/gomega/gexec"
) )

View File

@ -14,7 +14,7 @@
package hns package hns
import ( import (
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"testing" "testing"

View File

@ -18,7 +18,7 @@ import (
"net" "net"
"github.com/Microsoft/hcsshim/hcn" "github.com/Microsoft/hcsshim/hcn"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )

View File

@ -17,7 +17,7 @@ package ip
import ( import (
"net" "net"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )

View File

@ -15,7 +15,7 @@
package ip_test package ip_test
import ( import (
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"testing" "testing"

View File

@ -19,7 +19,7 @@ import (
"fmt" "fmt"
"net" "net"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )
@ -174,8 +174,8 @@ var _ = Describe("IP Operations", func() {
} }
}) })
It("Decode", func() { Context("Decode", func() {
Context("valid IP", func() { It("valid IP", func() {
testCases := []struct { testCases := []struct {
text string text string
expected *IP expected *IP
@ -208,7 +208,7 @@ var _ = Describe("IP Operations", func() {
}) })
Context("empty text", func() { It("empty text", func() {
ip := &IP{} ip := &IP{}
err := json.Unmarshal([]byte(`""`), ip) err := json.Unmarshal([]byte(`""`), ip)
@ -216,7 +216,7 @@ var _ = Describe("IP Operations", func() {
Expect(ip).To(Equal(newIP(nil, nil))) Expect(ip).To(Equal(newIP(nil, nil)))
}) })
Context("invalid IP", func() { It("invalid IP", func() {
testCases := []struct { testCases := []struct {
text string text string
expectedErr error expectedErr error
@ -243,7 +243,7 @@ var _ = Describe("IP Operations", func() {
} }
}) })
Context("IP slice", func() { It("IP slice", func() {
testCases := []struct { testCases := []struct {
text string text string
expected []*IP expected []*IP

View File

@ -4,7 +4,7 @@ import (
"os" "os"
"time" "time"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )

View File

@ -20,7 +20,7 @@ import (
"fmt" "fmt"
"net" "net"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"github.com/containernetworking/plugins/pkg/ip" "github.com/containernetworking/plugins/pkg/ip"

View File

@ -25,7 +25,7 @@ import (
"github.com/vishvananda/netlink" "github.com/vishvananda/netlink"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )

View File

@ -15,7 +15,7 @@
package ipam_test package ipam_test
import ( import (
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"testing" "testing"

View File

@ -17,7 +17,7 @@ package link_test
import ( import (
"testing" "testing"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )

View File

@ -18,7 +18,7 @@ import (
"fmt" "fmt"
"github.com/networkplumbing/go-nft/nft" "github.com/networkplumbing/go-nft/nft"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"github.com/containernetworking/plugins/pkg/link" "github.com/containernetworking/plugins/pkg/link"

View File

@ -23,7 +23,7 @@ import (
"github.com/containernetworking/plugins/pkg/ns" "github.com/containernetworking/plugins/pkg/ns"
"github.com/containernetworking/plugins/pkg/testutils" "github.com/containernetworking/plugins/pkg/testutils"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"golang.org/x/sys/unix" "golang.org/x/sys/unix"
) )

View File

@ -18,15 +18,14 @@ import (
"math/rand" "math/rand"
"runtime" "runtime"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
"github.com/onsi/ginkgo/config"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"testing" "testing"
) )
func TestNs(t *testing.T) { func TestNs(t *testing.T) {
rand.Seed(config.GinkgoConfig.RandomSeed) rand.Seed(GinkgoRandomSeed())
runtime.LockOSThread() runtime.LockOSThread()
RegisterFailHandler(Fail) RegisterFailHandler(Fail)

View File

@ -7,7 +7,7 @@ import (
"os/exec" "os/exec"
"strings" "strings"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"github.com/onsi/gomega/gbytes" "github.com/onsi/gomega/gbytes"
"github.com/onsi/gomega/gexec" "github.com/onsi/gomega/gexec"

View File

@ -1,7 +1,7 @@
package main_test package main_test
import ( import (
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"testing" "testing"

View File

@ -22,7 +22,7 @@ import (
"github.com/containernetworking/plugins/pkg/ns" "github.com/containernetworking/plugins/pkg/ns"
"github.com/containernetworking/plugins/pkg/testutils" "github.com/containernetworking/plugins/pkg/testutils"
"github.com/coreos/go-iptables/iptables" "github.com/coreos/go-iptables/iptables"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )

View File

@ -23,7 +23,7 @@ import (
"github.com/containernetworking/plugins/pkg/ns" "github.com/containernetworking/plugins/pkg/ns"
"github.com/containernetworking/plugins/pkg/testutils" "github.com/containernetworking/plugins/pkg/testutils"
"github.com/containernetworking/plugins/pkg/utils/sysctl" "github.com/containernetworking/plugins/pkg/utils/sysctl"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"github.com/vishvananda/netlink" "github.com/vishvananda/netlink"
) )
@ -37,7 +37,7 @@ var _ = Describe("Sysctl tests", func() {
var testIfaceName string var testIfaceName string
var cleanup func() var cleanup func()
BeforeEach(func() { beforeEach := func() {
// Save a reference to the original namespace, // Save a reference to the original namespace,
// Add a new NS // Add a new NS
@ -67,7 +67,7 @@ var _ = Describe("Sysctl tests", func() {
currNs.Set() currNs.Set()
} }
}) }
AfterEach(func() { AfterEach(func() {
cleanup() cleanup()
@ -75,6 +75,7 @@ var _ = Describe("Sysctl tests", func() {
Describe("Sysctl", func() { Describe("Sysctl", func() {
It("reads keys with dot separators", func() { It("reads keys with dot separators", func() {
beforeEach()
sysctlIfaceName := strings.Replace(testIfaceName, ".", "/", -1) sysctlIfaceName := strings.Replace(testIfaceName, ".", "/", -1)
sysctlKey := fmt.Sprintf(sysctlDotKeyTemplate, sysctlIfaceName) sysctlKey := fmt.Sprintf(sysctlDotKeyTemplate, sysctlIfaceName)
@ -85,6 +86,7 @@ var _ = Describe("Sysctl tests", func() {
Describe("Sysctl", func() { Describe("Sysctl", func() {
It("reads keys with slash separators", func() { It("reads keys with slash separators", func() {
beforeEach()
sysctlKey := fmt.Sprintf(sysctlSlashKeyTemplate, testIfaceName) sysctlKey := fmt.Sprintf(sysctlSlashKeyTemplate, testIfaceName)
_, err := sysctl.Sysctl(sysctlKey) _, err := sysctl.Sysctl(sysctlKey)
@ -94,6 +96,7 @@ var _ = Describe("Sysctl tests", func() {
Describe("Sysctl", func() { Describe("Sysctl", func() {
It("writes keys with dot separators", func() { It("writes keys with dot separators", func() {
beforeEach()
sysctlIfaceName := strings.Replace(testIfaceName, ".", "/", -1) sysctlIfaceName := strings.Replace(testIfaceName, ".", "/", -1)
sysctlKey := fmt.Sprintf(sysctlDotKeyTemplate, sysctlIfaceName) sysctlKey := fmt.Sprintf(sysctlDotKeyTemplate, sysctlIfaceName)
@ -104,6 +107,7 @@ var _ = Describe("Sysctl tests", func() {
Describe("Sysctl", func() { Describe("Sysctl", func() {
It("writes keys with slash separators", func() { It("writes keys with slash separators", func() {
beforeEach()
sysctlKey := fmt.Sprintf(sysctlSlashKeyTemplate, testIfaceName) sysctlKey := fmt.Sprintf(sysctlSlashKeyTemplate, testIfaceName)
_, err := sysctl.Sysctl(sysctlKey, "1") _, err := sysctl.Sysctl(sysctlKey, "1")

View File

@ -17,7 +17,7 @@ package sysctl_test
import ( import (
"testing" "testing"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )

View File

@ -15,7 +15,7 @@
package utils_test package utils_test
import ( import (
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"testing" "testing"

View File

@ -18,7 +18,7 @@ import (
"fmt" "fmt"
"strings" "strings"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )

View File

@ -29,7 +29,7 @@ import (
"github.com/vishvananda/netlink" "github.com/vishvananda/netlink"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )

View File

@ -15,7 +15,7 @@
package main package main
import ( import (
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"testing" "testing"

View File

@ -37,7 +37,7 @@ import (
"github.com/d2g/dhcp4server/leasepool" "github.com/d2g/dhcp4server/leasepool"
"github.com/d2g/dhcp4server/leasepool/memorypool" "github.com/d2g/dhcp4server/leasepool/memorypool"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )

View File

@ -15,7 +15,7 @@
package allocator_test package allocator_test
import ( import (
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"testing" "testing"

View File

@ -22,7 +22,7 @@ import (
current "github.com/containernetworking/cni/pkg/types/100" current "github.com/containernetworking/cni/pkg/types/100"
fakestore "github.com/containernetworking/plugins/plugins/ipam/host-local/backend/testing" fakestore "github.com/containernetworking/plugins/plugins/ipam/host-local/backend/testing"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )

View File

@ -18,7 +18,7 @@ import (
"net" "net"
"github.com/containernetworking/cni/pkg/types" "github.com/containernetworking/cni/pkg/types"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )

View File

@ -17,7 +17,7 @@ package allocator
import ( import (
"net" "net"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )

View File

@ -19,8 +19,7 @@ import (
"github.com/containernetworking/cni/pkg/types" "github.com/containernetworking/cni/pkg/types"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/ginkgo/extensions/table"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )

View File

@ -15,7 +15,7 @@
package disk package disk
import ( import (
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"testing" "testing"

View File

@ -18,7 +18,7 @@ import (
"os" "os"
"path/filepath" "path/filepath"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )

View File

@ -18,7 +18,7 @@ import (
"os" "os"
"github.com/containernetworking/cni/pkg/types" "github.com/containernetworking/cni/pkg/types"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )

View File

@ -15,7 +15,7 @@
package main package main
import ( import (
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"testing" "testing"

View File

@ -27,7 +27,7 @@ import (
"github.com/containernetworking/plugins/pkg/testutils" "github.com/containernetworking/plugins/pkg/testutils"
"github.com/containernetworking/plugins/plugins/ipam/host-local/backend/disk" "github.com/containernetworking/plugins/plugins/ipam/host-local/backend/disk"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )

View File

@ -17,7 +17,7 @@ package main_test
import ( import (
"testing" "testing"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )

View File

@ -24,7 +24,7 @@ import (
types100 "github.com/containernetworking/cni/pkg/types/100" types100 "github.com/containernetworking/cni/pkg/types/100"
"github.com/containernetworking/plugins/pkg/testutils" "github.com/containernetworking/plugins/pkg/testutils"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )

View File

@ -15,13 +15,26 @@
package main package main
import ( import (
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"testing" "testing"
) )
var (
resolvConf string
err error
)
func TestBridge(t *testing.T) { func TestBridge(t *testing.T) {
RegisterFailHandler(Fail) RegisterFailHandler(Fail)
resolvConf, err = newResolvConf()
Expect(err).NotTo(HaveOccurred())
RunSpecs(t, "plugins/main/bridge") RunSpecs(t, "plugins/main/bridge")
} }
var _ = AfterSuite(func() {
deleteResolvConf(resolvConf)
})

View File

@ -36,7 +36,7 @@ import (
"github.com/vishvananda/netlink" "github.com/vishvananda/netlink"
"github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator" "github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )
@ -1619,9 +1619,6 @@ var _ = Describe("bridge Operations", func() {
var originalNS, targetNS ns.NetNS var originalNS, targetNS ns.NetNS
var dataDir string var dataDir string
resolvConf, err := newResolvConf()
Expect(err).NotTo(HaveOccurred())
BeforeEach(func() { BeforeEach(func() {
// Create a new NetNS so we don't modify the host // Create a new NetNS so we don't modify the host
var err error var err error
@ -1645,10 +1642,6 @@ var _ = Describe("bridge Operations", func() {
Expect(testutils.UnmountNS(targetNS)).To(Succeed()) Expect(testutils.UnmountNS(targetNS)).To(Succeed())
}) })
AfterSuite(func() {
deleteResolvConf(resolvConf)
})
for _, ver := range testutils.AllSpecVersions { for _, ver := range testutils.AllSpecVersions {
// Redefine ver inside for scope so real value is picked up by each dynamically defined It() // Redefine ver inside for scope so real value is picked up by each dynamically defined It()
// See Gingkgo's "Patterns for dynamically generating tests" documentation. // See Gingkgo's "Patterns for dynamically generating tests" documentation.

View File

@ -17,7 +17,7 @@ package main_test
import ( import (
"github.com/onsi/gomega/gexec" "github.com/onsi/gomega/gexec"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"testing" "testing"

View File

@ -34,7 +34,7 @@ import (
"github.com/vishvananda/netlink" "github.com/vishvananda/netlink"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )

View File

@ -15,7 +15,7 @@
package main package main
import ( import (
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"testing" "testing"

View File

@ -31,7 +31,7 @@ import (
"github.com/containernetworking/plugins/pkg/ns" "github.com/containernetworking/plugins/pkg/ns"
"github.com/containernetworking/plugins/pkg/testutils" "github.com/containernetworking/plugins/pkg/testutils"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"github.com/vishvananda/netlink" "github.com/vishvananda/netlink"
) )

View File

@ -15,7 +15,7 @@
package main package main
import ( import (
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"testing" "testing"

View File

@ -33,7 +33,7 @@ import (
"github.com/vishvananda/netlink" "github.com/vishvananda/netlink"
"github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator" "github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )

View File

@ -17,7 +17,7 @@ package main_test
import ( import (
"github.com/onsi/gomega/gexec" "github.com/onsi/gomega/gexec"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"testing" "testing"

View File

@ -22,7 +22,7 @@ import (
"github.com/containernetworking/plugins/pkg/ns" "github.com/containernetworking/plugins/pkg/ns"
"github.com/containernetworking/plugins/pkg/testutils" "github.com/containernetworking/plugins/pkg/testutils"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"github.com/onsi/gomega/gbytes" "github.com/onsi/gomega/gbytes"
"github.com/onsi/gomega/gexec" "github.com/onsi/gomega/gexec"

View File

@ -15,7 +15,7 @@
package main package main
import ( import (
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"testing" "testing"

View File

@ -33,7 +33,7 @@ import (
"github.com/vishvananda/netlink" "github.com/vishvananda/netlink"
"github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator" "github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )

View File

@ -15,7 +15,7 @@
package main package main
import ( import (
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"testing" "testing"

View File

@ -31,7 +31,7 @@ import (
"github.com/vishvananda/netlink" "github.com/vishvananda/netlink"
"github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator" "github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )

View File

@ -17,7 +17,7 @@ package main
import ( import (
"testing" "testing"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )

View File

@ -23,7 +23,7 @@ import (
"strings" "strings"
"syscall" "syscall"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"github.com/vishvananda/netlink" "github.com/vishvananda/netlink"

View File

@ -15,7 +15,7 @@
package main package main
import ( import (
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"testing" "testing"

View File

@ -33,7 +33,7 @@ import (
"github.com/vishvananda/netlink" "github.com/vishvananda/netlink"
"github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator" "github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )

View File

@ -31,7 +31,7 @@ import (
"github.com/containernetworking/plugins/pkg/ns" "github.com/containernetworking/plugins/pkg/ns"
"github.com/containernetworking/plugins/pkg/testutils" "github.com/containernetworking/plugins/pkg/testutils"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"github.com/onsi/gomega/gexec" "github.com/onsi/gomega/gexec"
) )

View File

@ -30,7 +30,7 @@ import (
"github.com/vishvananda/netlink" "github.com/vishvananda/netlink"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )

View File

@ -30,7 +30,7 @@ import (
"github.com/godbus/dbus/v5" "github.com/godbus/dbus/v5"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )

View File

@ -26,7 +26,7 @@ import (
types100 "github.com/containernetworking/cni/pkg/types/100" types100 "github.com/containernetworking/cni/pkg/types/100"
"github.com/containernetworking/plugins/pkg/ns" "github.com/containernetworking/plugins/pkg/ns"
"github.com/containernetworking/plugins/pkg/testutils" "github.com/containernetworking/plugins/pkg/testutils"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )

View File

@ -31,7 +31,7 @@ import (
"github.com/coreos/go-iptables/iptables" "github.com/coreos/go-iptables/iptables"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )

View File

@ -15,7 +15,7 @@
package main package main
import ( import (
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"testing" "testing"

View File

@ -23,7 +23,7 @@ import (
"github.com/containernetworking/plugins/pkg/ns" "github.com/containernetworking/plugins/pkg/ns"
"github.com/containernetworking/plugins/pkg/testutils" "github.com/containernetworking/plugins/pkg/testutils"
"github.com/coreos/go-iptables/iptables" "github.com/coreos/go-iptables/iptables"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )
@ -36,7 +36,7 @@ var _ = Describe("chain tests", func() {
var testNs ns.NetNS var testNs ns.NetNS
var cleanup func() var cleanup func()
BeforeEach(func() { beforeEach := func() {
// Save a reference to the original namespace, // Save a reference to the original namespace,
// Add a new NS // Add a new NS
@ -84,9 +84,10 @@ var _ = Describe("chain tests", func() {
currNs.Set() currNs.Set()
} }
}) }
It("creates and destroys a chain", func() { It("creates and destroys a chain", func() {
beforeEach()
defer cleanup() defer cleanup()
tlChainName := testChain.entryChains[0] tlChainName := testChain.entryChains[0]
@ -152,6 +153,7 @@ var _ = Describe("chain tests", func() {
}) })
It("creates chains idempotently", func() { It("creates chains idempotently", func() {
beforeEach()
defer cleanup() defer cleanup()
err := testChain.setup(ipt) err := testChain.setup(ipt)
@ -171,6 +173,7 @@ var _ = Describe("chain tests", func() {
}) })
It("deletes chains idempotently", func() { It("deletes chains idempotently", func() {
beforeEach()
defer cleanup() defer cleanup()
err := testChain.setup(ipt) err := testChain.setup(ipt)
@ -199,6 +202,7 @@ var _ = Describe("chain tests", func() {
}) })
It("deletes chains idempotently in parallel", func() { It("deletes chains idempotently in parallel", func() {
beforeEach()
defer cleanup() defer cleanup()
// number of parallel executions // number of parallel executions
N := 10 N := 10

View File

@ -29,14 +29,12 @@ import (
"github.com/containernetworking/plugins/pkg/ns" "github.com/containernetworking/plugins/pkg/ns"
"github.com/containernetworking/plugins/pkg/testutils" "github.com/containernetworking/plugins/pkg/testutils"
"github.com/coreos/go-iptables/iptables" "github.com/coreos/go-iptables/iptables"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"github.com/onsi/gomega/gexec" "github.com/onsi/gomega/gexec"
"github.com/vishvananda/netlink" "github.com/vishvananda/netlink"
) )
const TIMEOUT = 90
func makeConfig(ver string) *libcni.NetworkConfigList { func makeConfig(ver string) *libcni.NetworkConfigList {
configList, err := libcni.ConfListFromBytes([]byte(fmt.Sprintf(`{ configList, err := libcni.ConfListFromBytes([]byte(fmt.Sprintf(`{
"cniVersion": "%s", "cniVersion": "%s",
@ -224,7 +222,7 @@ var _ = Describe("portmap integration tests", func() {
} }
close(done) close(done)
}, TIMEOUT*9) })
It(fmt.Sprintf("[%s] forwards a UDP port on ipv4 and keep working after creating a second container with the same HostPort", ver), func(done Done) { It(fmt.Sprintf("[%s] forwards a UDP port on ipv4 and keep working after creating a second container with the same HostPort", ver), func(done Done) {
var err error var err error
@ -421,7 +419,7 @@ var _ = Describe("portmap integration tests", func() {
} }
close(done) close(done)
}, TIMEOUT*9) })
}) })
} }
}) })

View File

@ -24,8 +24,7 @@ import (
"github.com/containernetworking/plugins/pkg/ns" "github.com/containernetworking/plugins/pkg/ns"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
"github.com/onsi/ginkgo/config"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"github.com/onsi/gomega/gbytes" "github.com/onsi/gomega/gbytes"
"github.com/onsi/gomega/gexec" "github.com/onsi/gomega/gexec"
@ -34,7 +33,7 @@ import (
) )
func TestPortmap(t *testing.T) { func TestPortmap(t *testing.T) {
rand.Seed(config.GinkgoConfig.RandomSeed) rand.Seed(GinkgoRandomSeed())
RegisterFailHandler(Fail) RegisterFailHandler(Fail)
RunSpecs(t, "plugins/meta/portmap") RunSpecs(t, "plugins/meta/portmap")

View File

@ -19,7 +19,7 @@ import (
"github.com/containernetworking/cni/pkg/types" "github.com/containernetworking/cni/pkg/types"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )

View File

@ -26,7 +26,7 @@ import (
"github.com/vishvananda/netlink" "github.com/vishvananda/netlink"
"golang.org/x/sys/unix" "golang.org/x/sys/unix"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )

View File

@ -3,7 +3,7 @@
package main package main
import ( import (
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"testing" "testing"

View File

@ -15,7 +15,7 @@
package main package main
import ( import (
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"testing" "testing"

View File

@ -30,7 +30,7 @@ import (
"github.com/vishvananda/netlink" "github.com/vishvananda/netlink"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )

View File

@ -15,7 +15,7 @@
package main package main
import ( import (
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"testing" "testing"

View File

@ -26,8 +26,7 @@ import (
"github.com/vishvananda/netlink" "github.com/vishvananda/netlink"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/ginkgo/extensions/table"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )

View File

@ -20,7 +20,7 @@ import (
"github.com/containernetworking/cni/pkg/skel" "github.com/containernetworking/cni/pkg/skel"
"github.com/containernetworking/plugins/pkg/ns" "github.com/containernetworking/plugins/pkg/ns"
"github.com/containernetworking/plugins/pkg/testutils" "github.com/containernetworking/plugins/pkg/testutils"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )

View File

@ -3,7 +3,7 @@
package main package main
import ( import (
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"testing" "testing"