From 42cfe0f8dcae8919832c955502b1e9de32282f94 Mon Sep 17 00:00:00 2001 From: Mike Brown Date: Tue, 17 May 2022 13:12:12 -0500 Subject: [PATCH] add in some serial setup tests; a little make cleanup Signed-off-by: Mike Brown --- .github/workflows/ci.yml | 3 +- Makefile | 6 ++-- integration/cni_setup_teardown_linux_test.go | 32 +++++++++++++++++--- 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f8d5e06..aa92ca4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -89,8 +89,7 @@ jobs: - run: | bash -x script/install-cni - make clean V=1 - make bin/integration.test V=1 + sudo make clean V=1 make test V=1 sudo make integration V=1 working-directory: src/github.com/containerd/go-cni diff --git a/Makefile b/Makefile index 581265a..0b2edf7 100644 --- a/Makefile +++ b/Makefile @@ -31,12 +31,10 @@ help: ## this help test: ## run tests, except integration tests and tests that require root $(Q)go test -v -race $(EXTRA_TESTFLAGS) -count=1 ./... -integration: ## run integration test +integration: bin/integration.test ## run integration test $(Q)bin/integration.test -test.v -test.count=1 -test.root $(EXTRA_TESTFLAGS) -test.parallel $(TESTFLAGS_PARALLEL) -FORCE: - -bin/integration.test: FORCE ## build integration test binary into bin +bin/integration.test: ## build integration test binary into bin $(Q)cd ./integration && go test -race -c . -o ../bin/integration.test clean: ## clean up binaries diff --git a/integration/cni_setup_teardown_linux_test.go b/integration/cni_setup_teardown_linux_test.go index da8bafe..612cc2f 100644 --- a/integration/cni_setup_teardown_linux_test.go +++ b/integration/cni_setup_teardown_linux_test.go @@ -198,14 +198,26 @@ func TestBasicSetupAndRemove(t *testing.T) { // Setup network result, err := l.Setup(ctx, id, nsPath) - assert.NoError(t, err, "[%v] setup network for namespace %v", idx, nsPath) + assert.NoError(t, err, "[%v] setup network interfaces for namespace in parallel %v", idx, nsPath) ip := result.Interfaces[defaultIfName].IPConfigs[0].IP.String() t.Logf("[%v] ip is %v", idx, ip) assert.NoError(t, l.Remove(ctx, id, nsPath), - "[%v] teardown network for namespace %v", idx, nsPath, + "[%v] teardown network interfaces for namespace %v", idx, nsPath, + ) + + // Setup network serially + result, err = l.SetupSerially(ctx, id, nsPath) + assert.NoError(t, err, "[%v] setup network interfaces for namespace serially%v", idx, nsPath) + + ip = result.Interfaces[defaultIfName].IPConfigs[0].IP.String() + t.Logf("[%v] ip is %v", idx, ip) + + assert.NoError(t, + l.Remove(ctx, id, nsPath), + "[%v] teardown network interfaces for namespace %v", idx, nsPath, ) } } @@ -271,14 +283,26 @@ func TestBasicSetupAndRemovePluginWithoutVersion(t *testing.T) { // Setup network result, err := l.Setup(ctx, id, nsPath) - assert.NoError(t, err, "[%v] setup network for namespace %v", idx, nsPath) + assert.NoError(t, err, "[%v] setup network interfaces for namespace in parallel %v", idx, nsPath) ip := result.Interfaces[defaultIfName].IPConfigs[0].IP.String() t.Logf("[%v] ip is %v", idx, ip) assert.NoError(t, l.Remove(ctx, id, nsPath), - "[%v] teardown network for namespace %v", idx, nsPath, + "[%v] teardown network interfaces for namespace %v", idx, nsPath, + ) + + // Setup network serially + result, err = l.SetupSerially(ctx, id, nsPath) + assert.NoError(t, err, "[%v] setup network interfaces for namespace serially%v", idx, nsPath) + + ip = result.Interfaces[defaultIfName].IPConfigs[0].IP.String() + t.Logf("[%v] ip is %v", idx, ip) + + assert.NoError(t, + l.Remove(ctx, id, nsPath), + "[%v] teardown network interfaces for namespace %v", idx, nsPath, ) } }