Commit graph

118 commits

Author SHA1 Message Date
Denis Laxalde ea92809cb3 Introduce a 'runner' test fixture
Instead of defining the CliRunner value in each test, we use a fixture.
The CliRunner is also configured with stdout and stderr separated
because mixing them will pose problem if we use stderr for other
purposes in tests, e.g. to emit log messages from a forth-coming HTTP
server.
2023-10-03 09:54:13 +02:00
Denis Laxalde d34e597e61 Use the tmp_path fixture instead of writing files to tests/ 2023-10-03 09:54:13 +02:00
Denis Laxalde bc2d2917c3 Introduce a fake_restapi test fixture
This fixture itself uses the 'use_old_replica_state' fixture, so that
it's no longer needed to use it explicitly in test functions.
2023-10-03 09:54:13 +02:00
Denis Laxalde c3cdb8cdd4 Set a default value to status parameter of my_mock in tests
Most of the times, it's 200, so the default value simplifies usage in
actual tests.
2023-10-03 09:54:13 +02:00
Denis Laxalde 123c300911 Add type hints in tests/conftest.py 2023-10-03 09:54:13 +02:00
Denis Laxalde a0189ebba7 Fix some typos spotted by codespell 2.2.6 2023-10-03 09:53:53 +02:00
Denis Laxalde 95f21a133d Drop superfluous type annotation of 'self'
See https://mypy.readthedocs.io/en/stable/cheat_sheet_py3.html#classes
> For instance methods, omit type for "self"
2023-10-03 09:39:40 +02:00
benoit de8b3daa7a Update tox.ini to run codespell on the documentation 2023-08-30 10:19:18 +02:00
benoit 82e0af8a9e Update README CONTRIBUTING RELEASE
* README: add information pertaining to shell completion;
* CONTRIBUTING: remove release information;
* RELEASE: create a dedicated file with all the relevant release
  information.
2023-08-30 10:19:18 +02:00
benoit 68b230ccb2 Release 1.0.0 2023-08-28 12:09:16 +02:00
benoit f0c2a243f0 Moving things around in README.md and CONTRIBUTING.md 2023-08-28 11:59:59 +02:00
benoit ee3837fab1 Add info and options about sync standby to cluster_has_replica
* Add `--sync-warning` and `--sync-critical`
* Add `sync_replica` to track the number of sync replica in the perf data
* Add `MEMBER-sync` to track if a member is a sync replica in the perf data
2023-08-24 17:34:08 +02:00
benoit b9fbdfdefd fix vagrant/check_patroni.sh 2023-08-24 17:30:39 +02:00
benoit fd801efa38 Revert_d39122d (move packaging to pyproject.toml)
This changes requiered python 3.7 which I overlooked at first. I would
like to be able to install the check any patroni server and Patroni
supports python 3.6.
2023-08-24 16:23:55 +02:00
benoit b69c2501fd Revert commit 20d9d48
For `node_is_alive`, it seemed to be a good idea to exit with a
`CRITICAL` when the target doesn't exist. But for all the rest, UNKNOWN
(which corresponds to a configuration error) seems better.
2023-08-23 18:35:06 +02:00
benoit 94a1388d06 Update changelog for cluster_has_scheduled_action 2023-08-23 18:35:06 +02:00
benoit 259f04587b Add a node_is_leader service to check for the leader states
It's possible to check for any kind of leader of specifically for a
standby leader.
2023-08-23 18:22:49 +02:00
benoit 8883d6bdc4 Add standby-leader as a valid leader type for cluster_has_leader 2023-08-23 18:22:49 +02:00
benoit 22bf7df3ea CHANGELOG update for node_is_replica 2023-08-23 16:05:02 +02:00
benoit 20d9d48d78 Fix the liveness check in node_is_alive
Previously if a node wasn't reachable whe would get an UNKNOWN error.
instead of a CRITICAL error.

```
NODEISALIVE UNKNOWN - Connection failed for all provided endpoints
```

We now get the correct error.

