blob: 72ed442ab42cf82979b79ed97a37f87558703d85 [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 Arhipovab7a80bb2020-12-04 15:36:36 +0200111 reclass_actions.commit("[from TCP-QA] Add galera_clustercheck_password")
Hanna Arhipova745fdbb2020-03-30 14:40:44 +0300112
113
Hanna Arhipova97fac6e2020-12-03 13:10:56 +0200114@pytest.fixture
115def wa_for_alerta_password_prod35958(reclass_actions,
116 salt_actions):
117 reclass_actions.add_key(
Hanna Arhipova2d0175f2020-12-08 11:45:55 +0200118 "parameters._param.alerta_admin_api_key_generated",
Hanna Arhipova97fac6e2020-12-03 13:10:56 +0200119 "a"*32,
Hanna Arhipova2d0175f2020-12-08 11:45:55 +0200120 "cluster/*/infra/secrets.yml")
121 reclass_actions.add_key(
122 "parameters._param.alerta_admin_key",
123 "${_param:alerta_admin_api_key_generated}",
Hanna Arhipovab7a80bb2020-12-04 15:36:36 +0200124 "cluster/*/stacklight/init.yml")
125 reclass_actions.commit("[from TCP-QA] Add alerta_admin_key")
Hanna Arhipova97fac6e2020-12-03 13:10:56 +0200126 salt_actions.run_state(
127 "I@prometheus:alerta or I@prometheus:alertmanager",
128 "saltutil.refresh_pillar")
129 salt_actions.enforce_state(
130 "I@prometheus:alerta", "prometheus.alerta")
131 salt_actions.enforce_state(
132 "I@prometheus:alertmanager", "prometheus.alertmanager")
133 salt_actions.enforce_state(
134 "I@prometheus:alerta or I@prometheus:alertmanager",
135 "docker.client")
136
137
Hanna Arhipova19429962019-10-17 15:16:49 +0300138@pytest.fixture(scope='class')
139def enable_openstack_update(reclass_actions, salt_actions):
140 param = "parameters._param.openstack_upgrade_enabled"
141 context_file = "cluster/*/infra/init.yml"
142
143 LOG.info("Enable openstack_upgrade_enabled in reclass")
144 reclass_actions.add_bool_key(param, "True", context_file)
145 salt_actions.run_state("*", "saltutil.refresh_pillar")
146 yield True
147 LOG.info("Disable openstack_upgrade_enabled in reclass")
148 reclass_actions.add_bool_key(param, "False", context_file)
149 salt_actions.run_state("*", "saltutil.refresh_pillar")
150
151
Hanna Arhipova745fdbb2020-03-30 14:40:44 +0300152@pytest.mark.usefixtures("switch_to_proposed_pipelines",
Hanna Arhipova97fac6e2020-12-03 13:10:56 +0200153 "wa_for_galera_clustercheck_password_prod35705",
154 "wa_for_alerta_password_prod35958")
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300155class TestUpdateMcpCluster(object):
156 """
157 Following the steps in
Hanna Arhipova94a8abe2019-08-22 14:11:46 +0300158 https://docs.mirantis.com/mcp/master/mcp-operations-guide/update-upgrade/minor-update.html#minor-update
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300159 """
160
161 @pytest.mark.grab_versions
162 @pytest.mark.parametrize("_", [settings.ENV_NAME])
163 @pytest.mark.run_mcp_update
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300164 def test_update_drivetrain(self, salt_actions, drivetrain_actions,
Hanna Arhipova19429962019-10-17 15:16:49 +0300165 show_step, _):
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300166 """Updating DriveTrain component to release/proposed/2019.2.0 version
167
168 Scenario:
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300169 1. Add workaround for PROD-32751
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300170 2. Run job git-mirror-downstream-mk-pipelines
171 3. Run job git-mirror-downstream-pipeline-library
172 4. If jobs are passed then start 'Deploy - upgrade MCP Drivetrain'
173
Hanna Arhipovad35a29b2019-09-04 13:24:06 +0300174 Duration: ~70 min
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300175 """
176 salt = salt_actions
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300177 dt = drivetrain_actions
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300178
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300179 # #################### Add workaround for PROD-32751 #################
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300180 show_step(1)
181
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300182 # FIXME: workaround for PROD-32751
183 salt.cmd_run("cfg01*", "cd /srv/salt/reclass; git add -u && \
184 git commit --allow-empty -m 'Cluster model update'")
185
186 # ################### Downstream mk-pipelines #########################
187 show_step(2)
188 job_name = 'git-mirror-downstream-mk-pipelines'
189 job_parameters = {
190 'BRANCHES': 'release/proposed/2019.2.0'
191 }
Hanna Arhipova508f6532021-01-27 15:52:45 +0200192 job_result, job_description = dt.start_job_on_jenkins(
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300193 job_name=job_name,
Hanna Arhipovac3c59292020-04-23 16:29:09 +0300194 job_parameters=job_parameters,
195 verbose=True)
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300196
Hanna Arhipova508f6532021-01-27 15:52:45 +0200197 assert job_result == 'SUCCESS', job_description
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300198
199 # ################### Downstream pipeline-library ####################
200 show_step(3)
201 job_name = 'git-mirror-downstream-pipeline-library'
202 job_parameters = {
203 'BRANCHES': 'release/proposed/2019.2.0'
204 }
Hanna Arhipova508f6532021-01-27 15:52:45 +0200205 job_result, job_description = dt.start_job_on_jenkins(
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300206 job_name=job_name,
Hanna Arhipovac3c59292020-04-23 16:29:09 +0300207 job_parameters=job_parameters,
208 verbose=True)
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300209
Hanna Arhipova508f6532021-01-27 15:52:45 +0200210 assert job_result == 'SUCCESS', job_description
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300211
212 # ################### Start 'Deploy - upgrade MCP Drivetrain' job #####
213 show_step(4)
214
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300215 job_name = 'upgrade-mcp-release'
216 job_parameters = {
Hanna Arhipovad35a29b2019-09-04 13:24:06 +0300217 'GIT_REFSPEC': 'release/proposed/2019.2.0',
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300218 'MK_PIPELINES_REFSPEC': 'release/proposed/2019.2.0',
219 'TARGET_MCP_VERSION': '2019.2.0'
220 }
Hanna Arhipova508f6532021-01-27 15:52:45 +0200221 job_result, job_description = dt.start_job_on_jenkins(
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300222 job_name=job_name,
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300223 job_parameters=job_parameters,
Hanna Arhipovac3c59292020-04-23 16:29:09 +0300224 verbose=True,
Hanna Arhipova85db4952020-03-31 20:20:06 +0300225 build_timeout=3 * 60 * 60)
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300226
Hanna Arhipova508f6532021-01-27 15:52:45 +0200227 assert job_result == 'SUCCESS', job_description
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300228
Hanna Arhipova94a8abe2019-08-22 14:11:46 +0300229 @pytest.mark.grab_versions
230 @pytest.mark.parametrize("_", [settings.ENV_NAME])
Hanna Arhipova71ecc272019-08-20 14:54:22 +0300231 @pytest.mark.run_mcp_update
Hanna Arhipovacc3759b2019-08-28 16:01:11 +0300232 def test_update_glusterfs(self, salt_actions, reclass_actions,
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300233 drivetrain_actions, show_step, _):
Hanna Arhipovacc3759b2019-08-28 16:01:11 +0300234 """ Upgrade GlusterFS
235 Scenario:
236 1. In infra/init.yml in Reclass, add the glusterfs_version parameter
237 2. Start linux.system.repo state
238 3. Start "update-glusterfs" job
239 4. Check version for GlusterFS servers
240 5. Check version for GlusterFS clients
241
242 """
243 salt = salt_actions
244 reclass = reclass_actions
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300245 dt = drivetrain_actions
Hanna Arhipovacc3759b2019-08-28 16:01:11 +0300246
Hanna Arhipovacc3759b2019-08-28 16:01:11 +0300247 # ############## Change reclass ######################################
248 show_step(1)
249 reclass.add_key(
250 "parameters._param.linux_system_repo_mcp_glusterfs_version_number",
251 "5",
252 "cluster/*/infra/init.yml"
253 )
254 # ################# Run linux.system state ###########################
255 show_step(2)
256 salt.enforce_state("*", "linux.system.repo")
257
258 # ############## Start deploy-upgrade-galera job #####################
259 show_step(3)
Hanna Arhipovacc3759b2019-08-28 16:01:11 +0300260 job_name = 'update-glusterfs'
261
Hanna Arhipova508f6532021-01-27 15:52:45 +0200262 job_result, job_description = dt.start_job_on_jenkins(
Hanna Arhipovacc3759b2019-08-28 16:01:11 +0300263 job_name=job_name,
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300264 build_timeout=40 * 60)
Hanna Arhipovacc3759b2019-08-28 16:01:11 +0300265
Hanna Arhipova508f6532021-01-27 15:52:45 +0200266 assert job_result == 'SUCCESS', job_description
Hanna Arhipovacc3759b2019-08-28 16:01:11 +0300267
268 # ################ Check GlusterFS version for servers ##############
269 show_step(4)
270 gluster_server_versions_by_nodes = salt.cmd_run(
271 "I@glusterfs:server",
272 "glusterd --version|head -n1")[0]
273
Hanna Arhipova19429962019-10-17 15:16:49 +0300274 assert has_only_similar(gluster_server_versions_by_nodes), \
Hanna Arhipovacc3759b2019-08-28 16:01:11 +0300275 gluster_server_versions_by_nodes
276
277 # ################ Check GlusterFS version for clients ##############
278 show_step(5)
279 gluster_client_versions_by_nodes = salt.cmd_run(
280 "I@glusterfs:client",
281 "glusterfs --version|head -n1")[0]
282
283 assert has_only_similar(gluster_client_versions_by_nodes), \
284 gluster_client_versions_by_nodes
285
286 @pytest.mark.grab_versions
287 @pytest.mark.parametrize("_", [settings.ENV_NAME])
288 @pytest.mark.run_mcp_update
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300289 def test_update_galera(self, salt_actions, reclass_actions,
290 drivetrain_actions, show_step, _):
Hanna Arhipova94a8abe2019-08-22 14:11:46 +0300291 """ Upgrade Galera automatically
292
293 Scenario:
294 1. Include the Galera upgrade pipeline job to DriveTrain
295 2. Apply the jenkins.client state on the Jenkins nodes
296 3. set the openstack_upgrade_enabled parameter to true
297 4. Refresh pillars
298 5. Add repositories with new Galera packages
299 6. Start job from Jenkins
300 """
301 salt = salt_actions
302 reclass = reclass_actions
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300303 dt = drivetrain_actions
Hanna Arhipova94a8abe2019-08-22 14:11:46 +0300304 # ################### Enable pipeline #################################
305 show_step(1)
306 reclass.add_class(
307 "system.jenkins.client.job.deploy.update.upgrade_galera",
308 "cluster/*/cicd/control/leader.yml")
309 show_step(2)
310 salt.enforce_state("I@jenkins:client", "jenkins.client")
311
312 # ############### Enable automatic upgrade ############################
313 show_step(3)
314 reclass.add_bool_key("parameters._param.openstack_upgrade_enabled",
315 "True",
316 "cluster/*/infra/init.yml")
317
318 show_step(4)
Hanna Arhipova7cfeb072019-10-11 15:04:10 +0300319 salt.run_state("dbs*", "saltutil.refresh_pillar")
Hanna Arhipova94a8abe2019-08-22 14:11:46 +0300320
321 # ############# Add repositories with new Galera packages #######
322 show_step(5)
323 salt.enforce_state("dbs*", "linux.system.repo")
324 salt.enforce_state("cfg*", "salt.master")
325
Hanna Arhipova94a8abe2019-08-22 14:11:46 +0300326 # #################### Login Jenkins on cid01 node ###################
327 show_step(6)
328
Hanna Arhipova94a8abe2019-08-22 14:11:46 +0300329 job_name = 'deploy-upgrade-galera'
330 job_parameters = {
331 'INTERACTIVE': 'false'
332 }
333
Hanna Arhipova508f6532021-01-27 15:52:45 +0200334 job_result, job_description = dt.start_job_on_jenkins(
Hanna Arhipova94a8abe2019-08-22 14:11:46 +0300335 job_name=job_name,
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300336 job_parameters=job_parameters,
337 build_timeout=40 * 60)
Hanna Arhipova94a8abe2019-08-22 14:11:46 +0300338
Hanna Arhipova508f6532021-01-27 15:52:45 +0200339 assert job_result == 'SUCCESS', job_description
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300340
341 @pytest.fixture
342 def disable_automatic_failover_neutron_for_test(self, salt_actions):
343 """
344 On each OpenStack controller node, modify the neutron.conf file
345 Restart the neutron-server service
346 """
Hanna Arhipova19429962019-10-17 15:16:49 +0300347
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300348 def comment_line(node, file_name, word):
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300349 """
350 Adds '#' before the specific line in specific file
351
352 :param node: string, salt target of node where the file locates
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300353 :param file_name: string, full path to the file
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300354 :param word: string, the begin of line which should be commented
355 :return: None
356 """
357 salt_actions.cmd_run(node,
358 "sed -i 's/^{word}/#{word}/' {file}".
359 format(word=word,
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300360 file=file_name))
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300361
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300362 def add_line(node, file_name, line):
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300363 """
364 Appends line to the end of file
365
366 :param node: string, salt target of node where the file locates
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300367 :param file_name: string, full path to the file
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300368 :param line: string, line that should be added
369 :return: None
370 """
371 salt_actions.cmd_run(node, "echo {line} >> {file}".format(
Hanna Arhipova19429962019-10-17 15:16:49 +0300372 line=line,
373 file=file_name))
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300374
375 neutron_conf = '/etc/neutron/neutron.conf'
376 neutron_server = "I@neutron:server"
377 # ######## Create backup for config file #######################
378 salt_actions.cmd_run(
379 neutron_server,
380 "cp -p {file} {file}.backup".format(file=neutron_conf))
381
382 # ## Change parameters in neutron.conf'
383 comment_line(neutron_server, neutron_conf,
Hanna Arhipova19429962019-10-17 15:16:49 +0300384 "allow_automatic_l3agent_failover", )
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300385 comment_line(neutron_server, neutron_conf,
386 "allow_automatic_dhcp_failover")
387 add_line(neutron_server, neutron_conf,
388 "allow_automatic_dhcp_failover = false")
389 add_line(neutron_server, neutron_conf,
390 "allow_automatic_l3agent_failover = false")
391
392 # ## Apply changed config to the neutron-server service
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300393 result = salt_actions.cmd_run(neutron_server,
394 "service neutron-server restart")
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300395 # TODO: add check that neutron-server is up and running
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300396 yield result
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300397 # ## Revert file changes
398 salt_actions.cmd_run(
399 neutron_server,
400 "cp -p {file}.backup {file}".format(file=neutron_conf))
401 salt_actions.cmd_run(neutron_server,
402 "service neutron-server restart")
403
404 @pytest.fixture
405 def disable_neutron_agents_for_test(self, salt_actions):
406 """
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300407 Disable the neutron services before the test and
408 enable it after test
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300409 """
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300410 result = salt_actions.cmd_run("I@neutron:server", """
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300411 service neutron-dhcp-agent stop && \
412 service neutron-l3-agent stop && \
413 service neutron-metadata-agent stop && \
414 service neutron-openvswitch-agent stop
415 """)
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300416 yield result
417 #
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300418 salt_actions.cmd_run("I@neutron:server", """
419 service neutron-dhcp-agent start && \
420 service neutron-l3-agent start && \
421 service neutron-metadata-agent start && \
422 service neutron-openvswitch-agent start
423 """)
424 # TODO: add check that all services are UP and running
425
426 @pytest.mark.grab_versions
427 @pytest.mark.parametrize("_", [settings.ENV_NAME])
428 @pytest.mark.run_mcp_update
429 def test_update_rabbit(self, salt_actions, reclass_actions,
430 drivetrain_actions, show_step, _,
431 disable_automatic_failover_neutron_for_test,
432 disable_neutron_agents_for_test):
433 """ Updates RabbitMQ
434 Scenario:
435 1. Include the RabbitMQ upgrade pipeline job to DriveTrain
436 2. Add repositories with new RabbitMQ packages
437 3. Start Deploy - upgrade RabbitMQ pipeline
438
439 Updating RabbitMq should be completed before the OpenStack updating
440 process starts
441 """
442 salt = salt_actions
443 reclass = reclass_actions
444 dt = drivetrain_actions
445
446 # ####### Include the RabbitMQ upgrade pipeline job to DriveTrain ####
447 show_step(1)
448 reclass.add_class(
449 "system.jenkins.client.job.deploy.update.upgrade_rabbitmq",
450 "cluster/*/cicd/control/leader.yml")
451 salt.enforce_state("I@jenkins:client", "jenkins.client")
452
453 reclass.add_bool_key("parameters._param.openstack_upgrade_enabled",
454 "True",
455 "cluster/*/infra/init.yml")
456 salt.run_state("I@rabbitmq:server", "saltutil.refresh_pillar")
457
458 # ########### Add repositories with new RabbitMQ packages ############
459 show_step(2)
460 salt.enforce_state("I@rabbitmq:server", "linux.system.repo")
461
462 # ########### Start Deploy - upgrade RabbitMQ pipeline ############
463 show_step(3)
464 job_parameters = {
465 'INTERACTIVE': 'false'
466 }
467
Hanna Arhipova508f6532021-01-27 15:52:45 +0200468 job_result, job_description = dt.start_job_on_jenkins(
Hanna Arhipova1fcaf442019-09-06 15:30:45 +0300469 job_name='deploy-upgrade-rabbitmq',
470 job_parameters=job_parameters,
471 build_timeout=40 * 60
472 )
Hanna Arhipova508f6532021-01-27 15:52:45 +0200473 assert job_result == 'SUCCESS', job_description
Hanna Arhipovad35a29b2019-09-04 13:24:06 +0300474
475 @pytest.mark.grab_versions
476 @pytest.mark.parametrize("_", [settings.ENV_NAME])
477 @pytest.mark.run_mcp_update
478 def test_update_ceph(self, salt_actions, drivetrain_actions, show_step, _):
479 """ Updates Ceph to the latest minor version
480
481 Scenario:
482 1. Add workaround for unhealth Ceph
483 2. Start ceph-upgrade job with default parameters
484 3. Check Ceph version for all nodes
485
486 https://docs.mirantis.com/mcp/master/mcp-operations-guide/update-upgrade/minor-update/ceph-update.html
487 """
488 salt = salt_actions
489 dt = drivetrain_actions
490
491 # ###################### Add workaround for unhealth Ceph ############
492 show_step(1)
493 salt.cmd_run("I@ceph:radosgw",
494 "ceph config set 'mon pg warn max object skew' 20")
495 # ###################### Start ceph-upgrade pipeline #################
496 show_step(2)
497 job_parameters = {}
498
Hanna Arhipova508f6532021-01-27 15:52:45 +0200499 job_result, job_description = dt.start_job_on_jenkins(
Hanna Arhipovad35a29b2019-09-04 13:24:06 +0300500 job_name='ceph-update',
501 job_parameters=job_parameters)
502
Hanna Arhipova508f6532021-01-27 15:52:45 +0200503 assert job_result == 'SUCCESS', job_description
Hanna Arhipovad35a29b2019-09-04 13:24:06 +0300504
505 # ########## Verify Ceph version #####################################
506 show_step(3)
507
508 ceph_version_by_nodes = salt.cmd_run(
Hanna Arhipova19429962019-10-17 15:16:49 +0300509 "I@ceph:* and not I@ceph:monitoring and not I@ceph:backup:server",
510 "ceph version")[0]
Hanna Arhipovad35a29b2019-09-04 13:24:06 +0300511
512 assert has_only_similar(ceph_version_by_nodes), ceph_version_by_nodes
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300513
Hanna Arhipovaac008562019-10-17 11:54:23 +0300514 @pytest.mark.grab_versions
515 @pytest.mark.parametrize("_", [settings.ENV_NAME])
516 @pytest.mark.run_mcp_update
517 def test_update_stacklight(self, _, drivetrain_actions):
518 """ Update packages for Stacklight
519 Scenario:
520 1. Start Deploy - upgrade Stacklight job
521 """
522 drivetrain = drivetrain_actions
523
524 job_parameters = {
525 "STAGE_UPGRADE_DOCKER_COMPONENTS": True,
526 "STAGE_UPGRADE_ES_KIBANA": True,
527 "STAGE_UPGRADE_SYSTEM_PART": True
528 }
Hanna Arhipova508f6532021-01-27 15:52:45 +0200529 job_result, job_description = drivetrain.start_job_on_jenkins(
Hanna Arhipovaac008562019-10-17 11:54:23 +0300530 job_name="stacklight-upgrade",
531 job_parameters=job_parameters)
532
Hanna Arhipova508f6532021-01-27 15:52:45 +0200533 assert job_result == 'SUCCESS', job_description
Hanna Arhipovaac008562019-10-17 11:54:23 +0300534
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300535
Hanna Arhipova19429962019-10-17 15:16:49 +0300536@pytest.mark.usefixtures("switch_to_proposed_pipelines",
537 "enable_openstack_update")
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300538class TestOpenstackUpdate(object):
539
540 @pytest.mark.grab_versions
541 @pytest.mark.run_mcp_update
542 def test__pre_update__enable_pipeline_job(self,
543 reclass_actions, salt_actions,
544 show_step):
545 """ Enable pipeline in the Drivetrain
546
547 Scenario:
548 1. Add deploy.update.* classes to the reclass
549 2. Start jenkins.client salt state
550
551 """
552 salt = salt_actions
553 reclass = reclass_actions
554 show_step(1)
555 reclass.add_class("system.jenkins.client.job.deploy.update.upgrade",
556 "cluster/*/cicd/control/leader.yml")
557
558 reclass.add_class(
559 "system.jenkins.client.job.deploy.update.upgrade_ovs_gateway",
560 "cluster/*/cicd/control/leader.yml")
561
562 reclass.add_class(
563 "system.jenkins.client.job.deploy.update.upgrade_compute",
564 "cluster/*/cicd/control/leader.yml")
565
566 show_step(2)
567 r, errors = salt.enforce_state("I@jenkins:client", "jenkins.client")
568 assert errors is None
569
570 @pytest.mark.grab_versions
571 @pytest.mark.parametrize('target', get_control_plane_targets())
572 @pytest.mark.run_mcp_update
Hanna Arhipova19429962019-10-17 15:16:49 +0300573 def test__update__control_plane(self, drivetrain_actions, target):
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300574 """Start 'Deploy - upgrade control VMs' for specific node
575 """
576 job_parameters = {
577 "TARGET_SERVERS": target,
Hanna Arhipova606d5182019-12-13 13:23:55 +0200578 "OS_DIST_UPGRADE": True,
PGlazoved19b352020-05-21 16:42:27 +0400579 "UPGRADE_SALTSTACK": False,
Hanna Arhipova606d5182019-12-13 13:23:55 +0200580 "OS_UPGRADE": True,
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300581 "INTERACTIVE": False}
Hanna Arhipova508f6532021-01-27 15:52:45 +0200582 job_result, job_description = drivetrain_actions.start_job_on_jenkins(
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300583 job_name="deploy-upgrade-control",
584 job_parameters=job_parameters)
585
Hanna Arhipova508f6532021-01-27 15:52:45 +0200586 assert job_result == 'SUCCESS', job_description
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300587
588 @pytest.mark.grab_versions
589 @pytest.mark.run_mcp_update
Hanna Arhipova606d5182019-12-13 13:23:55 +0200590 def test__update__data_plane(self, drivetrain_actions, salt_actions):
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300591 """Start 'Deploy - upgrade OVS gateway'
592 """
Hanna Arhipova606d5182019-12-13 13:23:55 +0200593 if not salt_actions.cmd_run("gtw*", "test.ping")[0].keys():
594 pytest.skip("This deployment doesn't have gtw* nodes")
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300595 job_parameters = {
Hanna Arhipova606d5182019-12-13 13:23:55 +0200596 "OS_DIST_UPGRADE": True,
597 "OS_UPGRADE": True,
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300598 "INTERACTIVE": False}
Hanna Arhipova508f6532021-01-27 15:52:45 +0200599 job_result, job_description = drivetrain_actions.start_job_on_jenkins(
Hanna Arhipovaeb3a2112019-09-13 18:45:21 +0300600 job_name="deploy-upgrade-ovs-gateway",
601 job_parameters=job_parameters)
602
Hanna Arhipova508f6532021-01-27 15:52:45 +0200603 assert job_result == 'SUCCESS', job_description
Hanna Arhipova19429962019-10-17 15:16:49 +0300604
605 @pytest.mark.grab_versions
606 @pytest.mark.run_mcp_update
607 def test__update__computes(self, drivetrain_actions):
608 """Start 'Deploy - upgrade computes'
609 """
610 job_parameters = {
Hanna Arhipova606d5182019-12-13 13:23:55 +0200611 "OS_DIST_UPGRADE": True,
612 "OS_UPGRADE": True,
Hanna Arhipova19429962019-10-17 15:16:49 +0300613 "INTERACTIVE": False}
Hanna Arhipova508f6532021-01-27 15:52:45 +0200614 job_result, job_description = drivetrain_actions.start_job_on_jenkins(
Hanna Arhipova19429962019-10-17 15:16:49 +0300615 job_name="deploy-upgrade-compute",
616 job_parameters=job_parameters)
617
Hanna Arhipova508f6532021-01-27 15:52:45 +0200618 assert job_result == 'SUCCESS', job_description