Commit b41e03b
committed
fix(tests): install eql_v3 via sqlx Migrator, not a hand-rolled installer (CIP-3141)
c012fdc made the property suites self-install eql_v3 with an embedded copy of
the release SQL guarded by a hand-rolled advisory lock. That raced: nextest
runs each test in its OWN process, several hit the empty shard DB at once, and
concurrent `CREATE SCHEMA eql_v3` failed with `duplicate key … pg_namespace`.
The lock attempt was reinventing — incorrectly — what sqlx already does.
Use the real thing: `ensure_eql_installed` now runs `sqlx::migrate!("./migrations")`
against the base pool — the SAME embedded migration set `#[sqlx::test]` applies
to every other test in the suite. `Migrator::run` records applied versions in
`_sqlx_migrations` and skips them (idempotent, so a developer's pre-migrated
local DB is a no-op) and holds a database-level advisory lock for the run, so
the per-test processes serialise: exactly one applies each migration, the rest
observe it already applied. No bespoke installer, no bespoke lock.
The migrator is built in the test target (property/mod.rs `migrator()`) so the
lib never embeds the gitignored generated `001_install_eql.sql`. Keeps the
`{e:#}` change from c012fdc that surfaces anyhow's cause chain (it is what
revealed the duplicate-key error in the first place).
Compiles clean; CI's sharded nextest run (process-per-test) is the verification
that the migrator serialises the concurrent install.1 parent c012fdc commit b41e03b
4 files changed
Lines changed: 38 additions & 55 deletions
File tree
- tests/sqlx
- src
- tests/encrypted_domain/property
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
| 25 | + | |
| 26 | + | |
31 | 27 | | |
32 | 28 | | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
40 | 35 | | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
59 | 47 | | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
| 48 | + | |
68 | 49 | | |
69 | 50 | | |
70 | 51 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
71 | | - | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
72 | 73 | | |
73 | 74 | | |
74 | 75 | | |
| |||
Lines changed: 3 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
69 | | - | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
70 | 71 | | |
71 | 72 | | |
72 | 73 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| |||
0 commit comments