This repository has two test layers:
- Unit tests (default, fast, no MongoDB required)
- Integration tests (optional, require a real MongoDB instance)
Run all unit tests:
go test ./...Unit tests are the default and are intentionally independent of local MongoDB availability.
Integration tests are behind the integration build tag and are skipped from default runs.
Current integration smoke test:
internal/mongo/TestRunWorkloadIntegration_OneShotExecutesFindUpdateAndSkipsInsertinternal/mongo/TestRunWorkloadIntegration_OneShotMultiDBMixedShardConfiginternal/mongo/TestRunWorkloadIntegration_MongosMixedShardedAndUnshardedCollections(mongos-only, gated)
From repository root:
docker compose -f docker-compose.integration.yml up -dThen run the integration smoke test:
go test -tags=integration ./internal/mongo -run TestRunWorkloadIntegration_OneShotExecutesFindUpdateAndSkipsInsert -vRun all integration tests available for your endpoint:
go test -tags=integration ./internal/mongo -vStop MongoDB when done:
docker compose -f docker-compose.integration.yml down -vSet the URI via environment variable:
PLGM_IT_MONGO_URI='mongodb://127.0.0.1:30777' \
go test -tags=integration ./internal/mongo -run TestRunWorkloadIntegration_OneShotExecutesFindUpdateAndSkipsInsert -vIf your MongoDB requires authentication, include credentials in PLGM_IT_MONGO_URI.
This test validates a real mongos path with one sharded and one unsharded collection in the same run:
TestRunWorkloadIntegration_MongosMixedShardedAndUnshardedCollections
It is intentionally gated and will skip unless explicitly enabled:
PLGM_IT_MONGO_URI='mongodb://<mongos-host>:27017' \
PLGM_IT_ENABLE_MONGOS_SHARD_TEST=true \
go test -tags=integration ./internal/mongo \
-run TestRunWorkloadIntegration_MongosMixedShardedAndUnshardedCollections \
-v -count=1Recommended CI/profiled environment requirements:
- URI must point to a real
mongosrouter - test user must have privileges for:
listShardsenableShardingshardCollection- normal read/write on test databases
- ideally run in a dedicated test cluster/profile to avoid interference with production workloads
# 1) Unit tests
go test ./...
# 2) Integration smoke test(s)
go test -tags=integration ./internal/mongo -v
# 3) Optional: mongos-only mixed sharding coverage
PLGM_IT_ENABLE_MONGOS_SHARD_TEST=true \
go test -tags=integration ./internal/mongo -run TestRunWorkloadIntegration_MongosMixedShardedAndUnshardedCollections -v -count=1If you are changing Post-Run Insights or explain-analysis behavior, these focused tests are useful:
go test ./internal/stats -run Insights -v
go test ./internal/webui -run Insights -vThese cover filtering/severity behavior, /api/insights lifecycle, and export payload parity with insights output.
/api/stats now includes explicit lifecycle state and structured initialization progress fields:
lifecyclePhase(initializing,running,completed,failed)lifecycleStep,lifecycleStepIndex,lifecycleStepTotallifecycleStepDone,lifecycleStepWork,lifecycleStepProgressPctlifecycleRecentEvents(bounded recent activity list)initializationDurationSecandexecutionElapsedSec
This enables UI/automation to distinguish preparation time from measured execution time.