Moving things around in README.md and CONTRIBUTING.md

This commit is contained in:
benoit 2023-08-28 11:59:59 +02:00
parent ee3837fab1
commit f0c2a243f0
3 changed files with 55 additions and 125 deletions

View file

@ -40,29 +40,70 @@ install check_patroni. You can then add a server to the supervision and
watch the graphs in grafana. It's in the `vagrant` directory. watch the graphs in grafana. It's in the `vagrant` directory.
A vagrant file can be found in [this A vagrant file can be found in [this
repository](https://github.com/ioguix/vagrant-patroni to generate a patroni/etcd repository](https://github.com/ioguix/vagrant-patroni) to generate a patroni/etcd
setup. setup.
The `README.md` can be geneated with `./docs/make_readme.sh`. The `README.md` can be geneated with `./docs/make_readme.sh`.
## Executing Tests ## Executing Tests
The pytests are in `./tests` and use a moker to provide a json response instead Crafting repeatable tests using a live Patroni cluster can be intricate. To
of having to call the patroni API. To manually run the tests use one of these simplify the development process, interactions with Patroni's API are
commands : substituted with a mock function that yields an HTTP return code and a JSON
object outlining the cluster's status. The JSON files containing this
information are housed in the `./tests/json` directory.
``` An important consideration is that there is a potential drawback: if the JSON
pytest ./tests # just the tests data is incorrect or if modifications have been made to Patroni without
tox # pytests for all supported version of python + mypy + flake8 corresponding updates to the tests documented here, the tests might still pass
tox -e py # pytests + mypy + flake8 or the default version of python erroneously.
```
The tests are executed automatically for each PR using the ci (see The tests are executed automatically for each PR using the ci (see
`.github/workflow/lint.yml` and `.github/workflow/tests.yml`). `.github/workflow/lint.yml` and `.github/workflow/tests.yml`).
Running the tests manually:
* Using patroni's nominal replica state of `streaming` (since v3.0.4):
```bash
pytest ./tests
```
* Using patroni's nominal replica state of `running` (before v3.0.4):
```bash
pytest --use-old-replica-state ./tests
```
* Using tox:
```bash
tox -e lint # mypy + flake8 + black + isort ° codespell
tox # pytests and "lint" tests for all supported version of python
tox -e py # pytests and "lint" tests for the default version of python
```
Please note that when dealing with any service that checks the state of a node
in patroni's `cluster` endpoint, the corresponding JSON test file must be added
in `./tests/tools.py`.
A bash script, `check_patroni.sh`, is provided to facilitate testing all
services on a Patroni endpoint (`./vagrant/check_patroni.sh`). It requires one
parameter: the endpoint URL that will be used as the argument for the
`-e/--endpoints` option of `check_patroni`. This script essentially compiles a
list of service calls and executes them sequentially in a bash script. It
creates a state file in the directory from which you run the script.
Here's an example usage:
```bash
./vagrant/check_patroni.sh http://10.20.30.51:8008
```
## Release ## Release
Update the Changelog.
The package is generated and uploaded to pypi when a `v*` tag is created (see The package is generated and uploaded to pypi when a `v*` tag is created (see
`.github/workflow/publish.yml`). `.github/workflow/publish.yml`).

View file

@ -115,62 +115,6 @@ Several options are available:
* `--cert_file`: your certificate or the concatenation of your certificate and private key * `--cert_file`: your certificate or the concatenation of your certificate and private key
* `--key_file`: your private key (optional) * `--key_file`: your private key (optional)
## Tests
Crafting repeatable tests using a live Patroni cluster can be intricate. To
simplify the development process, interactions with Patroni's API are
substituted with a mock function that yields an HTTP return code and a JSON
object outlining the cluster's status. The JSON files containing this
information are housed in the ./tests/json directory.
An important consideration is that there is a potential drawback: if the JSON
data is incorrect or if modifications have been made to Patroni without
corresponding updates to the tests documented here, the tests might still pass
erroneously.
To run the tests:
1. Clone the `check_patroni` repository, create a virtual environment, and
install the script:
```bash
git clone https://github.com/dalibo/check_patroni.git
cd check_patroni
python -m venv .venv
. .venv/bin/activate
pip install -e check_patroni[test]
```
2) Run the tests
- Using patroni's nominal replica state of `streaming` (since v3.0.4):
```bash
pytest ./tests
```
- Using patroni's nominal replica state of `running` (before v3.0.4):
```bash
pytest --use-old-replica-state ./tests
```
Please note that when dealing with any service that checks the state of a node
in patroni's `cluster` endpoint, the corresponding JSON test file must be added
in `./test/tools.py`.
A bash script, `check_patroni.sh`, is provided to facilitate testing all
services on a Patroni endpoint (`./vagrant/check_patroni.sh`). It requires one
parameter: the endpoint URL that will be used as the argument for the
`-e/--endpoints` option of `check_patroni`. This script essentially compiles a
list of service calls and executes them sequentially in a bash script.
Here's an example usage:
```bash
./vagrant/check_patroni.sh http://10.20.30.51:8008
```
## Cluster services ## Cluster services

View file

@ -40,9 +40,10 @@ check_patroni is licensed under PostgreSQL license.
$ pip install git+https://github.com/dalibo/check_patroni.git $ pip install git+https://github.com/dalibo/check_patroni.git
``` ```
Links: check_patroni works on python 3.6, we keep it that way because patroni also
* [pip & centos 7](https://linuxize.com/post/how-to-install-pip-on-centos-7/) supports it and there are still lots of RH 7 variants around. That being said
* [pip & debian10](https://linuxize.com/post/how-to-install-pip-on-debian-10/) python 3.6 has been EOL for age and there is no support for it in the github
CI.
## Support ## Support
@ -96,62 +97,6 @@ Several options are available:
* `--cert_file`: your certificate or the concatenation of your certificate and private key * `--cert_file`: your certificate or the concatenation of your certificate and private key
* `--key_file`: your private key (optional) * `--key_file`: your private key (optional)
## Tests
Crafting repeatable tests using a live Patroni cluster can be intricate. To
simplify the development process, interactions with Patroni's API are
substituted with a mock function that yields an HTTP return code and a JSON
object outlining the cluster's status. The JSON files containing this
information are housed in the ./tests/json directory.
An important consideration is that there is a potential drawback: if the JSON
data is incorrect or if modifications have been made to Patroni without
corresponding updates to the tests documented here, the tests might still pass
erroneously.
To run the tests:
1. Clone the `check_patroni` repository, create a virtual environment, and
install the script:
```bash
git clone https://github.com/dalibo/check_patroni.git
cd check_patroni
python -m venv .venv
. .venv/bin/activate
pip install -e check_patroni[test]
```
2) Run the tests
- Using patroni's nominal replica state of `streaming` (since v3.0.4):
```bash
pytest ./tests
```
- Using patroni's nominal replica state of `running` (before v3.0.4):
```bash
pytest --use-old-replica-state ./tests
```
Please note that when dealing with any service that checks the state of a node
in patroni's `cluster` endpoint, the corresponding JSON test file must be added
in `./test/tools.py`.
A bash script, `check_patroni.sh`, is provided to facilitate testing all
services on a Patroni endpoint (`./vagrant/check_patroni.sh`). It requires one
parameter: the endpoint URL that will be used as the argument for the
`-e/--endpoints` option of `check_patroni`. This script essentially compiles a
list of service calls and executes them sequentially in a bash script.
Here's an example usage:
```bash
./vagrant/check_patroni.sh http://10.20.30.51:8008
```
_EOF_ _EOF_
readme readme
readme "## Cluster services" readme "## Cluster services"