Commit ac48f74
authored
test: make incremental constraint functional tests rerun-safe (#1503)
## 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 #1499's forced-rerun repro.
- ruff / ruff-format / mypy pass.1 parent ee495c2 commit ac48f74
2 files changed
Lines changed: 48 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
Lines changed: 47 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
6 | 9 | | |
7 | 10 | | |
8 | 11 | | |
9 | 12 | | |
10 | | - | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
11 | 18 | | |
12 | 19 | | |
13 | 20 | | |
| |||
46 | 53 | | |
47 | 54 | | |
48 | 55 | | |
49 | | - | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
50 | 61 | | |
51 | 62 | | |
52 | 63 | | |
| |||
82 | 93 | | |
83 | 94 | | |
84 | 95 | | |
85 | | - | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
86 | 101 | | |
87 | 102 | | |
88 | 103 | | |
| |||
107 | 122 | | |
108 | 123 | | |
109 | 124 | | |
110 | | - | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
111 | 130 | | |
112 | 131 | | |
113 | 132 | | |
| |||
146 | 165 | | |
147 | 166 | | |
148 | 167 | | |
149 | | - | |
| 168 | + | |
150 | 169 | | |
151 | 170 | | |
152 | 171 | | |
153 | 172 | | |
154 | 173 | | |
155 | 174 | | |
156 | 175 | | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
157 | 180 | | |
158 | 181 | | |
159 | 182 | | |
| |||
205 | 228 | | |
206 | 229 | | |
207 | 230 | | |
208 | | - | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
209 | 237 | | |
210 | 238 | | |
211 | 239 | | |
| |||
258 | 286 | | |
259 | 287 | | |
260 | 288 | | |
261 | | - | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
262 | 295 | | |
263 | 296 | | |
264 | 297 | | |
| |||
323 | 356 | | |
324 | 357 | | |
325 | 358 | | |
326 | | - | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
327 | 365 | | |
328 | 366 | | |
329 | 367 | | |
| |||
0 commit comments