|
|
|
@ -17,6 +17,7 @@ GO_RACE_FLAG := $(if $(GO_RACE),-race) |
|
|
|
|
GO_BUILD_FLAGS += $(if $(GO_BUILD_DEV),-dev)
|
|
|
|
|
GO_BUILD_FLAGS += $(if $(GO_BUILD_TAGS),-build-tags=$(GO_BUILD_TAGS))
|
|
|
|
|
GO_BUILD_FLAGS += $(GO_RACE_FLAG)
|
|
|
|
|
GO_TEST_FLAGS += $(if $(GO_BUILD_TAGS),-tags=$(GO_BUILD_TAGS))
|
|
|
|
|
GO_TEST_OUTPUT := $(shell [ -n "$(GO_TEST_OUTPUT)" ] && echo '-json | tee $(GO_TEST_OUTPUT) | tparse -all')
|
|
|
|
|
GO_UNIT_COVERAGE ?= true
|
|
|
|
|
GO_UNIT_COVER_PROFILE ?= unit.cov
|
|
|
|
@ -250,12 +251,12 @@ test-go: test-go-unit test-go-integration |
|
|
|
|
.PHONY: test-go-unit |
|
|
|
|
test-go-unit: ## Run unit tests for backend with flags.
|
|
|
|
|
@echo "backend unit tests"
|
|
|
|
|
$(GO) test $(GO_RACE_FLAG) -v -short -timeout=30m $(GO_TEST_FILES) $(GO_TEST_OUTPUT)
|
|
|
|
|
$(GO) test $(GO_RACE_FLAG) $(GO_TEST_FLAGS) -v -short -timeout=30m $(GO_TEST_FILES) $(GO_TEST_OUTPUT)
|
|
|
|
|
|
|
|
|
|
.PHONY: test-go-unit-cov |
|
|
|
|
test-go-unit-cov: ## Run unit tests for backend with flags and coverage
|
|
|
|
|
@echo "backend unit tests with coverage"
|
|
|
|
|
$(GO) test $(GO_RACE_FLAG) -v -short $(if $(filter true,$(GO_UNIT_COVERAGE)),-covermode=atomic -coverprofile=$(GO_UNIT_COVER_PROFILE) $(if $(GO_UNIT_TEST_COVERPKG),-coverpkg=$(GO_UNIT_TEST_COVERPKG)),) -timeout=30m $(GO_TEST_FILES) $(GO_TEST_OUTPUT)
|
|
|
|
|
$(GO) test $(GO_RACE_FLAG) $(GO_TEST_FLAGS) -v -short $(if $(filter true,$(GO_UNIT_COVERAGE)),-covermode=atomic -coverprofile=$(GO_UNIT_COVER_PROFILE) $(if $(GO_UNIT_TEST_COVERPKG),-coverpkg=$(GO_UNIT_TEST_COVERPKG)),) -timeout=30m $(GO_TEST_FILES) $(GO_TEST_OUTPUT)
|
|
|
|
|
|
|
|
|
|
.PHONY: test-go-unit-pretty |
|
|
|
|
test-go-unit-pretty: check-tparse |
|
|
|
@ -263,12 +264,12 @@ test-go-unit-pretty: check-tparse |
|
|
|
|
echo "Notice: FILES variable is not set. Try \"make test-go-unit-pretty FILES=./pkg/services/mysvc\""; \
|
|
|
|
|
exit 1; \
|
|
|
|
|
fi
|
|
|
|
|
$(GO) test $(GO_RACE_FLAG) -timeout=10s $(FILES) -json | tparse -all
|
|
|
|
|
$(GO) test $(GO_RACE_FLAG) $(GO_TEST_FLAGS) -timeout=10s $(FILES) -json | tparse -all
|
|
|
|
|
|
|
|
|
|
.PHONY: test-go-integration |
|
|
|
|
test-go-integration: ## Run integration tests for backend with flags.
|
|
|
|
|
@echo "test backend integration tests"
|
|
|
|
|
$(GO) test $(GO_RACE_FLAG) -count=1 -run "^TestIntegration" -covermode=atomic -coverprofile=$(GO_INTEGRATION_COVER_PROFILE) -timeout=5m $(GO_INTEGRATION_TESTS) $(GO_TEST_OUTPUT)
|
|
|
|
|
$(GO) test $(GO_RACE_FLAG) $(GO_TEST_FLAGS) -count=1 -run "^TestIntegration" -covermode=atomic -coverprofile=$(GO_INTEGRATION_COVER_PROFILE) -timeout=5m $(GO_INTEGRATION_TESTS) $(GO_TEST_OUTPUT)
|
|
|
|
|
|
|
|
|
|
.PHONY: test-go-integration-alertmanager |
|
|
|
|
test-go-integration-alertmanager: ## Run integration tests for the remote alertmanager (config taken from the mimir_backend block).
|
|
|
|
@ -290,25 +291,25 @@ test-go-integration-postgres: devenv-postgres ## Run integration tests for postg |
|
|
|
|
@echo "test backend integration postgres tests"
|
|
|
|
|
$(GO) clean -testcache
|
|
|
|
|
GRAFANA_TEST_DB=postgres \
|
|
|
|
|
$(GO) test $(GO_RACE_FLAG) -p=1 -count=1 -run "^TestIntegration" -covermode=atomic -timeout=10m $(GO_INTEGRATION_TESTS)
|
|
|
|
|
$(GO) test $(GO_RACE_FLAG) $(GO_TEST_FLAGS) -p=1 -count=1 -run "^TestIntegration" -covermode=atomic -timeout=10m $(GO_INTEGRATION_TESTS)
|
|
|
|
|
|
|
|
|
|
.PHONY: test-go-integration-mysql |
|
|
|
|
test-go-integration-mysql: devenv-mysql ## Run integration tests for mysql backend with flags.
|
|
|
|
|
@echo "test backend integration mysql tests"
|
|
|
|
|
GRAFANA_TEST_DB=mysql \
|
|
|
|
|
$(GO) test $(GO_RACE_FLAG) -p=1 -count=1 -run "^TestIntegration" -covermode=atomic -timeout=10m $(GO_INTEGRATION_TESTS)
|
|
|
|
|
$(GO) test $(GO_RACE_FLAG) $(GO_TEST_FLAGS) -p=1 -count=1 -run "^TestIntegration" -covermode=atomic -timeout=10m $(GO_INTEGRATION_TESTS)
|
|
|
|
|
|
|
|
|
|
.PHONY: test-go-integration-redis |
|
|
|
|
test-go-integration-redis: ## Run integration tests for redis cache.
|
|
|
|
|
@echo "test backend integration redis tests"
|
|
|
|
|
$(GO) clean -testcache
|
|
|
|
|
REDIS_URL=localhost:6379 $(GO) test $(GO_RACE_FLAG) -run IntegrationRedis -covermode=atomic -timeout=2m $(GO_INTEGRATION_TESTS)
|
|
|
|
|
REDIS_URL=localhost:6379 $(GO) test $(GO_TEST_FLAGS) -run IntegrationRedis -covermode=atomic -timeout=2m $(GO_INTEGRATION_TESTS)
|
|
|
|
|
|
|
|
|
|
.PHONY: test-go-integration-memcached |
|
|
|
|
test-go-integration-memcached: ## Run integration tests for memcached cache.
|
|
|
|
|
@echo "test backend integration memcached tests"
|
|
|
|
|
$(GO) clean -testcache
|
|
|
|
|
MEMCACHED_HOSTS=localhost:11211 $(GO) test $(GO_RACE_FLAG) -run IntegrationMemcached -covermode=atomic -timeout=2m $(GO_INTEGRATION_TESTS)
|
|
|
|
|
MEMCACHED_HOSTS=localhost:11211 $(GO) test $(GO_RACE_FLAG) $(GO_TEST_FLAGS) -run IntegrationMemcached -covermode=atomic -timeout=2m $(GO_INTEGRATION_TESTS)
|
|
|
|
|
|
|
|
|
|
.PHONY: test-js |
|
|
|
|
test-js: ## Run tests for frontend.
|
|
|
|
@ -324,6 +325,7 @@ golangci-lint: |
|
|
|
|
@echo "lint via golangci-lint"
|
|
|
|
|
$(GO) tool golangci-lint run \
|
|
|
|
|
--config .golangci.yml \
|
|
|
|
|
$(if $(GO_BUILD_TAGS),--build-tags $(GO_BUILD_TAGS)) \
|
|
|
|
|
$(GO_LINT_FILES)
|
|
|
|
|
|
|
|
|
|
.PHONY: lint-go |
|
|
|
|