Skip to content

test(dbsync): cover epoch view schema change (db-sync 13.7.2)#3514

Merged
mkoura merged 1 commit into
masterfrom
test/dbsync-epoch-view-schema
Jul 7, 2026
Merged

test(dbsync): cover epoch view schema change (db-sync 13.7.2)#3514
mkoura merged 1 commit into
masterfrom
test/dbsync-epoch-view-schema

Conversation

@ArturWieczorek

@ArturWieczorek ArturWieczorek commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

In 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. Reads via epoch are unchanged.

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.
  • test_epoch_current: exercises the live epoch_current view branch end to end against a running db-sync (enabled, populated, one sane row for the current epoch). test_epoch only covers a finalized epoch. The view is read before the block table so the bound is race-free mid-epoch.
  • 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.

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.

@ArturWieczorek
ArturWieczorek force-pushed the test/dbsync-epoch-view-schema branch 3 times, most recently from b1e222d to b911ec9 Compare June 26, 2026 12:08
@ArturWieczorek

ArturWieczorek commented Jun 26, 2026

Copy link
Copy Markdown
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
ArturWieczorek marked this pull request as ready for review June 26, 2026 13:00
@ArturWieczorek
ArturWieczorek force-pushed the test/dbsync-epoch-view-schema branch 5 times, most recently from cf75df6 to 1e3a8d0 Compare July 1, 2026 15:49
@mkoura
mkoura requested a review from Copilot July 7, 2026 11:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 View enum plus SQL helpers to query view names and to read from epoch_current / epoch_sync_enabled.
  • Extend db-sync integration tests with test_view_names and test_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 epoch is 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.

Comment thread cardano_node_tests/tests/test_dbsync.py
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
mkoura force-pushed the test/dbsync-epoch-view-schema branch from 1e3a8d0 to 5080194 Compare July 7, 2026 11:23
@mkoura
mkoura merged commit 8c3f9bb into master Jul 7, 2026
3 checks passed
@mkoura
mkoura deleted the test/dbsync-epoch-view-schema branch July 7, 2026 11:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants