Hanna Arhipova | 54fec80 | 2020-10-30 12:45:46 +0200 | [diff] [blame] | 1 | import pytest |
| 2 | |
| 3 | from tcp_tests import logger |
| 4 | |
| 5 | LOG = logger.logger |
| 6 | |
Hanna Arhipova | d33353e | 2021-02-15 23:14:51 +0200 | [diff] [blame] | 7 | add_osd_ceph_init_yml = """ |
| 8 | parameters: |
| 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 | |
| 24 | add_osd_config_init_yml = """ |
| 25 | parameters: |
| 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 Arhipova | 54fec80 | 2020-10-30 12:45:46 +0200 | [diff] [blame] | 41 | |
| 42 | @pytest.fixture(scope='module') |
| 43 | def 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") |
| 74 | class TestCephOsd(object): |
| 75 | |
| 76 | @pytest.fixture |
| 77 | def describe_node_in_reclass(self, |
Hanna Arhipova | d33353e | 2021-02-15 23:14:51 +0200 | [diff] [blame] | 78 | reclass_actions, |
| 79 | salt_actions): |
Hanna Arhipova | 54fec80 | 2020-10-30 12:45:46 +0200 | [diff] [blame] | 80 | LOG.info("Executing pytest SETUP " |
| 81 | "from describe_node_in_reclass fixture") |
| 82 | reclass = reclass_actions |
| 83 | # ---- cluster/*/ceph/init.yml --------------- |
Hanna Arhipova | d33353e | 2021-02-15 23:14:51 +0200 | [diff] [blame] | 84 | reclass.merge_context(yaml_context=add_osd_ceph_init_yml, |
| 85 | short_path="cluster/*/ceph/init.yml") |
Hanna Arhipova | 54fec80 | 2020-10-30 12:45:46 +0200 | [diff] [blame] | 86 | |
| 87 | # ------- cluster/infra/config/init.yml ----------- |
Hanna Arhipova | d33353e | 2021-02-15 23:14:51 +0200 | [diff] [blame] | 88 | reclass.merge_context(yaml_context=add_osd_config_init_yml, |
| 89 | short_path="cluster/*/infra/config/init.yml") |
Hanna Arhipova | 54fec80 | 2020-10-30 12:45:46 +0200 | [diff] [blame] | 90 | |
| 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 |
PGlazov | 89ba918 | 2021-02-19 13:36:46 +0400 | [diff] [blame] | 101 | # Workaround for PROD-36132 |
| 102 | job_name = "ceph-add-node" |
Hanna Arhipova | 54fec80 | 2020-10-30 12:45:46 +0200 | [diff] [blame] | 103 | job_parameters = { |
| 104 | 'HOST': 'xtra*', |
PGlazov | 89ba918 | 2021-02-19 13:36:46 +0400 | [diff] [blame] | 105 | 'OSD_ONLY': False |
Hanna Arhipova | 54fec80 | 2020-10-30 12:45:46 +0200 | [diff] [blame] | 106 | } |
Hanna Arhipova | 508f653 | 2021-01-27 15:52:45 +0200 | [diff] [blame] | 107 | job_result, job_description = dt.start_job_on_jenkins( |
Hanna Arhipova | 54fec80 | 2020-10-30 12:45:46 +0200 | [diff] [blame] | 108 | job_name=job_name, |
| 109 | job_parameters=job_parameters, |
| 110 | verbose=True) |
Hanna Arhipova | 508f653 | 2021-01-27 15:52:45 +0200 | [diff] [blame] | 111 | assert job_result == 'SUCCESS', job_description |
Hanna Arhipova | 54fec80 | 2020-10-30 12:45:46 +0200 | [diff] [blame] | 112 | |
| 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*', |
PGlazov | 89ba918 | 2021-02-19 13:36:46 +0400 | [diff] [blame] | 141 | 'OSD': '*' |
Hanna Arhipova | 54fec80 | 2020-10-30 12:45:46 +0200 | [diff] [blame] | 142 | } |
Hanna Arhipova | 508f653 | 2021-01-27 15:52:45 +0200 | [diff] [blame] | 143 | job_result, job_description = dt.start_job_on_jenkins( |
Hanna Arhipova | 54fec80 | 2020-10-30 12:45:46 +0200 | [diff] [blame] | 144 | job_name=job_name, |
| 145 | job_parameters=job_parameters, |
| 146 | verbose=True) |
Hanna Arhipova | 508f653 | 2021-01-27 15:52:45 +0200 | [diff] [blame] | 147 | assert job_result == 'SUCCESS', job_description |
Hanna Arhipova | 54fec80 | 2020-10-30 12:45:46 +0200 | [diff] [blame] | 148 | |
| 149 | |
| 150 | class TestCephMon(object): |
| 151 | def test_add_node(self): |
| 152 | pass |
| 153 | |
| 154 | def test_delete_node(self): |
| 155 | pass |
| 156 | |
| 157 | |
| 158 | class TestCephMgr(object): |
| 159 | def test_add_node(self): |
| 160 | pass |
| 161 | |
| 162 | def test_delete_node(self): |
| 163 | pass |