```
NODEISALIVE CRITICAL - This node is not alive (patroni is not running). | is_alive=0;;@0
```
2023-08-23 16:05:02 +02:00
benoit 46dd431775 Fix test for node_is_primary 2023-08-23 15:41:15 +02:00
benoit 2bcddf9f87 Add a --is-sync and --is-async to node_is_replica 2023-08-23 15:41:15 +02:00
benoit 99bf1c5bb5 Add new service cluster_has_scheduled_action 2023-08-23 12:08:19 +02:00
benoit 7f6a03a3cc README 2023-08-23 10:53:09 +02:00
benoit e66e49b111 Update CHANGELOG 2023-08-23 10:53:09 +02:00
benoit d99faeba15 Add tests for the output of the script and support pre/post 3.0.4
* Change all replica status from `running` to `streaming`
* Add an option to pytest to change the state back to `running`
* Also tests the output of the script
* Add a quick test script for live clusters
2023-08-23 10:53:09 +02:00
benoit 4a6ae03458 Remove setuptools-scm as suggeted by @dlax 2023-08-22 11:18:27 +02:00
benoit 2c49d4a97c Add CHANGELOG.md 2023-08-22 11:18:27 +02:00
benoit d39122dd07 Move packaging metadata into pyproject.toml 2023-08-22 11:18:27 +02:00
benoit bb68d937e6 Fix a mistake in the vvv output of ClusterConfigHasChanged 2023-08-22 11:15:44 +02:00
benoit d07a26d324 Fix tests in a more pytonic way as proposed by @dlax 2023-08-21 15:13:22 +02:00
benoit 77722f40c1 Fix liveness check
The liveness probe used to return something. It looks like it doesn't do
it anymore and it breaks the `node_is_alive` check.

Issue: #31
2023-08-21 15:13:22 +02:00
benoit a01a535680 Add sync_standby as an acceptable state for a replica 2023-08-21 13:11:08 +02:00
benoit 021b572e53 Redefining cluster_node_count using Patroni 3.0.4's new status indicators
Previously, replica nodes were labeled with a `running` state. As a
result, our checks were based on nodes marked as `running` through
the `--running-[warning|critical]` options.

However, with the recent changes in Patroni 3.0.4, replica nodes now
carry a `streaming` state. This shift in terminology calls for an
adjustment in our approach. A new state, `healthy_member`, has been
introduced to encompass both `running` and `streaming` nodes.

Key Modifications:

* The existing `--running-[warning|critical]` option is now designated
  as `--healthy-[warning|critical]`.
* Introduction of the `healthy_member` perfdata, which serves as the
  reference point for the aforementioned options.
* Updates to documentation, help messages, and tests.
2023-08-21 11:59:55 +02:00
benoit 2f250e846e State change in patroni 3.0.4
Since patroni 3.0.4, standby node nominal state is "streaming" instead
of "running". Some services need to be changed to account for that.

Reported in issue #28
2023-08-21 11:59:55 +02:00
benoit e9f197b9d9 Release 0.2.0 2023-03-20 15:11:03 +01:00
benoit 7eb65ae903 Add python 3.11 to the tests and reduce version coverage
* Add python 3.11 to the test environnements
* Use only the oldest and latest versions for github workfkows
2023-03-20 15:04:37 +01:00
benoit df744bf7dc Use isort to automatically sort imports 2023-03-20 14:56:11 +01:00
benoit 050f9c6247 Fix code tag in README 2023-03-20 12:54:48 +01:00
benoit dff95eae2f Fixing logging issues in the previous modifications 2023-03-20 12:25:32 +01:00
benoit 7eea4c94be Reorganise for the urllib3 > requests change 2023-03-20 12:25:32 +01:00
benoit 2443505ad6 Change logging
We now use our own logger.
When debug is set (-vvv), we also display urllib3's debug info.
2023-03-20 12:25:32 +01:00
benoit 7256c1894a Fix tests for the urllib3 to requests change 2023-03-20 12:25:32 +01:00
benoit 7815f3379c Reverse the test for node_is_pending
Since the desired state is for there to be no restart pending state, it
makes more sense to modify the service logic so that the return code
reflects this. As a result, the test for the service `node_is_pending`
has been reversed.
2023-03-20 12:25:32 +01:00
benoit 9cd80f5af8 Move from urllib3 to requests 2023-03-20 12:25:32 +01:00
benoit 0800fc72e9 Add more info on states and roles for cluster_node_count 2023-03-10 10:16:01 +01:00
benoit 6f45618e08 Update node_is_alive to metion that it's an liveness check. 2023-03-10 10:16:01 +01:00
benoit 7286638121 -e/endpoints spec update
* it is now possible to specify a comma separated list of endpoints
* the documentation as been updated to explain that:
  + for node services if several addresses are specified they should
    point to different interfaces on the same server.
  + for cluster services several addresses should be used because we
    want the cluster status so the more API we try the better our chance
    of having a reply.
2023-03-10 10:16:01 +01:00
benoit 48d2656ec7 Update check_patroni's description to mention Patroni's API 2023-03-10 10:16:01 +01:00
benoit 93b196fb77 Fix a format string for cluster_config_has_changed 2023-03-02 17:32:18 +01:00