test: make incremental constraint functional tests rerun-safe#1503
Merged
Conversation
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.
5103980 to
0edaa91
Compare
Collaborator
Author
|
/integration-test |
|
Integration tests dispatched for PR #1503 by @sd-db. Track progress in the Actions tab. |
|
Integration results for PR #1503 — UC cluster ✅ success · SQL warehouse ✅ success · All-purpose cluster ✅ success · Shard coverage ✅ success |
jprakash-db
approved these changes
Jun 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The constraint tests in
tests/functional/adapter/incremental/test_incremental_constraints.pyrewriteschema.ymlin place mid-test (viautil.write_file) and build relations, but they aren't safe underpytest --reruns. pytest-rerunfailures retries a failed test without tearing down the class-scopedprojectfixture, so the mutatedschema.ymland 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_constraintin a nightly: an intermittent serverINTERNAL_ERRORfailed the initial attempt, and both--reruns 2retries 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 theschema.yml-mutating constraint classes. Before each attempt its autouse fixture restores the initial model files and drops the relations the test builds (named viarelations_to_reset). FK-holding relations are listed before their parents so the drop order respects the constraint. The two...DescribeJsonOnsubclasses inherit the mixin from their parents. Test-only; no adapter/runtime changes.Verification
test_incremental_constraints.pyondatabricks_uc_cluster: 15 passed, 0 failed.schema.ymlthen fails its first attempt recovers on rerun with the mixin (RERUN → PASSED) and fails without it (RERUN → FAILED) — the mixin restoresschema.ymland drops the relations before the retry. Mirrors test: make column-tag functional tests rerun-safe #1499's forced-rerun repro.