Testing PMM Dump¶
PMM Dump source code is shipped with unit and end-to-end tests that use test PMM and MongoDB instances. These instances are started automatically when tests are started unless you change this behavior in the configuration files.
Requirements¶
- Go compiler
- Docker
Running All Tests¶
Run
$ make run-tests
This command will initialize the test setup, then run all tests, then shut down the test setup. If any of the tests fail, all subsequent tests will be stopped.
Running End-To-End (e2e) Tests¶
Run
$ make run-e2e-tests
See Executing e2e tests for details.
Running Unit Tests¶
Run
$ make run-unit-tests
Shutting Down Test Environment¶
If, for some reason, the test environment was not destroyed automatically, you can destroy it by running
$ make down-tests
Adjusting options for your test instances¶
When you run
$ make run-tests
$ make init-tests
that creates a temporary directory test for test configuration and results. Files .env.test and .env2.test define the environment for your test instances. The instance that contains test data that needs to be exported is defined in .env.test. The instance that tests import is defined in .env2.test. These files are generated from the content of the .env file in the root directory.
The .env file is autogenerated first time when you run tests or you can create it by copying file .env.example and adjusting its values. This is useful when you need to redefine ports and Docker container names.
Available options are:
| Name | .env.example default |
Description |
|---|---|---|
| CLICKHOUSE_PORT | 9000 | ClickHouse port (for QAN export/import) |
| CLICKHOUSE_PORT_HTTP | 8123 | HTTP port for ClickHouse (for QAN export/import) |
| DOCKER_HTTP_PORT | 80 for PMM 2 and 8080 for PMM 3 | Docker HTTP port to use by the PMM server |
| DOCKER_HTTPS_PORT | 443 for PMM 2 and 8443 for PMM 3 | Docker HTTPS port to use by the PMM server |
| MONGO_IMAGE | mongo | Docker image for MongoDB |
| MONGO_PORT | 27017 | MongoDB port |
| PMM_AGENT_CONFIG_FILE | ./setup/pmm/agent.yaml | Configuraiton file for the pmm-agent |
| PMM_CLIENT_IMAGE | percona/pmm-client | Docker image for PMM client |
| PMM_CLIENT_NAME | pmm-client | Container name for PMM Client |
| PMM_DUMP_PASS | Password for the PMM Dump | |
| PMM_DUMP_PASS_FILEPATH | Password file location | |
| PMM_HTTP_PORT | 8281 | HTTP port for PMM |
| PMM_HTTPS_PORT | 8383 | HTTPS port for PMM |
| PMM_MONGO_NAME | mongo | Container name for MongoDB test instance |
| PMM_SERVER_IMAGE | percona/pmm-server | Docker image for the PMM Server |
| PMM_SERVER_NAME | pmm-server | Container name for PMM Server |
| PMM_URL | http://admin:admin@localhost | PMM Server URL (used only while USE_EXISTING_PMM=true_ |
| PMM_VERSION | 3 | PMM version |
| USE_EXISTING_PMM | false | Use existing PMM Server installation? |
Using existing PMM Server instance¶
To use an existing PMM Server instance either for export or import, set the option USE_EXISTING_PMM to true and PMM_URL to the valid URL of your PMM instance.
PMM versions compatibility test¶
The PMM versions compatibility test TestPMMCompatibility uses the configuration file internal/test/e2e/testdata/versions.yaml with a list of versions that need to be checked for compatibility. Edit this file before running tests if you need to add or remove a particular version.