Commit 93d6314
authored
test: make MV schedule and seed_onto_view functional tests rerun-safe (#1581)
## Description
Two functional tests flake in the nightly Integration suites when a
transient warehouse/auth blip kills an attempt mid-test.
`pytest-rerunfailures` retries in the same process **without** tearing
down the class-scoped `project`, so the leftover relation and the
in-place-rewritten model file leak into the retry, which then fails on a
spurious `AssertionError`:
- `TestMaterializedViewScheduleLifecycle::test_full_lifecycle` — `assert
'cron' == 'manual'` (retry re-enters with the MV already switched to
cron).
- `TestSeedOntoView::test_seed_onto_view_is_rejected` — `dbt exit state
did not match expected` (leftover `seed_over_view` relation).
These are **not** code regressions — the same tests pass on a clean run
— but they turn transient infra flakiness into red CI that reads like a
regression during nightly triage.
## Fix
Adopt the existing `RerunSafeMixin`
(`tests/functional/adapter/fixtures.py`) — the codebase-wide convention
already used by ~30 classes. Its autouse, function-scoped
`reset_project_state` fires on every attempt (the class-scoped `project`
survives reruns), restoring the `models` files to their initial content
and dropping the named `relations_to_reset` before the retry, so each
attempt starts from a clean slate. On the first attempt it is a no-op
(files already at initial content, relations don't exist yet), so
**happy-path behavior is unchanged**.
- `test_schedule_modes.py`: all four MV schedule classes inherit
`RerunSafeMixin` with a `relations_to_reset` naming their single MV
(`mv_on_update_bare`, `mv_drop_readd`, `mv_lifecycle`,
`mv_every_inputs`). The observed failure was `mv_lifecycle`; the
siblings share the identical latent leak (in-place `write_file` + fixed
names), so they are hardened too.
- `test_seeds.py`: `TestSeedOntoView` inherits `RerunSafeMixin` with
`relations_to_reset = ("seed_over_view",)`; `TestSeedOntoViewV2`
inherits it transitively.
## Verification
On the SQL-warehouse profile (`databricks_uc_sql_endpoint`):
- **No happy-path regression**: `test_schedule_modes.py` = 4 passed;
`TestSeedOntoView` + `TestSeedOntoViewV2` = 2 passed.
- **Rerun-safety proof** (throwaway test, not committed): injected a
one-shot failure right after the cron transition and ran `--reruns 1`. A
bare no-mixin copy **failed on rerun** with the exact nightly signature
`assert 'cron' == 'manual'`; the `RerunSafeMixin` copy **passed on
rerun**. Final: `1 failed, 1 passed, 2 rerun` — confirming both that the
leak is real and that the mixin fixes it.
- `pre-commit` (ruff, ruff-format, mypy) passes.
Test-only; no adapter/runtime code changes.
## Checklist
- [x] I have run this code in development, and it appears to resolve the
stated issue.
- [x] This PR includes tests, or tests are not required/relevant for
this PR.
- [x] I have updated the `CHANGELOG.md` and added information about my
change.1 parent 4f5c38e commit 93d6314
3 files changed
Lines changed: 28 additions & 7 deletions
File tree
- tests/functional/adapter
- materialized_view_tests
- simple_seed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| |||
Lines changed: 21 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
30 | | - | |
| 31 | + | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| |||
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
39 | 44 | | |
40 | 45 | | |
41 | 46 | | |
| |||
46 | 51 | | |
47 | 52 | | |
48 | 53 | | |
49 | | - | |
| 54 | + | |
50 | 55 | | |
51 | 56 | | |
52 | 57 | | |
| |||
57 | 62 | | |
58 | 63 | | |
59 | 64 | | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
60 | 69 | | |
61 | 70 | | |
62 | 71 | | |
| |||
82 | 91 | | |
83 | 92 | | |
84 | 93 | | |
85 | | - | |
| 94 | + | |
86 | 95 | | |
87 | 96 | | |
88 | 97 | | |
| |||
95 | 104 | | |
96 | 105 | | |
97 | 106 | | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
98 | 111 | | |
99 | 112 | | |
100 | 113 | | |
| |||
144 | 157 | | |
145 | 158 | | |
146 | 159 | | |
147 | | - | |
| 160 | + | |
148 | 161 | | |
149 | 162 | | |
150 | 163 | | |
| |||
157 | 170 | | |
158 | 171 | | |
159 | 172 | | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
160 | 177 | | |
161 | 178 | | |
162 | 179 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| |||
185 | 185 | | |
186 | 186 | | |
187 | 187 | | |
188 | | - | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
189 | 193 | | |
190 | 194 | | |
191 | 195 | | |
| |||
0 commit comments