blob: c906eb116ba66ba5559b8ae921032a87c5dcf5aa [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
99def wa_for_sphinx_prod34406(reclass_actions, salt_actions):
100 reclass_actions.add_key(
101 "parameters._param.sphinx_proxy_password_generated",
102 "a"*32,
103 "cluster/*/infra/secrets.yml")
104 salt_actions.run_state("I@nginx:server",
105 "saltutil.refresh_pillar")
106
107
Hanna Arhipova19429962019-10-17 15:16:49 +0300108@pytest.fixture(scope='class')
109def enable_openstack_update(reclass_actions, salt_actions):
110 param = "parameters._param.openstack_upgrade_enabled"
111 context_file = "cluster/*/infra/init.yml"
112
113 LOG.info("Enable openstack_upgrade_enabled in reclass")
114 reclass_actions.add_bool_key(param, "True", context_file)
115 salt_actions.run_state("*", "saltutil.refresh_pillar")
116 yield True
117 LOG.info("Disable openstack_upgrade_enabled in reclass")
118 reclass_actions.add_bool_key(param, "False", context_file)
119 salt_actions.run_state("*", "saltutil.refresh_pillar")
120
121
Hanna Arhipova745fdbb2020-03-30 14:40:44 +0300122@pytest.mark.usefixtures("switch_to_proposed_pipelines",
123 "wa_for_sphinx_prod34406")
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300124class TestUpdateMcpCluster(object):
125 """
126 Following the steps in
Hanna Arhipova94a8abe2019-08-22 14:11:46 +0300127 https://docs.mirantis.com/mcp/master/mcp-operations-guide/update-upgrade/minor-update.html#minor-update
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300128 """
129
130 @pytest.mark.grab_versions
131 @pytest.mark.parametrize("_", [settings.ENV_NAME])
132 @pytest.mark.run_mcp_update
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300133 def test_update_drivetrain(self, salt_actions, drivetrain_actions,
Hanna Arhipova19429962019-10-17 15:16:49 +0300134 show_step, _):
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300135 """Updating DriveTrain component to release/proposed/2019.2.0 version
136
137 Scenario:
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300138 1. Add workaround for PROD-32751
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300139 2. Run job git-mirror-downstream-mk-pipelines
140 3. Run job git-mirror-downstream-pipeline-library
141 4. If jobs are passed then start 'Deploy - upgrade MCP Drivetrain'
142
Hanna Arhipovad35a29b2019-09-04 13:24:06 +0300143 Duration: ~70 min
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300144 """
145 salt = salt_actions
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300146 dt = drivetrain_actions
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300147
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300148 # #################### Add workaround for PROD-32751 #################
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300149 show_step(1)
150
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300151 # FIXME: workaround for PROD-32751
152 salt.cmd_run("cfg01*", "cd /srv/salt/reclass; git add -u && \
153 git commit --allow-empty -m 'Cluster model update'")
154
155 # ################### Downstream mk-pipelines #########################
156 show_step(2)
157 job_name = 'git-mirror-downstream-mk-pipelines'
158 job_parameters = {
159 'BRANCHES': 'release/proposed/2019.2.0'
160 }
Hanna Arhipovaa85bfa62020-01-03 18:49:15 +0200161 update_pipelines = dt.start_job_on_jenkins(
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300162 job_name=job_name,
163 job_parameters=job_parameters)
164
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300165 assert update_pipelines == 'SUCCESS'
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300166
167 # ################### Downstream pipeline-library ####################
168 show_step(3)
169 job_name = 'git-mirror-downstream-pipeline-library'
170 job_parameters = {
171 'BRANCHES': 'release/proposed/2019.2.0'
172 }
Hanna Arhipovaa85bfa62020-01-03 18:49:15 +0200173 update_pipeline_library = dt.start_job_on_jenkins(
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300174 job_name=job_name,
175 job_parameters=job_parameters)
176
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300177 assert update_pipeline_library == 'SUCCESS'
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300178
179 # ################### Start 'Deploy - upgrade MCP Drivetrain' job #####
180 show_step(4)
181
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300182 job_name = 'upgrade-mcp-release'
183 job_parameters = {
Hanna Arhipovad35a29b2019-09-04 13:24:06 +0300184 'GIT_REFSPEC': 'release/proposed/2019.2.0',
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300185 'MK_PIPELINES_REFSPEC': 'release/proposed/2019.2.0',
186 'TARGET_MCP_VERSION': '2019.2.0'
187 }
Hanna Arhipovaa85bfa62020-01-03 18:49:15 +0200188 update_drivetrain = dt.start_job_on_jenkins(
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300189 job_name=job_name,
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300190 job_parameters=job_parameters,
Hanna Arhipova85db4952020-03-31 20:20:06 +0300191 build_timeout=3 * 60 * 60)
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300192
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300193 assert update_drivetrain == 'SUCCESS'
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300194
Hanna Arhipova94a8abe2019-08-22 14:11:46 +0300195 @pytest.mark.grab_versions
196 @pytest.mark.parametrize("_", [settings.ENV_NAME])
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300197 @pytest.mark.run_mcp_update
Hanna Arhipovacc3759b2019-08-28 16:01:11 +0300198 def test_update_glusterfs(self, salt_actions, reclass_actions,
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300199 drivetrain_actions, show_step, _):
Hanna Arhipovacc3759b2019-08-28 16:01:11 +0300200 """ Upgrade GlusterFS
201 Scenario:
202 1. In infra/init.yml in Reclass, add the glusterfs_version parameter
203 2. Start linux.system.repo state
204 3. Start "update-glusterfs" job
205 4. Check version for GlusterFS servers
206 5. Check version for GlusterFS clients
207
208 """
209 salt = salt_actions
210 reclass = reclass_actions
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300211 dt = drivetrain_actions
Hanna Arhipovacc3759b2019-08-28 16:01:11 +0300212
Hanna Arhipovacc3759b2019-08-28 16:01:11 +0300213 # ############## Change reclass ######################################
214 show_step(1)
215 reclass.add_key(
216 "parameters._param.linux_system_repo_mcp_glusterfs_version_number",
217 "5",
218 "cluster/*/infra/init.yml"
219 )
220 # ################# Run linux.system state ###########################
221 show_step(2)
222 salt.enforce_state("*", "linux.system.repo")
223
224 # ############## Start deploy-upgrade-galera job #####################
225 show_step(3)
Hanna Arhipovacc3759b2019-08-28 16:01:11 +0300226 job_name = 'update-glusterfs'
227
Hanna Arhipovaa85bfa62020-01-03 18:49:15 +0200228 update_glusterfs = dt.start_job_on_jenkins(
Hanna Arhipovacc3759b2019-08-28 16:01:11 +0300229 job_name=job_name,
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300230 build_timeout=40 * 60)
Hanna Arhipovacc3759b2019-08-28 16:01:11 +0300231
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300232 assert update_glusterfs == 'SUCCESS'
Hanna Arhipovacc3759b2019-08-28 16:01:11 +0300233
234 # ################ Check GlusterFS version for servers ##############
235 show_step(4)
236 gluster_server_versions_by_nodes = salt.cmd_run(
237 "I@glusterfs:server",
238 "glusterd --version|head -n1")[0]
239
Hanna Arhipova19429962019-10-17 15:16:49 +0300240 assert has_only_similar(gluster_server_versions_by_nodes), \
Hanna Arhipovacc3759b2019-08-28 16:01:11 +0300241 gluster_server_versions_by_nodes
242
243 # ################ Check GlusterFS version for clients ##############
244 show_step(5)
245 gluster_client_versions_by_nodes = salt.cmd_run(
246 "I@glusterfs:client",
247 "glusterfs --version|head -n1")[0]
248
249 assert has_only_similar(gluster_client_versions_by_nodes), \
250 gluster_client_versions_by_nodes
251
252 @pytest.mark.grab_versions
253 @pytest.mark.parametrize("_", [settings.ENV_NAME])
254 @pytest.mark.run_mcp_update
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300255 def test_update_galera(self, salt_actions, reclass_actions,
256 drivetrain_actions, show_step, _):
Hanna Arhipova94a8abe2019-08-22 14:11:46 +0300257 """ Upgrade Galera automatically
258
259 Scenario:
260 1. Include the Galera upgrade pipeline job to DriveTrain
261 2. Apply the jenkins.client state on the Jenkins nodes
262 3. set the openstack_upgrade_enabled parameter to true
263 4. Refresh pillars
264 5. Add repositories with new Galera packages
265 6. Start job from Jenkins
266 """
267 salt = salt_actions
268 reclass = reclass_actions
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300269 dt = drivetrain_actions
Hanna Arhipova94a8abe2019-08-22 14:11:46 +0300270 # ################### Enable pipeline #################################
271 show_step(1)
272 reclass.add_class(
273 "system.jenkins.client.job.deploy.update.upgrade_galera",
274 "cluster/*/cicd/control/leader.yml")
275 show_step(2)
276 salt.enforce_state("I@jenkins:client", "jenkins.client")
277
278 # ############### Enable automatic upgrade ############################
279 show_step(3)
280 reclass.add_bool_key("parameters._param.openstack_upgrade_enabled",
281 "True",
282 "cluster/*/infra/init.yml")
283
284 show_step(4)
Hanna Arhipova7cfeb072019-10-11 15:04:10 +0300285 salt.run_state("dbs*", "saltutil.refresh_pillar")
Hanna Arhipova94a8abe2019-08-22 14:11:46 +0300286
287 # ############# Add repositories with new Galera packages #######
288 show_step(5)
289 salt.enforce_state("dbs*", "linux.system.repo")
290 salt.enforce_state("cfg*", "salt.master")
291
Hanna Arhipova94a8abe2019-08-22 14:11:46 +0300292 # #################### Login Jenkins on cid01 node ###################
293 show_step(6)
294
Hanna Arhipova94a8abe2019-08-22 14:11:46 +0300295 job_name = 'deploy-upgrade-galera'
296 job_parameters = {
297 'INTERACTIVE': 'false'
298 }
299
Hanna Arhipovaa85bfa62020-01-03 18:49:15 +0200300 update_galera = dt.start_job_on_jenkins(
Hanna Arhipova94a8abe2019-08-22 14:11:46 +0300301 job_name=job_name,
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300302 job_parameters=job_parameters,
303 build_timeout=40 * 60)
Hanna Arhipova94a8abe2019-08-22 14:11:46 +0300304
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300305 assert update_galera == 'SUCCESS'
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300306
307 @pytest.fixture
308 def disable_automatic_failover_neutron_for_test(self, salt_actions):
309 """
310 On each OpenStack controller node, modify the neutron.conf file
311 Restart the neutron-server service
312 """
Hanna Arhipova19429962019-10-17 15:16:49 +0300313
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300314 def comment_line(node, file_name, word):
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300315 """
316 Adds '#' before the specific line in specific file
317
318 :param node: string, salt target of node where the file locates
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300319 :param file_name: string, full path to the file
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300320 :param word: string, the begin of line which should be commented
321 :return: None
322 """
323 salt_actions.cmd_run(node,
324 "sed -i 's/^{word}/#{word}/' {file}".
325 format(word=word,
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300326 file=file_name))
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300327
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300328 def add_line(node, file_name, line):
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300329 """
330 Appends line to the end of file
331
332 :param node: string, salt target of node where the file locates
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300333 :param file_name: string, full path to the file
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300334 :param line: string, line that should be added
335 :return: None
336 """
337 salt_actions.cmd_run(node, "echo {line} >> {file}".format(
Hanna Arhipova19429962019-10-17 15:16:49 +0300338 line=line,
339 file=file_name))
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300340
341 neutron_conf = '/etc/neutron/neutron.conf'
342 neutron_server = "I@neutron:server"
343 # ######## Create backup for config file #######################
344 salt_actions.cmd_run(
345 neutron_server,
346 "cp -p {file} {file}.backup".format(file=neutron_conf))
347
348 # ## Change parameters in neutron.conf'
349 comment_line(neutron_server, neutron_conf,
Hanna Arhipova19429962019-10-17 15:16:49 +0300350 "allow_automatic_l3agent_failover", )
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300351 comment_line(neutron_server, neutron_conf,
352 "allow_automatic_dhcp_failover")
353 add_line(neutron_server, neutron_conf,
354 "allow_automatic_dhcp_failover = false")
355 add_line(neutron_server, neutron_conf,
356 "allow_automatic_l3agent_failover = false")
357
358 # ## Apply changed config to the neutron-server service
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300359 result = salt_actions.cmd_run(neutron_server,
360 "service neutron-server restart")
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300361 # TODO: add check that neutron-server is up and running
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300362 yield result
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300363 # ## Revert file changes
364 salt_actions.cmd_run(
365 neutron_server,
366 "cp -p {file}.backup {file}".format(file=neutron_conf))
367 salt_actions.cmd_run(neutron_server,
368 "service neutron-server restart")
369
370 @pytest.fixture
371 def disable_neutron_agents_for_test(self, salt_actions):
372 """
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300373 Disable the neutron services before the test and
374 enable it after test
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300375 """
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300376 result = salt_actions.cmd_run("I@neutron:server", """
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300377 service neutron-dhcp-agent stop && \
378 service neutron-l3-agent stop && \
379 service neutron-metadata-agent stop && \
380 service neutron-openvswitch-agent stop
381 """)
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300382 yield result
383 #
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300384 salt_actions.cmd_run("I@neutron:server", """
385 service neutron-dhcp-agent start && \
386 service neutron-l3-agent start && \
387 service neutron-metadata-agent start && \
388 service neutron-openvswitch-agent start
389 """)
390 # TODO: add check that all services are UP and running
391
392 @pytest.mark.grab_versions
393 @pytest.mark.parametrize("_", [settings.ENV_NAME])
394 @pytest.mark.run_mcp_update
395 def test_update_rabbit(self, salt_actions, reclass_actions,
396 drivetrain_actions, show_step, _,
397 disable_automatic_failover_neutron_for_test,
398 disable_neutron_agents_for_test):
399 """ Updates RabbitMQ
400 Scenario:
401 1. Include the RabbitMQ upgrade pipeline job to DriveTrain
402 2. Add repositories with new RabbitMQ packages
403 3. Start Deploy - upgrade RabbitMQ pipeline
404
405 Updating RabbitMq should be completed before the OpenStack updating
406 process starts
407 """
408 salt = salt_actions
409 reclass = reclass_actions
410 dt = drivetrain_actions
411
412 # ####### Include the RabbitMQ upgrade pipeline job to DriveTrain ####
413 show_step(1)
414 reclass.add_class(
415 "system.jenkins.client.job.deploy.update.upgrade_rabbitmq",
416 "cluster/*/cicd/control/leader.yml")
417 salt.enforce_state("I@jenkins:client", "jenkins.client")
418
419 reclass.add_bool_key("parameters._param.openstack_upgrade_enabled",
420 "True",
421 "cluster/*/infra/init.yml")
422 salt.run_state("I@rabbitmq:server", "saltutil.refresh_pillar")
423
424 # ########### Add repositories with new RabbitMQ packages ############
425 show_step(2)
426 salt.enforce_state("I@rabbitmq:server", "linux.system.repo")
427
428 # ########### Start Deploy - upgrade RabbitMQ pipeline ############
429 show_step(3)
430 job_parameters = {
431 'INTERACTIVE': 'false'
432 }
433
Hanna Arhipovaa85bfa62020-01-03 18:49:15 +0200434 update_rabbit = dt.start_job_on_jenkins(
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300435 job_name='deploy-upgrade-rabbitmq',
436 job_parameters=job_parameters,
437 build_timeout=40 * 60
438 )
439 assert update_rabbit == 'SUCCESS'
Hanna Arhipovad35a29b2019-09-04 13:24:06 +0300440
441 @pytest.mark.grab_versions
442 @pytest.mark.parametrize("_", [settings.ENV_NAME])
443 @pytest.mark.run_mcp_update
444 def test_update_ceph(self, salt_actions, drivetrain_actions, show_step, _):
445 """ Updates Ceph to the latest minor version
446
447 Scenario:
448 1. Add workaround for unhealth Ceph
449 2. Start ceph-upgrade job with default parameters
450 3. Check Ceph version for all nodes
451
452 https://docs.mirantis.com/mcp/master/mcp-operations-guide/update-upgrade/minor-update/ceph-update.html
453 """
454 salt = salt_actions
455 dt = drivetrain_actions
456
457 # ###################### Add workaround for unhealth Ceph ############
458 show_step(1)
459 salt.cmd_run("I@ceph:radosgw",
460 "ceph config set 'mon pg warn max object skew' 20")
461 # ###################### Start ceph-upgrade pipeline #################
462 show_step(2)
463 job_parameters = {}
464
Hanna Arhipovaa85bfa62020-01-03 18:49:15 +0200465 update_ceph = dt.start_job_on_jenkins(
Hanna Arhipovad35a29b2019-09-04 13:24:06 +0300466 job_name='ceph-update',
467 job_parameters=job_parameters)
468
469 assert update_ceph == 'SUCCESS'
470
471 # ########## Verify Ceph version #####################################
472 show_step(3)
473
474 ceph_version_by_nodes = salt.cmd_run(
Hanna Arhipova19429962019-10-17 15:16:49 +0300475 "I@ceph:* and not I@ceph:monitoring and not I@ceph:backup:server",
476 "ceph version")[0]
Hanna Arhipovad35a29b2019-09-04 13:24:06 +0300477
478 assert has_only_similar(ceph_version_by_nodes), ceph_version_by_nodes
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300479
Hanna Arhipovaac008562019-10-17 11:54:23 +0300480 @pytest.mark.grab_versions
481 @pytest.mark.parametrize("_", [settings.ENV_NAME])
482 @pytest.mark.run_mcp_update
483 def test_update_stacklight(self, _, drivetrain_actions):
484 """ Update packages for Stacklight
485 Scenario:
486 1. Start Deploy - upgrade Stacklight job
487 """
488 drivetrain = drivetrain_actions
489
490 job_parameters = {
491 "STAGE_UPGRADE_DOCKER_COMPONENTS": True,
492 "STAGE_UPGRADE_ES_KIBANA": True,
493 "STAGE_UPGRADE_SYSTEM_PART": True
494 }
Hanna Arhipovaa85bfa62020-01-03 18:49:15 +0200495 upgrade_control_pipeline = drivetrain.start_job_on_jenkins(
Hanna Arhipovaac008562019-10-17 11:54:23 +0300496 job_name="stacklight-upgrade",
497 job_parameters=job_parameters)
498
499 assert upgrade_control_pipeline == 'SUCCESS'
500
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300501
Hanna Arhipova19429962019-10-17 15:16:49 +0300502@pytest.mark.usefixtures("switch_to_proposed_pipelines",
503 "enable_openstack_update")
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300504class TestOpenstackUpdate(object):
505
506 @pytest.mark.grab_versions
507 @pytest.mark.run_mcp_update
508 def test__pre_update__enable_pipeline_job(self,
509 reclass_actions, salt_actions,
510 show_step):
511 """ Enable pipeline in the Drivetrain
512
513 Scenario:
514 1. Add deploy.update.* classes to the reclass
515 2. Start jenkins.client salt state
516
517 """
518 salt = salt_actions
519 reclass = reclass_actions
520 show_step(1)
521 reclass.add_class("system.jenkins.client.job.deploy.update.upgrade",
522 "cluster/*/cicd/control/leader.yml")
523
524 reclass.add_class(
525 "system.jenkins.client.job.deploy.update.upgrade_ovs_gateway",
526 "cluster/*/cicd/control/leader.yml")
527
528 reclass.add_class(
529 "system.jenkins.client.job.deploy.update.upgrade_compute",
530 "cluster/*/cicd/control/leader.yml")
531
532 show_step(2)
533 r, errors = salt.enforce_state("I@jenkins:client", "jenkins.client")
534 assert errors is None
535
536 @pytest.mark.grab_versions
537 @pytest.mark.parametrize('target', get_control_plane_targets())
538 @pytest.mark.run_mcp_update
Hanna Arhipova19429962019-10-17 15:16:49 +0300539 def test__update__control_plane(self, drivetrain_actions, target):
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300540 """Start 'Deploy - upgrade control VMs' for specific node
541 """
542 job_parameters = {
543 "TARGET_SERVERS": target,
Hanna Arhipova606d5182019-12-13 13:23:55 +0200544 "OS_DIST_UPGRADE": True,
PGlazoved19b352020-05-21 16:42:27 +0400545 "UPGRADE_SALTSTACK": False,
Hanna Arhipova606d5182019-12-13 13:23:55 +0200546 "OS_UPGRADE": True,
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300547 "INTERACTIVE": False}
Hanna Arhipovaa85bfa62020-01-03 18:49:15 +0200548 upgrade_control_pipeline = drivetrain_actions.start_job_on_jenkins(
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300549 job_name="deploy-upgrade-control",
550 job_parameters=job_parameters)
551
552 assert upgrade_control_pipeline == 'SUCCESS'
553
554 @pytest.mark.grab_versions
555 @pytest.mark.run_mcp_update
Hanna Arhipova606d5182019-12-13 13:23:55 +0200556 def test__update__data_plane(self, drivetrain_actions, salt_actions):
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300557 """Start 'Deploy - upgrade OVS gateway'
558 """
Hanna Arhipova606d5182019-12-13 13:23:55 +0200559 if not salt_actions.cmd_run("gtw*", "test.ping")[0].keys():
560 pytest.skip("This deployment doesn't have gtw* nodes")
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300561 job_parameters = {
Hanna Arhipova606d5182019-12-13 13:23:55 +0200562 "OS_DIST_UPGRADE": True,
563 "OS_UPGRADE": True,
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300564 "INTERACTIVE": False}
Hanna Arhipovaa85bfa62020-01-03 18:49:15 +0200565 upgrade_data_pipeline = drivetrain_actions.start_job_on_jenkins(
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300566 job_name="deploy-upgrade-ovs-gateway",
567 job_parameters=job_parameters)
568
569 assert upgrade_data_pipeline == 'SUCCESS'
Hanna Arhipova19429962019-10-17 15:16:49 +0300570
571 @pytest.mark.grab_versions
572 @pytest.mark.run_mcp_update
573 def test__update__computes(self, drivetrain_actions):
574 """Start 'Deploy - upgrade computes'
575 """
576 job_parameters = {
Hanna Arhipova606d5182019-12-13 13:23:55 +0200577 "OS_DIST_UPGRADE": True,
578 "OS_UPGRADE": True,
Hanna Arhipova19429962019-10-17 15:16:49 +0300579 "INTERACTIVE": False}
Hanna Arhipovaa85bfa62020-01-03 18:49:15 +0200580 upgrade_compute_pipeline = drivetrain_actions.start_job_on_jenkins(
Hanna Arhipova19429962019-10-17 15:16:49 +0300581 job_name="deploy-upgrade-compute",
582 job_parameters=job_parameters)
583
584 assert upgrade_compute_pipeline == 'SUCCESS'