Skip to content

Commit 0355b4f

Browse files
mday-ioclaude
authored andcommitted
test: remove duplicate scoped-cleanup test coverage
test_get_expired_snapshots_scoped_excludes_shared_snapshots duplicated test_get_expired_snapshots_scoped_excludes_referenced_snapshots, and test_delete_expired_snapshots_scoped was a strict subset of test_delete_expired_snapshots_scoped_to_target_ids. Both pairs were introduced by separate merge-from-main rounds on this branch. Signed-off-by: mday-io <mdaytn@gmail.com>
1 parent 24126f4 commit 0355b4f

1 file changed

Lines changed: 0 additions & 93 deletions

File tree

tests/core/state_sync/test_state_sync.py

Lines changed: 0 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -4369,96 +4369,3 @@ def test_get_expired_snapshots_scoped_to_target_ids(
43694369
)
43704370
assert batch_all is not None
43714371
assert snapshot_b.snapshot_id in batch_all.expired_snapshot_ids
4372-
4373-
4374-
def test_get_expired_snapshots_scoped_excludes_shared_snapshots(
4375-
state_sync: EngineAdapterStateSync, make_snapshot: t.Callable
4376-
) -> None:
4377-
"""Test that scoped cleanup respects protection: snapshots shared with other environments are not deleted."""
4378-
now_ts = now_timestamp()
4379-
4380-
snapshot_a = make_snapshot(
4381-
SqlModel(
4382-
name="a",
4383-
query=parse_one("select a, ds"),
4384-
),
4385-
)
4386-
snapshot_a.ttl = "in 10 seconds"
4387-
snapshot_a.categorize_as(SnapshotChangeCategory.BREAKING)
4388-
snapshot_a.updated_ts = now_ts - 15000
4389-
4390-
snapshot_b = make_snapshot(
4391-
SqlModel(
4392-
name="b",
4393-
query=parse_one("select b, ds"),
4394-
),
4395-
)
4396-
snapshot_b.ttl = "in 10 seconds"
4397-
snapshot_b.categorize_as(SnapshotChangeCategory.BREAKING)
4398-
snapshot_b.updated_ts = now_ts - 15000
4399-
4400-
state_sync.push_snapshots([snapshot_a, snapshot_b])
4401-
4402-
# Promote snapshot_b to another active environment (prod-like).
4403-
prod_env = Environment(
4404-
name="prod",
4405-
snapshots=[snapshot_b.table_info],
4406-
start_at="2022-01-01",
4407-
end_at="2022-01-01",
4408-
plan_id="test_plan_id",
4409-
previous_plan_id="test_plan_id",
4410-
)
4411-
state_sync.promote(prod_env)
4412-
state_sync.finalize(prod_env)
4413-
4414-
# Even though snapshot_b is in the target set, it should NOT be returned
4415-
# because it is still referenced by prod_env.
4416-
batch = state_sync.get_expired_snapshots(
4417-
ignore_ttl=True,
4418-
batch_range=ExpiredBatchRange.all_batch_range(),
4419-
target_snapshot_ids=[snapshot_a.snapshot_id, snapshot_b.snapshot_id],
4420-
)
4421-
assert batch is not None
4422-
# Only snapshot_a is exclusively owned (not referenced by any active environment).
4423-
assert batch.expired_snapshot_ids == {snapshot_a.snapshot_id}
4424-
assert [t.snapshot.name for t in batch.cleanup_tasks] == [snapshot_a.name]
4425-
4426-
4427-
def test_delete_expired_snapshots_scoped(
4428-
state_sync: EngineAdapterStateSync, make_snapshot: t.Callable
4429-
) -> None:
4430-
"""Test that delete_expired_snapshots with target_snapshot_ids only deletes scoped snapshots."""
4431-
now_ts = now_timestamp()
4432-
4433-
snapshot_a = make_snapshot(
4434-
SqlModel(
4435-
name="a",
4436-
query=parse_one("select a, ds"),
4437-
),
4438-
)
4439-
snapshot_a.ttl = "in 10 seconds"
4440-
snapshot_a.categorize_as(SnapshotChangeCategory.BREAKING)
4441-
snapshot_a.updated_ts = now_ts - 15000
4442-
4443-
snapshot_b = make_snapshot(
4444-
SqlModel(
4445-
name="b",
4446-
query=parse_one("select b, ds"),
4447-
),
4448-
)
4449-
snapshot_b.ttl = "in 10 seconds"
4450-
snapshot_b.categorize_as(SnapshotChangeCategory.BREAKING)
4451-
snapshot_b.updated_ts = now_ts - 15000
4452-
4453-
state_sync.push_snapshots([snapshot_a, snapshot_b])
4454-
4455-
# Delete only snapshot_a via scoped cleanup.
4456-
state_sync.delete_expired_snapshots(
4457-
batch_range=ExpiredBatchRange.all_batch_range(),
4458-
ignore_ttl=True,
4459-
target_snapshot_ids=[snapshot_a.snapshot_id],
4460-
)
4461-
4462-
# snapshot_a should be deleted, snapshot_b should remain.
4463-
assert not state_sync.get_snapshots([snapshot_a])
4464-
assert state_sync.get_snapshots([snapshot_b])

0 commit comments

Comments
 (0)