Skip to content

Commit 80bf8c9

Browse files
authored
Reduce preparation steps for E2E tests (#2731)
Reduce preparation time for E2E tests by caching go modules in builder image and avoiding building not needed artifacts.
1 parent 8138965 commit 80bf8c9

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

Dockerfile.build

+4
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,9 @@ RUN \
99

1010
WORKDIR /go/src/github.com/elastic/fleet-server
1111

12+
# pre-copy/cache go.mod for pre-downloading dependencies and only redownloading them in subsequent builds if they change
13+
COPY go.mod go.sum ./
14+
RUN go mod download && go mod verify
15+
1216
ENTRYPOINT [ "make" ]
1317
CMD [ "release" ]

Makefile

+2-5
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,6 @@ local: ## - Build local binary for local environment (bin/fleet-server)
7676
go build $(if $(DEV),-tags="dev",) -gcflags="${GCFLAGS}" -ldflags="${LDFLAGS}" -o ./bin/fleet-server .
7777
@printf "${CMD_COLOR_ON} Binaries in ./bin/\n${CMD_COLOR_OFF}"
7878

79-
.PHONY: cover-e2e-binaries
80-
cover-e2e-binaries: ## - Build binaries for the test-e2e target with the go 1.20+ cover flag
81-
SNAPSHOT=true $(MAKE) $(COVER_TARGETS)
82-
8379
.PHONY: $(COVER_TARGETS)
8480
$(COVER_TARGETS): cover-%: ## - Build a binary with the -cover flag for integration testing
8581
@mkdir -p build/cover
@@ -239,7 +235,8 @@ docker-release: build-releaser ## - Builds a release for all platforms in a dock
239235

240236
.PHONY: docker-cover-e2e-binaries
241237
docker-cover-e2e-binaries: build-releaser
242-
docker run --rm -u $(shell id -u):$(shell id -g) --volume $(PWD):/go/src/github.com/elastic/fleet-server $(BUILDER_IMAGE) cover-e2e-binaries
238+
## Build for local architecture and for linux/amd64 for docker images.
239+
docker run --rm -u $(shell id -u):$(shell id -g) --volume $(PWD):/go/src/github.com/elastic/fleet-server -e SNAPSHOT=true $(BUILDER_IMAGE) cover-linux/amd64 cover-$(shell go env GOOS)/$(shell go env GOARCH)
243240

244241
.PHONY: release
245242
release: $(PLATFORM_TARGETS) ## - Builds a release. Specify exact platform with PLATFORMS env.

dev-tools/e2e/certs.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,11 @@ openssl genpkey -algorithm RSA \
2828
-out ${CERT_DIR}/fleet-server-key \
2929
2>/dev/null
3030

31+
OPENSSL_TOOLKIT="$(openssl version | cut -f1 -d' ')"
32+
OPENSSL_MAJOR="$(openssl version | cut -f2 -d' ' | cut -f1 -d.)"
33+
3134
# Ensure PKCS#1 format is used (https://github.com/elastic/elastic-agent-libs/issues/134)
32-
if [ "$(openssl version | cut -f2 -d' ' | cut -f1 -d.)" -ge 3 ]; then
35+
if [ "$OPENSSL_TOOLKIT" = "OpenSSL" -a "$OPENSSL_MAJOR" -ge 3 ]; then
3336
openssl rsa -aes-128-cbc \
3437
-traditional \
3538
-in ${CERT_DIR}/fleet-server-key \

0 commit comments

Comments
 (0)