Skip to content

test: assert expired snapshot ids in expire_snapshots tests - #3615

Open
anxkhn wants to merge 2 commits into
apache:mainfrom
anxkhn:test/expire-snapshots-assert-remove-update
Open

anxkhn wants to merge 2 commits into
apache:mainfrom
anxkhn:test/expire-snapshots-assert-remove-update

Conversation

@anxkhn

@anxkhn anxkhn commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Rationale for this change

Two snapshot-expiration tests checked metadata supplied by a mocked commit
response, so they could pass even when no snapshot IDs were selected for
expiration.

Following the maintainer's feedback, both tests now use the existing catalog
fixture instead of mocking the catalog or commit_table. They append real data,
create a tag, expire the selected snapshot IDs, and reload the table from the
catalog. Each test checks the exact remaining snapshot IDs and verifies that the
tag and main-branch references are preserved.

The fixture runs each test against the memory, SQL, and SQL-without-rowcount
catalogs. Only the two existing tests are rewritten. No library code, fixtures,
dependencies, or public APIs change.

Are these changes tested?

  • The target file passes all 14 cases.
  • make test passes 4,944 tests, with 6 skipped and 129 deselected.
  • Temporarily making ExpireSnapshots.by_id a no-op makes all six rewritten
    cases fail. by_ids delegates to by_id, so this verifies both entry points.
    The temporary production-code change was restored afterward.
  • make lint passes, including mypy, codespell, Ruff, and lockfile validation.
    A fresh Python 3.11 hook cache avoids an older cached Python 3.10 environment;
    no lint rules were changed or skipped.

Are there any user-facing changes?

No. This is a test-only change.

The update was prepared with AI assistance through OpenCode. Independent Opus
5.5 and Gemini 4 Neon source reviews found no blocking issues in the final test
rewrite.

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that's incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the dev@iceberg.apache.org list. Thank you for your contributions.

@github-actions github-actions Bot added the stale label Aug 7, 2026
@anxkhn

anxkhn commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

@Fokko this focused snapshot assertion fix is green and nearing stale closure. could you take a look?

@github-actions github-actions Bot removed the stale label Aug 13, 2026
@Fokko

Fokko commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Thanks @anxkhn for working on this, and sorry for my slow reply, I was touching grass. I'm not a big fan of mocking since it can diverge from the actual code. Let's rewrite the test and avoid mocking altogether. WDYT?

Copilot AI lite review requested due to automatic review settings September 17, 2026 04:13
@anxkhn
anxkhn force-pushed the test/expire-snapshots-assert-remove-update branch from 9391011 to a711956 Compare September 17, 2026 04:13

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.

🟢 Approval recommended

Test-only changes correctly validate expiration behavior.

Pull request overview

Strengthens snapshot expiration tests by verifying the actual IDs submitted for removal instead of mocked metadata.

Changes:

  • Replaces ineffective metadata assertions.
  • Verifies single- and multi-snapshot expiration IDs.
File summaries
File Description
tests/table/test_expire_snapshots.py Asserts captured expiration update IDs.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-actions

Copy link
Copy Markdown

This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that's incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the dev@iceberg.apache.org list. Thank you for your contributions.

@github-actions

Copy link
Copy Markdown

This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that's incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the dev@iceberg.apache.org list. Thank you for your contributions.

@github-actions github-actions Bot added the stale label Nov 25, 2026
test_expire_unprotected_snapshot and test_expire_snapshots_by_ids mocked the
catalog and hardcoded the commit_table response metadata to
snapshots=[KEEP_SNAPSHOT]. After commit, Table._do_commit sets
self.metadata = response.metadata, so the post-conditions only re-checked that
canned value: "EXPIRE_SNAPSHOT not in [KEEP_SNAPSHOT]" is int-not-in-list (always
true for distinct ids) and len(snapshots) == 1 just reads the mock. Both tests
still passed with ExpireSnapshots.by_id/by_ids neutered to no-ops, so they did
not exercise the expiration logic.

Assert the RemoveSnapshotsUpdate.snapshot_ids actually passed to commit_table
instead, matching the existing pattern in
test_expire_snapshots_by_timestamp_skips_protected. Compare as a set because the
update's ids come from a set. With this change both tests fail when the wrong
ids (or none) are expired.

Signed-off-by: Anas Khan <83116240+anxkhn@users.noreply.github.com>
Signed-off-by: Anas Khan <83116240+anxkhn@users.noreply.github.com>
@anxkhn
anxkhn force-pushed the test/expire-snapshots-assert-remove-update branch from a711956 to fb3e773 Compare November 26, 2026 18:13
@anxkhn

anxkhn commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Reworked both tests as requested, without mocking the catalog or commit_table.

The existing catalog fixture now exercises actual append, tag, expiration, and reload operations against its three catalog variants. The assertions check the exact remaining snapshots and confirm that the tag and main branch still point to the protected snapshots.

All 14 cases in the target file pass. make test passes 4,944 tests. A temporary no-op mutation in by_id makes all six rewritten cases fail, so the assertions no longer pass by rereading canned metadata. No library code or dependencies were changed.

make lint and the commit hooks pass. The initial local lint errors came from Python 3.10 hook environments; a fresh hook cache under the project's supported Python resolved them without changing or skipping checks. Independent Opus 5.5 and Gemini 4 Neon source reviews found no blocking issues.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants