Building from Source
Relevant source files
The following files were used as context for generating this wiki page:
Building pmm-dump from source allows developers to create a binary tailored for transferring metrics and QAN data between Percona Monitoring and Management (PMM) Server instances. The build process is primarily managed through a Makefile and requires the Go programming language environment.
Sources: README.md:3-5, cmd/pmm-dump/main.go:37-41
Prerequisites
To build the tool, the following software must be installed on the host system:
- Go: Version 1.21 or higher.
- Docker: Required for running the local development environment and end-to-end (e2e) tests.
- Make: Used to execute the build rules defined in the project's Makefile.
Sources: README.md:9-11, README.md:104-106, internal/test/README.md:7-9
Build Process
The build process is standardized using a Makefile. Running the build command produces a compiled binary named pmm-dump.
Standard Build
The primary command to compile the project from the root directory is:
make build
Sources: README.md:11, README.md:110
Build Artifacts and Metadata
During compilation, specific metadata is often injected into the binary to track the build's origin. The main application defines variables to capture version control information:
| Variable | Description |
|---|---|
GitBranch | The current git branch name during build. |
GitCommit | The specific git commit hash of the build. |
GitVersion | The version string assigned to the binary. |
Sources: cmd/pmm-dump/main.go:37-41, cmd/pmm-dump/main.go:426-428
Build Flow Diagram
The following diagram illustrates the high-level flow from source code to a functional test environment.
The diagram shows the transition from raw source code to a compiled binary, which then serves as the foundation for various testing tiers involving Docker-based PMM deployments.
Sources: README.md:104-117, internal/test/README.md:14-20
Testing the Build
After building the binary, it is critical to verify its functionality through the provided test suites.
Automated Test Rules
The Makefile provides several rules for different testing scopes:
| Rule | Description |
|---|---|
make run-tests | Runs all available tests. |
make run-unit-tests | Executes only the unit tests. |
make run-e2e-tests | Launches the end-to-end test suite using Docker Compose. |
Sources: README.md:115-117
Security Verification
The project includes a specific build tag for security testing. To verify that credentials are not leaked in process lists or logs, tests can be run using the security tag:
go test -v -tags security ./cmd/pmm-dump
These tests ensure that sensitive environment variables (like PMM_CLICKHOUSE_URL or PMM_POSTGRES_URL) are redacted in logs and not visible in /proc/<pid>/cmdline.
Sources: cmd/pmm-dump/security_test.go:17-19, cmd/pmm-dump/security_test.go:31-35
Development Environment Setup
The repository includes a local development environment powered by Docker Compose to simulate a real PMM ecosystem.
- Initialize Containers: Use
make upto set up PMM Server, PMM Client, and MongoDB. - Register Services: Use
make mongo-regto register the local MongoDB instance within the PMM environment. - Validate Export: Use
make export-allto run an export from the local PMM instance to verify the newly built binary.
Sources: README.md:104-114
Summary
Building pmm-dump from source requires Go 1.21+ and utilizes a Makefile to streamline the compilation and testing processes. The resulting binary is designed to be highly secure, with built-in mechanisms to prevent credential leakage, and can be thoroughly validated against a local Docker-based PMM environment before deployment.
Sources: README.md:104-106, cmd/pmm-dump/security_test.go:49-55