From 16b08b9201742ce4375a693bd7dd1121d7edf0be Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Fri, 27 Sep 2019 12:49:39 +0200 Subject: [PATCH] Automatically set the tags flags when needed Remove the `FLAG` environment variable used in the Makefile, and automatically add the `--tags` flag if a feature is specified when running functional tests. --- metricbeat-tests/Makefile | 7 +++++-- metricbeat-tests/README.md | 3 +-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/metricbeat-tests/Makefile b/metricbeat-tests/Makefile index 62dafb8498..7eb197a87e 100644 --- a/metricbeat-tests/Makefile +++ b/metricbeat-tests/Makefile @@ -1,5 +1,4 @@ FEATURE?= -FLAG?= FORMAT?=pretty LOG_INCLUDE_TIMESTAMP?=TRUE LOG_LEVEL?=INFO @@ -7,6 +6,10 @@ METRICBEAT_FETCH_TIMEOUT?=20 QUERY_MAX_ATTEMPTS?=5 RETRY_TIMEOUT?=3 +ifneq ($(FEATURE),) +FEATURE_FLAG=--tags +endif + .PHONY: build-binary build-binary: cd ../cli && go build -o op && mv op ../metricbeat-tests && cd - @@ -22,7 +25,7 @@ functional-test: OP_METRICBEAT_FETCH_TIMEOUT=${METRICBEAT_FETCH_TIMEOUT} \ OP_QUERY_MAX_ATTEMPTS=${QUERY_MAX_ATTEMPTS} \ OP_RETRY_TIMEOUT=${RETRY_TIMEOUT} \ - godog --format=${FORMAT} ${FLAG} ${FEATURE} + godog --format=${FORMAT} ${FEATURE_FLAG} ${FEATURE} .PHONY: run-elastic-stack run-elastic-stack: diff --git a/metricbeat-tests/README.md b/metricbeat-tests/README.md index b120f0e690..ac3d51f355 100644 --- a/metricbeat-tests/README.md +++ b/metricbeat-tests/README.md @@ -206,12 +206,11 @@ $ make functional-tests # runs the test suite You could set up the environment so that it's possible to run one single module. As we are using _tags_ for matching modules, we could tell `make` to run just the tests for redis: ```shell -$ LOG_LEVEL=DEBUG FLAG="-t" FEATURE="redis" make functional-test +$ LOG_LEVEL=DEBUG FEATURE="redis" make functional-test ``` where: - LOG_LEVEL: sets the default log level in the tool (DEBUG, INFO, WARN, ERROR, FATAL) -- FLAG: if set as `-t`, it will tell `Godog` to filter by tag. - FEATURE: sets the tag to filter by (apache, mysql, redis) ### Advanced usage