test(dbsync): cover epoch view schema change (db-sync 13.7.2)#3514
Merged
Conversation
ArturWieczorek
force-pushed
the
test/dbsync-epoch-view-schema
branch
3 times, most recently
from
June 26, 2026 12:08
b1e222d to
b911ec9
Compare
Collaborator
Author
|
Local cluster results: 💚 WARNING: Using `cardano-cli` from custom path!
WARNING: Using `cardano-node` from custom path!
============================= test session starts ==============================
platform linux -- Python 3.13.9, pytest-9.0.3, pluggy-1.5.0 -- /home/artur/Projects/cardano-node-tests/.venv/bin/python
hypothesis profile 'default'
metadata: {'Python': '3.13.9', 'Platform': 'Linux-6.8.0-124-generic-x86_64-with-glibc2.39', 'Packages': {'pytest': '9.0.3', 'pluggy': '1.5.0'}, 'Plugins': {'hypothesis': '6.148.7', 'html': '4.1.1', 'metadata': '3.1.1', 'xdist': '3.8.0', 'select': '0.1.2', 'allure-pytest': '2.15.2', 'order': '1.3.0'}, 'github actions url': '', 'cardano-node': '11.0.1', 'cardano-node rev': '97036a66bcf8c89f687ae57a048eecc0389977ef', 'cardano-node ghc': 'ghc-9.6', 'cardano-cli': '11.0.0.0', 'cardano-cli rev': '97036a66bcf8c89f687ae57a048eecc0389977ef', 'cardano-cli ghc': 'ghc-9.6', 'COMMAND_ERA': '', 'TESTNET_VARIANT': 'local_fast', 'NUM_POOLS': '3', 'UTXO_BACKEND': '', 'MIXED_UTXO_BACKENDS': '', 'MAX_TESTS_PER_CLUSTER': 8, 'CLUSTERS_COUNT': 1, 'HAS_CC': 'True', 'cardano-node-tests rev': 'b911ec9fd55c345c5ea44f1c4f22b27933c1a033', 'cardano-node-tests url': 'https://github.com/IntersectMBO/cardano-node-tests/tree/b911ec9fd55c345c5ea44f1c4f22b27933c1a033', 'CARDANO_NODE_SOCKET_PATH': '/var/tmp/cardonnay-of-artur/state-cluster0/bft1.socket', 'cardano-cli exe': '/home/artur/.local/bin/cardano-cli', 'cardano-node exe': '/home/artur/.local/bin/cardano-node', 'cardano-submit-api exe': '/home/artur/.local/bin/cardano-submit-api', 'network magic': 42, 'HAS_DBSYNC': 'True', 'db-sync': '13.7.2.1', 'db-sync rev': 'db8cdf668cda632e9a09c30e1159fcb9fb34e952', 'db-sync ghc': 'ghc-9.6', 'db-sync exe': '/home/artur/.local/bin/cardano-db-sync', 'HAS_SMASH': 'True', 'smash': '13.7.2.1', 'smash rev': 'db8cdf668cda632e9a09c30e1159fcb9fb34e952', 'smash ghc': 'ghc-9.6', 'smash exe': '/home/artur/.local/bin/cardano-smash-server'}
rootdir: /home/artur/Projects/cardano-node-tests
configfile: pyproject.toml
plugins: hypothesis-6.148.7, html-4.1.1, metadata-3.1.1, xdist-3.8.0, select-0.1.2, allure-pytest-2.15.2, order-1.3.0
collecting ... collected 8 items / 4 deselected / 4 selected
cardano_node_tests/tests/test_dbsync.py::TestDBSync::test_table_names@smoke
-------------------------------- live log setup --------------------------------
INFO cardano_node_tests.tests.conftest:conftest.py:225 Changed CWD to '/home/artur/Projects/cardano-node-tests/tmp/pytest-of-artur/pytest-11'.
PASSED [ 25%]
cardano_node_tests/tests/test_dbsync.py::TestDBSync::test_view_names@smoke PASSED [ 50%]
cardano_node_tests/tests/test_dbsync.py::TestDBSync::test_epoch@smoke PASSED [ 75%]
cardano_node_tests/tests/test_dbsync.py::TestDBSync::test_epoch_current@smoke PASSED [100%]
------------------------------ live log teardown -------------------------------
INFO cardano_node_tests.utils.dbsync_conn:dbsync_conn.py:35 Closing connection to db-sync database dbsync0.
======================= 4 passed, 4 deselected in 1.25s ========================
To be straight about provenance: this is a current run (note pytest-11 and the 1.25s timing), not a saved transcript of the earlier ones - I had filtered those through grep, so I never kept their raw text. It's the same four tests, same cluster (TESTNET_VARIANT: local_fast), same branch (b911ec9f), same db-sync: 13.7.2.1, all PASSED. If you want a verbatim artifact, I can also write this to a file (e.g. with --junitxml or tee to a log) so you have a timestamped record rather than a copy-paste.CI results: 💚 |
ArturWieczorek
marked this pull request as ready for review
June 26, 2026 13:00
ArturWieczorek
force-pushed
the
test/dbsync-epoch-view-schema
branch
5 times, most recently
from
July 1, 2026 15:49
cf75df6 to
1e3a8d0
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the db-sync integration tests to cover the db-sync 13.7.2 schema change where epoch moved from a table to a view (and introduces the new epoch_current live-aggregation view), ensuring the test suite detects missing/renamed views and exercises the live current-epoch branch end-to-end.
Changes:
- Bump nightly db-sync to
13.7.2.1. - Add a
Viewenum plus SQL helpers to query view names and to read fromepoch_current/epoch_sync_enabled. - Extend db-sync integration tests with
test_view_namesandtest_epoch_current, and adjust epoch validation to use a finalized epoch (current − 1).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
runner/env_nightly_dbsync |
Bumps nightly db-sync artifact version to 13.7.2.1. |
cardano_node_tests/utils/dbsync_service_manager.py |
Introduces View enum and updates table enum for the epoch schema split. |
cardano_node_tests/utils/dbsync_queries.py |
Adds view discovery (pg_views) and new queries for epoch_current and epoch_sync_enabled. |
cardano_node_tests/tests/test_dbsync.py |
Adds view-level schema assertions and a live epoch_current smoke test; updates epoch test to target a finalized epoch. |
Comments suppressed due to low confidence (1)
cardano_node_tests/tests/test_dbsync.py:429
- This docstring section still describes querying/validating an "epoch table"; since
epochis a view, the terminology should be updated for accuracy.
* Count blocks and transactions from block table records
* Query epoch summary from epoch table for same epoch
* Count blocks and transactions from epoch table records
* Verify block count matches between block table and epoch table
* Verify transaction count matches between block table and epoch table
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Since db-sync 13.7.2 the `epoch` table is replaced by a view: finalized rows UNION a live current-epoch aggregation, backed by the new `epoch_finalized` and `epoch_sync_enabled` tables. `test_table_names` was already updated for the two new tables. This adds the coverage that was still missing at the integration level: * query_view_names() + test_view_names: assert the `epoch` and `epoch_current` views exist. test_table_names only looks at pg_tables, so a dropped or renamed view would otherwise go unnoticed. The expected view set is derived from the View enum (single source of truth). * test_epoch_current: exercises the live current-epoch branch end to end. It asserts live sync is on via query_epoch_sync_enabled(), reads the `epoch_current` view directly via query_epoch_current(), and checks one sane, non-inflated row for the current epoch. The view is read before the blocks so its counts bound the later block-table read. This is a counts sanity check; out_sum/fees decoding correctness (issue #2118) is already covered hermetically by the db-sync repo's own unit tests (cardano-db EpochCalc), so it is not duplicated here. * test_epoch / test_epoch_current: wait_for_epoch() to guarantee the needed epoch instead of skipping, so the checks run as real coverage on fresh clusters (no-op on long-lived testnets). * Table enum fix: `epoch` is now a view; added `epoch_finalized` / `epoch_sync_enabled` and a View enum. * Bumped nightly db-sync to the latest release 13.7.2.1. All new tests are gated on dbsync >= 13.7.2.
mkoura
force-pushed
the
test/dbsync-epoch-view-schema
branch
from
July 7, 2026 11:23
1e3a8d0 to
5080194
Compare
mkoura
approved these changes
Jul 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In db-sync 13.7.2 the
epochtable is replaced by a view: finalized rows UNION a live current-epoch aggregation, backed by the newepoch_finalizedandepoch_sync_enabledtables. Reads viaepochare unchanged.test_table_nameswas already updated for the two new tables. This adds the coverage that was still missing at the integration level:query_view_names()+test_view_names: assert theepochandepoch_currentviews exist.test_table_namesonly looks at pg_tables, so a dropped or renamed view would otherwise go unnoticed.test_epoch_current: exercises the liveepoch_currentview branch end to end against a running db-sync (enabled, populated, one sane row for the current epoch).test_epochonly covers a finalized epoch. The view is read before the block table so the bound is race-free mid-epoch.epochis now a view; addedepoch_finalized/epoch_sync_enabledand a View enum.Scope note: this is integration-level coverage of schema shape and the live view branch. The out_sum/fees decoding correctness behind issue #2118 is covered hermetically by the db-sync repo's own unit tests (cardano-db
EpochCalc, added with the #2118 fix), so it is intentionally not duplicated here, where local-cluster values are too small to exercise the Word128 decoder path anyway.All new tests are gated on dbsync >= 13.7.2. Verified against a local conway_fast cluster (db-sync 13.7.2.1): 4 passed.