Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 1 | import pytest |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 2 | import sys |
| 3 | import os |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 4 | |
| 5 | from tcp_tests import logger |
| 6 | from tcp_tests import settings |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 7 | |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 8 | sys.path.append(os.getcwd()) |
| 9 | try: |
| 10 | from tcp_tests.fixtures import config_fixtures |
| 11 | from tcp_tests.managers import underlay_ssh_manager |
| 12 | from tcp_tests.managers import saltmanager as salt_manager |
| 13 | except ImportError: |
| 14 | print("ImportError: Run the application from the tcp-qa directory or " |
| 15 | "set the PYTHONPATH environment variable to directory which contains" |
| 16 | " ./tcp_tests") |
| 17 | sys.exit(1) |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 18 | LOG = logger.logger |
| 19 | |
| 20 | |
Hanna Arhipova | d35a29b | 2019-09-04 13:24:06 +0300 | [diff] [blame] | 21 | def has_only_similar(values_by_nodes): |
| 22 | """ |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 23 | :param values_by_nodes: dict |
Hanna Arhipova | d35a29b | 2019-09-04 13:24:06 +0300 | [diff] [blame] | 24 | :return: bool, True if all items in the dict have similar values |
| 25 | """ |
| 26 | values = list(values_by_nodes.values()) |
| 27 | return all(value == values[0] for value in values) |
| 28 | |
| 29 | |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 30 | def get_control_plane_targets(): |
| 31 | config = config_fixtures.config() |
| 32 | underlay = underlay_ssh_manager.UnderlaySSHManager(config) |
| 33 | saltmanager = salt_manager.SaltManager(config, underlay) |
Hanna Arhipova | fbcea85 | 2019-10-03 13:24:53 +0300 | [diff] [blame] | 34 | targets = list() |
| 35 | try: |
| 36 | targets += saltmanager.run_state( |
| 37 | "I@keystone:server", 'test.ping')[0]['return'][0].keys() |
| 38 | targets += saltmanager.run_state( |
| 39 | "I@nginx:server and not I@salt:master", |
| 40 | "test.ping")[0]['return'][0].keys() |
| 41 | except BaseException as err: |
| 42 | LOG.warning("Can't retrieve data from Salt. \ |
| 43 | Maybe cluster is not deployed completely.\ |
| 44 | Err: {}".format(err)) |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 45 | |
| 46 | # TODO: add check for Manila existence |
| 47 | # # Commented to avoid fails during OpenStack updates. |
| 48 | # # Anyway we don't have deployments with Manila yet |
| 49 | # targets.append('share*') |
| 50 | # TODO: add check for Tenant Telemetry existence |
| 51 | targets.append('mdb*') |
| 52 | # TODO: add check for Barbican existence |
| 53 | targets.append('kmn*') |
| 54 | return targets |
| 55 | |
| 56 | |
Hanna Arhipova | 1942996 | 2019-10-17 15:16:49 +0300 | [diff] [blame^] | 57 | @pytest.fixture(scope='class') |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 58 | def switch_to_proposed_pipelines(reclass_actions, salt_actions): |
Hanna Arhipova | 1942996 | 2019-10-17 15:16:49 +0300 | [diff] [blame^] | 59 | reclass = reclass_actions |
| 60 | proposed_repo = "http://mirror.mirantis.com/update/proposed/" |
| 61 | repo_param = "parameters._param.linux_system_repo_update_url" |
Hanna Arhipova | 7cfeb07 | 2019-10-11 15:04:10 +0300 | [diff] [blame] | 62 | |
Hanna Arhipova | 1942996 | 2019-10-17 15:16:49 +0300 | [diff] [blame^] | 63 | proposed_pipeline_branch = "release/proposed/2019.2.0" |
| 64 | pipeline_branch_param = "parameters._param.jenkins_pipelines_branch" |
| 65 | infra_yml = "cluster/*/infra/init.yml" |
| 66 | |
| 67 | LOG.info("Check reclass has release/proposed/2019.2.0 branches") |
| 68 | if reclass.get_key(pipeline_branch_param, |
| 69 | infra_yml) == proposed_pipeline_branch \ |
| 70 | and reclass.get_key(repo_param, infra_yml) == proposed_repo: |
| 71 | return True |
| 72 | |
| 73 | LOG.info("Switch to release/proposed/2019.2.0 branches") |
| 74 | reclass.add_key(pipeline_branch_param, proposed_pipeline_branch, infra_yml) |
| 75 | |
| 76 | reclass.add_key(repo_param, proposed_repo, infra_yml) |
| 77 | reclass.add_key(repo_param, proposed_repo, "cluster/*/openstack/init.yml") |
| 78 | reclass.add_key(repo_param, proposed_repo, "cluster/*/stacklight/init.yml") |
| 79 | reclass.add_key(repo_param, proposed_repo, "cluster/*/ceph/init.yml") |
Hanna Arhipova | 7cfeb07 | 2019-10-11 15:04:10 +0300 | [diff] [blame] | 80 | |
| 81 | salt_actions.run_state("*", "saltutil.refresh_pillar") |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 82 | salt_actions.enforce_state("I@jenkins:client", "jenkins.client") |
| 83 | |
| 84 | |
Hanna Arhipova | 1942996 | 2019-10-17 15:16:49 +0300 | [diff] [blame^] | 85 | @pytest.fixture(scope='class') |
| 86 | def enable_openstack_update(reclass_actions, salt_actions): |
| 87 | param = "parameters._param.openstack_upgrade_enabled" |
| 88 | context_file = "cluster/*/infra/init.yml" |
| 89 | |
| 90 | LOG.info("Enable openstack_upgrade_enabled in reclass") |
| 91 | reclass_actions.add_bool_key(param, "True", context_file) |
| 92 | salt_actions.run_state("*", "saltutil.refresh_pillar") |
| 93 | yield True |
| 94 | LOG.info("Disable openstack_upgrade_enabled in reclass") |
| 95 | reclass_actions.add_bool_key(param, "False", context_file) |
| 96 | salt_actions.run_state("*", "saltutil.refresh_pillar") |
| 97 | |
| 98 | |
| 99 | @pytest.mark.usefixtures("switch_to_proposed_pipelines") |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 100 | class TestUpdateMcpCluster(object): |
| 101 | """ |
| 102 | Following the steps in |
Hanna Arhipova | 94a8abe | 2019-08-22 14:11:46 +0300 | [diff] [blame] | 103 | https://docs.mirantis.com/mcp/master/mcp-operations-guide/update-upgrade/minor-update.html#minor-update |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 104 | """ |
| 105 | |
| 106 | @pytest.mark.grab_versions |
| 107 | @pytest.mark.parametrize("_", [settings.ENV_NAME]) |
| 108 | @pytest.mark.run_mcp_update |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 109 | def test_update_drivetrain(self, salt_actions, drivetrain_actions, |
Hanna Arhipova | 1942996 | 2019-10-17 15:16:49 +0300 | [diff] [blame^] | 110 | show_step, _): |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 111 | """Updating DriveTrain component to release/proposed/2019.2.0 version |
| 112 | |
| 113 | Scenario: |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 114 | 1. Add workaround for PROD-32751 |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 115 | 2. Run job git-mirror-downstream-mk-pipelines |
| 116 | 3. Run job git-mirror-downstream-pipeline-library |
| 117 | 4. If jobs are passed then start 'Deploy - upgrade MCP Drivetrain' |
| 118 | |
Hanna Arhipova | d35a29b | 2019-09-04 13:24:06 +0300 | [diff] [blame] | 119 | Duration: ~70 min |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 120 | """ |
| 121 | salt = salt_actions |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 122 | dt = drivetrain_actions |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 123 | |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 124 | # #################### Add workaround for PROD-32751 ################# |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 125 | show_step(1) |
| 126 | |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 127 | # FIXME: workaround for PROD-32751 |
| 128 | salt.cmd_run("cfg01*", "cd /srv/salt/reclass; git add -u && \ |
| 129 | git commit --allow-empty -m 'Cluster model update'") |
| 130 | |
| 131 | # ################### Downstream mk-pipelines ######################### |
| 132 | show_step(2) |
| 133 | job_name = 'git-mirror-downstream-mk-pipelines' |
| 134 | job_parameters = { |
| 135 | 'BRANCHES': 'release/proposed/2019.2.0' |
| 136 | } |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 137 | update_pipelines = dt.start_job_on_cid_jenkins( |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 138 | job_name=job_name, |
| 139 | job_parameters=job_parameters) |
| 140 | |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 141 | assert update_pipelines == 'SUCCESS' |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 142 | |
| 143 | # ################### Downstream pipeline-library #################### |
| 144 | show_step(3) |
| 145 | job_name = 'git-mirror-downstream-pipeline-library' |
| 146 | job_parameters = { |
| 147 | 'BRANCHES': 'release/proposed/2019.2.0' |
| 148 | } |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 149 | update_pipeline_library = dt.start_job_on_cid_jenkins( |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 150 | job_name=job_name, |
| 151 | job_parameters=job_parameters) |
| 152 | |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 153 | assert update_pipeline_library == 'SUCCESS' |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 154 | |
| 155 | # ################### Start 'Deploy - upgrade MCP Drivetrain' job ##### |
| 156 | show_step(4) |
| 157 | |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 158 | job_name = 'upgrade-mcp-release' |
| 159 | job_parameters = { |
Hanna Arhipova | d35a29b | 2019-09-04 13:24:06 +0300 | [diff] [blame] | 160 | 'GIT_REFSPEC': 'release/proposed/2019.2.0', |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 161 | 'MK_PIPELINES_REFSPEC': 'release/proposed/2019.2.0', |
| 162 | 'TARGET_MCP_VERSION': '2019.2.0' |
| 163 | } |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 164 | update_drivetrain = dt.start_job_on_cid_jenkins( |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 165 | job_name=job_name, |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 166 | job_parameters=job_parameters, |
Hanna Arhipova | 1942996 | 2019-10-17 15:16:49 +0300 | [diff] [blame^] | 167 | build_timeout=90 * 60) |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 168 | |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 169 | assert update_drivetrain == 'SUCCESS' |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 170 | |
Hanna Arhipova | 94a8abe | 2019-08-22 14:11:46 +0300 | [diff] [blame] | 171 | @pytest.mark.grab_versions |
| 172 | @pytest.mark.parametrize("_", [settings.ENV_NAME]) |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 173 | @pytest.mark.run_mcp_update |
Hanna Arhipova | cc3759b | 2019-08-28 16:01:11 +0300 | [diff] [blame] | 174 | def test_update_glusterfs(self, salt_actions, reclass_actions, |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 175 | drivetrain_actions, show_step, _): |
Hanna Arhipova | cc3759b | 2019-08-28 16:01:11 +0300 | [diff] [blame] | 176 | """ Upgrade GlusterFS |
| 177 | Scenario: |
| 178 | 1. In infra/init.yml in Reclass, add the glusterfs_version parameter |
| 179 | 2. Start linux.system.repo state |
| 180 | 3. Start "update-glusterfs" job |
| 181 | 4. Check version for GlusterFS servers |
| 182 | 5. Check version for GlusterFS clients |
| 183 | |
| 184 | """ |
| 185 | salt = salt_actions |
| 186 | reclass = reclass_actions |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 187 | dt = drivetrain_actions |
Hanna Arhipova | cc3759b | 2019-08-28 16:01:11 +0300 | [diff] [blame] | 188 | |
Hanna Arhipova | cc3759b | 2019-08-28 16:01:11 +0300 | [diff] [blame] | 189 | # ############## Change reclass ###################################### |
| 190 | show_step(1) |
| 191 | reclass.add_key( |
| 192 | "parameters._param.linux_system_repo_mcp_glusterfs_version_number", |
| 193 | "5", |
| 194 | "cluster/*/infra/init.yml" |
| 195 | ) |
| 196 | # ################# Run linux.system state ########################### |
| 197 | show_step(2) |
| 198 | salt.enforce_state("*", "linux.system.repo") |
| 199 | |
| 200 | # ############## Start deploy-upgrade-galera job ##################### |
| 201 | show_step(3) |
Hanna Arhipova | cc3759b | 2019-08-28 16:01:11 +0300 | [diff] [blame] | 202 | job_name = 'update-glusterfs' |
| 203 | |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 204 | update_glusterfs = dt.start_job_on_cid_jenkins( |
Hanna Arhipova | cc3759b | 2019-08-28 16:01:11 +0300 | [diff] [blame] | 205 | job_name=job_name, |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 206 | build_timeout=40 * 60) |
Hanna Arhipova | cc3759b | 2019-08-28 16:01:11 +0300 | [diff] [blame] | 207 | |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 208 | assert update_glusterfs == 'SUCCESS' |
Hanna Arhipova | cc3759b | 2019-08-28 16:01:11 +0300 | [diff] [blame] | 209 | |
| 210 | # ################ Check GlusterFS version for servers ############## |
| 211 | show_step(4) |
| 212 | gluster_server_versions_by_nodes = salt.cmd_run( |
| 213 | "I@glusterfs:server", |
| 214 | "glusterd --version|head -n1")[0] |
| 215 | |
Hanna Arhipova | 1942996 | 2019-10-17 15:16:49 +0300 | [diff] [blame^] | 216 | assert has_only_similar(gluster_server_versions_by_nodes), \ |
Hanna Arhipova | cc3759b | 2019-08-28 16:01:11 +0300 | [diff] [blame] | 217 | gluster_server_versions_by_nodes |
| 218 | |
| 219 | # ################ Check GlusterFS version for clients ############## |
| 220 | show_step(5) |
| 221 | gluster_client_versions_by_nodes = salt.cmd_run( |
| 222 | "I@glusterfs:client", |
| 223 | "glusterfs --version|head -n1")[0] |
| 224 | |
| 225 | assert has_only_similar(gluster_client_versions_by_nodes), \ |
| 226 | gluster_client_versions_by_nodes |
| 227 | |
| 228 | @pytest.mark.grab_versions |
| 229 | @pytest.mark.parametrize("_", [settings.ENV_NAME]) |
| 230 | @pytest.mark.run_mcp_update |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 231 | def test_update_galera(self, salt_actions, reclass_actions, |
| 232 | drivetrain_actions, show_step, _): |
Hanna Arhipova | 94a8abe | 2019-08-22 14:11:46 +0300 | [diff] [blame] | 233 | """ Upgrade Galera automatically |
| 234 | |
| 235 | Scenario: |
| 236 | 1. Include the Galera upgrade pipeline job to DriveTrain |
| 237 | 2. Apply the jenkins.client state on the Jenkins nodes |
| 238 | 3. set the openstack_upgrade_enabled parameter to true |
| 239 | 4. Refresh pillars |
| 240 | 5. Add repositories with new Galera packages |
| 241 | 6. Start job from Jenkins |
| 242 | """ |
| 243 | salt = salt_actions |
| 244 | reclass = reclass_actions |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 245 | dt = drivetrain_actions |
Hanna Arhipova | 94a8abe | 2019-08-22 14:11:46 +0300 | [diff] [blame] | 246 | # ################### Enable pipeline ################################# |
| 247 | show_step(1) |
| 248 | reclass.add_class( |
| 249 | "system.jenkins.client.job.deploy.update.upgrade_galera", |
| 250 | "cluster/*/cicd/control/leader.yml") |
| 251 | show_step(2) |
| 252 | salt.enforce_state("I@jenkins:client", "jenkins.client") |
| 253 | |
| 254 | # ############### Enable automatic upgrade ############################ |
| 255 | show_step(3) |
| 256 | reclass.add_bool_key("parameters._param.openstack_upgrade_enabled", |
| 257 | "True", |
| 258 | "cluster/*/infra/init.yml") |
| 259 | |
| 260 | show_step(4) |
Hanna Arhipova | 7cfeb07 | 2019-10-11 15:04:10 +0300 | [diff] [blame] | 261 | salt.run_state("dbs*", "saltutil.refresh_pillar") |
Hanna Arhipova | 94a8abe | 2019-08-22 14:11:46 +0300 | [diff] [blame] | 262 | |
| 263 | # ############# Add repositories with new Galera packages ####### |
| 264 | show_step(5) |
| 265 | salt.enforce_state("dbs*", "linux.system.repo") |
| 266 | salt.enforce_state("cfg*", "salt.master") |
| 267 | |
Hanna Arhipova | 94a8abe | 2019-08-22 14:11:46 +0300 | [diff] [blame] | 268 | # #################### Login Jenkins on cid01 node ################### |
| 269 | show_step(6) |
| 270 | |
Hanna Arhipova | 94a8abe | 2019-08-22 14:11:46 +0300 | [diff] [blame] | 271 | job_name = 'deploy-upgrade-galera' |
| 272 | job_parameters = { |
| 273 | 'INTERACTIVE': 'false' |
| 274 | } |
| 275 | |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 276 | update_galera = dt.start_job_on_cid_jenkins( |
Hanna Arhipova | 94a8abe | 2019-08-22 14:11:46 +0300 | [diff] [blame] | 277 | job_name=job_name, |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 278 | job_parameters=job_parameters, |
| 279 | build_timeout=40 * 60) |
Hanna Arhipova | 94a8abe | 2019-08-22 14:11:46 +0300 | [diff] [blame] | 280 | |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 281 | assert update_galera == 'SUCCESS' |
Hanna Arhipova | 1fcaf44 | 2019-09-06 15:30:45 +0300 | [diff] [blame] | 282 | |
| 283 | @pytest.fixture |
| 284 | def disable_automatic_failover_neutron_for_test(self, salt_actions): |
| 285 | """ |
| 286 | On each OpenStack controller node, modify the neutron.conf file |
| 287 | Restart the neutron-server service |
| 288 | """ |
Hanna Arhipova | 1942996 | 2019-10-17 15:16:49 +0300 | [diff] [blame^] | 289 | |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 290 | def comment_line(node, file_name, word): |
Hanna Arhipova | 1fcaf44 | 2019-09-06 15:30:45 +0300 | [diff] [blame] | 291 | """ |
| 292 | Adds '#' before the specific line in specific file |
| 293 | |
| 294 | :param node: string, salt target of node where the file locates |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 295 | :param file_name: string, full path to the file |
Hanna Arhipova | 1fcaf44 | 2019-09-06 15:30:45 +0300 | [diff] [blame] | 296 | :param word: string, the begin of line which should be commented |
| 297 | :return: None |
| 298 | """ |
| 299 | salt_actions.cmd_run(node, |
| 300 | "sed -i 's/^{word}/#{word}/' {file}". |
| 301 | format(word=word, |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 302 | file=file_name)) |
Hanna Arhipova | 1fcaf44 | 2019-09-06 15:30:45 +0300 | [diff] [blame] | 303 | |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 304 | def add_line(node, file_name, line): |
Hanna Arhipova | 1fcaf44 | 2019-09-06 15:30:45 +0300 | [diff] [blame] | 305 | """ |
| 306 | Appends line to the end of file |
| 307 | |
| 308 | :param node: string, salt target of node where the file locates |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 309 | :param file_name: string, full path to the file |
Hanna Arhipova | 1fcaf44 | 2019-09-06 15:30:45 +0300 | [diff] [blame] | 310 | :param line: string, line that should be added |
| 311 | :return: None |
| 312 | """ |
| 313 | salt_actions.cmd_run(node, "echo {line} >> {file}".format( |
Hanna Arhipova | 1942996 | 2019-10-17 15:16:49 +0300 | [diff] [blame^] | 314 | line=line, |
| 315 | file=file_name)) |
Hanna Arhipova | 1fcaf44 | 2019-09-06 15:30:45 +0300 | [diff] [blame] | 316 | |
| 317 | neutron_conf = '/etc/neutron/neutron.conf' |
| 318 | neutron_server = "I@neutron:server" |
| 319 | # ######## Create backup for config file ####################### |
| 320 | salt_actions.cmd_run( |
| 321 | neutron_server, |
| 322 | "cp -p {file} {file}.backup".format(file=neutron_conf)) |
| 323 | |
| 324 | # ## Change parameters in neutron.conf' |
| 325 | comment_line(neutron_server, neutron_conf, |
Hanna Arhipova | 1942996 | 2019-10-17 15:16:49 +0300 | [diff] [blame^] | 326 | "allow_automatic_l3agent_failover", ) |
Hanna Arhipova | 1fcaf44 | 2019-09-06 15:30:45 +0300 | [diff] [blame] | 327 | comment_line(neutron_server, neutron_conf, |
| 328 | "allow_automatic_dhcp_failover") |
| 329 | add_line(neutron_server, neutron_conf, |
| 330 | "allow_automatic_dhcp_failover = false") |
| 331 | add_line(neutron_server, neutron_conf, |
| 332 | "allow_automatic_l3agent_failover = false") |
| 333 | |
| 334 | # ## Apply changed config to the neutron-server service |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 335 | result = salt_actions.cmd_run(neutron_server, |
| 336 | "service neutron-server restart") |
Hanna Arhipova | 1fcaf44 | 2019-09-06 15:30:45 +0300 | [diff] [blame] | 337 | # TODO: add check that neutron-server is up and running |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 338 | yield result |
Hanna Arhipova | 1fcaf44 | 2019-09-06 15:30:45 +0300 | [diff] [blame] | 339 | # ## Revert file changes |
| 340 | salt_actions.cmd_run( |
| 341 | neutron_server, |
| 342 | "cp -p {file}.backup {file}".format(file=neutron_conf)) |
| 343 | salt_actions.cmd_run(neutron_server, |
| 344 | "service neutron-server restart") |
| 345 | |
| 346 | @pytest.fixture |
| 347 | def disable_neutron_agents_for_test(self, salt_actions): |
| 348 | """ |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 349 | Disable the neutron services before the test and |
| 350 | enable it after test |
Hanna Arhipova | 1fcaf44 | 2019-09-06 15:30:45 +0300 | [diff] [blame] | 351 | """ |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 352 | result = salt_actions.cmd_run("I@neutron:server", """ |
Hanna Arhipova | 1fcaf44 | 2019-09-06 15:30:45 +0300 | [diff] [blame] | 353 | service neutron-dhcp-agent stop && \ |
| 354 | service neutron-l3-agent stop && \ |
| 355 | service neutron-metadata-agent stop && \ |
| 356 | service neutron-openvswitch-agent stop |
| 357 | """) |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 358 | yield result |
| 359 | # |
Hanna Arhipova | 1fcaf44 | 2019-09-06 15:30:45 +0300 | [diff] [blame] | 360 | salt_actions.cmd_run("I@neutron:server", """ |
| 361 | service neutron-dhcp-agent start && \ |
| 362 | service neutron-l3-agent start && \ |
| 363 | service neutron-metadata-agent start && \ |
| 364 | service neutron-openvswitch-agent start |
| 365 | """) |
| 366 | # TODO: add check that all services are UP and running |
| 367 | |
| 368 | @pytest.mark.grab_versions |
| 369 | @pytest.mark.parametrize("_", [settings.ENV_NAME]) |
| 370 | @pytest.mark.run_mcp_update |
| 371 | def test_update_rabbit(self, salt_actions, reclass_actions, |
| 372 | drivetrain_actions, show_step, _, |
| 373 | disable_automatic_failover_neutron_for_test, |
| 374 | disable_neutron_agents_for_test): |
| 375 | """ Updates RabbitMQ |
| 376 | Scenario: |
| 377 | 1. Include the RabbitMQ upgrade pipeline job to DriveTrain |
| 378 | 2. Add repositories with new RabbitMQ packages |
| 379 | 3. Start Deploy - upgrade RabbitMQ pipeline |
| 380 | |
| 381 | Updating RabbitMq should be completed before the OpenStack updating |
| 382 | process starts |
| 383 | """ |
| 384 | salt = salt_actions |
| 385 | reclass = reclass_actions |
| 386 | dt = drivetrain_actions |
| 387 | |
| 388 | # ####### Include the RabbitMQ upgrade pipeline job to DriveTrain #### |
| 389 | show_step(1) |
| 390 | reclass.add_class( |
| 391 | "system.jenkins.client.job.deploy.update.upgrade_rabbitmq", |
| 392 | "cluster/*/cicd/control/leader.yml") |
| 393 | salt.enforce_state("I@jenkins:client", "jenkins.client") |
| 394 | |
| 395 | reclass.add_bool_key("parameters._param.openstack_upgrade_enabled", |
| 396 | "True", |
| 397 | "cluster/*/infra/init.yml") |
| 398 | salt.run_state("I@rabbitmq:server", "saltutil.refresh_pillar") |
| 399 | |
| 400 | # ########### Add repositories with new RabbitMQ packages ############ |
| 401 | show_step(2) |
| 402 | salt.enforce_state("I@rabbitmq:server", "linux.system.repo") |
| 403 | |
| 404 | # ########### Start Deploy - upgrade RabbitMQ pipeline ############ |
| 405 | show_step(3) |
| 406 | job_parameters = { |
| 407 | 'INTERACTIVE': 'false' |
| 408 | } |
| 409 | |
| 410 | update_rabbit = dt.start_job_on_cid_jenkins( |
| 411 | job_name='deploy-upgrade-rabbitmq', |
| 412 | job_parameters=job_parameters, |
| 413 | build_timeout=40 * 60 |
| 414 | ) |
| 415 | assert update_rabbit == 'SUCCESS' |
Hanna Arhipova | d35a29b | 2019-09-04 13:24:06 +0300 | [diff] [blame] | 416 | |
| 417 | @pytest.mark.grab_versions |
| 418 | @pytest.mark.parametrize("_", [settings.ENV_NAME]) |
| 419 | @pytest.mark.run_mcp_update |
| 420 | def test_update_ceph(self, salt_actions, drivetrain_actions, show_step, _): |
| 421 | """ Updates Ceph to the latest minor version |
| 422 | |
| 423 | Scenario: |
| 424 | 1. Add workaround for unhealth Ceph |
| 425 | 2. Start ceph-upgrade job with default parameters |
| 426 | 3. Check Ceph version for all nodes |
| 427 | |
| 428 | https://docs.mirantis.com/mcp/master/mcp-operations-guide/update-upgrade/minor-update/ceph-update.html |
| 429 | """ |
| 430 | salt = salt_actions |
| 431 | dt = drivetrain_actions |
| 432 | |
| 433 | # ###################### Add workaround for unhealth Ceph ############ |
| 434 | show_step(1) |
| 435 | salt.cmd_run("I@ceph:radosgw", |
| 436 | "ceph config set 'mon pg warn max object skew' 20") |
| 437 | # ###################### Start ceph-upgrade pipeline ################# |
| 438 | show_step(2) |
| 439 | job_parameters = {} |
| 440 | |
| 441 | update_ceph = dt.start_job_on_cid_jenkins( |
| 442 | job_name='ceph-update', |
| 443 | job_parameters=job_parameters) |
| 444 | |
| 445 | assert update_ceph == 'SUCCESS' |
| 446 | |
| 447 | # ########## Verify Ceph version ##################################### |
| 448 | show_step(3) |
| 449 | |
| 450 | ceph_version_by_nodes = salt.cmd_run( |
Hanna Arhipova | 1942996 | 2019-10-17 15:16:49 +0300 | [diff] [blame^] | 451 | "I@ceph:* and not I@ceph:monitoring and not I@ceph:backup:server", |
| 452 | "ceph version")[0] |
Hanna Arhipova | d35a29b | 2019-09-04 13:24:06 +0300 | [diff] [blame] | 453 | |
| 454 | assert has_only_similar(ceph_version_by_nodes), ceph_version_by_nodes |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 455 | |
| 456 | |
Hanna Arhipova | 1942996 | 2019-10-17 15:16:49 +0300 | [diff] [blame^] | 457 | @pytest.mark.usefixtures("switch_to_proposed_pipelines", |
| 458 | "enable_openstack_update") |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 459 | class TestOpenstackUpdate(object): |
| 460 | |
| 461 | @pytest.mark.grab_versions |
| 462 | @pytest.mark.run_mcp_update |
| 463 | def test__pre_update__enable_pipeline_job(self, |
| 464 | reclass_actions, salt_actions, |
| 465 | show_step): |
| 466 | """ Enable pipeline in the Drivetrain |
| 467 | |
| 468 | Scenario: |
| 469 | 1. Add deploy.update.* classes to the reclass |
| 470 | 2. Start jenkins.client salt state |
| 471 | |
| 472 | """ |
| 473 | salt = salt_actions |
| 474 | reclass = reclass_actions |
| 475 | show_step(1) |
| 476 | reclass.add_class("system.jenkins.client.job.deploy.update.upgrade", |
| 477 | "cluster/*/cicd/control/leader.yml") |
| 478 | |
| 479 | reclass.add_class( |
| 480 | "system.jenkins.client.job.deploy.update.upgrade_ovs_gateway", |
| 481 | "cluster/*/cicd/control/leader.yml") |
| 482 | |
| 483 | reclass.add_class( |
| 484 | "system.jenkins.client.job.deploy.update.upgrade_compute", |
| 485 | "cluster/*/cicd/control/leader.yml") |
| 486 | |
| 487 | show_step(2) |
| 488 | r, errors = salt.enforce_state("I@jenkins:client", "jenkins.client") |
| 489 | assert errors is None |
| 490 | |
| 491 | @pytest.mark.grab_versions |
| 492 | @pytest.mark.parametrize('target', get_control_plane_targets()) |
| 493 | @pytest.mark.run_mcp_update |
Hanna Arhipova | 1942996 | 2019-10-17 15:16:49 +0300 | [diff] [blame^] | 494 | def test__update__control_plane(self, drivetrain_actions, target): |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 495 | """Start 'Deploy - upgrade control VMs' for specific node |
| 496 | """ |
| 497 | job_parameters = { |
| 498 | "TARGET_SERVERS": target, |
| 499 | "INTERACTIVE": False} |
| 500 | upgrade_control_pipeline = drivetrain_actions.start_job_on_cid_jenkins( |
| 501 | job_name="deploy-upgrade-control", |
| 502 | job_parameters=job_parameters) |
| 503 | |
| 504 | assert upgrade_control_pipeline == 'SUCCESS' |
| 505 | |
| 506 | @pytest.mark.grab_versions |
| 507 | @pytest.mark.run_mcp_update |
| 508 | def test__update__data_plane(self, drivetrain_actions): |
| 509 | """Start 'Deploy - upgrade OVS gateway' |
| 510 | """ |
| 511 | job_parameters = { |
| 512 | "INTERACTIVE": False} |
| 513 | upgrade_data_pipeline = drivetrain_actions.start_job_on_cid_jenkins( |
| 514 | job_name="deploy-upgrade-ovs-gateway", |
| 515 | job_parameters=job_parameters) |
| 516 | |
| 517 | assert upgrade_data_pipeline == 'SUCCESS' |
Hanna Arhipova | 1942996 | 2019-10-17 15:16:49 +0300 | [diff] [blame^] | 518 | |
| 519 | @pytest.mark.grab_versions |
| 520 | @pytest.mark.run_mcp_update |
| 521 | def test__update__computes(self, drivetrain_actions): |
| 522 | """Start 'Deploy - upgrade computes' |
| 523 | """ |
| 524 | job_parameters = { |
| 525 | "INTERACTIVE": False} |
| 526 | upgrade_compute_pipeline = drivetrain_actions.start_job_on_cid_jenkins( |
| 527 | job_name="deploy-upgrade-compute", |
| 528 | job_parameters=job_parameters) |
| 529 | |
| 530 | assert upgrade_compute_pipeline == 'SUCCESS' |