Skip to content

Commit

Permalink
Fix test setup to run on ARM instances (#3904)
Browse files Browse the repository at this point in the history
Fix test setup to run on ARM instances
  • Loading branch information
michel-laterman authored Sep 23, 2024
1 parent 28e96bf commit 2df9042
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
3 changes: 2 additions & 1 deletion Dockerfile.build
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
ARG GO_VERSION
FROM docker.elastic.co/beats-dev/golang-crossbuild:${GO_VERSION}-main-debian11
ARG SUFFIX # Should be main-debian11 or arm
FROM docker.elastic.co/beats-dev/golang-crossbuild:${GO_VERSION}-${SUFFIX}

RUN \
apt-get update \
Expand Down
15 changes: 10 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ BUILDMODE_windows_amd64=-buildmode=pie
BUILDMODE_darwin_amd64=-buildmode=pie
BUILDMODE_darwin_arm64=-buildmode=pie

BUILDER_IMAGE=docker.elastic.co/beats-dev/golang-crossbuild:${GO_VERSION}-main-debian11
CROSSBUILD_SUFFIX=main-debian11
BUILDER_IMAGE=docker.elastic.co/beats-dev/golang-crossbuild:${GO_VERSION}-${CROSSBUILD_SUFFIX}

#Benchmark related targets
BENCH_BASE ?= benchmark-$(COMMIT).out
Expand Down Expand Up @@ -43,7 +44,6 @@ endif
DOCKER_IMAGE_TAG?=${VERSION}
DOCKER_IMAGE?=docker.elastic.co/fleet-server/fleet-server


PLATFORM_TARGETS=$(addprefix release-, $(PLATFORMS))
COVER_TARGETS=$(addprefix cover-, $(PLATFORMS))
COMMIT=$(shell git rev-parse --short HEAD)
Expand Down Expand Up @@ -248,7 +248,12 @@ else
endif

build-releaser: ## - Build a Docker image to run make package including all build tools
docker build -t $(BUILDER_IMAGE) -f Dockerfile.build --build-arg GO_VERSION=$(GO_VERSION) .
ifeq ($(shell uname -p),arm)
$(eval SUFFIX := arm)
else
$(eval SUFFIX := ${CROSSBUILD_SUFFIX})
endif
docker build -t $(BUILDER_IMAGE) -f Dockerfile.build --build-arg GO_VERSION=$(GO_VERSION) --build-arg SUFFIX=${SUFFIX} .

.PHONY: docker-release
docker-release: build-releaser ## - Builds a release for all platforms in a dockerised environment
Expand All @@ -257,7 +262,7 @@ docker-release: build-releaser ## - Builds a release for all platforms in a dock
.PHONY: docker-cover-e2e-binaries
docker-cover-e2e-binaries: build-releaser
## Build for local architecture and for linux/amd64 for docker images.
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)
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/$(shell go env GOARCH) cover-$(shell go env GOOS)/$(shell go env GOARCH)

.PHONY: release
release: $(PLATFORM_TARGETS) ## - Builds a release. Specify exact platform with PLATFORMS env.
Expand Down Expand Up @@ -336,7 +341,7 @@ test-int-set: ## - Run integration tests without setup
.PHONY: build-e2e-agent-image
build-e2e-agent-image: docker-cover-e2e-binaries ## - Build a custom elastic-agent image with fleet-server binaries with coverage enabled injected
@printf "${CMD_COLOR_ON} Creating test e2e agent image\n${CMD_COLOR_OFF}"
FLEET_VERSION=${DEFAULT_VERSION}-SNAPSHOT GOARCH=amd64 ./dev-tools/e2e/build.sh # force fleet version to be equal to VERSION-SNAPSHOT
FLEET_VERSION=${DEFAULT_VERSION}-SNAPSHOT ./dev-tools/e2e/build.sh # force fleet version to be equal to VERSION-SNAPSHOT

.PHONY: e2e-certs
e2e-certs: ## - Use openssl to create a CA, encrypted private key, and signed fleet-server cert testing purposes
Expand Down
4 changes: 1 addition & 3 deletions dev-tools/integration/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,10 @@ services:
- certs:/usr/share/elasticsearch/config/certs
ports:
- 127.0.0.1:9200:9200

elasticsearch-remote:
depends_on:
setup:
condition: service_healthy
condition: service_completed_successfully
image: "docker.elastic.co/elasticsearch/elasticsearch:${ELASTICSEARCH_VERSION}"
container_name: elasticsearch-remote
environment:
Expand Down Expand Up @@ -127,4 +126,3 @@ services:
- certs:/usr/share/elasticsearch/config/certs
ports:
- 127.0.0.1:9201:9200

0 comments on commit 2df9042

Please sign in to comment.