API tests for PMM 2.x
Make sure you have the latest Go version installed on your systems, execute the following steps to set up API-tests in your local systems.
- Run PMM Server. This can be done by running
make env-upin the root (pmm) directory. - In the case below,
$PMM_SERVER_URLshould be replaced with a URL in formathttp://USERNAME:PASSWORD@HOST. For local development it's usuallyhttp://admin:[email protected].
Run the tests using the following command:
go test ./... -pmm.server-url $PMM_SERVER_URL -v
Build Docker image using the following command:
docker build -t IMAGENAME .
Run Docker container using the following command:
docker run -e PMM_SERVER_URL=**pmm-server-url** IMAGENAME
where PMM_SERVER_URL should be pointing to pmm-server.
If pmm-server located locally:
- Use --network=host while running docker container or add both containers to the same docker network.
- Use the insecure url if you default to a self-generated certificate.
All tests should follow these rules:
- Tests can work in parallel and in real system, so take into account that there might be records in database.
- Always revert changes made by test.