Aiven-Open / pghoard

PostgreSQL® backup and restore service
http://aiven-open.github.io/pghoard/
Apache License 2.0
1.31k stars 96 forks source link

tests: fix flakiness while starting PostgreSQL and PGHoard webserver #573

Closed kmichel-aiven closed 1 year ago

kmichel-aiven commented 1 year ago

About this change - What it does

The tests were waiting a fixed amount of time for the web server thread and for PostgreSQL to start. This was too optimistic. Fix it by using an threading Event or polling the process startup instead.

Why this way

Because flaky tests are unpleasant.

codecov[bot] commented 1 year ago

Codecov Report

Merging #573 (b3e41f7) into main (6a29d01) will increase coverage by 0.60%. The diff coverage is 100.00%.

Additional details and impacted files [![Impacted file tree graph](https://codecov.io/gh/aiven/pghoard/pull/573/graphs/tree.svg?width=650&height=150&src=pr&token=nLr7M7hvCx&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aiven)](https://codecov.io/gh/aiven/pghoard/pull/573?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aiven) ```diff @@ Coverage Diff @@ ## main #573 +/- ## ========================================== + Coverage 90.62% 91.23% +0.60% ========================================== Files 30 30 Lines 4608 4586 -22 ========================================== + Hits 4176 4184 +8 + Misses 432 402 -30 ``` | [Impacted Files](https://codecov.io/gh/aiven/pghoard/pull/573?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aiven) | Coverage Δ | | |---|---|---| | [pghoard/compressor.py](https://codecov.io/gh/aiven/pghoard/pull/573/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aiven#diff-cGdob2FyZC9jb21wcmVzc29yLnB5) | `93.13% <100.00%> (+0.05%)` | :arrow_up: | | [pghoard/webserver.py](https://codecov.io/gh/aiven/pghoard/pull/573/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aiven#diff-cGdob2FyZC93ZWJzZXJ2ZXIucHk=) | `89.19% <100.00%> (+0.07%)` | :arrow_up: | | [pghoard/fetcher.py](https://codecov.io/gh/aiven/pghoard/pull/573/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aiven#diff-cGdob2FyZC9mZXRjaGVyLnB5) | `79.78% <0.00%> (-2.13%)` | :arrow_down: | | [pghoard/wal.py](https://codecov.io/gh/aiven/pghoard/pull/573/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aiven#diff-cGdob2FyZC93YWwucHk=) | `100.00% <0.00%> (ø)` | | | [pghoard/pghoard.py](https://codecov.io/gh/aiven/pghoard/pull/573/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aiven#diff-cGdob2FyZC9wZ2hvYXJkLnB5) | `84.73% <0.00%> (+0.16%)` | :arrow_up: | | [pghoard/basebackup/base.py](https://codecov.io/gh/aiven/pghoard/pull/573/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aiven#diff-cGdob2FyZC9iYXNlYmFja3VwL2Jhc2UucHk=) | `92.19% <0.00%> (+6.61%)` | :arrow_up: |