]> git.proxmox.com Git - ceph.git/blame - ceph/src/pybind/mgr/pg_autoscaler/tests/test_autoscaler.py
use the buster suite for getting the source package for now
[ceph.git] / ceph / src / pybind / mgr / pg_autoscaler / tests / test_autoscaler.py
CommitLineData
9f95a23c
TL
1from pg_autoscaler import effective_target_ratio
2from pytest import approx
3
4def check_simple_ratio(target_ratio, tot_ratio):
5 etr = effective_target_ratio(target_ratio, tot_ratio, 0, 0)
6 assert (target_ratio / tot_ratio) == approx(etr)
7 return etr
8
9def test_simple():
10 etr1 = check_simple_ratio(0.2, 0.9)
11 etr2 = check_simple_ratio(2, 9)
12 etr3 = check_simple_ratio(20, 90)
13 assert etr1 == approx(etr2)
14 assert etr1 == approx(etr3)
15
16 etr = check_simple_ratio(0.9, 0.9)
17 assert etr == approx(1.0)
18 etr1 = check_simple_ratio(1, 2)
19 etr2 = check_simple_ratio(0.5, 1.0)
20 assert etr1 == approx(etr2)
21
22def test_total_bytes():
23 etr = effective_target_ratio(1, 10, 5, 10)
24 assert etr == approx(0.05)
25 etr = effective_target_ratio(0.1, 1, 5, 10)
26 assert etr == approx(0.05)
27 etr = effective_target_ratio(1, 1, 5, 10)
28 assert etr == approx(0.5)
29 etr = effective_target_ratio(1, 1, 0, 10)
30 assert etr == approx(1.0)
31 etr = effective_target_ratio(0, 1, 5, 10)
32 assert etr == approx(0.0)
33 etr = effective_target_ratio(1, 1, 10, 10)
34 assert etr == approx(0.0)