Skip to content

Commit

Permalink
build(make): Fix acceptance test targets after refactor
Browse files Browse the repository at this point in the history
Put common acceptance test targets in Makefile.common and made
exceptions for `create-artifact-worker` and `reporting`.

Signed-off-by: Alf-Rune Siqveland <alf.rune@northern.tech>
  • Loading branch information
alfrunes committed Sep 5, 2024
1 parent 282de40 commit 70919bd
Show file tree
Hide file tree
Showing 15 changed files with 124 additions and 42 deletions.
20 changes: 20 additions & 0 deletions backend/services/Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,23 @@ docker-acceptance: export BUILDFLAGS += -cover -installsuffix=.test

.PHONY: docker-acceptance
docker-acceptance: docker

ifndef _no_include_acceptance_tests

test_acceptance_run_deps ?= docker-acceptance

.PHONY: test-acceptance-run
test-acceptance-run: $(test_acceptance_run_deps)
MENDER_IMAGE_PREFIX=$(MENDER_IMAGE_PREFIX) \
MENDER_IMAGE_TAG=$(MENDER_IMAGE_TAG) \
docker compose -f tests/docker-compose.yml run \
--remove-orphans \
--rm \
--use-aliases \
acceptance-tester $(PYTEST_ARGS)

.PHONY: test-acceptance
test-acceptance: test-acceptance-run
docker compose -f tests/docker-compose.yml down --remove-orphans -v

endif # _no_include_acceptance_tests
4 changes: 4 additions & 0 deletions backend/services/create-artifact-worker/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
COMPONENT := create-artifact-worker

_no_include_acceptance_tests := true

.PHONY: test-acceptance-run test-acceptance

include ../Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ services:
create-artifact-worker:
condition: service_started
deployments:
build:
args:
- BIN_FILE=backend/tests/bin/deployments.test
image: deployments:test
environment:
DEPLOYMENTS_PRESIGN_URL_SCHEME: "http"
DEPLOYMENTS_PRESIGN_URL_HOSTNAME: "deployments:8080"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ services:
FAKE_ADMISSION_ADDR: "0.0.0.0:9997"
FAKE_ORCHESTRATOR_ADDR: "0.0.0.0:9998"
deviceauth:
build:
args:
- BIN_FILE=backend/tests/bin/deviceauth.test
image: deviceauth:test
environment:
DEVICEAUTH_DEVADM_ADDR: "http://acceptance-tester:9997/"
DEVICEAUTH_ORCHESTRATOR_ADDR: "http://acceptance-tester:9998/"
Expand Down
19 changes: 19 additions & 0 deletions backend/services/deviceconfig/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
COMPONENT := deviceconfig

