From ee145f927a96daf9c31967d36b439c4ab252c289 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Wed, 29 Jan 2020 07:28:35 -0800 Subject: [PATCH] Re-enabling golang integration tests (#15819) * Adding debugging * Still debugging * Add deps for integration tests * Making progress, I think :) * Testing * Try a different way of passing the env var * Revert docker info change * Removing debugging statements * Ensure "AND"ing of build tags * Don't explicitly pass BEATS_DOCKER_INTEGRATION_TEST_ENV * Move mage goIntegTest usage to metricbeat makefile * Fixing up comment * Forgot the line continuation mark * Pass the env var --- libbeat/scripts/Makefile | 9 +++++++-- metricbeat/Makefile | 7 +++++++ .../windows/perfmon/pdh_integration_windows_test.go | 3 ++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/libbeat/scripts/Makefile b/libbeat/scripts/Makefile index ddd460c3d4c..db8236cdeef 100755 --- a/libbeat/scripts/Makefile +++ b/libbeat/scripts/Makefile @@ -197,7 +197,7 @@ unit: ## @testing Runs the unit tests without coverage reports. integration-tests: ## @testing Run integration tests. Unit tests are run as part of the integration tests. integration-tests: prepare-tests mage rm -f docker-compose.yml.lock - mage goIntegTest + $(COVERAGE_TOOL) -tags=integration $(RACE) -coverprofile=${COVERAGE_DIR}/integration.cov ${GOPACKAGES} .PHONY: integration-tests-environment integration-tests-environment: ## @testing Runs the integration inside a virtual environment. This can be run on any docker-machine (local, remote) @@ -207,7 +207,12 @@ integration-tests-environment: prepare-tests build-image # # This will make docker-compose command to display the logs on stdout on error, It's not enabled # by default because it can create noise if the test inside the container fails. - ${DOCKER_COMPOSE} run beat make integration-tests RACE_DETECTOR=$(RACE_DETECTOR) DOCKER_COMPOSE_PROJECT_NAME=${DOCKER_COMPOSE_PROJECT_NAME} + ${DOCKER_COMPOSE} run \ + -e RACE_DETECTOR=$(RACE_DETECTOR) \ + -e DOCKER_COMPOSE_PROJECT_NAME=${DOCKER_COMPOSE_PROJECT_NAME} \ + -e TEST_ENVIRONMENT=${TEST_ENVIRONMENT} \ + -e BEATS_DOCKER_INTEGRATION_TEST_ENV=${BEATS_DOCKER_INTEGRATION_TEST_ENV} \ + beat make integration-tests # Runs the system tests .PHONY: system-tests diff --git a/metricbeat/Makefile b/metricbeat/Makefile index 2900f9e4cc7..c0ff55b4435 100644 --- a/metricbeat/Makefile +++ b/metricbeat/Makefile @@ -3,6 +3,7 @@ BEAT_NAME?=metricbeat BEAT_TITLE?=Metricbeat SYSTEM_TESTS?=true TEST_ENVIRONMENT?=true +BEATS_DOCKER_INTEGRATION_TEST_ENV?=true ES_BEATS?=.. # Metricbeat can only be cross-compiled on platforms not requiring CGO. @@ -76,3 +77,9 @@ assets: go run ${ES_BEATS}/metricbeat/scripts/assets/assets.go ${ES_BEATS}/metricbeat/module mkdir -p include/fields go run ${ES_BEATS}/libbeat/scripts/cmd/global_fields/main.go -es_beats_path ${ES_BEATS} -beat_path ${PWD} | go run ${ES_BEATS}/dev-tools/cmd/asset/asset.go -license ${LICENSE} -out ./include/fields/fields.go -pkg include -priority asset.LibbeatFieldsPri ${ES_BEATS}/libbeat/fields.yml $(BEAT_NAME) + +.PHONY: integration-tests +integration-tests: ## @testing Run golang integration tests. +integration-tests: prepare-tests mage + rm -f docker-compose.yml.lock + mage goIntegTest diff --git a/metricbeat/module/windows/perfmon/pdh_integration_windows_test.go b/metricbeat/module/windows/perfmon/pdh_integration_windows_test.go index 1fe12ab20d1..366b4a57013 100644 --- a/metricbeat/module/windows/perfmon/pdh_integration_windows_test.go +++ b/metricbeat/module/windows/perfmon/pdh_integration_windows_test.go @@ -15,7 +15,8 @@ // specific language governing permissions and limitations // under the License. -// +build integration windows +// +build integration +// +build windows package perfmon