Skip to content

Commit

Permalink
Makefile: run pillar tests in pillar container
Browse files Browse the repository at this point in the history
Instead of running the tests in the builder container,
run those in the pillar container.
Advantages:
- the environment is nearer to the real EVE
- packages don't have to be put into pillar and builder container

Signed-off-by: Christoph Ostarek <christoph@zededa.com>
  • Loading branch information
christoph-zededa committed Mar 11, 2024
1 parent 66af833 commit 81bcd03
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,9 @@ currentversion:

test: $(LINUXKIT) test-images-patches | $(DIST)
@echo Running tests on $(GOMODULE)
$(QUIET)$(DOCKER_GO) "gotestsum --jsonfile $(DOCKER_DIST)/results.json --junitfile $(DOCKER_DIST)/results.xml --raw-command -- go test -coverprofile=coverage.txt -covermode=atomic -race -json ./..." $(GOTREE) $(GOMODULE)
$(QUIET)$(DOCKER_GO) "cd \"$(GOTREE)\"; ../../tools/fuzz_test.sh" $(GOTREE) $(GOMODULE)
make -C pkg/pillar test
cp pkg/pillar/results.json $(DIST)/
cp pkg/pillar/results.xml $(DIST)/
$(QUIET): $@: Succeeded

# wrap command into DOCKER_GO and propagate it to the pillar's Makefile
Expand Down
4 changes: 4 additions & 0 deletions pkg/pillar/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ FROM build-native AS target-arm64-build-arm64
# hadolint ignore=DL3006
FROM target-${TARGETARCH}-build-${BUILDARCH} AS build
ARG DEV=n
ARG TEST_TOOLS=n
ARG TARGETARCH

# some parts of pillar are build conditionally based on the hypervisor
Expand Down Expand Up @@ -110,6 +111,9 @@ RUN --mount=type=cache,target=/root/.cache/go-build if [ ${DEV} = "y" ]; then \
GOFLAGS= CGO_ENABLED=0 go build -ldflags "-s -w -extldflags '-static'" github.com/go-delve/delve/cmd/dlv && \
cp dlv /final/opt/ ; \
fi
RUN --mount=type=cache,target=/root/.cache/go-build if [ "${TEST_TOOLS}" == "y" ]; then \
GOFLAGS= go install gotest.tools/gotestsum@v1.7.0; \
fi

FROM lfedge/eve-fscrypt:0b7cc0d9d620e47fc54e21d56cb8a5cd224f9c9b as fscrypt
FROM lfedge/eve-dnsmasq:3af908d86a95a627c729e09b1b125bf8de7fadcb as dnsmasq
Expand Down
21 changes: 19 additions & 2 deletions pkg/pillar/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,25 @@ enter-docker-dev: build-docker-dev
build-docker-git:
git archive HEAD | docker build $(DOCKER_ARGS) -t $(DOCKER_TAG) -

test:
go test -mod=vendor ./...
build-docker-test:
docker build $(DOCKER_ARGS) --build-arg TEST_TOOLS=y -t $(DOCKER_TAG) . --target build

test: build-docker-test
rm -f results.json
rm -f results.xml
touch results.json
touch results.xml
docker run --platform linux/$(ZARCH) -w /pillar \
--mount type=bind,source=./results.json,target=/pillar/results.json \
--mount type=bind,source=./results.xml,target=/pillar/results.xml \
--entrypoint /root/go/bin/gotestsum $(DOCKER_TAG) \
--jsonfile /pillar/results.json \
--junitfile /pillar/results.xml \
--raw-command -- go test -coverprofile=coverage.txt -covermode=atomic -race -json \
./...
docker run --platform linux/$(ZARCH) -w /pillar \
--entrypoint /bin/sh $(DOCKER_TAG) \
/pillar/build-scripts/fuzz_test.sh

clean:
@rm -rf $(DISTDIR)
Expand Down
File renamed without changes.

0 comments on commit 81bcd03

Please sign in to comment.