blob: eb64fb27deee983ce8e8027ca109cfbbe742c5d0 [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,
Hanna Arhipovac3c59292020-04-23 16:29:09 +0300163 job_parameters=job_parameters,
164 verbose=True)
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300165
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300166 assert update_pipelines == 'SUCCESS'
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300167
168 # ################### Downstream pipeline-library ####################
169 show_step(3)
170 job_name = 'git-mirror-downstream-pipeline-library'
171 job_parameters = {
172 'BRANCHES': 'release/proposed/2019.2.0'
173 }
Hanna Arhipovaa85bfa62020-01-03 18:49:15 +0200174 update_pipeline_library = dt.start_job_on_jenkins(
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300175 job_name=job_name,
Hanna Arhipovac3c59292020-04-23 16:29:09 +0300176 job_parameters=job_parameters,
177 verbose=True)
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300178
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300179 assert update_pipeline_library == 'SUCCESS'
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300180
181 # ################### Start 'Deploy - upgrade MCP Drivetrain' job #####
182 show_step(4)
183
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300184 job_name = 'upgrade-mcp-release'
185 job_parameters = {
Hanna Arhipovad35a29b2019-09-04 13:24:06 +0300186 'GIT_REFSPEC': 'release/proposed/2019.2.0',
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300187 'MK_PIPELINES_REFSPEC': 'release/proposed/2019.2.0',
188 'TARGET_MCP_VERSION': '2019.2.0'
189 }
Hanna Arhipovaa85bfa62020-01-03 18:49:15 +0200190 update_drivetrain = dt.start_job_on_jenkins(
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300191 job_name=job_name,
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300192 job_parameters=job_parameters,
Hanna Arhipovac3c59292020-04-23 16:29:09 +0300193 verbose=True,
Hanna Arhipova85db4952020-03-31 20:20:06 +0300194 build_timeout=3 * 60 * 60)
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300195
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300196 assert update_drivetrain == 'SUCCESS'
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300197
Hanna Arhipova94a8abe2019-08-22 14:11:46 +0300198 @pytest.mark.grab_versions
199 @pytest.mark.parametrize("_", [settings.ENV_NAME])
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300200 @pytest.mark.run_mcp_update
Hanna Arhipovacc3759b2019-08-28 16:01:11 +0300201 def test_update_glusterfs(self, salt_actions, reclass_actions,
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300202 drivetrain_actions, show_step, _):
Hanna Arhipovacc3759b2019-08-28 16:01:11 +0300203 """ Upgrade GlusterFS
204 Scenario:
205 1. In infra/init.yml in Reclass, add the glusterfs_version parameter
206 2. Start linux.system.repo state
207 3. Start "update-glusterfs" job
208 4. Check version for GlusterFS servers
209 5. Check version for GlusterFS clients
210
211 """
212 salt = salt_actions
213 reclass = reclass_actions
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300214 dt = drivetrain_actions
Hanna Arhipovacc3759b2019-08-28 16:01:11 +0300215
Hanna Arhipovacc3759b2019-08-28 16:01:11 +0300216 # ############## Change reclass ######################################
217 show_step(1)
218 reclass.add_key(
219 "parameters._param.linux_system_repo_mcp_glusterfs_version_number",
220 "5",
221 "cluster/*/infra/init.yml"
222 )
223 # ################# Run linux.system state ###########################
224 show_step(2)
225 salt.enforce_state("*", "linux.system.repo")
226
227 # ############## Start deploy-upgrade-galera job #####################
228 show_step(3)
Hanna Arhipovacc3759b2019-08-28 16:01:11 +0300229 job_name = 'update-glusterfs'
230
Hanna Arhipovaa85bfa62020-01-03 18:49:15 +0200231 update_glusterfs = dt.start_job_on_jenkins(
Hanna Arhipovacc3759b2019-08-28 16:01:11 +0300232 job_name=job_name,
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300233 build_timeout=40 * 60)
Hanna Arhipovacc3759b2019-08-28 16:01:11 +0300234
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300235 assert update_glusterfs == 'SUCCESS'
Hanna Arhipovacc3759b2019-08-28 16:01:11 +0300236
237 # ################ Check GlusterFS version for servers ##############
238 show_step(4)
239 gluster_server_versions_by_nodes = salt.cmd_run(
240 "I@glusterfs:server",
241 "glusterd --version|head -n1")[0]
242
Hanna Arhipova19429962019-10-17 15:16:49 +0300243 assert has_only_similar(gluster_server_versions_by_nodes), \
Hanna Arhipovacc3759b2019-08-28 16:01:11 +0300244 gluster_server_versions_by_nodes
245
246 # ################ Check GlusterFS version for clients ##############
247 show_step(5)
248 gluster_client_versions_by_nodes = salt.cmd_run(
249 "I@glusterfs:client",
250 "glusterfs --version|head -n1")[0]
251
252 assert has_only_similar(gluster_client_versions_by_nodes), \
253 gluster_client_versions_by_nodes
254
255 @pytest.mark.grab_versions
256 @pytest.mark.parametrize("_", [settings.ENV_NAME])
257 @pytest.mark.run_mcp_update
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300258 def test_update_galera(self, salt_actions, reclass_actions,
259 drivetrain_actions, show_step, _):
Hanna Arhipova94a8abe2019-08-22 14:11:46 +0300260 """ Upgrade Galera automatically
261
262 Scenario:
263 1. Include the Galera upgrade pipeline job to DriveTrain
264 2. Apply the jenkins.client state on the Jenkins nodes
265 3. set the openstack_upgrade_enabled parameter to true
266 4. Refresh pillars
267 5. Add repositories with new Galera packages
268 6. Start job from Jenkins
269 """
270 salt = salt_actions
271 reclass = reclass_actions
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300272 dt = drivetrain_actions
Hanna Arhipova94a8abe2019-08-22 14:11:46 +0300273 # ################### Enable pipeline #################################
274 show_step(1)
275 reclass.add_class(
276 "system.jenkins.client.job.deploy.update.upgrade_galera",
277 "cluster/*/cicd/control/leader.yml")
278 show_step(2)
279 salt.enforce_state("I@jenkins:client", "jenkins.client")
280
281 # ############### Enable automatic upgrade ############################
282 show_step(3)
283 reclass.add_bool_key("parameters._param.openstack_upgrade_enabled",
284 "True",
285 "cluster/*/infra/init.yml")
286
287 show_step(4)
Hanna Arhipova7cfeb072019-10-11 15:04:10 +0300288 salt.run_state("dbs*", "saltutil.refresh_pillar")
Hanna Arhipova94a8abe2019-08-22 14:11:46 +0300289
290 # ############# Add repositories with new Galera packages #######
291 show_step(5)
292 salt.enforce_state("dbs*", "linux.system.repo")
293 salt.enforce_state("cfg*", "salt.master")
294
Hanna Arhipova94a8abe2019-08-22 14:11:46 +0300295 # #################### Login Jenkins on cid01 node ###################
296 show_step(6)
297
Hanna Arhipova94a8abe2019-08-22 14:11:46 +0300298 job_name = 'deploy-upgrade-galera'
299 job_parameters = {
300 'INTERACTIVE': 'false'
301 }
302
Hanna Arhipovaa85bfa62020-01-03 18:49:15 +0200303 update_galera = dt.start_job_on_jenkins(
Hanna Arhipova94a8abe2019-08-22 14:11:46 +0300304 job_name=job_name,
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300305 job_parameters=job_parameters,
306 build_timeout=40 * 60)
Hanna Arhipova94a8abe2019-08-22 14:11:46 +0300307
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300308 assert update_galera == 'SUCCESS'
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300309
310 @pytest.fixture
311 def disable_automatic_failover_neutron_for_test(self, salt_actions):
312 """
313 On each OpenStack controller node, modify the neutron.conf file
314 Restart the neutron-server service
315 """
Hanna Arhipova19429962019-10-17 15:16:49 +0300316
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300317 def comment_line(node, file_name, word):
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300318 """
319 Adds '#' before the specific line in specific 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 word: string, the begin of line which should be commented
324 :return: None
325 """
326 salt_actions.cmd_run(node,
327 "sed -i 's/^{word}/#{word}/' {file}".
328 format(word=word,
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300329 file=file_name))
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300330
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300331 def add_line(node, file_name, line):
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300332 """
333 Appends line to the end of file
334
335 :param node: string, salt target of node where the file locates
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300336 :param file_name: string, full path to the file
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300337 :param line: string, line that should be added
338 :return: None
339 """
340 salt_actions.cmd_run(node, "echo {line} >> {file}".format(
Hanna Arhipova19429962019-10-17 15:16:49 +0300341 line=line,
342 file=file_name))
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300343
344 neutron_conf = '/etc/neutron/neutron.conf'
345 neutron_server = "I@neutron:server"
346 # ######## Create backup for config file #######################
347 salt_actions.cmd_run(
348 neutron_server,
349 "cp -p {file} {file}.backup".format(file=neutron_conf))
350
351 # ## Change parameters in neutron.conf'
352 comment_line(neutron_server, neutron_conf,
Hanna Arhipova19429962019-10-17 15:16:49 +0300353 "allow_automatic_l3agent_failover", )
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300354 comment_line(neutron_server, neutron_conf,
355 "allow_automatic_dhcp_failover")
356 add_line(neutron_server, neutron_conf,
357 "allow_automatic_dhcp_failover = false")
358 add_line(neutron_server, neutron_conf,
359 "allow_automatic_l3agent_failover = false")
360
361 # ## Apply changed config to the neutron-server service
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300362 result = salt_actions.cmd_run(neutron_server,
363 "service neutron-server restart")
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300364 # TODO: add check that neutron-server is up and running
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300365 yield result
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300366 # ## Revert file changes
367 salt_actions.cmd_run(
368 neutron_server,
369 "cp -p {file}.backup {file}".format(file=neutron_conf))
370 salt_actions.cmd_run(neutron_server,
371 "service neutron-server restart")
372
373 @pytest.fixture
374 def disable_neutron_agents_for_test(self, salt_actions):
375 """
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300376 Disable the neutron services before the test and
377 enable it after test
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300378 """
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300379 result = salt_actions.cmd_run("I@neutron:server", """
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300380 service neutron-dhcp-agent stop && \
381 service neutron-l3-agent stop && \
382 service neutron-metadata-agent stop && \
383 service neutron-openvswitch-agent stop
384 """)
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300385 yield result
386 #
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300387 salt_actions.cmd_run("I@neutron:server", """
388 service neutron-dhcp-agent start && \
389 service neutron-l3-agent start && \
390 service neutron-metadata-agent start && \
391 service neutron-openvswitch-agent start
392 """)
393 # TODO: add check that all services are UP and running
394
395 @pytest.mark.grab_versions
396 @pytest.mark.parametrize("_", [settings.ENV_NAME])
397 @pytest.mark.run_mcp_update
398 def test_update_rabbit(self, salt_actions, reclass_actions,
399 drivetrain_actions, show_step, _,
400 disable_automatic_failover_neutron_for_test,
401 disable_neutron_agents_for_test):
402 """ Updates RabbitMQ
403 Scenario:
404 1. Include the RabbitMQ upgrade pipeline job to DriveTrain
405 2. Add repositories with new RabbitMQ packages
406 3. Start Deploy - upgrade RabbitMQ pipeline
407
408 Updating RabbitMq should be completed before the OpenStack updating
409 process starts
410 """
411 salt = salt_actions
412 reclass = reclass_actions
413 dt = drivetrain_actions
414
415 # ####### Include the RabbitMQ upgrade pipeline job to DriveTrain ####
416 show_step(1)
417 reclass.add_class(
418 "system.jenkins.client.job.deploy.update.upgrade_rabbitmq",
419 "cluster/*/cicd/control/leader.yml")
420 salt.enforce_state("I@jenkins:client", "jenkins.client")
421
422 reclass.add_bool_key("parameters._param.openstack_upgrade_enabled",
423 "True",
424 "cluster/*/infra/init.yml")
425 salt.run_state("I@rabbitmq:server", "saltutil.refresh_pillar")
426
427 # ########### Add repositories with new RabbitMQ packages ############
428 show_step(2)
429 salt.enforce_state("I@rabbitmq:server", "linux.system.repo")
430
431 # ########### Start Deploy - upgrade RabbitMQ pipeline ############
432 show_step(3)
433 job_parameters = {
434 'INTERACTIVE': 'false'
435 }
436
Hanna Arhipovaa85bfa62020-01-03 18:49:15 +0200437 update_rabbit = dt.start_job_on_jenkins(
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300438 job_name='deploy-upgrade-rabbitmq',
439 job_parameters=job_parameters,
440 build_timeout=40 * 60
441 )
442 assert update_rabbit == 'SUCCESS'
Hanna Arhipovad35a29b2019-09-04 13:24:06 +0300443
444 @pytest.mark.grab_versions
445 @pytest.mark.parametrize("_", [settings.ENV_NAME])
446 @pytest.mark.run_mcp_update
447 def test_update_ceph(self, salt_actions, drivetrain_actions, show_step, _):
448 """ Updates Ceph to the latest minor version
449
450 Scenario:
451 1. Add workaround for unhealth Ceph
452 2. Start ceph-upgrade job with default parameters
453 3. Check Ceph version for all nodes
454
455 https://docs.mirantis.com/mcp/master/mcp-operations-guide/update-upgrade/minor-update/ceph-update.html
456 """
457 salt = salt_actions
458 dt = drivetrain_actions
459
460 # ###################### Add workaround for unhealth Ceph ############
461 show_step(1)
462 salt.cmd_run("I@ceph:radosgw",
463 "ceph config set 'mon pg warn max object skew' 20")
464 # ###################### Start ceph-upgrade pipeline #################
465 show_step(2)
466 job_parameters = {}
467
Hanna Arhipovaa85bfa62020-01-03 18:49:15 +0200468 update_ceph = dt.start_job_on_jenkins(
Hanna Arhipovad35a29b2019-09-04 13:24:06 +0300469 job_name='ceph-update',
470 job_parameters=job_parameters)
471
472 assert update_ceph == 'SUCCESS'
473
474 # ########## Verify Ceph version #####################################
475 show_step(3)
476
477 ceph_version_by_nodes = salt.cmd_run(
Hanna Arhipova19429962019-10-17 15:16:49 +0300478 "I@ceph:* and not I@ceph:monitoring and not I@ceph:backup:server",
479 "ceph version")[0]
Hanna Arhipovad35a29b2019-09-04 13:24:06 +0300480
481 assert has_only_similar(ceph_version_by_nodes), ceph_version_by_nodes
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300482
Hanna Arhipovaac008562019-10-17 11:54:23 +0300483 @pytest.mark.grab_versions
484 @pytest.mark.parametrize("_", [settings.ENV_NAME])
485 @pytest.mark.run_mcp_update
486 def test_update_stacklight(self, _, drivetrain_actions):
487 """ Update packages for Stacklight
488 Scenario:
489 1. Start Deploy - upgrade Stacklight job
490 """
491 drivetrain = drivetrain_actions
492
493 job_parameters = {
494 "STAGE_UPGRADE_DOCKER_COMPONENTS": True,
495 "STAGE_UPGRADE_ES_KIBANA": True,
496 "STAGE_UPGRADE_SYSTEM_PART": True
497 }
Hanna Arhipovaa85bfa62020-01-03 18:49:15 +0200498 upgrade_control_pipeline = drivetrain.start_job_on_jenkins(
Hanna Arhipovaac008562019-10-17 11:54:23 +0300499 job_name="stacklight-upgrade",
500 job_parameters=job_parameters)
501
502 assert upgrade_control_pipeline == 'SUCCESS'
503
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300504
Hanna Arhipova19429962019-10-17 15:16:49 +0300505@pytest.mark.usefixtures("switch_to_proposed_pipelines",
506 "enable_openstack_update")
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300507class TestOpenstackUpdate(object):
508
509 @pytest.mark.grab_versions
510 @pytest.mark.run_mcp_update
511 def test__pre_update__enable_pipeline_job(self,
512 reclass_actions, salt_actions,
513 show_step):
514 """ Enable pipeline in the Drivetrain
515
516 Scenario:
517 1. Add deploy.update.* classes to the reclass
518 2. Start jenkins.client salt state
519
520 """
521 salt = salt_actions
522 reclass = reclass_actions
523 show_step(1)
524 reclass.add_class("system.jenkins.client.job.deploy.update.upgrade",
525 "cluster/*/cicd/control/leader.yml")
526
527 reclass.add_class(
528 "system.jenkins.client.job.deploy.update.upgrade_ovs_gateway",
529 "cluster/*/cicd/control/leader.yml")
530
531 reclass.add_class(
532 "system.jenkins.client.job.deploy.update.upgrade_compute",
533 "cluster/*/cicd/control/leader.yml")
534
535 show_step(2)
536 r, errors = salt.enforce_state("I@jenkins:client", "jenkins.client")
537 assert errors is None
538
539 @pytest.mark.grab_versions
540 @pytest.mark.parametrize('target', get_control_plane_targets())
541 @pytest.mark.run_mcp_update
Hanna Arhipova19429962019-10-17 15:16:49 +0300542 def test__update__control_plane(self, drivetrain_actions, target):
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300543 """Start 'Deploy - upgrade control VMs' for specific node
544 """
545 job_parameters = {
546 "TARGET_SERVERS": target,
Hanna Arhipova606d5182019-12-13 13:23:55 +0200547 "OS_DIST_UPGRADE": True,
PGlazoved19b352020-05-21 16:42:27 +0400548 "UPGRADE_SALTSTACK": False,
Hanna Arhipova606d5182019-12-13 13:23:55 +0200549 "OS_UPGRADE": True,
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300550 "INTERACTIVE": False}
Hanna Arhipovaa85bfa62020-01-03 18:49:15 +0200551 upgrade_control_pipeline = drivetrain_actions.start_job_on_jenkins(
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300552 job_name="deploy-upgrade-control",
553 job_parameters=job_parameters)
554
555 assert upgrade_control_pipeline == 'SUCCESS'
556
557 @pytest.mark.grab_versions
558 @pytest.mark.run_mcp_update
Hanna Arhipova606d5182019-12-13 13:23:55 +0200559 def test__update__data_plane(self, drivetrain_actions, salt_actions):
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300560 """Start 'Deploy - upgrade OVS gateway'
561 """
Hanna Arhipova606d5182019-12-13 13:23:55 +0200562 if not salt_actions.cmd_run("gtw*", "test.ping")[0].keys():
563 pytest.skip("This deployment doesn't have gtw* nodes")
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300564 job_parameters = {
Hanna Arhipova606d5182019-12-13 13:23:55 +0200565 "OS_DIST_UPGRADE": True,
566 "OS_UPGRADE": True,
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300567 "INTERACTIVE": False}
Hanna Arhipovaa85bfa62020-01-03 18:49:15 +0200568 upgrade_data_pipeline = drivetrain_actions.start_job_on_jenkins(
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300569 job_name="deploy-upgrade-ovs-gateway",
570 job_parameters=job_parameters)
571
572 assert upgrade_data_pipeline == 'SUCCESS'
Hanna Arhipova19429962019-10-17 15:16:49 +0300573
574 @pytest.mark.grab_versions
575 @pytest.mark.run_mcp_update
576 def test__update__computes(self, drivetrain_actions):
577 """Start 'Deploy - upgrade computes'
578 """
579 job_parameters = {
Hanna Arhipova606d5182019-12-13 13:23:55 +0200580 "OS_DIST_UPGRADE": True,
581 "OS_UPGRADE": True,
Hanna Arhipova19429962019-10-17 15:16:49 +0300582 "INTERACTIVE": False}
Hanna Arhipovaa85bfa62020-01-03 18:49:15 +0200583 upgrade_compute_pipeline = drivetrain_actions.start_job_on_jenkins(
Hanna Arhipova19429962019-10-17 15:16:49 +0300584 job_name="deploy-upgrade-compute",
585 job_parameters=job_parameters)
586
587 assert upgrade_compute_pipeline == 'SUCCESS'