Skip to content

test: make incremental constraint functional tests rerun-safe#1503

Merged
sd-db merged 2 commits into
mainfrom
sd-db/make-constraint-tests-rerun-safe
Jun 8, 2026
Merged

test: make incremental constraint functional tests rerun-safe#1503
sd-db merged 2 commits into
mainfrom
sd-db/make-constraint-tests-rerun-safe

Conversation

@sd-db
Copy link
Copy Markdown
Collaborator

@sd-db sd-db commented Jun 8, 2026

Problem

The constraint tests in tests/functional/adapter/incremental/test_incremental_constraints.py rewrite schema.yml in place mid-test (via util.write_file) and build relations, but they aren't safe under pytest --reruns. pytest-rerunfailures retries a failed test without tearing down the class-scoped project fixture, so the mutated schema.yml and the relations created by the failed attempt leak into the retry and fail it deterministically — meaning a single intermittent error burns all retries.

Observed on TestIncrementalRemoveForeignKeyConstraint::test_remove_foreign_key_constraint in a nightly: an intermittent server INTERNAL_ERROR failed the initial attempt, and both --reruns 2 retries then failed because they ran against the un-reset, half-built state (only the corrupted FK-parent kept failing; its siblings kept succeeding).

Change

Apply the existing RerunSafeMixin (added in #1499) to the schema.yml-mutating constraint classes. Before each attempt its autouse fixture restores the initial model files and drops the relations the test builds (named via relations_to_reset). FK-holding relations are listed before their parents so the drop order respects the constraint. The two ...DescribeJsonOn subclasses inherit the mixin from their parents. Test-only; no adapter/runtime changes.

Verification

  • Full test_incremental_constraints.py on databricks_uc_cluster: 15 passed, 0 failed.
  • Deterministic rerun-recovery proof (throwaway): a class that mutates schema.yml then fails its first attempt recovers on rerun with the mixin (RERUN → PASSED) and fails without it (RERUN → FAILED) — the mixin restores schema.yml and drops the relations before the retry. Mirrors test: make column-tag functional tests rerun-safe #1499's forced-rerun repro.
  • ruff / ruff-format / mypy pass.

@sd-db sd-db requested a review from jprakash-db as a code owner June 8, 2026 06:23
The constraint tests in test_incremental_constraints.py rewrite schema.yml in
place mid-test and build relations, but are not safe under pytest --reruns: a
retry reuses the class-scoped project fixture, so the mutated schema.yml and the
relations from the failed attempt leak into the retry and fail it
deterministically. A single intermittent error then burns all retries (observed
on TestIncrementalRemoveForeignKeyConstraint, which failed its initial run plus
both reruns in a nightly).

Apply the existing RerunSafeMixin (added in #1499) to the schema.yml-mutating
classes so each attempt restores the initial model files and drops the relations
it builds; FK-holding relations are dropped before their parents. The two
DescribeJsonOn subclasses inherit the mixin from their parents. Test-only; no
adapter/runtime changes.
@sd-db
Copy link
Copy Markdown
Collaborator Author

sd-db commented Jun 8, 2026

/integration-test

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 8, 2026

Integration tests dispatched for PR #1503 by @sd-db. Track progress in the Actions tab.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 8, 2026

Coverage report

This PR does not seem to contain any modification to coverable code.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 8, 2026

Integration results for PR #1503 — UC cluster ✅ success · SQL warehouse ✅ success · All-purpose cluster ✅ success · Shard coverage ✅ success

Run details.

@sd-db sd-db merged commit ac48f74 into main Jun 8, 2026
9 checks passed
@sd-db sd-db deleted the sd-db/make-constraint-tests-rerun-safe branch June 8, 2026 07:22
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.

2 participants