Skip to content

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

Open
ArturWieczorek wants to merge 1 commit into
masterfrom
test/dbsync-epoch-view-schema
Open

test(dbsync): cover epoch view schema change (db-sync 13.7.2)#3514
ArturWieczorek wants to merge 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 3 times, most recently from 6a31691 to ea49bc3 Compare June 27, 2026 08:42
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.
@ArturWieczorek ArturWieczorek force-pushed the test/dbsync-epoch-view-schema branch from ea49bc3 to cf75df6 Compare June 27, 2026 09:20
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.

1 participant