From 70919bdda6ca3af15bdd61f3cbe03f01156fe71c Mon Sep 17 00:00:00 2001 From: Alf-Rune Siqveland Date: Wed, 4 Sep 2024 12:04:11 +0200 Subject: [PATCH] build(make): Fix acceptance test targets after refactor Put common acceptance test targets in Makefile.common and made exceptions for `create-artifact-worker` and `reporting`. Signed-off-by: Alf-Rune Siqveland --- backend/services/Makefile.common | 20 +++++++++++ .../services/create-artifact-worker/Makefile | 4 +++ .../tests/docker-compose.acceptance.yml | 4 --- .../tests/docker-compose.acceptance.yml | 4 --- backend/services/deviceconfig/Makefile | 19 +++++++++++ .../tests/docker-compose.acceptance.yml | 4 --- backend/services/deviceconnect/Makefile | 19 +++++++++++ .../tests/docker-compose.acceptance.yml | 4 --- .../tests/docker-compose.acceptance.yml | 4 --- backend/services/iot-manager/Makefile | 19 +++++++++++ .../tests/docker-compose.acceptance.yml | 4 --- backend/services/reporting/Makefile | 19 +++++++++++ .../tests/docker-compose.acceptance.yml | 4 --- .../tests/docker-compose.acceptance.yml | 4 --- .../workflows/tests/docker-compose.yml | 34 +++++++++++++------ 15 files changed, 124 insertions(+), 42 deletions(-) diff --git a/backend/services/Makefile.common b/backend/services/Makefile.common index f31847f3..91a00af9 100644 --- a/backend/services/Makefile.common +++ b/backend/services/Makefile.common @@ -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 diff --git a/backend/services/create-artifact-worker/Makefile b/backend/services/create-artifact-worker/Makefile index 0e6ea2c5..5423d8ce 100644 --- a/backend/services/create-artifact-worker/Makefile +++ b/backend/services/create-artifact-worker/Makefile @@ -1,3 +1,7 @@ COMPONENT := create-artifact-worker +_no_include_acceptance_tests := true + +.PHONY: test-acceptance-run test-acceptance + include ../Makefile.common diff --git a/backend/services/deployments/tests/docker-compose.acceptance.yml b/backend/services/deployments/tests/docker-compose.acceptance.yml index 46ab1684..d649da64 100644 --- a/backend/services/deployments/tests/docker-compose.acceptance.yml +++ b/backend/services/deployments/tests/docker-compose.acceptance.yml @@ -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" diff --git a/backend/services/deviceauth/tests/docker-compose.acceptance.yml b/backend/services/deviceauth/tests/docker-compose.acceptance.yml index d5ce2320..59f43bf9 100644 --- a/backend/services/deviceauth/tests/docker-compose.acceptance.yml +++ b/backend/services/deviceauth/tests/docker-compose.acceptance.yml @@ -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/" diff --git a/backend/services/deviceconfig/Makefile b/backend/services/deviceconfig/Makefile index 69f56aa1..90825fa3 100644 --- a/backend/services/deviceconfig/Makefile +++ b/backend/services/deviceconfig/Makefile @@ -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 diff --git a/backend/services/deviceconfig/tests/docker-compose.acceptance.yml b/backend/services/deviceconfig/tests/docker-compose.acceptance.yml index d93be791..06e6bf62 100644 --- a/backend/services/deviceconfig/tests/docker-compose.acceptance.yml +++ b/backend/services/deviceconfig/tests/docker-compose.acceptance.yml @@ -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" diff --git a/backend/services/deviceconnect/Makefile b/backend/services/deviceconnect/Makefile index dfd3f6d0..8616630d 100644 --- a/backend/services/deviceconnect/Makefile +++ b/backend/services/deviceconnect/Makefile @@ -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 diff --git a/backend/services/deviceconnect/tests/docker-compose.acceptance.yml b/backend/services/deviceconnect/tests/docker-compose.acceptance.yml index 1a4edc96..e3831be9 100644 --- a/backend/services/deviceconnect/tests/docker-compose.acceptance.yml +++ b/backend/services/deviceconnect/tests/docker-compose.acceptance.yml @@ -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 diff --git a/backend/services/inventory/tests/docker-compose.acceptance.yml b/backend/services/inventory/tests/docker-compose.acceptance.yml index c28394bf..2b87706c 100644 --- a/backend/services/inventory/tests/docker-compose.acceptance.yml +++ b/backend/services/inventory/tests/docker-compose.acceptance.yml @@ -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} diff --git a/backend/services/iot-manager/Makefile b/backend/services/iot-manager/Makefile index b384b5ba..1646bcf4 100644 --- a/backend/services/iot-manager/Makefile +++ b/backend/services/iot-manager/Makefile @@ -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)) diff --git a/backend/services/iot-manager/tests/docker-compose.acceptance.yml b/backend/services/iot-manager/tests/docker-compose.acceptance.yml index a8c4bc9b..cbf04aa1 100644 --- a/backend/services/iot-manager/tests/docker-compose.acceptance.yml +++ b/backend/services/iot-manager/tests/docker-compose.acceptance.yml @@ -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" diff --git a/backend/services/reporting/Makefile b/backend/services/reporting/Makefile index e5b67710..bd30cdae 100644 --- a/backend/services/reporting/Makefile +++ b/backend/services/reporting/Makefile @@ -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 diff --git a/backend/services/reporting/tests/docker-compose.acceptance.yml b/backend/services/reporting/tests/docker-compose.acceptance.yml index e5fb2d9a..991d7755 100644 --- a/backend/services/reporting/tests/docker-compose.acceptance.yml +++ b/backend/services/reporting/tests/docker-compose.acceptance.yml @@ -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" diff --git a/backend/services/useradm/tests/docker-compose.acceptance.yml b/backend/services/useradm/tests/docker-compose.acceptance.yml index dbbd2d5d..c160056b 100644 --- a/backend/services/useradm/tests/docker-compose.acceptance.yml +++ b/backend/services/useradm/tests/docker-compose.acceptance.yml @@ -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} diff --git a/backend/services/workflows/tests/docker-compose.yml b/backend/services/workflows/tests/docker-compose.yml index 73a77988..d102471d 100644 --- a/backend/services/workflows/tests/docker-compose.yml +++ b/backend/services/workflows/tests/docker-compose.yml @@ -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: @@ -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} @@ -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: