mirror of
https://github.com/ansible-collections/hetzner.hcloud.git
synced 2026-02-04 08:01:49 +00:00
feat: compute load balancer targets status using a filter (#550)
##### SUMMARY Allow to compute the status of a load balancer using a filter. Closes #467 ##### ISSUE TYPE - Feature Pull Request ##### COMPONENT NAME hetzner.hcloud.loab_balancer_status
This commit is contained in:
parent
a85bd39738
commit
fce8bc9bb9
10 changed files with 199 additions and 10 deletions
45
tests/unit/filter/test_all.py
Normal file
45
tests/unit/filter/test_all.py
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
from plugins.filter.all import load_balancer_status
|
||||
|
||||
LOAD_BALANCER_STATUS_TEST_CASES = (
|
||||
({"targets": [{"health_status": []}]}, "unknown"),
|
||||
({"targets": [{"health_status": [{}]}]}, "unknown"),
|
||||
({"targets": [{"health_status": [{"status": "unknown"}]}]}, "unknown"),
|
||||
({"targets": [{"health_status": [{"status": "unhealthy"}]}]}, "unhealthy"),
|
||||
({"targets": [{"health_status": [{"status": "healthy"}]}]}, "healthy"),
|
||||
(
|
||||
{
|
||||
"targets": [
|
||||
{"health_status": [{"status": "healthy"}]},
|
||||
{"health_status": [{"status": "healthy"}]},
|
||||
]
|
||||
},
|
||||
"healthy",
|
||||
),
|
||||
(
|
||||
{
|
||||
"targets": [
|
||||
{"health_status": [{"status": "healthy"}, {"status": "unhealthy"}]},
|
||||
{"health_status": [{"status": "healthy"}, {"status": "unknown"}]},
|
||||
]
|
||||
},
|
||||
"unhealthy",
|
||||
),
|
||||
(
|
||||
{
|
||||
"targets": [
|
||||
{"health_status": [{"status": "healthy"}]},
|
||||
{"health_status": [{"status": "unhealthy"}]},
|
||||
]
|
||||
},
|
||||
"unhealthy",
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(("value", "expected"), LOAD_BALANCER_STATUS_TEST_CASES)
|
||||
def test_load_balancer_status(value, expected):
|
||||
assert expected == load_balancer_status(value)
|
||||
Loading…
Add table
Add a link
Reference in a new issue