blob: 6f2fb525fa4bbd1db7707a618eac0d2fb321c9ff [file] [log] [blame]
Hanna Arhipova54fec802020-10-30 12:45:46 +02001import pytest
2
3from tcp_tests import logger
4
5LOG = logger.logger
6
Hanna Arhipovad60430e2021-02-12 18:23:47 +02007xtra_network_interface = """
8parameters:
9 _param:
10 linux_network_interfaces:
11 br_ctl:
12 address: ${_param:single_address}
13 enabled: True
14 name_servers:
15 - ${_param:dns_server01}
16 - ${_param:dns_server02}
17 netmask: ${_param:control_network_netmask}
18 proto: static
19 require_interfaces: ['ens4']
20 type: bridge
21 use_interfaces: ['ens4']
22 ens3:
23 enabled: True
24 name: ens3
25 proto: dhcp
26 type: eth
27 ens4:
28 enabled: True
29 ipflush_onchange: True
30 name: ens4
31 proto: manual
32 type: eth
33"""
34
Hanna Arhipovad33353e2021-02-15 23:14:51 +020035add_osd_ceph_init_yml = """
36parameters:
37 _param:
38 ceph_osd_node04_hostname: xtra
39 ceph_osd_node04_address: 10.6.0.205
Hanna Arhipovad33353e2021-02-15 23:14:51 +020040 ceph_osd_system_codename: xenial
41 linux:
42 network:
43 host:
44 xtra:
45 address: ${_param:ceph_osd_node04_address}
46 names:
47 - ${_param:ceph_osd_node04_hostname}
48 - ${_param:ceph_osd_node04_hostname}.${_param:cluster_domain}
49 """
50
51add_osd_config_init_yml = """
52parameters:
53 reclass:
54 storage:
55 node:
56 ceph_osd_node04:
57 name: ${_param:ceph_osd_node04_hostname}
58 domain: ${_param:cluster_domain}
59 classes:
60 - cluster.${_param:cluster_name}.ceph.osd
61 params:
62 salt_master_host: ${_param:reclass_config_master}
63 linux_system_codename: ${_param:ceph_osd_system_codename}
64 single_address: ${_param:ceph_osd_node04_address}
65 ceph_crush_parent: rack02
66"""
67
Hanna Arhipova54fec802020-10-30 12:45:46 +020068
Hanna Arhipovae92b66b2021-04-15 19:56:30 +030069@pytest.fixture(scope='session')
Hanna Arhipovad60430e2021-02-12 18:23:47 +020070def add_xtra_node_to_salt(salt_actions, underlay_actions,
71 config, reclass_actions):
Hanna Arhipova54fec802020-10-30 12:45:46 +020072 """
73
74 :return:
75 """
76 LOG.info("Executing pytest SETUP from add_xtra_node_to_salt fixture")
77 xtra_node = [node['node_name'] for node in config.underlay.ssh
78 if 'xtra' in node.get('node_name')][0]
79
80 cfg_node = [node['node_name'] for node in config.underlay.ssh
81 if 'salt_master' in node.get('roles')][0]
82
Hanna Arhipovae92b66b2021-04-15 19:56:30 +030083 salt_actions.enforce_state("*", "reclass")
84 reclass_actions.add_class(
85 "environment.heat-cicd-queens-dvr-sl.linux_network_interface",
86 short_path="../nodes/_generated/xtra.*.yml")
87 reclass_actions.add_class("environment.heat-cicd-queens-dvr-sl.overrides",
88 short_path="../nodes/_generated/xtra.*.yml")
89 reclass_actions.merge_context(yaml_context=xtra_network_interface,
90 short_path="../nodes/_generated/xtra.*.yml")
91
Hanna Arhipova54fec802020-10-30 12:45:46 +020092 underlay_actions.check_call(
93 "salt-key -a {node} --include-all -y".format(node=xtra_node),
94 node_name=cfg_node,
95 raise_on_err=False)
96 # Need to restart salt-minion service after accepting it in Salt Master
97 underlay_actions.check_call(
98 "systemctl restart salt-minion",
99 node_name=xtra_node,
100 raise_on_err=False)
Hanna Arhipovad60430e2021-02-12 18:23:47 +0200101 salt_actions.enforce_state("I@salt:master", "reclass")
Hanna Arhipovae92b66b2021-04-15 19:56:30 +0300102 salt_actions.enforce_state("xtra*", "linux")
103 salt_actions.enforce_state("xtra*", "openssh")
Hanna Arhipovad60430e2021-02-12 18:23:47 +0200104
Hanna Arhipova54fec802020-10-30 12:45:46 +0200105 yield
106
107 # LOG.info("Executing pytest TEARDOWN from add_xtra_node_to_salt fixture")
108 # underlay_actions.check_call(
109 # "salt-key -r {node} --include-all -y".format(node=node),
110 # node_name=cfg_node,
111 # raise_on_err=False)
112
113
Hanna Arhipovae92b66b2021-04-15 19:56:30 +0300114@pytest.fixture(scope='session')
115def wa_prod36167(reclass_actions):
116 reclass_actions.delete_class("system.salt.control.virt",
117 "classes/cluster/*/infra/kvm.yml")
118
119
Hanna Arhipova54fec802020-10-30 12:45:46 +0200120@pytest.mark.usefixtures("add_xtra_node_to_salt")
121class TestCephOsd(object):
122
123 @pytest.fixture
124 def describe_node_in_reclass(self,
Hanna Arhipovad33353e2021-02-15 23:14:51 +0200125 reclass_actions,
126 salt_actions):
Hanna Arhipova54fec802020-10-30 12:45:46 +0200127 LOG.info("Executing pytest SETUP "
128 "from describe_node_in_reclass fixture")
129 reclass = reclass_actions
130 # ---- cluster/*/ceph/init.yml ---------------
Hanna Arhipovad33353e2021-02-15 23:14:51 +0200131 reclass.merge_context(yaml_context=add_osd_ceph_init_yml,
132 short_path="cluster/*/ceph/init.yml")
Hanna Arhipova54fec802020-10-30 12:45:46 +0200133
134 # ------- cluster/infra/config/init.yml -----------
Hanna Arhipovad33353e2021-02-15 23:14:51 +0200135 reclass.merge_context(yaml_context=add_osd_config_init_yml,
136 short_path="cluster/*/infra/config/init.yml")
Hanna Arhipovad60430e2021-02-12 18:23:47 +0200137 salt_actions.run_state("*", "saltutil.refresh_pillar")
138
139 @pytest.fixture
140 def remove_node_from_reclass(self,
141 reclass_actions):
142 reclass = reclass_actions
143
144 reclass.delete_key(
145 key="parameters.reclass.storage.node.ceph_osd_node04",
146 short_path="cluster/*/infra/config/init.yml"
147 )
148 reclass.delete_key(
149 key="parameters.linux.network.host.xtra",
150 short_path="cluster/*/ceph/init.yml"
151 )
Hanna Arhipova54fec802020-10-30 12:45:46 +0200152
153 def test_add_node_process(self, describe_node_in_reclass,
154 drivetrain_actions):
155 """
156 https://docs.mirantis.com/mcp/q4-18/mcp-operations-guide/openstack-operations/ceph-operations/manage-nodes/add-osd-nodes.html
157 :param describe_node_in_reclass:
158 :param drivetrain_actions:
159 :return:
160 test took about 20 min
161 """
162 dt = drivetrain_actions
PGlazov89ba9182021-02-19 13:36:46 +0400163 # Workaround for PROD-36132
164 job_name = "ceph-add-node"
Hanna Arhipova54fec802020-10-30 12:45:46 +0200165 job_parameters = {
166 'HOST': 'xtra*',
PGlazov89ba9182021-02-19 13:36:46 +0400167 'OSD_ONLY': False
Hanna Arhipova54fec802020-10-30 12:45:46 +0200168 }
Hanna Arhipova508f6532021-01-27 15:52:45 +0200169 job_result, job_description = dt.start_job_on_jenkins(
Hanna Arhipova54fec802020-10-30 12:45:46 +0200170 job_name=job_name,
171 job_parameters=job_parameters,
172 verbose=True)
Hanna Arhipova508f6532021-01-27 15:52:45 +0200173 assert job_result == 'SUCCESS', job_description
Hanna Arhipova54fec802020-10-30 12:45:46 +0200174
175 def test_added_node(self):
176 # root@osd001:~# ceph osd tree in
177 # ID CLASS WEIGHT TYPE NAME STATUS REWEIGHT PRI-AFF
178 # -1 0.18585 root default
179 # -3 0.04646 host osd001
180 # 0 hdd 0.01549 osd.0 up 1.00000 1.00000
181 # 1 hdd 0.01549 osd.1 up 1.00000 1.00000
182 # 2 hdd 0.01549 osd.2 up 1.00000 1.00000
183 # -5 0.04646 host osd002
184 # 3 hdd 0.01549 osd.3 up 1.00000 1.00000
185 # 5 hdd 0.01549 osd.5 up 1.00000 1.00000
186 # 6 hdd 0.01549 osd.6 up 1.00000 1.00000
187 # -7 0.04646 host osd003
188 # 4 hdd 0.01549 osd.4 up 1.00000 1.00000
189 # 7 hdd 0.01549 osd.7 up 1.00000 1.00000
190 # 8 hdd 0.01549 osd.8 up 1.00000 1.00000
191 # -9 0.04646 host xtra
192 # 9 hdd 0.01549 osd.9 up 1.00000 1.00000
193 # 10 hdd 0.01549 osd.10 up 1.00000 1.00000
194 # 11 hdd 0.01549 osd.11 up 1.00000 1.00000
195 pass
196
Hanna Arhipovad60430e2021-02-12 18:23:47 +0200197 def test_delete_node_process(self,
198 remove_node_from_reclass,
199 drivetrain_actions):
Hanna Arhipova54fec802020-10-30 12:45:46 +0200200 dt = drivetrain_actions
201
202 job_name = "ceph-remove-node"
203 job_parameters = {
204 'HOST': 'xtra*',
PGlazov89ba9182021-02-19 13:36:46 +0400205 'OSD': '*'
Hanna Arhipova54fec802020-10-30 12:45:46 +0200206 }
Hanna Arhipova508f6532021-01-27 15:52:45 +0200207 job_result, job_description = dt.start_job_on_jenkins(
Hanna Arhipova54fec802020-10-30 12:45:46 +0200208 job_name=job_name,
209 job_parameters=job_parameters,
210 verbose=True)
Hanna Arhipova508f6532021-01-27 15:52:45 +0200211 assert job_result == 'SUCCESS', job_description
Hanna Arhipova54fec802020-10-30 12:45:46 +0200212
213
Hanna Arhipovad60430e2021-02-12 18:23:47 +0200214add_mon_ceph_init_yml = """
215parameters:
216 _param:
217 ceph_mon_node04_hostname: xtra
218 ceph_mon_node04_address: 10.6.0.205
219 ceph_mon_node04_ceph_public_address: 10.166.49.209
220 ceph_mon_node04_ceph_backup_hour: 4
221 ceph_mon_node04_ceph_backup_minute: 0
222 linux:
223 network:
224 host:
225 xtra:
226 address: ${_param:ceph_mon_node04_address}
227 names:
228 - ${_param:ceph_mon_node04_hostname}
229 - ${_param:ceph_mon_node04_hostname}.${_param:cluster_domain}
230"""
Hanna Arhipova54fec802020-10-30 12:45:46 +0200231
Hanna Arhipovad60430e2021-02-12 18:23:47 +0200232add_mon_ceph_common_yml = """
233parameters:
234 ceph:
235 common:
236 members:
237 - name: ${_param:ceph_mon_node04_hostname}
238 host: ${_param:ceph_mon_node04_address}
239"""
240
241add_mon_config_node_yml = """
242parameters:
243 reclass:
244 storage:
245 node:
246 ceph_mon_node04:
247 name: ${_param:ceph_mon_node04_hostname}
248 domain: ${_param:cluster_domain}
249 classes:
250 - cluster.${_param:cluster_name}.ceph.mon
251 params:
252 ceph_public_address: ${_param:ceph_mon_node04_ceph_public_address}
253 ceph_backup_time_hour: ${_param:ceph_mon_node04_ceph_backup_hour}
254 ceph_backup_time_minute: ${_param:ceph_mon_node04_ceph_backup_minute}
255 salt_master_host: ${_param:reclass_config_master}
256 linux_system_codename: ${_param:ceph_mon_system_codename}
257 single_address: ${_param:ceph_mon_node04_address}
258 keepalived_vip_priority: 104
259""" # noqa: E501
260
261add_mon_infra_kvm_yml = """
262parameters:
263 salt:
264 control:
265 size:
266 ceph.mon:
267 cpu: 8
268 ram: 16384
269 disk_profile: small
270 net_profile: default
271 cluster:
272 internal:
273 node:
274 cmn04:
275 name: ${_param:ceph_mon_node04_hostname}
276 provider: ${_param:infra_kvm_node03_hostname}.${_param:cluster_domain}
277 image: ${_param:salt_control_xenial_image}
278 size: ceph.mon
279""" # noqa: E501
280
281
282@pytest.mark.usefixtures("add_xtra_node_to_salt")
283class TestCephMon(object):
284 @pytest.fixture
285 def describe_node_in_reclass(self,
286 reclass_actions, salt_actions):
287 LOG.info("Executing pytest SETUP "
288 "from describe_node_in_reclass fixture")
289 reclass = reclass_actions
290 # ---- cluster/*/ceph/init.yml --------------
291 reclass.merge_context(yaml_context=add_mon_ceph_init_yml,
292 short_path="cluster/*/ceph/init.yml")
293
294 # ------- cluster/infra/config/init.yml -----------
295 reclass.merge_context(yaml_context=add_mon_ceph_common_yml,
296 short_path="cluster/*/ceph/common.yml")
297 reclass.merge_context(yaml_context=add_mon_config_node_yml,
298 short_path="cluster/*/infra/config/nodes.yml")
299
300 # ------- define settings for new mon node in KVM cluster -----------
301 reclass.merge_context(yaml_context=add_mon_infra_kvm_yml,
302 short_path="cluster/*/infra/kvm.yml")
303
304 salt_actions.run_state("*", "saltutil.refresh_pillar")
305
306 @pytest.fixture
307 def remove_node_from_reclass(self,
308 reclass_actions, salt_actions):
309 LOG.info("Executing pytest SETUP "
310 "from remove_node_from_reclass fixture")
311 reclass = reclass_actions
312 reclass.delete_key(
313 key="parameters.reclass.storage.node.ceph_mon_node04",
314 short_path="cluster/*/infra/config/init.yml")
315 reclass.delete_key(
316 key="parameters.salt.control.cluster.internal.node.cmn04",
317 short_path="cluster/*/infra/kvm.yml"
318 )
319 reclass.delete_key(
320 key="parameters.linux.network.host.xtra",
321 short_path="cluster/*/ceph/init.yml"
322 )
323
324 def test_add_node_process(self,
325 drivetrain_actions,
326 describe_node_in_reclass):
Hanna Arhipovae92b66b2021-04-15 19:56:30 +0300327 """
328 https://docs.mirantis.com/mcp/q4-18/mcp-operations-guide/openstack-operations/ceph-operations/manage-nodes/add-mon-nodes.html
329 :param drivetrain_actions:
330 :param describe_node_in_reclass:
331 :return:
332 """
Hanna Arhipovad60430e2021-02-12 18:23:47 +0200333 dt = drivetrain_actions
334
335 job_name = "ceph-add-node"
336 job_parameters = {
337 'HOST': 'xtra*',
338 'USE_UPMAP': True
339 }
340 job_result, job_description = dt.start_job_on_jenkins(
341 job_name=job_name,
342 job_parameters=job_parameters,
343 verbose=True)
344 assert job_result == 'SUCCESS', job_description
345
346 def test_delete_node_process(self,
347 remove_node_from_reclass,
348 drivetrain_actions):
349 dt = drivetrain_actions
350
351 job_name = "ceph-remove-node"
352 job_parameters = {
353 'HOST': 'xtra*',
354 'USE_UPMAP': True
355 }
356 job_result, job_description = dt.start_job_on_jenkins(
357 job_name=job_name,
358 job_parameters=job_parameters,
359 verbose=True)
360 assert job_result == 'SUCCESS', job_description
Hanna Arhipova54fec802020-10-30 12:45:46 +0200361
362
Hanna Arhipovae92b66b2021-04-15 19:56:30 +0300363add_rgw_ceph_init_yml = """
364parameters:
365 _param:
366 ceph_rgw_node04_hostname: xtra
367 ceph_rgw_node04_address: 10.6.0.205
368 ceph_rgw_node04_ceph_public_address: 10.166.49.209
369 linux:
370 network:
371 host:
372 rgw04:
373 address: ${_param:ceph_rgw_node04_address}
374 names:
375 - ${_param:ceph_rgw_node04_hostname}
376 - ${_param:ceph_rgw_node04_hostname}.${_param:cluster_domain}
377""" # noqa: E501
378
379add_rgw_ceph_rgw_yml = """
380parameters:
381 _param:
382 cluster_node04_hostname: ${_param:ceph_rgw_node04_hostname}
383 cluster_node04_address: ${_param:ceph_rgw_node04_address}
384 ceph:
385 common:
386 keyring:
387 rgw.xtra:
388 caps:
389 mon: "allow rw"
390 osd: "allow rwx"
391 haproxy:
392 proxy:
393 listen:
394 radosgw:
395 servers:
396 - name: ${_param:cluster_node04_hostname}
397 host: ${_param:cluster_node04_address}
398 port: ${_param:haproxy_radosgw_source_port}
399 params: check
400"""
401
402add_rgw_config_init_yml = """
403parameters:
404 reclass:
405 storage:
406 node:
407 ceph_rgw_node04:
408 name: ${_param:ceph_rgw_node04_hostname}
409 domain: ${_param:cluster_domain}
410 classes:
411 - cluster.${_param:cluster_name}.ceph.rgw
412 params:
413 salt_master_host: ${_param:reclass_config_master}
414 linux_system_codename: ${_param:ceph_rgw_system_codename}
415 single_address: ${_param:ceph_rgw_node04_address}
416 deploy_address: ${_param:ceph_rgw_node04_deploy_address}
417 ceph_public_address: ${_param:ceph_rgw_node04_public_address}
418 keepalived_vip_priority: 104
419"""
420
421
422@pytest.mark.usefixtures("add_xtra_node_to_salt")
423class TestCephRgw(object):
424 @pytest.fixture
425 def describe_node_in_reclass(self,
426 reclass_actions, salt_actions):
427 LOG.info("Executing pytest SETUP "
428 "from describe_node_in_reclass fixture")
429 reclass = reclass_actions
430 # ---- cluster/*/ceph/init.yml --------------
431 reclass.merge_context(yaml_context=add_rgw_ceph_init_yml,
432 short_path="cluster/*/ceph/init.yml")
433
434 reclass.merge_context(yaml_context=add_rgw_ceph_rgw_yml,
435 short_path="cluster/*/ceph/rgw.yml")
436
437 reclass.merge_context(yaml_context=add_rgw_config_init_yml,
438 short_path="cluster/*/infra/config/init.yml")
439
440 salt_actions.run_state("*", "saltutil.refresh_pillar")
441
442 @pytest.fixture
443 def remove_node_from_reclass(self,
444 reclass_actions, salt_actions):
445 LOG.info("Executing pytest SETUP "
446 "from remove_node_from_reclass fixture")
447 # reclass = reclass_actions
448 # reclass.delete_key(
449 # key="parameters.reclass.storage.node.ceph_rgw_node04",
450 # short_path="cluster/*/infra/config/init.yml")
451 # reclass.delete_key(
452 # key="parameters.linux.network.host.xtra",
453 # short_path="cluster/*/ceph/init.yml"
454 # )
455
456 def test_add_node_process(self,
457 drivetrain_actions,
458 describe_node_in_reclass):
459 """
460 https://docs.mirantis.com/mcp/q4-18/mcp-operations-guide/openstack-operations/ceph-operations/manage-nodes/add-rgw-nodes.html
461 :param drivetrain_actions:
462 :param describe_node_in_reclass:
463 :return:
464 """
465 dt = drivetrain_actions
466
467 job_name = "ceph-add-node"
468 job_parameters = {
469 'HOST': 'xtra*',
470 'USE_UPMAP': True
471 }
472 job_result, job_description = dt.start_job_on_jenkins(
473 job_name=job_name,
474 job_parameters=job_parameters,
475 verbose=True)
476 assert job_result == 'SUCCESS', job_description
477
478 def test_delete_node_process(self,
479 remove_node_from_reclass,
480 drivetrain_actions):
481 dt = drivetrain_actions
482
483 job_name = "ceph-remove-node"
484 job_parameters = {
485 'HOST': 'xtra*',
486 'USE_UPMAP': True
487 }
488 job_result, job_description = dt.start_job_on_jenkins(
489 job_name=job_name,
490 job_parameters=job_parameters,
491 verbose=True)
492 assert job_result == 'SUCCESS', job_description
493
494
495@pytest.mark.usefixtures("add_xtra_node_to_salt")
Hanna Arhipova54fec802020-10-30 12:45:46 +0200496class TestCephMgr(object):
497 def test_add_node(self):
498 pass
499
500 def test_delete_node(self):
501 pass