From 6f4625bb7884e7133f5d3f1a2f69c16780d5ff1f Mon Sep 17 00:00:00 2001 From: Barry Date: Thu, 11 Jul 2019 09:33:53 +0100 Subject: [PATCH] Update docs readme for running MySQL/Postgres tests --- README.md | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e2c105d5732..d8cd44d8453 100644 --- a/README.md +++ b/README.md @@ -147,12 +147,34 @@ Writing & watching frontend tests ```bash # Run Golang tests using sqlite3 as database (default) go test ./pkg/... +``` -# Run Golang tests using mysql as database - convenient to use /docker/blocks/mysql_tests -GRAFANA_TEST_DB=mysql go test ./pkg/... +##### Running the MySQL or Postgres backend tests: -# Run Golang tests using postgres as database - convenient to use /docker/blocks/postgres_tests -GRAFANA_TEST_DB=postgres go test ./pkg/... +Run these by setting `GRAFANA_TEST_DB` in your environment. + +- `GRAFANA_TEST_DB=mysql` to test MySQL +- `GRAFANA_TEST_DB=postgres` to test Postgres + +Follow the instructions in `./devenv` to spin up test containers running the appropriate databases with `docker-compose` +- Use `docker/blocks/mysql_tests` or `docker/blocks/postgres_tests` as appropriate + +```bash +# MySQL +# Tests can only be ran in one Go package at a time due to clashing db queries. To run MySQL tests for the "pkg/services/sqlstore" package, run: +GRAFANA_TEST_DB=mysql go test ./pkg/services/sqlstore/... + +# Or run all the packages using the circle CI scripts. This method will be slower as the scripts will run all the tests, including the integration tests. +./scripts/circle-test-mysql.sh +``` + +```bash +# Postgres +# Tests can only be ran in one Go package at a time due to clashing db queries. To run Postgres tests for the "pkg/services/sqlstore" package, run: +GRAFANA_TEST_DB=postgres go test ./pkg/services/sqlstore/... + +# Or run all the packages using the circle CI scripts. This method will be slower as the scripts will run all the tests, including the integration tests. +./scripts/circle-test-postgres.sh ``` #### End-to-end