ワンクリックで
ワンクリックで
Manage local multigres cluster components (multipooler, pgctld, multiorch, multigateway) - start/stop services, view logs, connect with psql, test S3 backups locally
Generate a PR title and description from the current branch diff against main
Fix markdown linting and prettier formatting issues in markdown files
| name | Development Tools |
| description | Run unit tests, integration tests, and development tasks for multigres |
Development commands for the multigres project.
/mt-dev [test-type] [args...]
When executing commands:
make build before integration testsscripts/portpool.sh start (idempotent, safe to call every time). Then prefix the go test command with MULTIGRES_PORT_POOL_ADDR=/tmp/multigres-port-pool.sock to coordinate port allocation and avoid flaky collisions. If the socket already exists (e.g. from a previous session), just set the env var — no need to restart.Unit tests are fast, isolated tests for individual functions and packages. They don't require external services or build artifacts.
Note: plain go test ./go/... will also traverse go/test/endtoend/...; use -short for unit-focused runs.
Run all unit tests:
/mt-dev unit all
Executes: go test -short ./go/...
Run specific package:
/mt-dev unit <package-path>
Examples:
/mt-dev unit ./go/services/multipooler/... - All multipooler package tests/mt-dev unit ./go/multigateway/... - All multigateway package tests/mt-dev unit ./go/pgprotocol/... - All pgprotocol package testsRun specific test:
/mt-dev unit <package-path> <TestName>
Examples:
/mt-dev unit ./go/services/multipooler TestConnectionPool/mt-dev unit ./go/pgprotocol TestParseQueryRun with pattern matching:
/mt-dev unit <package-path> <TestPattern>
Examples:
/mt-dev unit ./go/services/multipooler TestConn.* - All tests starting with TestConn/mt-dev unit ./go/multigateway Test.*Route.* - All tests with "Route" in name-v - Verbose output (shows all test names as they run)-race - Enable race detector (slower, catches concurrency bugs)-cover - Show coverage percentage-coverprofile=coverage.out - Generate coverage report-count=N - Run tests N times (useful for flaky test detection); -count=1 also forces re-run and bypasses test cache-timeout=30s - Set timeout (default: 10m)-short - Skip long-running tests-parallel=N - Run N tests in parallel (default: GOMAXPROCS)# Quick test run
/mt-dev unit all
# Verbose with race detection
/mt-dev unit ./go/services/multipooler/... -v -race
# Coverage report
/mt-dev unit ./go/pgprotocol/... -cover
# Test for flakiness
/mt-dev unit ./go/multigateway TestRouting -count=10
# Fast tests only
/mt-dev unit all -short
# Specific test with verbose output
/mt-dev unit ./go/services/multipooler TestConnectionPool -v
/mt-dev unit all/mt-dev unit ./go/services/multipooler/.../mt-dev unit ./go/services/multipooler TestConnectionPool/mt-dev unit all -cover/mt-dev unit ./go/multigateway/... -raceIntegration tests are end-to-end tests that start real components (MultiGateway, MultiPooler, PostgreSQL) and test their interactions. These tests are slower and require building the project first.
IMPORTANT: Integration tests always run make build first.
all - Run all integration testsmultipooler - Connection pooling, pool lifecycle, connection managementmultiorch - Orchestration, failover, leader election, consensus protocolqueryserving - Query routing, execution, transaction handlinglocalprovisioner - Local cluster provisioning and setupshardsetup - Shard configuration and managementpgregresstest - PostgreSQL regression tests (opt-in, comprehensive)Run all integration tests:
/mt-dev integration all
Executes: make build && go test ./go/test/endtoend/...
Run specific package:
/mt-dev integration <package-name>
Examples:
/mt-dev integration multipooler → make build && go test ./go/test/endtoend/multipooler/.../mt-dev integration multiorch → make build && go test ./go/test/endtoend/multiorch/.../mt-dev integration queryserving → make build && go test ./go/test/endtoend/queryserving/...Run specific test:
/mt-dev integration <package-name> <TestName>
Examples:
/mt-dev integration multiorch TestFixReplication → make build && go test -run TestFixReplication ./go/test/endtoend/multiorch/.../mt-dev integration multipooler TestConnCache → make build && go test -run TestConnCache ./go/test/endtoend/multipooler/...Run specific test in all packages:
/mt-dev integration all <TestName>
Example:
/mt-dev integration all TestBootstrap → make build && go test -run TestBootstrap ./go/test/endtoend/...Run with pattern matching:
/mt-dev integration <package-name> <TestPattern>
Examples:
/mt-dev integration queryserving Test.*Transaction.* - All transaction tests/mt-dev integration multipooler TestConn.* - All connection testsSame flags as unit tests, plus:
-timeout=30m - Integration tests often need longer timeouts (default: 10m)-p=1 - Run packages sequentially (useful if tests conflict on resources)-count=N - Run tests N times (useful to detect flakes); -count=1 also forces re-run and bypasses test cache# Run all integration tests
/mt-dev integration all
# Test multipooler with verbose output
/mt-dev integration multipooler -v
# Test specific failure scenario
/mt-dev integration multiorch TestFixReplication
# Check for race conditions in query serving
/mt-dev integration queryserving -race
# Test for flakiness (run 10 times)
/mt-dev integration multipooler TestConnCache -count=10
# Run with extended timeout
/mt-dev integration all -timeout=45m
# Sequential execution to avoid resource conflicts
/mt-dev integration all -p=1
/mt-dev integration all/mt-dev integration multipooler/mt-dev integration multiorch TestFixReplication/mt-dev integration all -race/mt-dev integration queryservingPASS
ok github.com/multigres/multigres/go/services/multipooler 2.456s
--- FAIL: TestConnectionPool (0.15s)
pool_test.go:45: expected 10 connections, got 8
FAIL
FAIL github.com/multigres/multigres/go/services/multipooler 2.456s
# github.com/multigres/multigres/go/services/multipooler
./connection.go:123:45: undefined: somethingMissing
FAIL github.com/multigres/multigres/go/services/multipooler [build failed]
==================
WARNING: DATA RACE
Read at 0x00c0001a2080 by goroutine 7:
...
==================
panic: test timed out after 10m0s
# 1. Run unit tests (fast feedback)
/mt-dev unit all
# 2. If unit tests pass, run integration tests
/mt-dev integration all
# 3. Check for race conditions
/mt-dev integration all -race
# 1. Run the specific test with verbose output
/mt-dev integration multipooler TestConnCache -v
# 2. Check if it's flaky (intermittent failure)
/mt-dev integration multipooler TestConnCache -count=10
# 3. Run with race detector
/mt-dev integration multipooler TestConnCache -race -v
# Unit tests first (fast)
/mt-dev unit ./go/services/multipooler/... -v
# Integration tests second
/mt-dev integration multipooler -v
make build manually to see detailed error-count=10 to reproduce-raceWhen integration tests fail, logs are automatically preserved in a temp directory. Follow this systematic approach to debug failures:
After a test failure, look for this message in the test output:
==== TEST LOGS PRESERVED ====
Logs available at: /tmp/shardsetup_test_XXXXXXXXXX
Set TEST_PRINT_LOGS=1 to print log contents
===========================
The temp directory contains all component logs from the failed test.
Integration test log directories follow this structure:
/tmp/shardsetup_test_XXXXXXXXXX/
├── multigateway.log # Multigateway service logs
├── temp-multiorch/ # Temporary multiorch used during bootstrap
│ └── multiorch.log
├── pooler-1/ # First multipooler instance (pooler-1, pooler-2, etc.)
│ ├── multipooler.log # Multipooler service logs
│ ├── pgctld.log # PostgreSQL control daemon logs
│ └── data/
│ ├── pg_data/
│ │ └── postgresql.log # PostgreSQL server logs
│ ├── pg_sockets/ # Unix sockets for PostgreSQL connections
│ └── pgbackrest/
│ └── logs/ # Backup/restore logs
│ ├── multigres-backup.log
│ ├── multigres-restore.log
│ └── all-server.log
├── pooler-2/ # Second multipooler instance
│ └── (same structure as pooler-1)
├── pooler-3/ # Third multipooler instance
│ └── (same structure as pooler-1)
├── etcd_data/ # etcd data directory
├── backup-repo/ # pgBackRest backup repository
└── certs/ # TLS certificates for pgBackRest
Read the test failure message to identify which component is involved:
Example failure patterns:
pooler-*/data/pgbackrest/logs/Use this decision tree:
What component is the test about?
pooler-*/multipooler.logpooler-*/data/pg_data/postgresql.logmultigateway.logtemp-multiorch/multiorch.logLook for ERROR or FATAL level messages in the relevant logs
Check timestamps - Look at logs around the time of the test failure
Follow the chain - If one component reports an error from another, check that component's logs next
# View all log files in the preserved directory
find /tmp/shardsetup_test_XXXXXXXXXX -name "*.log" -type f
# Search for errors across all logs
grep -r "ERROR\|FATAL" /tmp/shardsetup_test_XXXXXXXXXX/
# View logs for a specific pooler
cat /tmp/shardsetup_test_XXXXXXXXXX/pooler-1/multipooler.log
cat /tmp/shardsetup_test_XXXXXXXXXX/pooler-1/data/pg_data/postgresql.log
# View multigateway logs
cat /tmp/shardsetup_test_XXXXXXXXXX/multigateway.log
# View backup/restore logs
ls /tmp/shardsetup_test_XXXXXXXXXX/pooler-1/data/pgbackrest/logs/
To see full log contents printed directly in test output (useful for CI):
TEST_PRINT_LOGS=1 /mt-dev integration shardsetup TestName
This will print all log files to stdout after the test fails, making them visible in CI logs without needing to download artifacts.
Scenario: TestReplicationWorks fails with "replication not configured"
Find logs: Test output shows /tmp/shardsetup_test_1342939839
Identify components: Replication involves multipooler and PostgreSQL on all nodes
Check pooler logs:
# Check multipooler logs for all poolers
grep -i "replication\|primary_conninfo" /tmp/shardsetup_test_1342939839/pooler-*/multipooler.log
# Check PostgreSQL logs
grep -i "replication\|standby" /tmp/shardsetup_test_1342939839/pooler-*/data/pg_data/postgresql.log
Look for specific issues:
primary_conninfo being set?Check multiorch logs if bootstrap or failover is involved:
cat /tmp/shardsetup_test_1342939839/temp-multiorch/multiorch.log
t.Fatal() at the endjq for pretty printing:
cat pooler-1/multipooler.log | jq '.'
-short flag on unit tests to skip slow tests during rapid iteration-v flag when debugging to see which test is running-race flag before committing to catch concurrency bugs-count=10 to verify test stability (per CLAUDE.md guidelines)-count=1 to bypass cached results after environment or build changes-coverprofile=coverage.outFirst argument (required):
Second argument (optional):
Test: use as -run <TestName> argument-: treat as flagAdditional arguments:
Unit tests:
go test [flags] [-run TestName] <package-path>
Integration tests:
make build && scripts/portpool.sh start && MULTIGRES_PORT_POOL_ADDR=/tmp/multigres-port-pool.sock go test [flags] [-run TestName] ./go/test/endtoend/<package>/...