Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions .ci/buildspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,16 @@ phases:

build:
commands:
- make go-check
- make mdlint

- make -C vpp-manager clean-vpp
- make clean-vpp
- make images
- docker images

- make run-integration-tests
- make mdlint
- make ci-lint
- make ci-test
- make ci-cov

- make push

post_build:
commands:
- echo "Build complete"

- echo Build completed on `date`
2 changes: 1 addition & 1 deletion Dockerfile.depend
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ENV UNATTENDED=y

RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y -qq \
apt-utils wget cmake curl git
apt-utils wget cmake curl git docker.io

ENV GOVERSION=1.24.0
ENV GOROOT="/root/.go"
Expand Down
84 changes: 65 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@ include common.mk
check-%:
@: $(if $(value $*),,$(error $* is undefined))

bin:
@mkdir -p bin

.PHONY: calicovppctl
calicovppctl: bin
${DOCKER_RUN} go build -o bin/calicovppctl ./cmd/calicovppctl/main.go

.PHONY: build
build:
build: calicovppctl
$(MAKE) -C calico-vpp-agent $@
$(MAKE) -C vpp-manager $@
$(MAKE) -C multinet-monitor $@
@mkdir -p cmd/bin
go build -o cmd/bin/calicovppctl ./cmd/calicovppctl/main.go

.PHONY: image images
images: image
Expand Down Expand Up @@ -56,6 +61,10 @@ dev:
$(MAKE) -C vpp-manager ALSO_LATEST=y $@
$(MAKE) -C multinet-monitor ALSO_LATEST=y $@

.PHONY: clean-vpp
clean-vpp:
$(MAKE) -C vpp-manager clean-vpp

.PHONY: proto
proto:
$(MAKE) -C calico-vpp-agent $@
Expand Down Expand Up @@ -284,22 +293,14 @@ lint:
test -d vpp-manager/vpp_build && touch vpp-manager/vpp_build/go.mod || true
golangci-lint run --color=never

.PHONY: test
test: go-lint
rm -rf .coverage/unit
mkdir -p .coverage/unit
go test -cover -covermode=atomic ./... \
-args \
-test.gocoverdir=$(shell pwd)/.coverage/unit

.PHONY: cov-html
cov-html:
go tool covdata percent -i=.coverage/unit
go tool covdata textfmt -i=.coverage/unit -o .coverage/profile
go tool cover -html=.coverage/profile

.PHONY: cov
cov: test
cov:
go tool covdata percent -i=.coverage/unit
@go tool covdata textfmt -i=.coverage/unit -o .coverage/profile
@echo "TOTAL:"
Expand Down Expand Up @@ -347,16 +348,61 @@ builder-image: ## Make dependencies image. (Not required normally; is implied in
&& ${PUSH_IMAGE} )
docker tag ${DEPEND_IMAGE} ${DEPEND_BASE}:latest

.PHONY: go-check
go-check: builder-image
@echo Checking go code
# make test - runs the unit & VPP-integration tests
# requiring sudo, this is useful in dev as this caches go deps.
# Altought this requires go, sudo installed
.PHONY: test
test: builder-image bin
@rm -rf $(shell pwd)/.coverage/unit
@mkdir -p $(shell pwd)/.coverage/unit
$(MAKE) -C vpp-manager image
$(MAKE) -C vpp-manager mock-pod-image
sudo -E env "PATH=$$PATH" VPP_BINARY=/usr/bin/vpp \
VPP_IMAGE=calicovpp/vpp:$(TAG) \
go test ./... \
-cover \
-covermode=atomic \
# we prevent parallel test execution
# as test infra does not currently support parallel VPPs
-p 1 \
-test.v \
-test.gocoverdir=$(shell pwd)/.coverage/unit \

# make ci-test - runs the unit & VPP-integration tests
# within a container, with mounted /var/run/docker.sock
# this is portable, but lack go cache
.PHONY: ci-test
ci-test: builder-image bin
@rm -rf $(shell pwd)/.coverage/unit
@mkdir -p $(shell pwd)/.coverage/unit
$(MAKE) -C vpp-manager image
$(MAKE) -C vpp-manager mock-pod-image
docker run -t --rm \
--privileged \
--pid=host \
-v /proc:/proc \
-v $(CURDIR):/vpp-dataplane \
-v /tmp/cni-tests-vpp:/tmp/cni-tests-vpp \
-v /var/run/docker.sock:/var/run/docker.sock \
--env VPP_BINARY=/usr/bin/vpp \
--env VPP_IMAGE=calicovpp/vpp:$(TAG) \
-w /vpp-dataplane \
${DEPEND_IMAGE} \
make -C /vpp-dataplane cov

