hezarfen_backend
Clone
https://git.tahinli.com/Hezarfen/hezarfen_backend.git
0 watching0 forksRust8.3 MiB6d68754Ahmet Kaan Gümüş2 months ago566 commits
| 1 | #!/usr/bin/env bash |
| 2 | # Boot N copies of the backend at once against a Postgres whose school |
| 3 | # template has just been dropped, and report what each boot did. |
| 4 | # |
| 5 | # This is the reproduction for the concurrent-boot class. Two things are being |
| 6 | # watched: |
| 7 | # * every boot must reach `listening` — overlapping `CREATE DATABASE`s used |
| 8 | # to kill the losers, because Postgres reports the losing side as a |
| 9 | # `pg_database_datname_index` unique violation (`23505`) rather than the |
| 10 | # `42P04` duplicate-database error, and the swallow only matched `42P04`; |
| 11 | # * the server log must stay clean *of create refusals* — a create that is |
| 12 | # issued and refused is logged by the server even when the client swallows |
| 13 | # the error, which is why the create now runs behind a probe and under an |
| 14 | # advisory lock. The assertion is scoped to those lines so that a test |
| 15 | # suite sharing the server (its deliberate foreign-key violations) does |
| 16 | # not read as a boot failure. |
| 17 | # Exit status is non-zero if any boot failed or the server logged a create |
| 18 | # refusal. |
| 19 | # |
| 20 | # The template of the control database is dropped first; the next boot (this |
| 21 | # script, or your usual `podman compose up -d backend`) rebuilds and migrates |
| 22 | # it, so a dev database is the only thing this may disturb. |
| 23 | # |
| 24 | # Needs the compose Postgres up (`podman compose up -d postgres`) and a built |
| 25 | # binary (`cargo build`). |
| 26 | |
| 27 | |
| 28 | CONTAINER="" |
| 29 | CONTROL_DB="" |
| 30 | N="" |
| 31 | BASE_PORT="" |
| 32 | OUT="" |
| 33 | HERE="" |
| 34 | BIN="" |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 | |
| 40 | before= |
| 41 | |
| 42 | |
| 43 | for; do |
| 44 | ( |
| 45 | HOST=127.0.0.1 PORT= \ |
| 46 | |
| 47 | |
| 48 | |
| 49 | ) & |
| 50 | done |
| 51 | |
| 52 | |
| 53 | fail=0 |
| 54 | for; do |
| 55 | if ; then |
| 56 | |
| 57 | else |
| 58 | |
| 59 | |
| 60 | fail=1 |
| 61 | fi |
| 62 | done |
| 63 | |
| 64 | errors= |
| 65 | |
| 66 | |
| 67 | [ || fail=1 |
| 68 | |
| 69 | |
| 70 | |
| 71 | |
| 72 |