blob: ab38698ed4727473ad167c6f1e61ed472f16cdf4 [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 Arhipova19429962019-10-17 15:16:49 +030098@pytest.fixture(scope='class')
99def enable_openstack_update(reclass_actions, salt_actions):
100 param = "parameters._param.openstack_upgrade_enabled"
101 context_file = "cluster/*/infra/init.yml"
102
103 LOG.info("Enable openstack_upgrade_enabled in reclass")
104 reclass_actions.add_bool_key(param, "True", context_file)
105 salt_actions.run_state("*", "saltutil.refresh_pillar")
106 yield True
107 LOG.info("Disable openstack_upgrade_enabled in reclass")
108 reclass_actions.add_bool_key(param, "False", context_file)
109 salt_actions.run_state("*", "saltutil.refresh_pillar")
110
111
112@pytest.mark.usefixtures("switch_to_proposed_pipelines")
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300113class TestUpdateMcpCluster(object):
114 """
115 Following the steps in
Hanna Arhipova94a8abe2019-08-22 14:11:46 +0300116 https://docs.mirantis.com/mcp/master/mcp-operations-guide/update-upgrade/minor-update.html#minor-update
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300117 """
118
119 @pytest.mark.grab_versions
120 @pytest.mark.parametrize("_", [settings.ENV_NAME])
121 @pytest.mark.run_mcp_update
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300122 def test_update_drivetrain(self, salt_actions, drivetrain_actions,
Hanna Arhipova19429962019-10-17 15:16:49 +0300123 show_step, _):
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300124 """Updating DriveTrain component to release/proposed/2019.2.0 version
125
126 Scenario:
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300127 1. Add workaround for PROD-32751
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300128 2. Run job git-mirror-downstream-mk-pipelines
129 3. Run job git-mirror-downstream-pipeline-library
130 4. If jobs are passed then start 'Deploy - upgrade MCP Drivetrain'
131
Hanna Arhipovad35a29b2019-09-04 13:24:06 +0300132 Duration: ~70 min
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300133 """
134 salt = salt_actions
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300135 dt = drivetrain_actions
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300136
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300137 # #################### Add workaround for PROD-32751 #################
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300138 show_step(1)
139
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300140 # FIXME: workaround for PROD-32751
141 salt.cmd_run("cfg01*", "cd /srv/salt/reclass; git add -u && \
142 git commit --allow-empty -m 'Cluster model update'")
143
144 # ################### Downstream mk-pipelines #########################
145 show_step(2)
146 job_name = 'git-mirror-downstream-mk-pipelines'
147 job_parameters = {
148 'BRANCHES': 'release/proposed/2019.2.0'
149 }
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300150 update_pipelines = dt.start_job_on_cid_jenkins(
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300151 job_name=job_name,
152 job_parameters=job_parameters)
153
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300154 assert update_pipelines == 'SUCCESS'
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300155
156 # ################### Downstream pipeline-library ####################
157 show_step(3)
158 job_name = 'git-mirror-downstream-pipeline-library'
159 job_parameters = {
160 'BRANCHES': 'release/proposed/2019.2.0'
161 }
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300162 update_pipeline_library = dt.start_job_on_cid_jenkins(
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300163 job_name=job_name,
164 job_parameters=job_parameters)
165
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300166 assert update_pipeline_library == 'SUCCESS'
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300167
168 # ################### Start 'Deploy - upgrade MCP Drivetrain' job #####
169 show_step(4)
170
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300171 job_name = 'upgrade-mcp-release'
172 job_parameters = {
Hanna Arhipovad35a29b2019-09-04 13:24:06 +0300173 'GIT_REFSPEC': 'release/proposed/2019.2.0',
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300174 'MK_PIPELINES_REFSPEC': 'release/proposed/2019.2.0',
175 'TARGET_MCP_VERSION': '2019.2.0'
176 }
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300177 update_drivetrain = dt.start_job_on_cid_jenkins(
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300178 job_name=job_name,
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300179 job_parameters=job_parameters,
Hanna Arhipova19429962019-10-17 15:16:49 +0300180 build_timeout=90 * 60)
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300181
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300182 assert update_drivetrain == 'SUCCESS'
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300183
Hanna Arhipova94a8abe2019-08-22 14:11:46 +0300184 @pytest.mark.grab_versions
185 @pytest.mark.parametrize("_", [settings.ENV_NAME])
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300186 @pytest.mark.run_mcp_update
Hanna Arhipovacc3759b2019-08-28 16:01:11 +0300187 def test_update_glusterfs(self, salt_actions, reclass_actions,
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300188 drivetrain_actions, show_step, _):
Hanna Arhipovacc3759b2019-08-28 16:01:11 +0300189 """ Upgrade GlusterFS
190 Scenario:
191 1. In infra/init.yml in Reclass, add the glusterfs_version parameter
192 2. Start linux.system.repo state
193 3. Start "update-glusterfs" job
194 4. Check version for GlusterFS servers
195 5. Check version for GlusterFS clients
196
197 """
198 salt = salt_actions
199 reclass = reclass_actions
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300200 dt = drivetrain_actions
Hanna Arhipovacc3759b2019-08-28 16:01:11 +0300201
Hanna Arhipovacc3759b2019-08-28 16:01:11 +0300202 # ############## Change reclass ######################################
203 show_step(1)
204 reclass.add_key(
205 "parameters._param.linux_system_repo_mcp_glusterfs_version_number",
206 "5",
207 "cluster/*/infra/init.yml"
208 )
209 # ################# Run linux.system state ###########################
210 show_step(2)
211 salt.enforce_state("*", "linux.system.repo")
212
213 # ############## Start deploy-upgrade-galera job #####################
214 show_step(3)
Hanna Arhipovacc3759b2019-08-28 16:01:11 +0300215 job_name = 'update-glusterfs'
216
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300217 update_glusterfs = dt.start_job_on_cid_jenkins(
Hanna Arhipovacc3759b2019-08-28 16:01:11 +0300218 job_name=job_name,
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300219 build_timeout=40 * 60)
Hanna Arhipovacc3759b2019-08-28 16:01:11 +0300220
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300221 assert update_glusterfs == 'SUCCESS'
Hanna Arhipovacc3759b2019-08-28 16:01:11 +0300222
223 # ################ Check GlusterFS version for servers ##############
224 show_step(4)
225 gluster_server_versions_by_nodes = salt.cmd_run(
226 "I@glusterfs:server",
227 "glusterd --version|head -n1")[0]
228
Hanna Arhipova19429962019-10-17 15:16:49 +0300229 assert has_only_similar(gluster_server_versions_by_nodes), \
Hanna Arhipovacc3759b2019-08-28 16:01:11 +0300230 gluster_server_versions_by_nodes
231
232 # ################ Check GlusterFS version for clients ##############
233 show_step(5)
234 gluster_client_versions_by_nodes = salt.cmd_run(
235 "I@glusterfs:client",
236 "glusterfs --version|head -n1")[0]
237
238 assert has_only_similar(gluster_client_versions_by_nodes), \
239 gluster_client_versions_by_nodes
240
241 @pytest.mark.grab_versions
242 @pytest.mark.parametrize("_", [settings.ENV_NAME])
243 @pytest.mark.run_mcp_update
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300244 def test_update_galera(self, salt_actions, reclass_actions,
245 drivetrain_actions, show_step, _):
Hanna Arhipova94a8abe2019-08-22 14:11:46 +0300246 """ Upgrade Galera automatically
247
248 Scenario:
249 1. Include the Galera upgrade pipeline job to DriveTrain
250 2. Apply the jenkins.client state on the Jenkins nodes
251 3. set the openstack_upgrade_enabled parameter to true
252 4. Refresh pillars
253 5. Add repositories with new Galera packages
254 6. Start job from Jenkins
255 """
256 salt = salt_actions
257 reclass = reclass_actions
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300258 dt = drivetrain_actions
Hanna Arhipova94a8abe2019-08-22 14:11:46 +0300259 # ################### Enable pipeline #################################
260 show_step(1)
261 reclass.add_class(
262 "system.jenkins.client.job.deploy.update.upgrade_galera",
263 "cluster/*/cicd/control/leader.yml")
264 show_step(2)
265 salt.enforce_state("I@jenkins:client", "jenkins.client")
266
267 # ############### Enable automatic upgrade ############################
268 show_step(3)
269 reclass.add_bool_key("parameters._param.openstack_upgrade_enabled",
270 "True",
271 "cluster/*/infra/init.yml")
272
273 show_step(4)
Hanna Arhipova7cfeb072019-10-11 15:04:10 +0300274 salt.run_state("dbs*", "saltutil.refresh_pillar")
Hanna Arhipova94a8abe2019-08-22 14:11:46 +0300275
276 # ############# Add repositories with new Galera packages #######
277 show_step(5)
278 salt.enforce_state("dbs*", "linux.system.repo")
279 salt.enforce_state("cfg*", "salt.master")
280
Hanna Arhipova94a8abe2019-08-22 14:11:46 +0300281 # #################### Login Jenkins on cid01 node ###################
282 show_step(6)
283
Hanna Arhipova94a8abe2019-08-22 14:11:46 +0300284 job_name = 'deploy-upgrade-galera'
285 job_parameters = {
286 'INTERACTIVE': 'false'
287 }
288
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300289 update_galera = dt.start_job_on_cid_jenkins(
Hanna Arhipova94a8abe2019-08-22 14:11:46 +0300290 job_name=job_name,
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300291 job_parameters=job_parameters,
292 build_timeout=40 * 60)
Hanna Arhipova94a8abe2019-08-22 14:11:46 +0300293
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300294 assert update_galera == 'SUCCESS'
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300295
296 @pytest.fixture
297 def disable_automatic_failover_neutron_for_test(self, salt_actions):
298 """
299 On each OpenStack controller node, modify the neutron.conf file
300 Restart the neutron-server service
301 """
Hanna Arhipova19429962019-10-17 15:16:49 +0300302
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300303 def comment_line(node, file_name, word):
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300304 """
305 Adds '#' before the specific line in specific file
306
307 :param node: string, salt target of node where the file locates
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300308 :param file_name: string, full path to the file
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300309 :param word: string, the begin of line which should be commented
310 :return: None
311 """
312 salt_actions.cmd_run(node,
313 "sed -i 's/^{word}/#{word}/' {file}".
314 format(word=word,
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300315 file=file_name))
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300316
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300317 def add_line(node, file_name, line):
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300318 """
319 Appends line to the end of file
320
321 :param node: string, salt target of node where the file locates
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300322 :param file_name: string, full path to the file
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300323 :param line: string, line that should be added
324 :return: None
325 """
326 salt_actions.cmd_run(node, "echo {line} >> {file}".format(
Hanna Arhipova19429962019-10-17 15:16:49 +0300327 line=line,
328 file=file_name))
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300329
330 neutron_conf = '/etc/neutron/neutron.conf'
331 neutron_server = "I@neutron:server"
332 # ######## Create backup for config file #######################
333 salt_actions.cmd_run(
334 neutron_server,
335 "cp -p {file} {file}.backup".format(file=neutron_conf))
336
337 # ## Change parameters in neutron.conf'
338 comment_line(neutron_server, neutron_conf,
Hanna Arhipova19429962019-10-17 15:16:49 +0300339 "allow_automatic_l3agent_failover", )
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300340 comment_line(neutron_server, neutron_conf,
341 "allow_automatic_dhcp_failover")
342 add_line(neutron_server, neutron_conf,
343 "allow_automatic_dhcp_failover = false")
344 add_line(neutron_server, neutron_conf,
345 "allow_automatic_l3agent_failover = false")
346
347 # ## Apply changed config to the neutron-server service
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300348 result = salt_actions.cmd_run(neutron_server,
349 "service neutron-server restart")
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300350 # TODO: add check that neutron-server is up and running
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300351 yield result
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300352 # ## Revert file changes
353 salt_actions.cmd_run(
354 neutron_server,
355 "cp -p {file}.backup {file}".format(file=neutron_conf))
356 salt_actions.cmd_run(neutron_server,
357 "service neutron-server restart")
358
359 @pytest.fixture
360 def disable_neutron_agents_for_test(self, salt_actions):
361 """
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300362 Disable the neutron services before the test and
363 enable it after test
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300364 """
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300365 result = salt_actions.cmd_run("I@neutron:server", """
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300366 service neutron-dhcp-agent stop && \
367 service neutron-l3-agent stop && \
368 service neutron-metadata-agent stop && \
369 service neutron-openvswitch-agent stop
370 """)
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300371 yield result
372 #
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300373 salt_actions.cmd_run("I@neutron:server", """
374 service neutron-dhcp-agent start && \
375 service neutron-l3-agent start && \
376 service neutron-metadata-agent start && \
377 service neutron-openvswitch-agent start
378 """)
379 # TODO: add check that all services are UP and running
380
381 @pytest.mark.grab_versions
382 @pytest.mark.parametrize("_", [settings.ENV_NAME])
383 @pytest.mark.run_mcp_update
384 def test_update_rabbit(self, salt_actions, reclass_actions,
385 drivetrain_actions, show_step, _,
386 disable_automatic_failover_neutron_for_test,
387 disable_neutron_agents_for_test):
388 """ Updates RabbitMQ
389 Scenario:
390 1. Include the RabbitMQ upgrade pipeline job to DriveTrain
391 2. Add repositories with new RabbitMQ packages
392 3. Start Deploy - upgrade RabbitMQ pipeline
393
394 Updating RabbitMq should be completed before the OpenStack updating
395 process starts
396 """
397 salt = salt_actions
398 reclass = reclass_actions
399 dt = drivetrain_actions
400
401 # ####### Include the RabbitMQ upgrade pipeline job to DriveTrain ####
402 show_step(1)
403 reclass.add_class(
404 "system.jenkins.client.job.deploy.update.upgrade_rabbitmq",
405 "cluster/*/cicd/control/leader.yml")
406 salt.enforce_state("I@jenkins:client", "jenkins.client")
407
408 reclass.add_bool_key("parameters._param.openstack_upgrade_enabled",
409 "True",
410 "cluster/*/infra/init.yml")
411 salt.run_state("I@rabbitmq:server", "saltutil.refresh_pillar")
412
413 # ########### Add repositories with new RabbitMQ packages ############
414 show_step(2)
415 salt.enforce_state("I@rabbitmq:server", "linux.system.repo")
416
417 # ########### Start Deploy - upgrade RabbitMQ pipeline ############
418 show_step(3)
419 job_parameters = {
420 'INTERACTIVE': 'false'
421 }
422
423 update_rabbit = dt.start_job_on_cid_jenkins(
424 job_name='deploy-upgrade-rabbitmq',
425 job_parameters=job_parameters,
426 build_timeout=40 * 60
427 )
428 assert update_rabbit == 'SUCCESS'
Hanna Arhipovad35a29b2019-09-04 13:24:06 +0300429
430 @pytest.mark.grab_versions
431 @pytest.mark.parametrize("_", [settings.ENV_NAME])
432 @pytest.mark.run_mcp_update
433 def test_update_ceph(self, salt_actions, drivetrain_actions, show_step, _):
434 """ Updates Ceph to the latest minor version
435
436 Scenario:
437 1. Add workaround for unhealth Ceph
438 2. Start ceph-upgrade job with default parameters
439 3. Check Ceph version for all nodes
440
441 https://docs.mirantis.com/mcp/master/mcp-operations-guide/update-upgrade/minor-update/ceph-update.html
442 """
443 salt = salt_actions
444 dt = drivetrain_actions
445
446 # ###################### Add workaround for unhealth Ceph ############
447 show_step(1)
448 salt.cmd_run("I@ceph:radosgw",
449 "ceph config set 'mon pg warn max object skew' 20")
450 # ###################### Start ceph-upgrade pipeline #################
451 show_step(2)
452 job_parameters = {}
453
454 update_ceph = dt.start_job_on_cid_jenkins(
455 job_name='ceph-update',
456 job_parameters=job_parameters)
457
458 assert update_ceph == 'SUCCESS'
459
460 # ########## Verify Ceph version #####################################
461 show_step(3)
462
463 ceph_version_by_nodes = salt.cmd_run(
Hanna Arhipova19429962019-10-17 15:16:49 +0300464 "I@ceph:* and not I@ceph:monitoring and not I@ceph:backup:server",
465 "ceph version")[0]
Hanna Arhipovad35a29b2019-09-04 13:24:06 +0300466
467 assert has_only_similar(ceph_version_by_nodes), ceph_version_by_nodes
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300468
Hanna Arhipovaac008562019-10-17 11:54:23 +0300469 @pytest.mark.grab_versions
470 @pytest.mark.parametrize("_", [settings.ENV_NAME])
471 @pytest.mark.run_mcp_update
472 def test_update_stacklight(self, _, drivetrain_actions):
473 """ Update packages for Stacklight
474 Scenario:
475 1. Start Deploy - upgrade Stacklight job
476 """
477 drivetrain = drivetrain_actions
478
479 job_parameters = {
480 "STAGE_UPGRADE_DOCKER_COMPONENTS": True,
481 "STAGE_UPGRADE_ES_KIBANA": True,
482 "STAGE_UPGRADE_SYSTEM_PART": True
483 }
484 upgrade_control_pipeline = drivetrain.start_job_on_cid_jenkins(
485 job_name="stacklight-upgrade",
486 job_parameters=job_parameters)
487
488 assert upgrade_control_pipeline == 'SUCCESS'
489
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300490
Hanna Arhipova19429962019-10-17 15:16:49 +0300491@pytest.mark.usefixtures("switch_to_proposed_pipelines",
492 "enable_openstack_update")
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300493class TestOpenstackUpdate(object):
494
495 @pytest.mark.grab_versions
496 @pytest.mark.run_mcp_update
497 def test__pre_update__enable_pipeline_job(self,
498 reclass_actions, salt_actions,
499 show_step):
500 """ Enable pipeline in the Drivetrain
501
502 Scenario:
503 1. Add deploy.update.* classes to the reclass
504 2. Start jenkins.client salt state
505
506 """
507 salt = salt_actions
508 reclass = reclass_actions
509 show_step(1)
510 reclass.add_class("system.jenkins.client.job.deploy.update.upgrade",
511 "cluster/*/cicd/control/leader.yml")
512
513 reclass.add_class(
514 "system.jenkins.client.job.deploy.update.upgrade_ovs_gateway",
515 "cluster/*/cicd/control/leader.yml")
516
517 reclass.add_class(
518 "system.jenkins.client.job.deploy.update.upgrade_compute",
519 "cluster/*/cicd/control/leader.yml")
520
521 show_step(2)
522 r, errors = salt.enforce_state("I@jenkins:client", "jenkins.client")
523 assert errors is None
524
525 @pytest.mark.grab_versions
526 @pytest.mark.parametrize('target', get_control_plane_targets())
527 @pytest.mark.run_mcp_update
Hanna Arhipova19429962019-10-17 15:16:49 +0300528 def test__update__control_plane(self, drivetrain_actions, target):
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300529 """Start 'Deploy - upgrade control VMs' for specific node
530 """
531 job_parameters = {
532 "TARGET_SERVERS": target,
533 "INTERACTIVE": False}
534 upgrade_control_pipeline = drivetrain_actions.start_job_on_cid_jenkins(
535 job_name="deploy-upgrade-control",
536 job_parameters=job_parameters)
537
538 assert upgrade_control_pipeline == 'SUCCESS'
539
540 @pytest.mark.grab_versions
541 @pytest.mark.run_mcp_update
542 def test__update__data_plane(self, drivetrain_actions):
543 """Start 'Deploy - upgrade OVS gateway'
544 """
545 job_parameters = {
546 "INTERACTIVE": False}
547 upgrade_data_pipeline = drivetrain_actions.start_job_on_cid_jenkins(
548 job_name="deploy-upgrade-ovs-gateway",
549 job_parameters=job_parameters)
550
551 assert upgrade_data_pipeline == 'SUCCESS'
Hanna Arhipova19429962019-10-17 15:16:49 +0300552
553 @pytest.mark.grab_versions
554 @pytest.mark.run_mcp_update
555 def test__update__computes(self, drivetrain_actions):
556 """Start 'Deploy - upgrade computes'
557 """
558 job_parameters = {
559 "INTERACTIVE": False}
560 upgrade_compute_pipeline = drivetrain_actions.start_job_on_cid_jenkins(
561 job_name="deploy-upgrade-compute",
562 job_parameters=job_parameters)
563
564 assert upgrade_compute_pipeline == 'SUCCESS'