blob: bc5dc0cc59651a9752d5f037bd1630debacbe0e8 [file] [log] [blame]
Hanna Arhipova54fec802020-10-30 12:45:46 +02001import pytest
2
3from tcp_tests import logger
4
5LOG = logger.logger
6
Hanna Arhipovad33353e2021-02-15 23:14:51 +02007add_osd_ceph_init_yml = """
8parameters:
9 _param:
10 ceph_osd_node04_hostname: xtra
11 ceph_osd_node04_address: 10.6.0.205
12 ceph_mon_node04_ceph_public_address: #10.166.49.205
13 ceph_osd_system_codename: xenial
14 linux:
15 network:
16 host:
17 xtra:
18 address: ${_param:ceph_osd_node04_address}
19 names:
20 - ${_param:ceph_osd_node04_hostname}
21 - ${_param:ceph_osd_node04_hostname}.${_param:cluster_domain}
22 """
23
24add_osd_config_init_yml = """
25parameters:
26 reclass:
27 storage:
28 node:
29 ceph_osd_node04:
30 name: ${_param:ceph_osd_node04_hostname}
31 domain: ${_param:cluster_domain}
32 classes:
33 - cluster.${_param:cluster_name}.ceph.osd
34 params:
35 salt_master_host: ${_param:reclass_config_master}
36 linux_system_codename: ${_param:ceph_osd_system_codename}
37 single_address: ${_param:ceph_osd_node04_address}
38 ceph_crush_parent: rack02
39"""
40
Hanna Arhipova54fec802020-10-30 12:45:46 +020041
42@pytest.fixture(scope='module')
43def add_xtra_node_to_salt(salt_actions, underlay_actions, config):
44 """
45
46 :return:
47 """
48 LOG.info("Executing pytest SETUP from add_xtra_node_to_salt fixture")
49 xtra_node = [node['node_name'] for node in config.underlay.ssh
50 if 'xtra' in node.get('node_name')][0]
51
52 cfg_node = [node['node_name'] for node in config.underlay.ssh
53 if 'salt_master' in node.get('roles')][0]
54
55 underlay_actions.check_call(
56 "salt-key -a {node} --include-all -y".format(node=xtra_node),
57 node_name=cfg_node,
58 raise_on_err=False)
59 # Need to restart salt-minion service after accepting it in Salt Master
60 underlay_actions.check_call(
61 "systemctl restart salt-minion",
62 node_name=xtra_node,
63 raise_on_err=False)
64 yield
65
66 # LOG.info("Executing pytest TEARDOWN from add_xtra_node_to_salt fixture")
67 # underlay_actions.check_call(
68 # "salt-key -r {node} --include-all -y".format(node=node),
69 # node_name=cfg_node,
70 # raise_on_err=False)
71
72
73@pytest.mark.usefixtures("add_xtra_node_to_salt")
74class TestCephOsd(object):
75
76 @pytest.fixture
77 def describe_node_in_reclass(self,
Hanna Arhipovad33353e2021-02-15 23:14:51 +020078 reclass_actions,
79 salt_actions):
Hanna Arhipova54fec802020-10-30 12:45:46 +020080 LOG.info("Executing pytest SETUP "
81 "from describe_node_in_reclass fixture")
82 reclass = reclass_actions
83 # ---- cluster/*/ceph/init.yml ---------------
Hanna Arhipovad33353e2021-02-15 23:14:51 +020084 reclass.merge_context(yaml_context=add_osd_ceph_init_yml,
85 short_path="cluster/*/ceph/init.yml")
Hanna Arhipova54fec802020-10-30 12:45:46 +020086
87 # ------- cluster/infra/config/init.yml -----------
Hanna Arhipovad33353e2021-02-15 23:14:51 +020088 reclass.merge_context(yaml_context=add_osd_config_init_yml,
89 short_path="cluster/*/infra/config/init.yml")
Hanna Arhipova54fec802020-10-30 12:45:46 +020090
91 def test_add_node_process(self, describe_node_in_reclass,
92 drivetrain_actions):
93 """
94 https://docs.mirantis.com/mcp/q4-18/mcp-operations-guide/openstack-operations/ceph-operations/manage-nodes/add-osd-nodes.html
95 :param describe_node_in_reclass:
96 :param drivetrain_actions:
97 :return:
98 test took about 20 min
99 """
100 dt = drivetrain_actions
PGlazov89ba9182021-02-19 13:36:46 +0400101 # Workaround for PROD-36132
102 job_name = "ceph-add-node"
Hanna Arhipova54fec802020-10-30 12:45:46 +0200103 job_parameters = {
104 'HOST': 'xtra*',
PGlazov89ba9182021-02-19 13:36:46 +0400105 'OSD_ONLY': False
Hanna Arhipova54fec802020-10-30 12:45:46 +0200106 }
Hanna Arhipova508f6532021-01-27 15:52:45 +0200107 job_result, job_description = dt.start_job_on_jenkins(
Hanna Arhipova54fec802020-10-30 12:45:46 +0200108 job_name=job_name,
109 job_parameters=job_parameters,
110 verbose=True)
Hanna Arhipova508f6532021-01-27 15:52:45 +0200111 assert job_result == 'SUCCESS', job_description
Hanna Arhipova54fec802020-10-30 12:45:46 +0200112
113 def test_added_node(self):
114 # root@osd001:~# ceph osd tree in
115 # ID CLASS WEIGHT TYPE NAME STATUS REWEIGHT PRI-AFF
116 # -1 0.18585 root default
117 # -3 0.04646 host osd001
118 # 0 hdd 0.01549 osd.0 up 1.00000 1.00000
119 # 1 hdd 0.01549 osd.1 up 1.00000 1.00000
120 # 2 hdd 0.01549 osd.2 up 1.00000 1.00000
121 # -5 0.04646 host osd002
122 # 3 hdd 0.01549 osd.3 up 1.00000 1.00000
123 # 5 hdd 0.01549 osd.5 up 1.00000 1.00000
124 # 6 hdd 0.01549 osd.6 up 1.00000 1.00000
125 # -7 0.04646 host osd003
126 # 4 hdd 0.01549 osd.4 up 1.00000 1.00000
127 # 7 hdd 0.01549 osd.7 up 1.00000 1.00000
128 # 8 hdd 0.01549 osd.8 up 1.00000 1.00000
129 # -9 0.04646 host xtra
130 # 9 hdd 0.01549 osd.9 up 1.00000 1.00000
131 # 10 hdd 0.01549 osd.10 up 1.00000 1.00000
132 # 11 hdd 0.01549 osd.11 up 1.00000 1.00000
133 pass
134
135 def test_delete_node_process(self, drivetrain_actions):
136 dt = drivetrain_actions
137
138 job_name = "ceph-remove-node"
139 job_parameters = {
140 'HOST': 'xtra*',
PGlazov89ba9182021-02-19 13:36:46 +0400141 'OSD': '*'
Hanna Arhipova54fec802020-10-30 12:45:46 +0200142 }
Hanna Arhipova508f6532021-01-27 15:52:45 +0200143 job_result, job_description = dt.start_job_on_jenkins(
Hanna Arhipova54fec802020-10-30 12:45:46 +0200144 job_name=job_name,
145 job_parameters=job_parameters,
146 verbose=True)
Hanna Arhipova508f6532021-01-27 15:52:45 +0200147 assert job_result == 'SUCCESS', job_description
Hanna Arhipova54fec802020-10-30 12:45:46 +0200148
149
150class TestCephMon(object):
151 def test_add_node(self):
152 pass
153
154 def test_delete_node(self):
155 pass
156
157
158class TestCephMgr(object):
159 def test_add_node(self):
160 pass
161
162 def test_delete_node(self):
163 pass