Skip to content

Commit

Permalink
Merge pull request #104 from thomasferrandiz/fix-tests
Browse files Browse the repository at this point in the history
Bump to go 1.23.3 and delete network namespace after each test
  • Loading branch information
thomasferrandiz authored Nov 28, 2024
2 parents 399e862 + 4a32784 commit 0cab1c8
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/buildTests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
fail-fast: false
matrix:
go: [ "1.22.7" ]
go: [ "1.23.3" ]
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:
- created

env:
GO_VERSION: "1.22.7"
GO_VERSION: "1.23.3"
REPOSITORY: flannel/flannel-cni-plugin

jobs:
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ GO?=$(go)
GOPATH?=$(go env GOPATH)

# this is the upstream CNI plugin version used for testing
TEST_TAG?=v1.4.1
TEST_TAG?=v1.6.0

# Only enable CGO (and build the UDP backend) on AMD64
ifeq ($(ARCH),amd64)
Expand All @@ -21,7 +21,7 @@ else
endif

# Go version to use for builds. Can be overridden
GOLANG_VERSION?=1.22.7
GOLANG_VERSION?=1.23.3

build_all: vendor build_all_linux build_windows
@echo "All arches should be built for $(TAG)"
Expand Down
17 changes: 12 additions & 5 deletions flannel_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ import (
. "github.com/onsi/gomega"
)

func deleteNamespace(ns ns.NetNS) error {
if err := ns.Close(); err != nil {
return err
}
return testutils.UnmountNS(ns)
}

var _ = Describe("Flannel", func() {
var (
originalNS ns.NetNS
Expand All @@ -48,7 +55,7 @@ var _ = Describe("Flannel", func() {
})

AfterEach(func() {
Expect(originalNS.Close()).To(Succeed())
Expect(deleteNamespace(originalNS)).To(Succeed())
})

const hostLocalDataDir = "/var/lib/cni/networks/cni-flannel"
Expand Down Expand Up @@ -159,7 +166,7 @@ FLANNEL_IPMASQ=true

targetNs, err := testutils.NewNS()
Expect(err).NotTo(HaveOccurred())
defer targetNs.Close()
defer deleteNamespace(targetNs)

args := &skel.CmdArgs{
ContainerID: "some-container-id-ipv4",
Expand Down Expand Up @@ -238,7 +245,7 @@ FLANNEL_IPMASQ=true

targetNs, err := testutils.NewNS()
Expect(err).NotTo(HaveOccurred())
defer targetNs.Close()
defer deleteNamespace(targetNs)

args := &skel.CmdArgs{
ContainerID: "some-container-id-ipv4-multiple",
Expand Down Expand Up @@ -320,7 +327,7 @@ FLANNEL_IPMASQ=true

targetNs, err := testutils.NewNS()
Expect(err).NotTo(HaveOccurred())
defer targetNs.Close()
defer deleteNamespace(targetNs)

args := &skel.CmdArgs{
ContainerID: "some-container-id-ipv6",
Expand Down Expand Up @@ -399,7 +406,7 @@ FLANNEL_IPMASQ=true

targetNs, err := testutils.NewNS()
Expect(err).NotTo(HaveOccurred())
defer targetNs.Close()
defer deleteNamespace(targetNs)

args := &skel.CmdArgs{
ContainerID: "some-container-id-dual-stack",
Expand Down
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module github.com/flannel-io/cni-plugin

go 1.22
toolchain go1.23.2
go 1.23

require (
github.com/containernetworking/cni v1.2.3
Expand Down
2 changes: 1 addition & 1 deletion scripts/test_linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function download_cnis {

function testrun {
download_cnis
sudo -E bash -c "umask 0; PATH=${GOPATH}/dist:$(pwd)/dist:${PATH} go test $@"
sudo -E bash -c "umask 0; PATH=${GOPATH}/dist:$(pwd)/dist:${PATH} go test -count=1 $@"
}

COVERALLS=${COVERALLS:-""}
Expand Down
2 changes: 1 addition & 1 deletion scripts/version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ PLATFORM=${GOOS}-${GOARCH}
RELEASE=${PROG}-${GOARCH}
# hardcode versions unless set specifically
VERSION=${VERSION:-v1.0.0}
GOLANG_VERSION=${GOLANG_VERSION:-1.22.7}
GOLANG_VERSION=${GOLANG_VERSION:-1.23.3}

if [ -d .git ]; then
if [ -z "${GIT_TAG}" ]; then
Expand Down

0 comments on commit 0cab1c8

Please sign in to comment.