blob: 62af49d0fe01b9eb155390b829c968a650b9c39f [file] [log] [blame]
Oleksii Zhurbae592ed12018-06-21 18:01:09 -05001import pytest
2
3
4def test_ceph_replicas(local_salt_client):
5 """
6 Test aimed to check number of replicas
7 for most of deployments if there is no
8 special requirement for that.
9 """
10
11 ceph_monitors = local_salt_client.cmd(
12 'ceph:mon',
13 'test.ping',
14 expr_form='pillar')
15
16 if not ceph_monitors:
17 pytest.skip("Ceph is not found on this environment")
18
19 monitor = ceph_monitors.keys()[0]
20
21 raw_pool_replicas = local_salt_client.cmd(
22 monitor,
23 'cmd.run',
24 ["ceph osd dump | grep size | " \
25 "awk '{print $3, $5, $6, $7, $8}'"],
26 expr_form='glob').get(
27 ceph_monitors.keys()[0]).split('\n')
28
29 pools_replicas = {}
30 for pool in raw_pool_replicas:
31 pool_name = pool.split(" ", 1)[0]
32 pool_replicas = {}
33 raw_replicas = pool.split(" ", 1)[1].split()
34 for elem in raw_replicas:
35 pool_replicas[raw_replicas[0]] = int(raw_replicas[1])
36 pool_replicas[raw_replicas[2]] = int(raw_replicas[3])
37 pools_replicas[pool_name] = pool_replicas
38
39 error = []
40 for pool, replicas in pools_replicas.items():
41 for replica, value in replicas.items():
42 if replica == 'min_size' and value < 2:
43 error.append(pool + " " + replica + " "
44 + str(value) + " must be 2")
45 if replica == 'size' and value < 3:
46 error.append(pool + " " + replica + " "
47 + str(value) + " must be 3")
48
49 assert not error, "Wrong pool replicas found\n{}".format(error)