blob: d1b30eab852595d185a4ccafb46d27aaf89e4dcb [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 Arhipova745fdbb2020-03-30 14:40:44 +0300101 reclass_actions.add_key(
Hanna Arhipovaec201e72020-10-26 17:14:25 +0200102 "parameters._param.galera_clustercheck_password",
Hanna Arhipova745fdbb2020-03-30 14:40:44 +0300103 "a"*32,
104 "cluster/*/infra/secrets.yml")
Hanna Arhipovaec201e72020-10-26 17:14:25 +0200105 salt_actions.run_state(
106 "I@galera:master or I@galera:slave", "saltutil.refresh_pillar")
107 salt_actions.enforce_state(
108 "I@galera:master or I@galera:slave", "galera")
109 salt_actions.enforce_state(
110 "I@galera:master or I@galera:slave", "haproxy")
Hanna Arhipova745fdbb2020-03-30 14:40:44 +0300111
112
Hanna Arhipova19429962019-10-17 15:16:49 +0300113@pytest.fixture(scope='class')
114def enable_openstack_update(reclass_actions, salt_actions):
115 param = "parameters._param.openstack_upgrade_enabled"
116 context_file = "cluster/*/infra/init.yml"
117
118 LOG.info("Enable openstack_upgrade_enabled in reclass")
119 reclass_actions.add_bool_key(param, "True", context_file)
120 salt_actions.run_state("*", "saltutil.refresh_pillar")
121 yield True
122 LOG.info("Disable openstack_upgrade_enabled in reclass")
123 reclass_actions.add_bool_key(param, "False", context_file)
124 salt_actions.run_state("*", "saltutil.refresh_pillar")
125
126
Hanna Arhipova745fdbb2020-03-30 14:40:44 +0300127@pytest.mark.usefixtures("switch_to_proposed_pipelines",
Hanna Arhipovaec201e72020-10-26 17:14:25 +0200128 "wa_for_galera_clustercheck_password_prod35705")
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300129class TestUpdateMcpCluster(object):
130 """
131 Following the steps in
Hanna Arhipova94a8abe2019-08-22 14:11:46 +0300132 https://docs.mirantis.com/mcp/master/mcp-operations-guide/update-upgrade/minor-update.html#minor-update
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300133 """
134
135 @pytest.mark.grab_versions
136 @pytest.mark.parametrize("_", [settings.ENV_NAME])
137 @pytest.mark.run_mcp_update
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300138 def test_update_drivetrain(self, salt_actions, drivetrain_actions,
Hanna Arhipova19429962019-10-17 15:16:49 +0300139 show_step, _):
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300140 """Updating DriveTrain component to release/proposed/2019.2.0 version
141
142 Scenario:
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300143 1. Add workaround for PROD-32751
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300144 2. Run job git-mirror-downstream-mk-pipelines
145 3. Run job git-mirror-downstream-pipeline-library
146 4. If jobs are passed then start 'Deploy - upgrade MCP Drivetrain'
147
Hanna Arhipovad35a29b2019-09-04 13:24:06 +0300148 Duration: ~70 min
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300149 """
150 salt = salt_actions
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300151 dt = drivetrain_actions
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300152
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300153 # #################### Add workaround for PROD-32751 #################
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300154 show_step(1)
155
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300156 # FIXME: workaround for PROD-32751
157 salt.cmd_run("cfg01*", "cd /srv/salt/reclass; git add -u && \
158 git commit --allow-empty -m 'Cluster model update'")
159
160 # ################### Downstream mk-pipelines #########################
161 show_step(2)
162 job_name = 'git-mirror-downstream-mk-pipelines'
163 job_parameters = {
164 'BRANCHES': 'release/proposed/2019.2.0'
165 }
Hanna Arhipovaa85bfa62020-01-03 18:49:15 +0200166 update_pipelines = dt.start_job_on_jenkins(
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300167 job_name=job_name,
Hanna Arhipovac3c59292020-04-23 16:29:09 +0300168 job_parameters=job_parameters,
169 verbose=True)
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300170
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300171 assert update_pipelines == 'SUCCESS'
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300172
173 # ################### Downstream pipeline-library ####################
174 show_step(3)
175 job_name = 'git-mirror-downstream-pipeline-library'
176 job_parameters = {
177 'BRANCHES': 'release/proposed/2019.2.0'
178 }
Hanna Arhipovaa85bfa62020-01-03 18:49:15 +0200179 update_pipeline_library = dt.start_job_on_jenkins(
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300180 job_name=job_name,
Hanna Arhipovac3c59292020-04-23 16:29:09 +0300181 job_parameters=job_parameters,
182 verbose=True)
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300183
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300184 assert update_pipeline_library == 'SUCCESS'
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300185
186 # ################### Start 'Deploy - upgrade MCP Drivetrain' job #####
187 show_step(4)
188
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300189 job_name = 'upgrade-mcp-release'
190 job_parameters = {
Hanna Arhipovad35a29b2019-09-04 13:24:06 +0300191 'GIT_REFSPEC': 'release/proposed/2019.2.0',
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300192 'MK_PIPELINES_REFSPEC': 'release/proposed/2019.2.0',
193 'TARGET_MCP_VERSION': '2019.2.0'
194 }
Hanna Arhipovaa85bfa62020-01-03 18:49:15 +0200195 update_drivetrain = dt.start_job_on_jenkins(
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300196 job_name=job_name,
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300197 job_parameters=job_parameters,
Hanna Arhipovac3c59292020-04-23 16:29:09 +0300198 verbose=True,
Hanna Arhipova85db4952020-03-31 20:20:06 +0300199 build_timeout=3 * 60 * 60)
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300200
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300201 assert update_drivetrain == 'SUCCESS'
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300202
Hanna Arhipova94a8abe2019-08-22 14:11:46 +0300203 @pytest.mark.grab_versions
204 @pytest.mark.parametrize("_", [settings.ENV_NAME])
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300205 @pytest.mark.run_mcp_update
Hanna Arhipovacc3759b2019-08-28 16:01:11 +0300206 def test_update_glusterfs(self, salt_actions, reclass_actions,
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300207 drivetrain_actions, show_step, _):
Hanna Arhipovacc3759b2019-08-28 16:01:11 +0300208 """ Upgrade GlusterFS
209 Scenario:
210 1. In infra/init.yml in Reclass, add the glusterfs_version parameter
211 2. Start linux.system.repo state
212 3. Start "update-glusterfs" job
213 4. Check version for GlusterFS servers
214 5. Check version for GlusterFS clients
215
216 """
217 salt = salt_actions
218 reclass = reclass_actions
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300219 dt = drivetrain_actions
Hanna Arhipovacc3759b2019-08-28 16:01:11 +0300220
Hanna Arhipovacc3759b2019-08-28 16:01:11 +0300221 # ############## Change reclass ######################################
222 show_step(1)
223 reclass.add_key(
224 "parameters._param.linux_system_repo_mcp_glusterfs_version_number",
225 "5",
226 "cluster/*/infra/init.yml"
227 )
228 # ################# Run linux.system state ###########################
229 show_step(2)
230 salt.enforce_state("*", "linux.system.repo")
231
232 # ############## Start deploy-upgrade-galera job #####################
233 show_step(3)
Hanna Arhipovacc3759b2019-08-28 16:01:11 +0300234 job_name = 'update-glusterfs'
235
Hanna Arhipovaa85bfa62020-01-03 18:49:15 +0200236 update_glusterfs = dt.start_job_on_jenkins(
Hanna Arhipovacc3759b2019-08-28 16:01:11 +0300237 job_name=job_name,
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300238 build_timeout=40 * 60)
Hanna Arhipovacc3759b2019-08-28 16:01:11 +0300239
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300240 assert update_glusterfs == 'SUCCESS'
Hanna Arhipovacc3759b2019-08-28 16:01:11 +0300241
242 # ################ Check GlusterFS version for servers ##############
243 show_step(4)
244 gluster_server_versions_by_nodes = salt.cmd_run(
245 "I@glusterfs:server",
246 "glusterd --version|head -n1")[0]
247
Hanna Arhipova19429962019-10-17 15:16:49 +0300248 assert has_only_similar(gluster_server_versions_by_nodes), \
Hanna Arhipovacc3759b2019-08-28 16:01:11 +0300249 gluster_server_versions_by_nodes
250
251 # ################ Check GlusterFS version for clients ##############
252 show_step(5)
253 gluster_client_versions_by_nodes = salt.cmd_run(
254 "I@glusterfs:client",
255 "glusterfs --version|head -n1")[0]
256
257 assert has_only_similar(gluster_client_versions_by_nodes), \
258 gluster_client_versions_by_nodes
259
260 @pytest.mark.grab_versions
261 @pytest.mark.parametrize("_", [settings.ENV_NAME])
262 @pytest.mark.run_mcp_update
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300263 def test_update_galera(self, salt_actions, reclass_actions,
264 drivetrain_actions, show_step, _):
Hanna Arhipova94a8abe2019-08-22 14:11:46 +0300265 """ Upgrade Galera automatically
266
267 Scenario:
268 1. Include the Galera upgrade pipeline job to DriveTrain
269 2. Apply the jenkins.client state on the Jenkins nodes
270 3. set the openstack_upgrade_enabled parameter to true
271 4. Refresh pillars
272 5. Add repositories with new Galera packages
273 6. Start job from Jenkins
274 """
275 salt = salt_actions
276 reclass = reclass_actions
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300277 dt = drivetrain_actions
Hanna Arhipova94a8abe2019-08-22 14:11:46 +0300278 # ################### Enable pipeline #################################
279 show_step(1)
280 reclass.add_class(
281 "system.jenkins.client.job.deploy.update.upgrade_galera",
282 "cluster/*/cicd/control/leader.yml")
283 show_step(2)
284 salt.enforce_state("I@jenkins:client", "jenkins.client")
285
286 # ############### Enable automatic upgrade ############################
287 show_step(3)
288 reclass.add_bool_key("parameters._param.openstack_upgrade_enabled",
289 "True",
290 "cluster/*/infra/init.yml")
291
292 show_step(4)
Hanna Arhipova7cfeb072019-10-11 15:04:10 +0300293 salt.run_state("dbs*", "saltutil.refresh_pillar")
Hanna Arhipova94a8abe2019-08-22 14:11:46 +0300294
295 # ############# Add repositories with new Galera packages #######
296 show_step(5)
297 salt.enforce_state("dbs*", "linux.system.repo")
298 salt.enforce_state("cfg*", "salt.master")
299
Hanna Arhipova94a8abe2019-08-22 14:11:46 +0300300 # #################### Login Jenkins on cid01 node ###################
301 show_step(6)
302
Hanna Arhipova94a8abe2019-08-22 14:11:46 +0300303 job_name = 'deploy-upgrade-galera'
304 job_parameters = {
305 'INTERACTIVE': 'false'
306 }
307
Hanna Arhipovaa85bfa62020-01-03 18:49:15 +0200308 update_galera = dt.start_job_on_jenkins(
Hanna Arhipova94a8abe2019-08-22 14:11:46 +0300309 job_name=job_name,
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300310 job_parameters=job_parameters,
311 build_timeout=40 * 60)
Hanna Arhipova94a8abe2019-08-22 14:11:46 +0300312
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300313 assert update_galera == 'SUCCESS'
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300314
315 @pytest.fixture
316 def disable_automatic_failover_neutron_for_test(self, salt_actions):
317 """
318 On each OpenStack controller node, modify the neutron.conf file
319 Restart the neutron-server service
320 """
Hanna Arhipova19429962019-10-17 15:16:49 +0300321
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300322 def comment_line(node, file_name, word):
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300323 """
324 Adds '#' before the specific line in specific file
325
326 :param node: string, salt target of node where the file locates
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300327 :param file_name: string, full path to the file
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300328 :param word: string, the begin of line which should be commented
329 :return: None
330 """
331 salt_actions.cmd_run(node,
332 "sed -i 's/^{word}/#{word}/' {file}".
333 format(word=word,
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300334 file=file_name))
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300335
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300336 def add_line(node, file_name, line):
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300337 """
338 Appends line to the end of file
339
340 :param node: string, salt target of node where the file locates
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300341 :param file_name: string, full path to the file
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300342 :param line: string, line that should be added
343 :return: None
344 """
345 salt_actions.cmd_run(node, "echo {line} >> {file}".format(
Hanna Arhipova19429962019-10-17 15:16:49 +0300346 line=line,
347 file=file_name))
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300348
349 neutron_conf = '/etc/neutron/neutron.conf'
350 neutron_server = "I@neutron:server"
351 # ######## Create backup for config file #######################
352 salt_actions.cmd_run(
353 neutron_server,
354 "cp -p {file} {file}.backup".format(file=neutron_conf))
355
356 # ## Change parameters in neutron.conf'
357 comment_line(neutron_server, neutron_conf,
Hanna Arhipova19429962019-10-17 15:16:49 +0300358 "allow_automatic_l3agent_failover", )
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300359 comment_line(neutron_server, neutron_conf,
360 "allow_automatic_dhcp_failover")
361 add_line(neutron_server, neutron_conf,
362 "allow_automatic_dhcp_failover = false")
363 add_line(neutron_server, neutron_conf,
364 "allow_automatic_l3agent_failover = false")
365
366 # ## Apply changed config to the neutron-server service
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300367 result = salt_actions.cmd_run(neutron_server,
368 "service neutron-server restart")
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300369 # TODO: add check that neutron-server is up and running
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300370 yield result
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300371 # ## Revert file changes
372 salt_actions.cmd_run(
373 neutron_server,
374 "cp -p {file}.backup {file}".format(file=neutron_conf))
375 salt_actions.cmd_run(neutron_server,
376 "service neutron-server restart")
377
378 @pytest.fixture
379 def disable_neutron_agents_for_test(self, salt_actions):
380 """
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300381 Disable the neutron services before the test and
382 enable it after test
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300383 """
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300384 result = salt_actions.cmd_run("I@neutron:server", """
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300385 service neutron-dhcp-agent stop && \
386 service neutron-l3-agent stop && \
387 service neutron-metadata-agent stop && \
388 service neutron-openvswitch-agent stop
389 """)
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300390 yield result
391 #
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300392 salt_actions.cmd_run("I@neutron:server", """
393 service neutron-dhcp-agent start && \
394 service neutron-l3-agent start && \
395 service neutron-metadata-agent start && \
396 service neutron-openvswitch-agent start
397 """)
398 # TODO: add check that all services are UP and running
399
400 @pytest.mark.grab_versions
401 @pytest.mark.parametrize("_", [settings.ENV_NAME])
402 @pytest.mark.run_mcp_update
403 def test_update_rabbit(self, salt_actions, reclass_actions,
404 drivetrain_actions, show_step, _,
405 disable_automatic_failover_neutron_for_test,
406 disable_neutron_agents_for_test):
407 """ Updates RabbitMQ
408 Scenario:
409 1. Include the RabbitMQ upgrade pipeline job to DriveTrain
410 2. Add repositories with new RabbitMQ packages
411 3. Start Deploy - upgrade RabbitMQ pipeline
412
413 Updating RabbitMq should be completed before the OpenStack updating
414 process starts
415 """
416 salt = salt_actions
417 reclass = reclass_actions
418 dt = drivetrain_actions
419
420 # ####### Include the RabbitMQ upgrade pipeline job to DriveTrain ####
421 show_step(1)
422 reclass.add_class(
423 "system.jenkins.client.job.deploy.update.upgrade_rabbitmq",
424 "cluster/*/cicd/control/leader.yml")
425 salt.enforce_state("I@jenkins:client", "jenkins.client")
426
427 reclass.add_bool_key("parameters._param.openstack_upgrade_enabled",
428 "True",
429 "cluster/*/infra/init.yml")
430 salt.run_state("I@rabbitmq:server", "saltutil.refresh_pillar")
431
432 # ########### Add repositories with new RabbitMQ packages ############
433 show_step(2)
434 salt.enforce_state("I@rabbitmq:server", "linux.system.repo")
435
436 # ########### Start Deploy - upgrade RabbitMQ pipeline ############
437 show_step(3)
438 job_parameters = {
439 'INTERACTIVE': 'false'
440 }
441
Hanna Arhipovaa85bfa62020-01-03 18:49:15 +0200442 update_rabbit = dt.start_job_on_jenkins(
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300443 job_name='deploy-upgrade-rabbitmq',
444 job_parameters=job_parameters,
445 build_timeout=40 * 60
446 )
447 assert update_rabbit == 'SUCCESS'
Hanna Arhipovad35a29b2019-09-04 13:24:06 +0300448
449 @pytest.mark.grab_versions
450 @pytest.mark.parametrize("_", [settings.ENV_NAME])
451 @pytest.mark.run_mcp_update
452 def test_update_ceph(self, salt_actions, drivetrain_actions, show_step, _):
453 """ Updates Ceph to the latest minor version
454
455 Scenario:
456 1. Add workaround for unhealth Ceph
457 2. Start ceph-upgrade job with default parameters
458 3. Check Ceph version for all nodes
459
460 https://docs.mirantis.com/mcp/master/mcp-operations-guide/update-upgrade/minor-update/ceph-update.html
461 """
462 salt = salt_actions
463 dt = drivetrain_actions
464
465 # ###################### Add workaround for unhealth Ceph ############
466 show_step(1)
467 salt.cmd_run("I@ceph:radosgw",
468 "ceph config set 'mon pg warn max object skew' 20")
469 # ###################### Start ceph-upgrade pipeline #################
470 show_step(2)
471 job_parameters = {}
472
Hanna Arhipovaa85bfa62020-01-03 18:49:15 +0200473 update_ceph = dt.start_job_on_jenkins(
Hanna Arhipovad35a29b2019-09-04 13:24:06 +0300474 job_name='ceph-update',
475 job_parameters=job_parameters)
476
477 assert update_ceph == 'SUCCESS'
478
479 # ########## Verify Ceph version #####################################
480 show_step(3)
481
482 ceph_version_by_nodes = salt.cmd_run(
Hanna Arhipova19429962019-10-17 15:16:49 +0300483 "I@ceph:* and not I@ceph:monitoring and not I@ceph:backup:server",
484 "ceph version")[0]
Hanna Arhipovad35a29b2019-09-04 13:24:06 +0300485
486 assert has_only_similar(ceph_version_by_nodes), ceph_version_by_nodes
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300487
Hanna Arhipovaac008562019-10-17 11:54:23 +0300488 @pytest.mark.grab_versions
489 @pytest.mark.parametrize("_", [settings.ENV_NAME])
490 @pytest.mark.run_mcp_update
491 def test_update_stacklight(self, _, drivetrain_actions):
492 """ Update packages for Stacklight
493 Scenario:
494 1. Start Deploy - upgrade Stacklight job
495 """
496 drivetrain = drivetrain_actions
497
498 job_parameters = {
499 "STAGE_UPGRADE_DOCKER_COMPONENTS": True,
500 "STAGE_UPGRADE_ES_KIBANA": True,
501 "STAGE_UPGRADE_SYSTEM_PART": True
502 }
Hanna Arhipovaa85bfa62020-01-03 18:49:15 +0200503 upgrade_control_pipeline = drivetrain.start_job_on_jenkins(
Hanna Arhipovaac008562019-10-17 11:54:23 +0300504 job_name="stacklight-upgrade",
505 job_parameters=job_parameters)
506
507 assert upgrade_control_pipeline == 'SUCCESS'
508
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300509
Hanna Arhipova19429962019-10-17 15:16:49 +0300510@pytest.mark.usefixtures("switch_to_proposed_pipelines",
511 "enable_openstack_update")
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300512class TestOpenstackUpdate(object):
513
514 @pytest.mark.grab_versions
515 @pytest.mark.run_mcp_update
516 def test__pre_update__enable_pipeline_job(self,
517 reclass_actions, salt_actions,
518 show_step):
519 """ Enable pipeline in the Drivetrain
520
521 Scenario:
522 1. Add deploy.update.* classes to the reclass
523 2. Start jenkins.client salt state
524
525 """
526 salt = salt_actions
527 reclass = reclass_actions
528 show_step(1)
529 reclass.add_class("system.jenkins.client.job.deploy.update.upgrade",
530 "cluster/*/cicd/control/leader.yml")
531
532 reclass.add_class(
533 "system.jenkins.client.job.deploy.update.upgrade_ovs_gateway",
534 "cluster/*/cicd/control/leader.yml")
535
536 reclass.add_class(
537 "system.jenkins.client.job.deploy.update.upgrade_compute",
538 "cluster/*/cicd/control/leader.yml")
539
540 show_step(2)
541 r, errors = salt.enforce_state("I@jenkins:client", "jenkins.client")
542 assert errors is None
543
544 @pytest.mark.grab_versions
545 @pytest.mark.parametrize('target', get_control_plane_targets())
546 @pytest.mark.run_mcp_update
Hanna Arhipova19429962019-10-17 15:16:49 +0300547 def test__update__control_plane(self, drivetrain_actions, target):
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300548 """Start 'Deploy - upgrade control VMs' for specific node
549 """
550 job_parameters = {
551 "TARGET_SERVERS": target,
Hanna Arhipova606d5182019-12-13 13:23:55 +0200552 "OS_DIST_UPGRADE": True,
PGlazoved19b352020-05-21 16:42:27 +0400553 "UPGRADE_SALTSTACK": False,
Hanna Arhipova606d5182019-12-13 13:23:55 +0200554 "OS_UPGRADE": True,
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300555 "INTERACTIVE": False}
Hanna Arhipovaa85bfa62020-01-03 18:49:15 +0200556 upgrade_control_pipeline = drivetrain_actions.start_job_on_jenkins(
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300557 job_name="deploy-upgrade-control",
558 job_parameters=job_parameters)
559
560 assert upgrade_control_pipeline == 'SUCCESS'
561
562 @pytest.mark.grab_versions
563 @pytest.mark.run_mcp_update
Hanna Arhipova606d5182019-12-13 13:23:55 +0200564 def test__update__data_plane(self, drivetrain_actions, salt_actions):
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300565 """Start 'Deploy - upgrade OVS gateway'
566 """
Hanna Arhipova606d5182019-12-13 13:23:55 +0200567 if not salt_actions.cmd_run("gtw*", "test.ping")[0].keys():
568 pytest.skip("This deployment doesn't have gtw* nodes")
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300569 job_parameters = {
Hanna Arhipova606d5182019-12-13 13:23:55 +0200570 "OS_DIST_UPGRADE": True,
571 "OS_UPGRADE": True,
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300572 "INTERACTIVE": False}
Hanna Arhipovaa85bfa62020-01-03 18:49:15 +0200573 upgrade_data_pipeline = drivetrain_actions.start_job_on_jenkins(
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300574 job_name="deploy-upgrade-ovs-gateway",
575 job_parameters=job_parameters)
576
577 assert upgrade_data_pipeline == 'SUCCESS'
Hanna Arhipova19429962019-10-17 15:16:49 +0300578
579 @pytest.mark.grab_versions
580 @pytest.mark.run_mcp_update
581 def test__update__computes(self, drivetrain_actions):
582 """Start 'Deploy - upgrade computes'
583 """
584 job_parameters = {
Hanna Arhipova606d5182019-12-13 13:23:55 +0200585 "OS_DIST_UPGRADE": True,
586 "OS_UPGRADE": True,
Hanna Arhipova19429962019-10-17 15:16:49 +0300587 "INTERACTIVE": False}
Hanna Arhipovaa85bfa62020-01-03 18:49:15 +0200588 upgrade_compute_pipeline = drivetrain_actions.start_job_on_jenkins(
Hanna Arhipova19429962019-10-17 15:16:49 +0300589 job_name="deploy-upgrade-compute",
590 job_parameters=job_parameters)
591
592 assert upgrade_compute_pipeline == 'SUCCESS'