blob: 6957f645ee30562480f8c28e2c4329bb23eecaa6 [file] [log] [blame]
Hanna Arhipova71ecc272019-08-20 14:54:22 +03001import pytest
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +03002import sys
3import os
Hanna Arhipova71ecc272019-08-20 14:54:22 +03004
5from tcp_tests import logger
6from tcp_tests import settings
Hanna Arhipova71ecc272019-08-20 14:54:22 +03007
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +03008sys.path.append(os.getcwd())
9try:
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
13except 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 Arhipova71ecc272019-08-20 14:54:22 +030018LOG = logger.logger
19
20
Hanna Arhipovad35a29b2019-09-04 13:24:06 +030021def has_only_similar(values_by_nodes):
22 """
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +030023 :param values_by_nodes: dict
Hanna Arhipovad35a29b2019-09-04 13:24:06 +030024 :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 Arhipovaeb3a2112019-09-13 18:45:21 +030030def get_control_plane_targets():
31 config = config_fixtures.config()
32 underlay = underlay_ssh_manager.UnderlaySSHManager(config)
33 saltmanager = salt_manager.SaltManager(config, underlay)
Hanna Arhipovafbcea852019-10-03 13:24:53 +030034 targets = list()
Hanna Arhipova52bb17d2019-10-28 19:15:17 +020035 telemetry_exists = False
36 barbican_exists = False
Hanna Arhipovafbcea852019-10-03 13:24:53 +030037 try:
38 targets += saltmanager.run_state(
39 "I@keystone:server", 'test.ping')[0]['return'][0].keys()
40 targets += saltmanager.run_state(
41 "I@nginx:server and not I@salt:master",
42 "test.ping")[0]['return'][0].keys()
Hanna Arhipova4462dd02019-10-28 19:05:08 +020043 telemetry_exists = saltmanager.get_single_pillar(
44 "I@salt:master",
45 "_param:openstack_telemetry_hostname")
46 barbican_exists = saltmanager.get_single_pillar(
47 "I@salt:master",
48 "_param:barbican_enabled")
Hanna Arhipovafbcea852019-10-03 13:24:53 +030049 except BaseException as err:
50 LOG.warning("Can't retrieve data from Salt. \
51 Maybe cluster is not deployed completely.\
52 Err: {}".format(err))
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +030053
Hanna Arhipova75f21bb2019-10-07 19:22:15 +030054 # check for Manila existence
55 # if saltmanager.get_single_pillar("I@salt:master",
56 # "_param:manila_service_protocol"):
57 # targets.append('share*')
58
59 # check for Tenant Telemetry existence
Hanna Arhipova4462dd02019-10-28 19:05:08 +020060 if telemetry_exists:
Hanna Arhipova75f21bb2019-10-07 19:22:15 +030061 targets.append('mdb*')
62
63 # check for Barbican existence
Hanna Arhipova4462dd02019-10-28 19:05:08 +020064 if barbican_exists:
Hanna Arhipova75f21bb2019-10-07 19:22:15 +030065 targets.append('kmn*')
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +030066 return targets
67
68
Hanna Arhipova19429962019-10-17 15:16:49 +030069@pytest.fixture(scope='class')
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +030070def switch_to_proposed_pipelines(reclass_actions, salt_actions):
Hanna Arhipova19429962019-10-17 15:16:49 +030071 reclass = reclass_actions
72 proposed_repo = "http://mirror.mirantis.com/update/proposed/"
73 repo_param = "parameters._param.linux_system_repo_update_url"
Hanna Arhipova7cfeb072019-10-11 15:04:10 +030074
Hanna Arhipova19429962019-10-17 15:16:49 +030075 proposed_pipeline_branch = "release/proposed/2019.2.0"
76 pipeline_branch_param = "parameters._param.jenkins_pipelines_branch"
77 infra_yml = "cluster/*/infra/init.yml"
78
79 LOG.info("Check reclass has release/proposed/2019.2.0 branches")
80 if reclass.get_key(pipeline_branch_param,
81 infra_yml) == proposed_pipeline_branch \
82 and reclass.get_key(repo_param, infra_yml) == proposed_repo:
83 return True
84
85 LOG.info("Switch to release/proposed/2019.2.0 branches")
86 reclass.add_key(pipeline_branch_param, proposed_pipeline_branch, infra_yml)
87
88 reclass.add_key(repo_param, proposed_repo, infra_yml)
89 reclass.add_key(repo_param, proposed_repo, "cluster/*/openstack/init.yml")
90 reclass.add_key(repo_param, proposed_repo, "cluster/*/stacklight/init.yml")
91 reclass.add_key(repo_param, proposed_repo, "cluster/*/ceph/init.yml")
Hanna Arhipova7cfeb072019-10-11 15:04:10 +030092
93 salt_actions.run_state("*", "saltutil.refresh_pillar")
Hanna Arhipova9ee75902019-10-29 16:33:26 +020094 salt_actions.enforce_state("*", "salt.minion")
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +030095 salt_actions.enforce_state("I@jenkins:client", "jenkins.client")
96
97
Hanna Arhipova745fdbb2020-03-30 14:40:44 +030098@pytest.fixture
Hanna Arhipovaec201e72020-10-26 17:14:25 +020099def wa_for_galera_clustercheck_password_prod35705(reclass_actions,
100 salt_actions):
Hanna Arhipova0e816d22021-01-29 00:17:44 +0200101 tgt = "I@galera:master or I@galera:slave"
102 if not salt_actions.get_pillar(tgt,
103 "_param:galera_clustercheck_password")[0]:
104 reclass_actions.add_key(
105 "parameters._param.galera_clustercheck_password",
106 "a"*32,
107 "cluster/*/infra/secrets.yml")
108 salt_actions.run_state(tgt, "saltutil.refresh_pillar")
109 salt_actions.enforce_state(tgt, "galera")
110 salt_actions.enforce_state(tgt, "haproxy")
111 reclass_actions.commit(
112 "[from TCP-QA] Add galera_clustercheck_password")
113 else:
114 LOG.info("Skipping WA for Galera Clustercheck Password")
Hanna Arhipova745fdbb2020-03-30 14:40:44 +0300115
116
Hanna Arhipova97fac6e2020-12-03 13:10:56 +0200117@pytest.fixture
118def wa_for_alerta_password_prod35958(reclass_actions,
119 salt_actions):
Hanna Arhipova0e816d22021-01-29 00:17:44 +0200120
121 if not salt_actions.get_pillar("I@prometheus:alerta",
122 "_param:alerta_admin_api_key_generated")[0]:
123 reclass_actions.add_key(
124 "parameters._param.alerta_admin_api_key_generated",
125 "a"*32,
126 "cluster/*/infra/secrets.yml")
127 reclass_actions.add_key(
128 "parameters._param.alerta_admin_key",
129 "${_param:alerta_admin_api_key_generated}",
130 "cluster/*/stacklight/init.yml")
131 reclass_actions.commit("[from TCP-QA] Add alerta_admin_key")
132 salt_actions.run_state(
133 "I@prometheus:alerta or I@prometheus:alertmanager",
134 "saltutil.refresh_pillar")
135 salt_actions.enforce_state(
136 "I@prometheus:alerta", "prometheus.alerta")
137 salt_actions.enforce_state(
138 "I@prometheus:alertmanager", "prometheus.alertmanager")
139 salt_actions.enforce_state(
140 "I@prometheus:alerta or I@prometheus:alertmanager",
141 "docker.client")
142 else:
143 LOG.info("Skipping WA for Alerta API key")
Hanna Arhipova97fac6e2020-12-03 13:10:56 +0200144
145
Hanna Arhipova19429962019-10-17 15:16:49 +0300146@pytest.fixture(scope='class')
147def enable_openstack_update(reclass_actions, salt_actions):
148 param = "parameters._param.openstack_upgrade_enabled"
149 context_file = "cluster/*/infra/init.yml"
150
151 LOG.info("Enable openstack_upgrade_enabled in reclass")
152 reclass_actions.add_bool_key(param, "True", context_file)
153 salt_actions.run_state("*", "saltutil.refresh_pillar")
154 yield True
155 LOG.info("Disable openstack_upgrade_enabled in reclass")
156 reclass_actions.add_bool_key(param, "False", context_file)
157 salt_actions.run_state("*", "saltutil.refresh_pillar")
158
159
Hanna Arhipova745fdbb2020-03-30 14:40:44 +0300160@pytest.mark.usefixtures("switch_to_proposed_pipelines",
Hanna Arhipova97fac6e2020-12-03 13:10:56 +0200161 "wa_for_galera_clustercheck_password_prod35705",
162 "wa_for_alerta_password_prod35958")
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300163class TestUpdateMcpCluster(object):
164 """
165 Following the steps in
Hanna Arhipova94a8abe2019-08-22 14:11:46 +0300166 https://docs.mirantis.com/mcp/master/mcp-operations-guide/update-upgrade/minor-update.html#minor-update
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300167 """
168
169 @pytest.mark.grab_versions
170 @pytest.mark.parametrize("_", [settings.ENV_NAME])
171 @pytest.mark.run_mcp_update
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300172 def test_update_drivetrain(self, salt_actions, drivetrain_actions,
Hanna Arhipova19429962019-10-17 15:16:49 +0300173 show_step, _):
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300174 """Updating DriveTrain component to release/proposed/2019.2.0 version
175
176 Scenario:
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300177 1. Add workaround for PROD-32751
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300178 2. Run job git-mirror-downstream-mk-pipelines
179 3. Run job git-mirror-downstream-pipeline-library
180 4. If jobs are passed then start 'Deploy - upgrade MCP Drivetrain'
181
Hanna Arhipovad35a29b2019-09-04 13:24:06 +0300182 Duration: ~70 min
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300183 """
184 salt = salt_actions
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300185 dt = drivetrain_actions
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300186
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300187 # #################### Add workaround for PROD-32751 #################
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300188 show_step(1)
189
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300190 # FIXME: workaround for PROD-32751
191 salt.cmd_run("cfg01*", "cd /srv/salt/reclass; git add -u && \
192 git commit --allow-empty -m 'Cluster model update'")
193
194 # ################### Downstream mk-pipelines #########################
195 show_step(2)
196 job_name = 'git-mirror-downstream-mk-pipelines'
197 job_parameters = {
198 'BRANCHES': 'release/proposed/2019.2.0'
199 }
Hanna Arhipova508f6532021-01-27 15:52:45 +0200200 job_result, job_description = dt.start_job_on_jenkins(
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300201 job_name=job_name,
Hanna Arhipovac3c59292020-04-23 16:29:09 +0300202 job_parameters=job_parameters,
203 verbose=True)
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300204
Hanna Arhipova508f6532021-01-27 15:52:45 +0200205 assert job_result == 'SUCCESS', job_description
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300206
207 # ################### Downstream pipeline-library ####################
208 show_step(3)
209 job_name = 'git-mirror-downstream-pipeline-library'
210 job_parameters = {
211 'BRANCHES': 'release/proposed/2019.2.0'
212 }
Hanna Arhipova508f6532021-01-27 15:52:45 +0200213 job_result, job_description = dt.start_job_on_jenkins(
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300214 job_name=job_name,
Hanna Arhipovac3c59292020-04-23 16:29:09 +0300215 job_parameters=job_parameters,
216 verbose=True)
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300217
Hanna Arhipova508f6532021-01-27 15:52:45 +0200218 assert job_result == 'SUCCESS', job_description
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300219
220 # ################### Start 'Deploy - upgrade MCP Drivetrain' job #####
221 show_step(4)
222
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300223 job_name = 'upgrade-mcp-release'
224 job_parameters = {
Hanna Arhipovad35a29b2019-09-04 13:24:06 +0300225 'GIT_REFSPEC': 'release/proposed/2019.2.0',
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300226 'MK_PIPELINES_REFSPEC': 'release/proposed/2019.2.0',
227 'TARGET_MCP_VERSION': '2019.2.0'
228 }
Hanna Arhipova508f6532021-01-27 15:52:45 +0200229 job_result, job_description = dt.start_job_on_jenkins(
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300230 job_name=job_name,
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300231 job_parameters=job_parameters,
Hanna Arhipovac3c59292020-04-23 16:29:09 +0300232 verbose=True,
Hanna Arhipovae7f2e322021-02-25 13:53:18 +0200233 build_timeout=4 * 60 * 60)
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300234
Hanna Arhipova508f6532021-01-27 15:52:45 +0200235 assert job_result == 'SUCCESS', job_description
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300236
Hanna Arhipova94a8abe2019-08-22 14:11:46 +0300237 @pytest.mark.grab_versions
238 @pytest.mark.parametrize("_", [settings.ENV_NAME])
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300239 @pytest.mark.run_mcp_update
Hanna Arhipovacc3759b2019-08-28 16:01:11 +0300240 def test_update_glusterfs(self, salt_actions, reclass_actions,
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300241 drivetrain_actions, show_step, _):
Hanna Arhipovacc3759b2019-08-28 16:01:11 +0300242 """ Upgrade GlusterFS
243 Scenario:
244 1. In infra/init.yml in Reclass, add the glusterfs_version parameter
245 2. Start linux.system.repo state
246 3. Start "update-glusterfs" job
247 4. Check version for GlusterFS servers
248 5. Check version for GlusterFS clients
249
250 """
251 salt = salt_actions
252 reclass = reclass_actions
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300253 dt = drivetrain_actions
Hanna Arhipovacc3759b2019-08-28 16:01:11 +0300254
Hanna Arhipovacc3759b2019-08-28 16:01:11 +0300255 # ############## Change reclass ######################################
256 show_step(1)
257 reclass.add_key(
258 "parameters._param.linux_system_repo_mcp_glusterfs_version_number",
259 "5",
260 "cluster/*/infra/init.yml"
261 )
262 # ################# Run linux.system state ###########################
263 show_step(2)
264 salt.enforce_state("*", "linux.system.repo")
265
266 # ############## Start deploy-upgrade-galera job #####################
267 show_step(3)
Hanna Arhipovacc3759b2019-08-28 16:01:11 +0300268 job_name = 'update-glusterfs'
269
Hanna Arhipova508f6532021-01-27 15:52:45 +0200270 job_result, job_description = dt.start_job_on_jenkins(
Hanna Arhipovacc3759b2019-08-28 16:01:11 +0300271 job_name=job_name,
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300272 build_timeout=40 * 60)
Hanna Arhipovacc3759b2019-08-28 16:01:11 +0300273
Hanna Arhipova508f6532021-01-27 15:52:45 +0200274 assert job_result == 'SUCCESS', job_description
Hanna Arhipovacc3759b2019-08-28 16:01:11 +0300275
276 # ################ Check GlusterFS version for servers ##############
277 show_step(4)
278 gluster_server_versions_by_nodes = salt.cmd_run(
279 "I@glusterfs:server",
280 "glusterd --version|head -n1")[0]
281
Hanna Arhipova19429962019-10-17 15:16:49 +0300282 assert has_only_similar(gluster_server_versions_by_nodes), \
Hanna Arhipovacc3759b2019-08-28 16:01:11 +0300283 gluster_server_versions_by_nodes
284
285 # ################ Check GlusterFS version for clients ##############
286 show_step(5)
287 gluster_client_versions_by_nodes = salt.cmd_run(
288 "I@glusterfs:client",
289 "glusterfs --version|head -n1")[0]
290
291 assert has_only_similar(gluster_client_versions_by_nodes), \
292 gluster_client_versions_by_nodes
293
294 @pytest.mark.grab_versions
295 @pytest.mark.parametrize("_", [settings.ENV_NAME])
296 @pytest.mark.run_mcp_update
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300297 def test_update_galera(self, salt_actions, reclass_actions,
298 drivetrain_actions, show_step, _):
Hanna Arhipova94a8abe2019-08-22 14:11:46 +0300299 """ Upgrade Galera automatically
300
301 Scenario:
302 1. Include the Galera upgrade pipeline job to DriveTrain
303 2. Apply the jenkins.client state on the Jenkins nodes
304 3. set the openstack_upgrade_enabled parameter to true
305 4. Refresh pillars
306 5. Add repositories with new Galera packages
307 6. Start job from Jenkins
308 """
309 salt = salt_actions
310 reclass = reclass_actions
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300311 dt = drivetrain_actions
Hanna Arhipova94a8abe2019-08-22 14:11:46 +0300312 # ################### Enable pipeline #################################
313 show_step(1)
314 reclass.add_class(
315 "system.jenkins.client.job.deploy.update.upgrade_galera",
316 "cluster/*/cicd/control/leader.yml")
317 show_step(2)
318 salt.enforce_state("I@jenkins:client", "jenkins.client")
319
320 # ############### Enable automatic upgrade ############################
321 show_step(3)
322 reclass.add_bool_key("parameters._param.openstack_upgrade_enabled",
323 "True",
324 "cluster/*/infra/init.yml")
325
326 show_step(4)
Hanna Arhipova7cfeb072019-10-11 15:04:10 +0300327 salt.run_state("dbs*", "saltutil.refresh_pillar")
Hanna Arhipova94a8abe2019-08-22 14:11:46 +0300328
329 # ############# Add repositories with new Galera packages #######
330 show_step(5)
331 salt.enforce_state("dbs*", "linux.system.repo")
332 salt.enforce_state("cfg*", "salt.master")
333
Hanna Arhipova94a8abe2019-08-22 14:11:46 +0300334 # #################### Login Jenkins on cid01 node ###################
335 show_step(6)
336
Hanna Arhipova94a8abe2019-08-22 14:11:46 +0300337 job_name = 'deploy-upgrade-galera'
338 job_parameters = {
339 'INTERACTIVE': 'false'
340 }
341
Hanna Arhipova508f6532021-01-27 15:52:45 +0200342 job_result, job_description = dt.start_job_on_jenkins(
Hanna Arhipova94a8abe2019-08-22 14:11:46 +0300343 job_name=job_name,
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300344 job_parameters=job_parameters,
345 build_timeout=40 * 60)
Hanna Arhipova94a8abe2019-08-22 14:11:46 +0300346
Hanna Arhipova508f6532021-01-27 15:52:45 +0200347 assert job_result == 'SUCCESS', job_description
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300348
349 @pytest.fixture
350 def disable_automatic_failover_neutron_for_test(self, salt_actions):
351 """
352 On each OpenStack controller node, modify the neutron.conf file
353 Restart the neutron-server service
354 """
Hanna Arhipova19429962019-10-17 15:16:49 +0300355
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300356 def comment_line(node, file_name, word):
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300357 """
358 Adds '#' before the specific line in specific file
359
360 :param node: string, salt target of node where the file locates
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300361 :param file_name: string, full path to the file
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300362 :param word: string, the begin of line which should be commented
363 :return: None
364 """
365 salt_actions.cmd_run(node,
366 "sed -i 's/^{word}/#{word}/' {file}".
367 format(word=word,
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300368 file=file_name))
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300369
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300370 def add_line(node, file_name, line):
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300371 """
372 Appends line to the end of file
373
374 :param node: string, salt target of node where the file locates
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300375 :param file_name: string, full path to the file
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300376 :param line: string, line that should be added
377 :return: None
378 """
379 salt_actions.cmd_run(node, "echo {line} >> {file}".format(
Hanna Arhipova19429962019-10-17 15:16:49 +0300380 line=line,
381 file=file_name))
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300382
383 neutron_conf = '/etc/neutron/neutron.conf'
384 neutron_server = "I@neutron:server"
385 # ######## Create backup for config file #######################
386 salt_actions.cmd_run(
387 neutron_server,
388 "cp -p {file} {file}.backup".format(file=neutron_conf))
389
390 # ## Change parameters in neutron.conf'
391 comment_line(neutron_server, neutron_conf,
Hanna Arhipova19429962019-10-17 15:16:49 +0300392 "allow_automatic_l3agent_failover", )
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300393 comment_line(neutron_server, neutron_conf,
394 "allow_automatic_dhcp_failover")
395 add_line(neutron_server, neutron_conf,
396 "allow_automatic_dhcp_failover = false")
397 add_line(neutron_server, neutron_conf,
398 "allow_automatic_l3agent_failover = false")
399
400 # ## Apply changed config to the neutron-server service
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300401 result = salt_actions.cmd_run(neutron_server,
402 "service neutron-server restart")
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300403 # TODO: add check that neutron-server is up and running
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300404 yield result
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300405 # ## Revert file changes
406 salt_actions.cmd_run(
407 neutron_server,
408 "cp -p {file}.backup {file}".format(file=neutron_conf))
409 salt_actions.cmd_run(neutron_server,
410 "service neutron-server restart")
411
412 @pytest.fixture
413 def disable_neutron_agents_for_test(self, salt_actions):
414 """
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300415 Disable the neutron services before the test and
416 enable it after test
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300417 """
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300418 result = salt_actions.cmd_run("I@neutron:server", """
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300419 service neutron-dhcp-agent stop && \
420 service neutron-l3-agent stop && \
421 service neutron-metadata-agent stop && \
422 service neutron-openvswitch-agent stop
423 """)
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300424 yield result
425 #
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300426 salt_actions.cmd_run("I@neutron:server", """
427 service neutron-dhcp-agent start && \
428 service neutron-l3-agent start && \
429 service neutron-metadata-agent start && \
430 service neutron-openvswitch-agent start
431 """)
432 # TODO: add check that all services are UP and running
433
434 @pytest.mark.grab_versions
435 @pytest.mark.parametrize("_", [settings.ENV_NAME])
436 @pytest.mark.run_mcp_update
437 def test_update_rabbit(self, salt_actions, reclass_actions,
438 drivetrain_actions, show_step, _,
439 disable_automatic_failover_neutron_for_test,
440 disable_neutron_agents_for_test):
441 """ Updates RabbitMQ
442 Scenario:
443 1. Include the RabbitMQ upgrade pipeline job to DriveTrain
444 2. Add repositories with new RabbitMQ packages
445 3. Start Deploy - upgrade RabbitMQ pipeline
446
447 Updating RabbitMq should be completed before the OpenStack updating
448 process starts
449 """
450 salt = salt_actions
451 reclass = reclass_actions
452 dt = drivetrain_actions
453
454 # ####### Include the RabbitMQ upgrade pipeline job to DriveTrain ####
455 show_step(1)
456 reclass.add_class(
457 "system.jenkins.client.job.deploy.update.upgrade_rabbitmq",
458 "cluster/*/cicd/control/leader.yml")
459 salt.enforce_state("I@jenkins:client", "jenkins.client")
460
461 reclass.add_bool_key("parameters._param.openstack_upgrade_enabled",
462 "True",
463 "cluster/*/infra/init.yml")
464 salt.run_state("I@rabbitmq:server", "saltutil.refresh_pillar")
465
466 # ########### Add repositories with new RabbitMQ packages ############
467 show_step(2)
468 salt.enforce_state("I@rabbitmq:server", "linux.system.repo")
469
470 # ########### Start Deploy - upgrade RabbitMQ pipeline ############
471 show_step(3)
472 job_parameters = {
473 'INTERACTIVE': 'false'
474 }
475
Hanna Arhipova508f6532021-01-27 15:52:45 +0200476 job_result, job_description = dt.start_job_on_jenkins(
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300477 job_name='deploy-upgrade-rabbitmq',
478 job_parameters=job_parameters,
479 build_timeout=40 * 60
480 )
Hanna Arhipova508f6532021-01-27 15:52:45 +0200481 assert job_result == 'SUCCESS', job_description
Hanna Arhipovad35a29b2019-09-04 13:24:06 +0300482
483 @pytest.mark.grab_versions
484 @pytest.mark.parametrize("_", [settings.ENV_NAME])
485 @pytest.mark.run_mcp_update
486 def test_update_ceph(self, salt_actions, drivetrain_actions, show_step, _):
487 """ Updates Ceph to the latest minor version
488
489 Scenario:
490 1. Add workaround for unhealth Ceph
491 2. Start ceph-upgrade job with default parameters
492 3. Check Ceph version for all nodes
493
494 https://docs.mirantis.com/mcp/master/mcp-operations-guide/update-upgrade/minor-update/ceph-update.html
495 """
496 salt = salt_actions
497 dt = drivetrain_actions
498
499 # ###################### Add workaround for unhealth Ceph ############
500 show_step(1)
501 salt.cmd_run("I@ceph:radosgw",
502 "ceph config set 'mon pg warn max object skew' 20")
503 # ###################### Start ceph-upgrade pipeline #################
504 show_step(2)
505 job_parameters = {}
506
Hanna Arhipova508f6532021-01-27 15:52:45 +0200507 job_result, job_description = dt.start_job_on_jenkins(
Hanna Arhipovad35a29b2019-09-04 13:24:06 +0300508 job_name='ceph-update',
509 job_parameters=job_parameters)
510
Hanna Arhipova508f6532021-01-27 15:52:45 +0200511 assert job_result == 'SUCCESS', job_description
Hanna Arhipovad35a29b2019-09-04 13:24:06 +0300512
513 # ########## Verify Ceph version #####################################
514 show_step(3)
515
516 ceph_version_by_nodes = salt.cmd_run(
Hanna Arhipova19429962019-10-17 15:16:49 +0300517 "I@ceph:* and not I@ceph:monitoring and not I@ceph:backup:server",
518 "ceph version")[0]
Hanna Arhipovad35a29b2019-09-04 13:24:06 +0300519
520 assert has_only_similar(ceph_version_by_nodes), ceph_version_by_nodes
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300521
Hanna Arhipovaac008562019-10-17 11:54:23 +0300522 @pytest.mark.grab_versions
523 @pytest.mark.parametrize("_", [settings.ENV_NAME])
524 @pytest.mark.run_mcp_update
525 def test_update_stacklight(self, _, drivetrain_actions):
526 """ Update packages for Stacklight
527 Scenario:
528 1. Start Deploy - upgrade Stacklight job
529 """
530 drivetrain = drivetrain_actions
531
532 job_parameters = {
533 "STAGE_UPGRADE_DOCKER_COMPONENTS": True,
534 "STAGE_UPGRADE_ES_KIBANA": True,
535 "STAGE_UPGRADE_SYSTEM_PART": True
536 }
Hanna Arhipova508f6532021-01-27 15:52:45 +0200537 job_result, job_description = drivetrain.start_job_on_jenkins(
Hanna Arhipovaac008562019-10-17 11:54:23 +0300538 job_name="stacklight-upgrade",
539 job_parameters=job_parameters)
540
Hanna Arhipova508f6532021-01-27 15:52:45 +0200541 assert job_result == 'SUCCESS', job_description
Hanna Arhipovaac008562019-10-17 11:54:23 +0300542
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300543
Hanna Arhipova19429962019-10-17 15:16:49 +0300544@pytest.mark.usefixtures("switch_to_proposed_pipelines",
545 "enable_openstack_update")
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300546class TestOpenstackUpdate(object):
547
548 @pytest.mark.grab_versions
549 @pytest.mark.run_mcp_update
550 def test__pre_update__enable_pipeline_job(self,
551 reclass_actions, salt_actions,
552 show_step):
553 """ Enable pipeline in the Drivetrain
554
555 Scenario:
556 1. Add deploy.update.* classes to the reclass
557 2. Start jenkins.client salt state
558
559 """
560 salt = salt_actions
561 reclass = reclass_actions
562 show_step(1)
563 reclass.add_class("system.jenkins.client.job.deploy.update.upgrade",
564 "cluster/*/cicd/control/leader.yml")
565
566 reclass.add_class(
567 "system.jenkins.client.job.deploy.update.upgrade_ovs_gateway",
568 "cluster/*/cicd/control/leader.yml")
569
570 reclass.add_class(
571 "system.jenkins.client.job.deploy.update.upgrade_compute",
572 "cluster/*/cicd/control/leader.yml")
573
574 show_step(2)
575 r, errors = salt.enforce_state("I@jenkins:client", "jenkins.client")
576 assert errors is None
577
578 @pytest.mark.grab_versions
579 @pytest.mark.parametrize('target', get_control_plane_targets())
580 @pytest.mark.run_mcp_update
Hanna Arhipova19429962019-10-17 15:16:49 +0300581 def test__update__control_plane(self, drivetrain_actions, target):
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300582 """Start 'Deploy - upgrade control VMs' for specific node
583 """
584 job_parameters = {
585 "TARGET_SERVERS": target,
Hanna Arhipova606d5182019-12-13 13:23:55 +0200586 "OS_DIST_UPGRADE": True,
PGlazoved19b352020-05-21 16:42:27 +0400587 "UPGRADE_SALTSTACK": False,
Hanna Arhipova606d5182019-12-13 13:23:55 +0200588 "OS_UPGRADE": True,
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300589 "INTERACTIVE": False}
Hanna Arhipova508f6532021-01-27 15:52:45 +0200590 job_result, job_description = drivetrain_actions.start_job_on_jenkins(
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300591 job_name="deploy-upgrade-control",
592 job_parameters=job_parameters)
593
Hanna Arhipova508f6532021-01-27 15:52:45 +0200594 assert job_result == 'SUCCESS', job_description
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300595
596 @pytest.mark.grab_versions
597 @pytest.mark.run_mcp_update
Hanna Arhipova606d5182019-12-13 13:23:55 +0200598 def test__update__data_plane(self, drivetrain_actions, salt_actions):
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300599 """Start 'Deploy - upgrade OVS gateway'
600 """
Hanna Arhipova606d5182019-12-13 13:23:55 +0200601 if not salt_actions.cmd_run("gtw*", "test.ping")[0].keys():
602 pytest.skip("This deployment doesn't have gtw* nodes")
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300603 job_parameters = {
Hanna Arhipova606d5182019-12-13 13:23:55 +0200604 "OS_DIST_UPGRADE": True,
605 "OS_UPGRADE": True,
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300606 "INTERACTIVE": False}
Hanna Arhipova508f6532021-01-27 15:52:45 +0200607 job_result, job_description = drivetrain_actions.start_job_on_jenkins(
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300608 job_name="deploy-upgrade-ovs-gateway",
609 job_parameters=job_parameters)
610
Hanna Arhipova508f6532021-01-27 15:52:45 +0200611 assert job_result == 'SUCCESS', job_description
Hanna Arhipova19429962019-10-17 15:16:49 +0300612
613 @pytest.mark.grab_versions
614 @pytest.mark.run_mcp_update
615 def test__update__computes(self, drivetrain_actions):
616 """Start 'Deploy - upgrade computes'
617 """
618 job_parameters = {
Hanna Arhipova606d5182019-12-13 13:23:55 +0200619 "OS_DIST_UPGRADE": True,
620 "OS_UPGRADE": True,
Hanna Arhipova19429962019-10-17 15:16:49 +0300621 "INTERACTIVE": False}
Hanna Arhipova508f6532021-01-27 15:52:45 +0200622 job_result, job_description = drivetrain_actions.start_job_on_jenkins(
Hanna Arhipova19429962019-10-17 15:16:49 +0300623 job_name="deploy-upgrade-compute",
624 job_parameters=job_parameters)
625
Hanna Arhipova508f6532021-01-27 15:52:45 +0200626 assert job_result == 'SUCCESS', job_description