blob: 44ae0146cfd3e63ac57bc3480a26aa2e04389881 [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",
Hanna Arhipova3ea92b22021-07-01 15:44:15 +0300117 "cluster/*/infra/kvm.yml")
Hanna Arhipovae92b66b2021-04-15 19:56:30 +0300118
119
PGlazovf9d5d232021-07-02 12:34:18 +0400120@pytest.mark.usefixtures("add_xtra_node_to_salt",
121 "wa_prod36167")
Hanna Arhipova54fec802020-10-30 12:45:46 +0200122class TestCephOsd(object):
123
124 @pytest.fixture
125 def describe_node_in_reclass(self,
Hanna Arhipovad33353e2021-02-15 23:14:51 +0200126 reclass_actions,
127 salt_actions):
Hanna Arhipova54fec802020-10-30 12:45:46 +0200128 LOG.info("Executing pytest SETUP "
129 "from describe_node_in_reclass fixture")
130 reclass = reclass_actions
131 # ---- cluster/*/ceph/init.yml ---------------
Hanna Arhipovad33353e2021-02-15 23:14:51 +0200132 reclass.merge_context(yaml_context=add_osd_ceph_init_yml,
133 short_path="cluster/*/ceph/init.yml")
Hanna Arhipova54fec802020-10-30 12:45:46 +0200134
135 # ------- cluster/infra/config/init.yml -----------
Hanna Arhipovad33353e2021-02-15 23:14:51 +0200136 reclass.merge_context(yaml_context=add_osd_config_init_yml,
137 short_path="cluster/*/infra/config/init.yml")
Hanna Arhipovad60430e2021-02-12 18:23:47 +0200138 salt_actions.run_state("*", "saltutil.refresh_pillar")
139
140 @pytest.fixture
141 def remove_node_from_reclass(self,
142 reclass_actions):
143 reclass = reclass_actions
144
145 reclass.delete_key(
146 key="parameters.reclass.storage.node.ceph_osd_node04",
147 short_path="cluster/*/infra/config/init.yml"
148 )
149 reclass.delete_key(
150 key="parameters.linux.network.host.xtra",
151 short_path="cluster/*/ceph/init.yml"
152 )
Hanna Arhipova54fec802020-10-30 12:45:46 +0200153
154 def test_add_node_process(self, describe_node_in_reclass,
155 drivetrain_actions):
156 """
157 https://docs.mirantis.com/mcp/q4-18/mcp-operations-guide/openstack-operations/ceph-operations/manage-nodes/add-osd-nodes.html
158 :param describe_node_in_reclass:
159 :param drivetrain_actions:
160 :return:
161 test took about 20 min
162 """
163 dt = drivetrain_actions
PGlazov89ba9182021-02-19 13:36:46 +0400164 # Workaround for PROD-36132
165 job_name = "ceph-add-node"
Hanna Arhipova54fec802020-10-30 12:45:46 +0200166 job_parameters = {
167 'HOST': 'xtra*',
PGlazov89ba9182021-02-19 13:36:46 +0400168 'OSD_ONLY': False
Hanna Arhipova54fec802020-10-30 12:45:46 +0200169 }
Hanna Arhipova508f6532021-01-27 15:52:45 +0200170 job_result, job_description = dt.start_job_on_jenkins(
Hanna Arhipova54fec802020-10-30 12:45:46 +0200171 job_name=job_name,
172 job_parameters=job_parameters,
173 verbose=True)
Hanna Arhipova508f6532021-01-27 15:52:45 +0200174 assert job_result == 'SUCCESS', job_description
Hanna Arhipova54fec802020-10-30 12:45:46 +0200175
176 def test_added_node(self):
177 # root@osd001:~# ceph osd tree in
178 # ID CLASS WEIGHT TYPE NAME STATUS REWEIGHT PRI-AFF
179 # -1 0.18585 root default
180 # -3 0.04646 host osd001
181 # 0 hdd 0.01549 osd.0 up 1.00000 1.00000
182 # 1 hdd 0.01549 osd.1 up 1.00000 1.00000
183 # 2 hdd 0.01549 osd.2 up 1.00000 1.00000
184 # -5 0.04646 host osd002
185 # 3 hdd 0.01549 osd.3 up 1.00000 1.00000
186 # 5 hdd 0.01549 osd.5 up 1.00000 1.00000
187 # 6 hdd 0.01549 osd.6 up 1.00000 1.00000
188 # -7 0.04646 host osd003
189 # 4 hdd 0.01549 osd.4 up 1.00000 1.00000
190 # 7 hdd 0.01549 osd.7 up 1.00000 1.00000
191 # 8 hdd 0.01549 osd.8 up 1.00000 1.00000
192 # -9 0.04646 host xtra
193 # 9 hdd 0.01549 osd.9 up 1.00000 1.00000
194 # 10 hdd 0.01549 osd.10 up 1.00000 1.00000
195 # 11 hdd 0.01549 osd.11 up 1.00000 1.00000
196 pass
197
Hanna Arhipovad60430e2021-02-12 18:23:47 +0200198 def test_delete_node_process(self,
199 remove_node_from_reclass,
200 drivetrain_actions):
Hanna Arhipova54fec802020-10-30 12:45:46 +0200201 dt = drivetrain_actions
202
203 job_name = "ceph-remove-node"
204 job_parameters = {
205 'HOST': 'xtra*',
PGlazov89ba9182021-02-19 13:36:46 +0400206 'OSD': '*'
Hanna Arhipova54fec802020-10-30 12:45:46 +0200207 }
Hanna Arhipova508f6532021-01-27 15:52:45 +0200208 job_result, job_description = dt.start_job_on_jenkins(
Hanna Arhipova54fec802020-10-30 12:45:46 +0200209 job_name=job_name,
210 job_parameters=job_parameters,
211 verbose=True)
Hanna Arhipova508f6532021-01-27 15:52:45 +0200212 assert job_result == 'SUCCESS', job_description
Hanna Arhipova54fec802020-10-30 12:45:46 +0200213
214
Hanna Arhipovad60430e2021-02-12 18:23:47 +0200215add_mon_ceph_init_yml = """
216parameters:
217 _param:
218 ceph_mon_node04_hostname: xtra
219 ceph_mon_node04_address: 10.6.0.205
220 ceph_mon_node04_ceph_public_address: 10.166.49.209
221 ceph_mon_node04_ceph_backup_hour: 4
222 ceph_mon_node04_ceph_backup_minute: 0
223 linux:
224 network:
225 host:
226 xtra:
227 address: ${_param:ceph_mon_node04_address}
228 names:
229 - ${_param:ceph_mon_node04_hostname}
230 - ${_param:ceph_mon_node04_hostname}.${_param:cluster_domain}
231"""
Hanna Arhipova54fec802020-10-30 12:45:46 +0200232
Hanna Arhipovad60430e2021-02-12 18:23:47 +0200233add_mon_ceph_common_yml = """
234parameters:
235 ceph:
236 common:
237 members:
238 - name: ${_param:ceph_mon_node04_hostname}
239 host: ${_param:ceph_mon_node04_address}
240"""
241
242add_mon_config_node_yml = """
243parameters:
244 reclass:
245 storage:
246 node:
247 ceph_mon_node04:
248 name: ${_param:ceph_mon_node04_hostname}
249 domain: ${_param:cluster_domain}
250 classes:
251 - cluster.${_param:cluster_name}.ceph.mon
252 params:
253 ceph_public_address: ${_param:ceph_mon_node04_ceph_public_address}
254 ceph_backup_time_hour: ${_param:ceph_mon_node04_ceph_backup_hour}
255 ceph_backup_time_minute: ${_param:ceph_mon_node04_ceph_backup_minute}
256 salt_master_host: ${_param:reclass_config_master}
257 linux_system_codename: ${_param:ceph_mon_system_codename}
258 single_address: ${_param:ceph_mon_node04_address}
259 keepalived_vip_priority: 104
260""" # noqa: E501
261
262add_mon_infra_kvm_yml = """
263parameters:
264 salt:
265 control:
266 size:
267 ceph.mon:
268 cpu: 8
269 ram: 16384
270 disk_profile: small
271 net_profile: default
272 cluster:
273 internal:
274 node:
275 cmn04:
276 name: ${_param:ceph_mon_node04_hostname}
277 provider: ${_param:infra_kvm_node03_hostname}.${_param:cluster_domain}
278 image: ${_param:salt_control_xenial_image}
279 size: ceph.mon
280""" # noqa: E501
281
282
PGlazovf9d5d232021-07-02 12:34:18 +0400283@pytest.mark.usefixtures("add_xtra_node_to_salt",
284 "wa_prod36167")
Hanna Arhipovad60430e2021-02-12 18:23:47 +0200285class TestCephMon(object):
286 @pytest.fixture
287 def describe_node_in_reclass(self,
288 reclass_actions, salt_actions):
289 LOG.info("Executing pytest SETUP "
290 "from describe_node_in_reclass fixture")
291 reclass = reclass_actions
292 # ---- cluster/*/ceph/init.yml --------------
293 reclass.merge_context(yaml_context=add_mon_ceph_init_yml,
294 short_path="cluster/*/ceph/init.yml")
295
296 # ------- cluster/infra/config/init.yml -----------
297 reclass.merge_context(yaml_context=add_mon_ceph_common_yml,
298 short_path="cluster/*/ceph/common.yml")
299 reclass.merge_context(yaml_context=add_mon_config_node_yml,
300 short_path="cluster/*/infra/config/nodes.yml")
301
302 # ------- define settings for new mon node in KVM cluster -----------
303 reclass.merge_context(yaml_context=add_mon_infra_kvm_yml,
304 short_path="cluster/*/infra/kvm.yml")
305
306 salt_actions.run_state("*", "saltutil.refresh_pillar")
307
308 @pytest.fixture
309 def remove_node_from_reclass(self,
310 reclass_actions, salt_actions):
311 LOG.info("Executing pytest SETUP "
312 "from remove_node_from_reclass fixture")
313 reclass = reclass_actions
314 reclass.delete_key(
315 key="parameters.reclass.storage.node.ceph_mon_node04",
316 short_path="cluster/*/infra/config/init.yml")
317 reclass.delete_key(
318 key="parameters.salt.control.cluster.internal.node.cmn04",
319 short_path="cluster/*/infra/kvm.yml"
320 )
321 reclass.delete_key(
322 key="parameters.linux.network.host.xtra",
323 short_path="cluster/*/ceph/init.yml"
324 )
325
326 def test_add_node_process(self,
327 drivetrain_actions,
328 describe_node_in_reclass):
Hanna Arhipovae92b66b2021-04-15 19:56:30 +0300329 """
330 https://docs.mirantis.com/mcp/q4-18/mcp-operations-guide/openstack-operations/ceph-operations/manage-nodes/add-mon-nodes.html
331 :param drivetrain_actions:
332 :param describe_node_in_reclass:
333 :return:
334 """
Hanna Arhipovad60430e2021-02-12 18:23:47 +0200335 dt = drivetrain_actions
336
337 job_name = "ceph-add-node"
338 job_parameters = {
339 'HOST': 'xtra*',
340 'USE_UPMAP': True
341 }
342 job_result, job_description = dt.start_job_on_jenkins(
343 job_name=job_name,
344 job_parameters=job_parameters,
345 verbose=True)
346 assert job_result == 'SUCCESS', job_description
347
348 def test_delete_node_process(self,
349 remove_node_from_reclass,
350 drivetrain_actions):
351 dt = drivetrain_actions
352
353 job_name = "ceph-remove-node"
354 job_parameters = {
355 'HOST': 'xtra*',
356 'USE_UPMAP': True
357 }
358 job_result, job_description = dt.start_job_on_jenkins(
359 job_name=job_name,
360 job_parameters=job_parameters,
361 verbose=True)
362 assert job_result == 'SUCCESS', job_description
Hanna Arhipova54fec802020-10-30 12:45:46 +0200363
364
Hanna Arhipovae92b66b2021-04-15 19:56:30 +0300365add_rgw_ceph_init_yml = """
366parameters:
367 _param:
368 ceph_rgw_node04_hostname: xtra
369 ceph_rgw_node04_address: 10.6.0.205
370 ceph_rgw_node04_ceph_public_address: 10.166.49.209
371 linux:
372 network:
373 host:
374 rgw04:
375 address: ${_param:ceph_rgw_node04_address}
376 names:
377 - ${_param:ceph_rgw_node04_hostname}
378 - ${_param:ceph_rgw_node04_hostname}.${_param:cluster_domain}
379""" # noqa: E501
380
381add_rgw_ceph_rgw_yml = """
382parameters:
383 _param:
384 cluster_node04_hostname: ${_param:ceph_rgw_node04_hostname}
385 cluster_node04_address: ${_param:ceph_rgw_node04_address}
386 ceph:
387 common:
388 keyring:
389 rgw.xtra:
390 caps:
391 mon: "allow rw"
392 osd: "allow rwx"
393 haproxy:
394 proxy:
395 listen:
396 radosgw:
397 servers:
398 - name: ${_param:cluster_node04_hostname}
399 host: ${_param:cluster_node04_address}
400 port: ${_param:haproxy_radosgw_source_port}
401 params: check
402"""
403
404add_rgw_config_init_yml = """
405parameters:
406 reclass:
407 storage:
408 node:
409 ceph_rgw_node04:
410 name: ${_param:ceph_rgw_node04_hostname}
411 domain: ${_param:cluster_domain}
412 classes:
413 - cluster.${_param:cluster_name}.ceph.rgw
414 params:
415 salt_master_host: ${_param:reclass_config_master}
416 linux_system_codename: ${_param:ceph_rgw_system_codename}
417 single_address: ${_param:ceph_rgw_node04_address}
418 deploy_address: ${_param:ceph_rgw_node04_deploy_address}
419 ceph_public_address: ${_param:ceph_rgw_node04_public_address}
420 keepalived_vip_priority: 104
421"""
422
423
PGlazovf9d5d232021-07-02 12:34:18 +0400424@pytest.mark.usefixtures("add_xtra_node_to_salt",
425 "wa_prod36167")
Hanna Arhipovae92b66b2021-04-15 19:56:30 +0300426class TestCephRgw(object):
427 @pytest.fixture
428 def describe_node_in_reclass(self,
429 reclass_actions, salt_actions):
430 LOG.info("Executing pytest SETUP "
431 "from describe_node_in_reclass fixture")
432 reclass = reclass_actions
433 # ---- cluster/*/ceph/init.yml --------------
434 reclass.merge_context(yaml_context=add_rgw_ceph_init_yml,
435 short_path="cluster/*/ceph/init.yml")
436
437 reclass.merge_context(yaml_context=add_rgw_ceph_rgw_yml,
438 short_path="cluster/*/ceph/rgw.yml")
439
440 reclass.merge_context(yaml_context=add_rgw_config_init_yml,
441 short_path="cluster/*/infra/config/init.yml")
442
443 salt_actions.run_state("*", "saltutil.refresh_pillar")
444
445 @pytest.fixture
446 def remove_node_from_reclass(self,
447 reclass_actions, salt_actions):
448 LOG.info("Executing pytest SETUP "
449 "from remove_node_from_reclass fixture")
450 # reclass = reclass_actions
451 # reclass.delete_key(
452 # key="parameters.reclass.storage.node.ceph_rgw_node04",
453 # short_path="cluster/*/infra/config/init.yml")
454 # reclass.delete_key(
455 # key="parameters.linux.network.host.xtra",
456 # short_path="cluster/*/ceph/init.yml"
457 # )
458
459 def test_add_node_process(self,
460 drivetrain_actions,
461 describe_node_in_reclass):
462 """
463 https://docs.mirantis.com/mcp/q4-18/mcp-operations-guide/openstack-operations/ceph-operations/manage-nodes/add-rgw-nodes.html
464 :param drivetrain_actions:
465 :param describe_node_in_reclass:
466 :return:
467 """
468 dt = drivetrain_actions
469
470 job_name = "ceph-add-node"
471 job_parameters = {
472 'HOST': 'xtra*',
473 'USE_UPMAP': True
474 }
475 job_result, job_description = dt.start_job_on_jenkins(
476 job_name=job_name,
477 job_parameters=job_parameters,
478 verbose=True)
479 assert job_result == 'SUCCESS', job_description
480
481 def test_delete_node_process(self,
482 remove_node_from_reclass,
483 drivetrain_actions):
484 dt = drivetrain_actions
485
486 job_name = "ceph-remove-node"
487 job_parameters = {
488 'HOST': 'xtra*',
489 'USE_UPMAP': True
490 }
491 job_result, job_description = dt.start_job_on_jenkins(
492 job_name=job_name,
493 job_parameters=job_parameters,
494 verbose=True)
495 assert job_result == 'SUCCESS', job_description
496
497
PGlazovf9d5d232021-07-02 12:34:18 +0400498@pytest.mark.usefixtures("add_xtra_node_to_salt",
499 "wa_prod36167")
Hanna Arhipova54fec802020-10-30 12:45:46 +0200500class TestCephMgr(object):
501 def test_add_node(self):
502 pass
503
504 def test_delete_node(self):
505 pass