.PHONY: go-lint
go-lint: lint
go test ./... \
-cover \
-covermode=atomic \
# we prevent parallel test execution
# as test infra does not currently support parallel VPPs
-p 1 \
-test.v \
-test.gocoverdir=/vpp-dataplane/.coverage/unit

.PHONY: ci-%
ci-%: builder-image
docker run -t --rm \
-v $(CURDIR):/vpp-dataplane \
${DEPEND_IMAGE} \
make -C /vpp-dataplane $*

.PHONY: depend-image-hash
depend-image-hash:
Expand Down
30 changes: 18 additions & 12 deletions calico-vpp-agent/Makefile
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
include ../common.mk

.PHONY: all build gobgp image push proto

TAG ?= latest # Tag images with :$(TAG)
ALSO_LATEST ?= n # If 'y' also tag images with :latest
GENERATE_LOG_FILE=../vpplink/generated/generate.log
VERSION_FILE=version

all: build gobgp image
.PHONY: all
all: image

bin:
mkdir -p bin

.PHONY: felix-api-proxy
felix-api-proxy: bin
${DOCKER_RUN} go build -o ./bin/felix-api-proxy ./cmd/api-proxy

build: felix-api-proxy bin
${DOCKER_RUN} go build -o ./bin/calico-vpp-agent ./cmd

gobgp: bin
.PHONY: build
build: bin
${DOCKER_RUN} go build $(COVER_OPTS) -o ./bin/felix-api-proxy ./cmd/api-proxy
${DOCKER_RUN} go build $(COVER_OPTS) -o ./bin/calico-vpp-agent ./cmd
${DOCKER_RUN} go build -o ./bin/gobgp github.com/osrg/gobgp/v3/cmd/gobgp/

image: build gobgp
.PHONY: image
image: build
@echo "Image tag : $(TAG)" > $(VERSION_FILE)
@echo "VPP-dataplane version : $(shell git log -1 --oneline)" >> $(VERSION_FILE)
@cat $(GENERATE_LOG_FILE) >> $(VERSION_FILE)
Expand All @@ -32,6 +28,14 @@ image: build gobgp
docker tag calicovpp/agent:$(TAG) calicovpp/agent:prerelease; \
fi

.PHONY: image-cov
image-cov: build-cov
@echo "Image tag : $(TAG)" > $(VERSION_FILE)
@echo "VPP-dataplane version : $(shell git log -1 --oneline)" >> $(VERSION_FILE)
@cat $(GENERATE_LOG_FILE) >> $(VERSION_FILE)
docker build --pull -t calicovpp/agent:$(TAG) .

.PHONY: push
push: ${PUSH_DEP}
set -e; for registry in ${REGISTRIES}; do \
docker tag calicovpp/agent:$(TAG) $${registry}calicovpp/agent:$(TAG); \
Expand All @@ -42,7 +46,9 @@ push: ${PUSH_DEP}
docker push --all-tags $${registry}calicovpp/agent; \
done

.PHONY: dev
dev: image

.PHONY: proto
proto:
$(MAKE) -C proto $@
4 changes: 4 additions & 0 deletions calico-vpp-agent/cmd/calico_vpp_dataplane.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,10 @@ func main() {
syscall.SIGUSR2,
)

ctx, cancel := context.WithCancel(context.Background())
defer cancel()
config.HandleUsr2Signal(ctx, log.WithFields(logrus.Fields{"component": "sighdlr"}))

select {
case sig := <-sigChan:
switch sig {
Expand Down
9 changes: 4 additions & 5 deletions calico-vpp-agent/cni/cni_node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,15 @@ import (

// Names of integration tests arguments
const (
IntegrationTestEnableArgName = "INTEGRATION_TEST"
VppImageArgName = "VPP_IMAGE"
VppBinaryArgName = "VPP_BINARY"
VppContainerExtraArgsName = "VPP_CONTAINER_EXTRA_ARGS"
VppImageArgName = "VPP_IMAGE"
VppBinaryArgName = "VPP_BINARY"
VppContainerExtraArgsName = "VPP_CONTAINER_EXTRA_ARGS"
)

// TestCniIntegration runs all the ginkgo integration test inside CNI package
func TestCniIntegration(t *testing.T) {
// skip test if test run is not integration test run (prevent accidental run of integration tests using go test ./...)
_, isIntegrationTestRun := os.LookupEnv(IntegrationTestEnableArgName)
_, isIntegrationTestRun := os.LookupEnv(VppImageArgName)
if !isIntegrationTestRun {
t.Skip("skipping CNI integration tests (set INTEGRATION_TEST env variable to run these tests)")
}
Expand Down
Loading
Loading