DOCFILES := $(wildcard docs/*_api.yml)
MAKEDIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))

tests/%: docs/%.yml
[ -e $@ ] && rm -r $@; \
docker run --rm -t -v $(MAKEDIR):/work -w /work \
--ulimit nofile=65536:65536 \
-u $(shell id -u):$(shell id -g) \
openapitools/openapi-generator-cli:v4.3.1 generate \
-g python -i $< \
-c tests/.openapi-generator.yml \
-o $(dir $@) \
--additional-properties=packageName=$*

.PHONY: docs
docs: $(patsubst docs/%.yml,tests/%,$(DOCFILES))

test_acceptance_run_deps := docker-acceptance docs

include ../Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ services:
- deviceconfig

deviceconfig:
build:
args:
- BIN_FILE=backend/tests/bin/deviceconfig.test
image: deviceconfig:test
environment:
DEVICECONFIG_ENABLE_AUDIT: "true"
DEVICECONFIG_WORKFLOWS_URL: "http://mender-workflows-server:8080"
Expand Down
19 changes: 19 additions & 0 deletions backend/services/deviceconnect/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
COMPONENT := deviceconnect

DOCFILES := $(wildcard docs/*_api.yml)
MAKEDIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))

tests/%: docs/%.yml
[ -e $@ ] && rm -r $@; \
docker run --rm -t -v $(MAKEDIR):/work -w /work \
--ulimit nofile=65536:65536 \
-u $(shell id -u):$(shell id -g) \
openapitools/openapi-generator-cli:v4.3.1 generate \
-g python -i $< \
-c tests/.openapi-generator.yml \
-o $(dir $@) \
--additional-properties=packageName=$*

.PHONY: docs
docs: $(patsubst docs/%.yml,tests/%,$(DOCFILES))

test_acceptance_run_deps := docker-acceptance docs

include ../Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ services:
- mender-workflows-server

deviceconnect:
build:
args:
- BIN_FILE=backend/tests/bin/deviceconnect.test
image: deviceconnect:test
environment:
DEVICECONNECT_NATS_URL: "nats://nats"
GOCOVERDIR: /cover
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ services:
- --management-v2-spec=/docs/management_api_v2.yml
- --mongo-url=mongodb://mongo
inventory:
build:
args:
- BIN_FILE=backend/tests/bin/inventory.test
image: inventory:test
environment:
GOCOVERDIR: /cover
user: ${UID:-0}:${GID:-0}
Expand Down
19 changes: 19 additions & 0 deletions backend/services/iot-manager/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
COMPONENT := iot-manager

test_acceptance_run_deps := docker-acceptance docs

include ../Makefile.common

DOCFILES := $(wildcard docs/*_api.yml)
ROOTDIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))

tests/%: docs/%.yml
[ -e $@ ] && rm -r $@; \
docker run --rm -t -v $(ROOTDIR):$(ROOTDIR) -w $(ROOTDIR) \
--ulimit=nofile=65535 \
-u $(shell id -u):$(shell id -g) \
openapitools/openapi-generator-cli:v5.3.1 generate \
-g python -i $< \
-c tests/.openapi-generator.yml \
-o $(dir $@) \
--additional-properties=packageName=$*

.PHONY: docs
docs: $(patsubst docs/%.yml,tests/%,$(DOCFILES))
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ services:
- iot.region.amazonaws.com

iot-manager:
build:
args:
- BIN_FILE=backend/tests/bin/iot-manager.test
image: iot-manager:test
environment:
IOT_MANAGER_AES_ENCRYPTION_KEY: "+mg+KXQM8/7A+uqs1bJzfH0KW9NclMEVRjkmqhfpjDg="
IOT_MANAGER_DOMAIN_WHITELIST: "*.azure-devices.net mmock"
Expand Down
19 changes: 19 additions & 0 deletions backend/services/reporting/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
COMPONENT := reporting

DOCFILES := $(wildcard docs/*_api.yml)
ROOTDIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))

tests/%: docs/%.yml
[ -e $@ ] && rm -r $@; \
docker run --rm -t -v $(ROOTDIR):$(ROOTDIR) -w $(ROOTDIR) \
-u $(shell id -u):$(shell id -g) \
openapitools/openapi-generator-cli:v5.3.1 generate \
-g python -i $< \
-c tests/.openapi-generator.yml \
-o $(dir $@) \
--additional-properties=packageName=$*

.PHONY: docs
docs: $(patsubst docs/%.yml,tests/%,$(DOCFILES))

.PHONY: test-acceptance-run test-acceptance
_no_include_acceptance_tests := true

include ../Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ services:
- mmock
- reporting
reporting:
build:
args:
- BIN_FILE=backend/tests/bin/reporting.test
image: reporting:test
environment:
REPORTING_OPENSEARCH_ADDRESSES: "http://opensearch:9200"
REPORTING_DEVICEAUTH_ADDR: "http://deviceauth:8080"
Expand Down
4 changes: 0 additions & 4 deletions backend/services/useradm/tests/docker-compose.acceptance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ services:
- mmock
- useradm
useradm:
build:
args:
- BIN_FILE=backend/tests/bin/useradm.test
image: useradm:test
environment:
GOCOVERDIR: /cover
user: ${UID:-0}:${GID:-0}
Expand Down
34 changes: 24 additions & 10 deletions backend/services/workflows/tests/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,15 @@ services:

mmock:
image: jordimartin/mmock:v2.7.6
command: ["-server-ip", "0.0.0.0", "-console-ip", "0.0.0.0", "-server-port", "8080"]
command:
[
"-server-ip",
"0.0.0.0",
"-console-ip",
"0.0.0.0",
"-server-port",
"8080",
]
ports:
- 8082:8082
volumes:
Expand All @@ -50,10 +58,9 @@ services:
- mmock

workflows-worker:
image: workflows:test
build:
args:
- BIN_FILE=backend/tests/bin/workflows.test
extends:
file: ../../../../dev/docker-compose.yml
service: workflows-worker
pull_policy: never
command: ["worker"]
user: ${UID:-0}:${GID:-0}
Expand All @@ -70,17 +77,24 @@ services:
HAVE_DEVICECONNECT: 1
HAVE_DEVICECONFIG: 1
GOCOVERDIR: /cover
DEPLOYMENTS_ADDR: "mender-deployments:8080"
DEVICE-AUTH_ADDR: "mender-device-auth:8080"
INVENTORY_ADDR: "mender-inventory:8080"
TENANTADM_ADDR: "mender-tenantadm:8080"
USERADM_ADDR: "mender-useradm:8080"
DEVICECONNECT_ADDR: "mender-deviceconnect:8080"
DEVICECONFIG_ADDR: "mender-deviceconfig:8080"
REPORTING_ADDR: "mender-reporting:8080"
IOT_MANAGER_ADDR: "mender-iot-manager:8080"
restart: always
depends_on:
mongo:
condition: service_started

workflows:
image: workflows:test
command: [server, --automigrate]
build:
args:
- BIN_FILE=backend/tests/bin/workflows.test
extends:
file: ../../../../dev/docker-compose.yml
service: workflows
ports:
- "8080:8080"
environment:
Expand Down

0 comments on commit 70919bd

Please sign in to comment.