Skip to content

Latest commit

 

History

History
46 lines (32 loc) · 2.5 KB

File metadata and controls

46 lines (32 loc) · 2.5 KB

Mimir integration tests are written in Go and based on a custom framework running Mimir and its dependencies in Docker containers and using the Go testing package for assertions. Integration tests run in CI for every PR, and can be easily executed locally during development (it just requires Docker).

How to run integration tests

When integration tests run in CI, we build the Mimir Docker image based on the PR code and then run the integration tests against it. When running tests locally you should build the Mimir Docker image first:

make ./cmd/mimir/.uptodate

This will locally build the grafana/mimir:latest image used by integration tests. Whenever the Mimir code changes (cmd/, pkg/ or vendors) you should rebuild the Mimir image, while it's not necessary to rebuild it while developing integration tests.

Once the Docker image is built, you can run integration tests:

go test -v ./integration/...

If you want to run a single test you can use a filter. For example, to only run TestChunksStorageAllIndexBackends:

go test -v ./integration -run "^TestChunksStorageAllIndexBackends$"

When running all integration tests, the test process may time out before the tests complete. If this happens, you can increase go test's default 10 minute timeout to something longer with the -timeout flag, for example:

go test -v -timeout=20m ./integration/...

Supported environment variables

  • MIMIR_IMAGE
    Docker image used to run Mimir in integration tests (defaults to grafana/mimir:latest)
  • MIMIRTOOL_IMAGE
    Docker image used to run mimirtool in integration tests (defaults to grafana/mimirtool:latest)
  • MIMIR_CHECKOUT_DIR
    The absolute path of the Mimir repository local checkout (defaults to $GOPATH/src/github.com/grafana/mimir)
  • E2E_TEMP_DIR
    The absolute path to a directory where the integration test will create an additional temporary directory to store files generated during the test.
  • E2E_NETWORK_NAME
    Name of the docker network to create and use for integration tests. If no variable is set, defaults to e2e-mimir-test.

Isolation

Each integration test runs in isolation. For each integration test, we do create a Docker network, start Mimir and its dependencies containers, push/query series to/from Mimir and run assertions on it. Once the test is done, both the Docker network and containers are terminated and deleted.