package
3.0.0+incompatible
Repository: https://github.com/percona/pmm.git
Documentation: pkg.go.dev

# README

pmm-api-tests

API tests for PMM 3.x

Setup Instructions

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.

  1. Run PMM Server. This can be done by running make env-up in the root (pmm) directory.
  2. Replace $PMM_SERVER_URL with a URL in format http://USERNAME:PASSWORD@HOST. For local development it's usually http://admin:[email protected].

Usage

Run the tests using the following command:

go test ./... -pmm.server-url $PMM_SERVER_URL -v

Docker

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 a running PMM Server.

If pmm-server is 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.

Contributing

All tests should follow these rules:

  • Tests can work in parallel and on a real system, so take into account that there might be records in database.
  • Always revert changes made by tests.

# Packages

No description provided by the author
No description provided by the author
Package inventory contains inventory API tests.
Package management contains management API tests.
Package server contains PMM server API tests.

# Functions

AddGenericNode adds a generic node.
AddNode adds a node.
AddPMMAgent adds a PMM agent.
AddRemoteNode adds a remote node.
AssertAPIErrorf check that actual API error equals expected.
ExpectFailure sets up expectations for a test case to fail.
RemoveAgents removes specified agents.
RemoveAgentsWithForce removes specified agents along with dependents.
RemoveNodes removes specified nodes.
RemoveServices removes specified services.
TestString returns semi-random string that can be used as a test data.
Transport returns configured Swagger transport for given URL.
UnregisterNodes unregister specified nodes.

# Variables

BaseURL contains PMM Server base URL like https://admin:[email protected]:8443/.
Context is canceled on SIGTERM or SIGINT.
Debug is true if -debug or -trace flag is passed.
Hostname contains local hostname that is used for generating test data.
RunAdvisorTests is true if Advisor tests should be run.
RunUpdateTest is true if PMM Server update should be tested.

# Interfaces

ErrorResponse represents the response structure for error scenarios.
TestingT contains minimal subset of *testing.T that we use that is also should be implemented by *expectedFailureTestingT.

# Type aliases

NginxError is an error type for nginx HTML response.