1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# Disable autopep8 for this file:
# fmt: off
import pytest
from cephadm.autotune import MemoryAutotuner
from orchestrator import DaemonDescription
@pytest.mark.parametrize("total,daemons,config,result",
[ # noqa: E128
(
128 * 1024 * 1024 * 1024,
[],
{},
None,
),
(
128 * 1024 * 1024 * 1024,
[
DaemonDescription('osd', '1', 'host1'),
DaemonDescription('osd', '2', 'host1'),
],
{},
64 * 1024 * 1024 * 1024,
),
(
128 * 1024 * 1024 * 1024,
[
DaemonDescription('osd', '1', 'host1'),
DaemonDescription('osd', '2', 'host1'),
DaemonDescription('osd', '3', 'host1'),
],
{
'osd.3': 16 * 1024 * 1024 * 1024,
},
56 * 1024 * 1024 * 1024,
),
(
128 * 1024 * 1024 * 1024,
[
DaemonDescription('mgr', 'a', 'host1'),
DaemonDescription('osd', '1', 'host1'),
DaemonDescription('osd', '2', 'host1'),
],
{},
62 * 1024 * 1024 * 1024,
)
])
def test_autotune(total, daemons, config, result):
def fake_getter(who, opt):
if opt == 'osd_memory_target_autotune':
if who in config:
return False
else:
return True
if opt == 'osd_memory_target':
return config.get(who, 4 * 1024 * 1024 * 1024)
if opt == 'mds_cache_memory_limit':
return 16 * 1024 * 1024 * 1024
a = MemoryAutotuner(
total_mem=total,
daemons=daemons,
config_get=fake_getter,
)
val, osds = a.tune()
assert val == result
|