Sync tests for cardano-node and cardano-db-sync.
| Doc | Purpose |
|---|---|
doc/LEARNING.md |
Index of learning and troubleshooting docs |
doc/SYNC_TEST_TROUBLESHOOTING.md |
Buildkite, Postgres, Nix, stuck runs |
history.md |
Branch timeline, incidents, owner conventions |
ISSUES_ENCOUNTERED.md |
Known issues and fixes |
CURSOR_GUIDE.md |
Style and where to save chat takeaways |
From the repository root:
python3 -m venv .venv
source .venv/bin/activate
pip install -e .
# or: pip install -r requirements-dev.txtCI often uses nix develop --accept-flake-config .#python --command pytest ... instead.
Example tags below use 10.6.2 for cardano-node and 13.6.0.5 for db-sync; substitute current releases as needed.
All sync workflows use Pytest with session-scoped fixtures.
pytest sync_tests/tests/test_nodesync_artifacts.py \
--node-revision 10.6.2 \
--environment previewpytest sync_tests/tests/test_sync_dbsync.py \
--db-sync-revision 13.6.0.5 \
--node-socket-path /path/to/node.socket \
--environment previewpytest sync_tests/tests/ \
--node-revision 10.6.2 \
--db-sync-revision 13.6.0.5 \
--environment previewpytest sync_tests/tests/ \
--node-revision 10.6.2 \
--db-sync-revision 13.6.0.5 \
--db-sync-start-era babbage \
--environment previewpytest sync_tests/tests/ \
--node-revision 10.6.2 \
--db-sync-revision 13.6.0.5 \
--db-sync-start-era babbage \
--db-sync-start-options "consumed-tx-out" \
--environment preprodpytest sync_tests/tests/ \
--node-revision 10.6.2 \
--db-sync-revision 13.6.0.5 \
--workdir /tmp/sync_output \
--environment mainnet| Option | Default | Description |
|---|---|---|
--environment |
preview |
preview | preprod | mainnet |
--node-revision |
None |
Node tag/branch to build; omit to skip node sync |
--db-sync-revision |
None |
DB-sync tag/branch; omit to skip db-sync |
--db-sync-start-era |
shelley |
Min node era before starting db-sync |
--db-sync-start-options |
"" |
Extra db-sync flags |
--node-socket-path |
None |
Existing node socket path |
--workdir |
./test_workdir |
Output directory for logs and artifacts |
When db-sync tests are included, test_dbsync_artifacts.py generates a comprehensive
test results JSON and checks db-sync logs for errors and rollbacks.
Current CI artifact behavior (Buildkite artifact_paths):
sync_logs.zipsync_results.zipmonitor.zip
Bundle generation is CI-agnostic and keyed off standard CI variables
(CI, GITHUB_ACTIONS, BUILDKITE, GITLAB_CI, CIRCLECI). The runner uploads
the zips; local runs keep raw files under test_workdir/ for debugging.
Results JSON includes enriched performance samples under system_metrics.
Fixtures write sync-completion markers to sync_markers_<env>.json so that
post-sync test durations are excluded from measured sync time.
- Node log:
test_workdir/node_sync.log - DB-sync log:
test_workdir/db_sync.log
Generate performance graphs from sync test results using sync_static_graphs.py:
python3 sync_tests/scripts/sync_static_graphs.py \
-i test_workdir/node_sync_results.json \
-o test_workdir/graphs \
--mode nodeGenerates (5 graphs):
nodesync_cpu_consumption.png- CPU load over slotnodesync_rss_consumption.png- RSS memory over slotnodesync_ram_consumption.png- Heap memory over slotnodesync_duration_per_epoch.png- Sync duration per epochnodesync_time_per_era.png- Sync time per era (stacked bar)
python3 sync_tests/scripts/sync_static_graphs.py \
-i test_workdir/db_sync_results.json \
-o test_workdir/graphs \
--mode dbsyncGenerates (7 graphs):
dbsync_cpu_over_time.png- CPU usage over timedbsync_rss_over_time.png- RSS memory usage over timedbsync_combined_resources.png- Combined CPU + RSS (dual Y-axis)dbsync_epoch_duration.png- Sync duration per epochdbsync_blocks_per_epoch.png- Blocks per epochdbsync_block_throughput.png- Block throughput (configurable modes)dbsync_era_breakdown.png- Sync time per era
python3 sync_tests/scripts/sync_static_graphs.py \
-i test_workdir/*_results.json \
-o test_workdir/graphs \
--mode autoThe script automatically detects whether JSON files are node-sync or db-sync format and generates appropriate graphs.
| Option | Default | Description |
|---|---|---|
-i, --json-files |
Required | One or more JSON result files |
-o, --output-dir |
. |
Output directory for graphs |
--mode |
auto |
node, dbsync, or auto (detect from JSON) |
--throughput-mode |
both |
raw (instantaneous), rolling (smoothed), both |
--throughput-window |
5 |
Rolling average window size in minutes |
--dpi |
150 |
Image resolution |
--format |
png |
Output format (png, pdf, svg) |
Control how block throughput is rendered:
# Raw only - shows instantaneous block insertion rate (noisy)
python3 sync_tests/scripts/sync_static_graphs.py \
-i test_workdir/db_sync_results.json \
-o test_workdir/graphs \
--mode dbsync --throughput-mode raw
# Rolling average only - smoothed with configurable window
python3 sync_tests/scripts/sync_static_graphs.py \
-i test_workdir/db_sync_results.json \
-o test_workdir/graphs \
--mode dbsync --throughput-mode rolling --throughput-window 10
# Both (default) - raw + rolling on same chart for correlation analysis
python3 sync_tests/scripts/sync_static_graphs.py \
-i test_workdir/db_sync_results.json \
-o test_workdir/graphs \
--mode dbsync --throughput-mode bothWhen using test_workdir/cardano-db-sync/db_sync_performance_stats.json (list of system metrics only):
- Available graphs: CPU, RSS, Combined Resources
- Empty graphs: Epoch Duration, Blocks per Epoch, Block Throughput
- Recommendation: Use full
test_workdir/db_sync_results.jsonfor complete graph set
| Document | Purpose |
|---|---|
doc/LEARNING.md |
Short index: doc map, high-signal facts, debugging entry point |
history.md |
Branch timeline, local notes, What Martin wants, chat archive pointers |
doc/SYNC_TEST_TROUBLESHOOTING.md |
Stuck runs, Buildkite, disk / Postgres, Nix cardano-cli, agent variance, pipeline YAML (§11) |
ISSUES_ENCOUNTERED.md |
Short issue → fix index |
CURSOR_GUIDE.md |
Style, pytest, Buildkite, where to save chat takeaways |
SYNC_TESTS_ARCHITECTURE.md |
Module layout and pytest model |
SYNC_TESTS_COMPREHENSIVE_GUIDE.md |
Setup, CLI, markers, Buildkite env mapping |
NODE_SYNC_TEST_EXECUTION_FLOW.md |
Node-only pytest flow vs legacy script context |
REFRACTOR_PLAN.md |
Planned refactors |