Chore: Add new go test commands for unit, integration, and pro tests to makefile (#51202)

* Chore: Add new go test commands for unit, integration tests to makefile

* Add test-go-unit and test-go-integration targets as dependencies of the test-go target

* Add makefile target for mysql & postgres backends

* Set GRAFANA_TEST_DB variable for the xargs postgres command

Co-authored-by: Sofia Papagiannaki <1632407+papagian@users.noreply.github.com>

* Set GRAFANA_TEST_DB variable for the xargs mysql command

Co-authored-by: Sofia Papagiannaki <1632407+papagian@users.noreply.github.com>

* Use postgres_tests as source

Co-authored-by: Sofia Papagiannaki <1632407+papagian@users.noreply.github.com>

* Set postgres_tests as source

Co-authored-by: Sofia Papagiannaki <1632407+papagian@users.noreply.github.com>

* Clean test cache before postgres and mysql integration test makefile commands

Co-authored-by: Sofia Papagiannaki <1632407+papagian@users.noreply.github.com>
This commit is contained in:
Kat Yang 2022-07-19 04:04:38 -04:00 committed by GitHub
parent 2617a25fb5
commit ab8ad1bb42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -94,9 +94,30 @@ run-frontend: deps-js ## Fetch js dependencies and watch frontend for rebuild
##@ Testing
test-go: ## Run tests for backend.
@echo "test backend"
$(GO) test -v ./pkg/...
.PHONY: test-go
test-go: test-go-unit test-go-integration
.PHONY: test-go-unit
test-go-unit: ## Run unit tests for backend with flags.
@echo "test backend unit tests"
$(GO) test -short -covermode=atomic -timeout=30m ./pkg/...
.PHONY: test-go-integration
test-go-integration: ## Run integration tests for backend with flags.
@echo "test backend integration tests"
$(GO) test -run Integration -covermode=atomic -timeout=30m ./pkg/...
.PHONY: test-go-integration-postgres
test-go-integration-postgres: devenv-postgres ## Run integration tests for postgres backend with flags.
@echo "test backend integration postgres tests"
$(GO) clean -testcache
$(GO) list './pkg/...' | xargs -I {} sh -c 'GRAFANA_TEST_DB=postgres go test -run Integration -covermode=atomic -timeout=30m {}'
.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"
$(GO) clean -testcache
$(GO) list './pkg/...' | xargs -I {} sh -c 'GRAFANA_TEST_DB=mysql go test -run Integration -covermode=atomic -timeout=30m {}'
test-js: ## Run tests for frontend.
@echo "test frontend"
@ -153,6 +174,14 @@ devenv-down: ## Stop optional services.
test -f docker-compose.yaml && \
docker-compose down || exit 0;
devenv-postgres:
@cd devenv; \
sources=postgres_tests
devenv-mysql:
@cd devenv; \
sources=mysql_tests
##@ Helpers
# We separate the protobuf generation because most development tasks on