blob: f3834d3d51f0002f5584b2061993ef2b8e99a3a8 [file] [log] [blame]
Hanna Arhipova71ecc272019-08-20 14:54:22 +03001import pytest
2
3from tcp_tests import logger
4from tcp_tests import settings
Hanna Arhipova71ecc272019-08-20 14:54:22 +03005
6LOG = logger.logger
7
8
9class TestUpdateMcpCluster(object):
10 """
11 Following the steps in
Hanna Arhipova94a8abe2019-08-22 14:11:46 +030012 https://docs.mirantis.com/mcp/master/mcp-operations-guide/update-upgrade/minor-update.html#minor-update
Hanna Arhipova71ecc272019-08-20 14:54:22 +030013 """
14
15 @pytest.mark.grab_versions
16 @pytest.mark.parametrize("_", [settings.ENV_NAME])
17 @pytest.mark.run_mcp_update
Hanna Arhipova17b2c102019-09-06 16:44:17 +030018 def test_update_drivetrain(self, salt_actions, drivetrain_actions,
19 show_step, _):
Hanna Arhipova71ecc272019-08-20 14:54:22 +030020 """Updating DriveTrain component to release/proposed/2019.2.0 version
21
22 Scenario:
Hanna Arhipova17b2c102019-09-06 16:44:17 +030023 1. Add workaround for PROD-32751
Hanna Arhipova71ecc272019-08-20 14:54:22 +030024 2. Run job git-mirror-downstream-mk-pipelines
25 3. Run job git-mirror-downstream-pipeline-library
26 4. If jobs are passed then start 'Deploy - upgrade MCP Drivetrain'
27
28 Duration: ~35 min
29 """
30 salt = salt_actions
Hanna Arhipova17b2c102019-09-06 16:44:17 +030031 dt = drivetrain_actions
Hanna Arhipova71ecc272019-08-20 14:54:22 +030032
Hanna Arhipova17b2c102019-09-06 16:44:17 +030033 # #################### Add workaround for PROD-32751 #################
Hanna Arhipova71ecc272019-08-20 14:54:22 +030034 show_step(1)
35
Hanna Arhipova71ecc272019-08-20 14:54:22 +030036 # FIXME: workaround for PROD-32751
37 salt.cmd_run("cfg01*", "cd /srv/salt/reclass; git add -u && \
38 git commit --allow-empty -m 'Cluster model update'")
39
40 # ################### Downstream mk-pipelines #########################
41 show_step(2)
42 job_name = 'git-mirror-downstream-mk-pipelines'
43 job_parameters = {
44 'BRANCHES': 'release/proposed/2019.2.0'
45 }
Hanna Arhipova17b2c102019-09-06 16:44:17 +030046 update_pipelines = dt.start_job_on_cid_jenkins(
Hanna Arhipova71ecc272019-08-20 14:54:22 +030047 job_name=job_name,
48 job_parameters=job_parameters)
49
Hanna Arhipova17b2c102019-09-06 16:44:17 +030050 assert update_pipelines == 'SUCCESS'
Hanna Arhipova71ecc272019-08-20 14:54:22 +030051
52 # ################### Downstream pipeline-library ####################
53 show_step(3)
54 job_name = 'git-mirror-downstream-pipeline-library'
55 job_parameters = {
56 'BRANCHES': 'release/proposed/2019.2.0'
57 }
Hanna Arhipova17b2c102019-09-06 16:44:17 +030058 update_pipeline_library = dt.start_job_on_cid_jenkins(
Hanna Arhipova71ecc272019-08-20 14:54:22 +030059 job_name=job_name,
60 job_parameters=job_parameters)
61
Hanna Arhipova17b2c102019-09-06 16:44:17 +030062 assert update_pipeline_library == 'SUCCESS'
Hanna Arhipova71ecc272019-08-20 14:54:22 +030063
64 # ################### Start 'Deploy - upgrade MCP Drivetrain' job #####
65 show_step(4)
66
Hanna Arhipova71ecc272019-08-20 14:54:22 +030067 job_name = 'upgrade-mcp-release'
68 job_parameters = {
69 'MK_PIPELINES_REFSPEC': 'release/proposed/2019.2.0',
70 'TARGET_MCP_VERSION': '2019.2.0'
71 }
Hanna Arhipova17b2c102019-09-06 16:44:17 +030072 update_drivetrain = dt.start_job_on_cid_jenkins(
Hanna Arhipova71ecc272019-08-20 14:54:22 +030073 job_name=job_name,
Hanna Arhipova17b2c102019-09-06 16:44:17 +030074 job_parameters=job_parameters,
75 build_timeout=3600)
Hanna Arhipova71ecc272019-08-20 14:54:22 +030076
Hanna Arhipova17b2c102019-09-06 16:44:17 +030077 assert update_drivetrain == 'SUCCESS'
Hanna Arhipova71ecc272019-08-20 14:54:22 +030078
Hanna Arhipova94a8abe2019-08-22 14:11:46 +030079 @pytest.mark.grab_versions
80 @pytest.mark.parametrize("_", [settings.ENV_NAME])
Hanna Arhipova71ecc272019-08-20 14:54:22 +030081 @pytest.mark.run_mcp_update
Hanna Arhipovacc3759b2019-08-28 16:01:11 +030082 def test_update_glusterfs(self, salt_actions, reclass_actions,
Hanna Arhipova17b2c102019-09-06 16:44:17 +030083 drivetrain_actions, show_step, _):
Hanna Arhipovacc3759b2019-08-28 16:01:11 +030084 """ Upgrade GlusterFS
85 Scenario:
86 1. In infra/init.yml in Reclass, add the glusterfs_version parameter
87 2. Start linux.system.repo state
88 3. Start "update-glusterfs" job
89 4. Check version for GlusterFS servers
90 5. Check version for GlusterFS clients
91
92 """
93 salt = salt_actions
94 reclass = reclass_actions
Hanna Arhipova17b2c102019-09-06 16:44:17 +030095 dt = drivetrain_actions
Hanna Arhipovacc3759b2019-08-28 16:01:11 +030096
97 def has_only_similar(param_by_nodes):
98 """
99 :param param_by_nodes: dict
100 :return: bool, True if all items in the dict have similar keys
101 """
102 params = list(param_by_nodes.values())
103
104 def are_similar(x): return x == params[0]
105
106 return all(map(are_similar, params)),
107 # ############## Change reclass ######################################
108 show_step(1)
109 reclass.add_key(
110 "parameters._param.linux_system_repo_mcp_glusterfs_version_number",
111 "5",
112 "cluster/*/infra/init.yml"
113 )
114 # ################# Run linux.system state ###########################
115 show_step(2)
116 salt.enforce_state("*", "linux.system.repo")
117
118 # ############## Start deploy-upgrade-galera job #####################
119 show_step(3)
Hanna Arhipovacc3759b2019-08-28 16:01:11 +0300120 job_name = 'update-glusterfs'
121
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300122 update_glusterfs = dt.start_job_on_cid_jenkins(
Hanna Arhipovacc3759b2019-08-28 16:01:11 +0300123 job_name=job_name,
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300124 build_timeout=40 * 60)
Hanna Arhipovacc3759b2019-08-28 16:01:11 +0300125
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300126 assert update_glusterfs == 'SUCCESS'
Hanna Arhipovacc3759b2019-08-28 16:01:11 +0300127
128 # ################ Check GlusterFS version for servers ##############
129 show_step(4)
130 gluster_server_versions_by_nodes = salt.cmd_run(
131 "I@glusterfs:server",
132 "glusterd --version|head -n1")[0]
133
134 assert has_only_similar(gluster_server_versions_by_nodes),\
135 gluster_server_versions_by_nodes
136
137 # ################ Check GlusterFS version for clients ##############
138 show_step(5)
139 gluster_client_versions_by_nodes = salt.cmd_run(
140 "I@glusterfs:client",
141 "glusterfs --version|head -n1")[0]
142
143 assert has_only_similar(gluster_client_versions_by_nodes), \
144 gluster_client_versions_by_nodes
145
146 @pytest.mark.grab_versions
147 @pytest.mark.parametrize("_", [settings.ENV_NAME])
148 @pytest.mark.run_mcp_update
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300149 def test_update_galera(self, salt_actions, reclass_actions,
150 drivetrain_actions, show_step, _):
Hanna Arhipova94a8abe2019-08-22 14:11:46 +0300151 """ Upgrade Galera automatically
152
153 Scenario:
154 1. Include the Galera upgrade pipeline job to DriveTrain
155 2. Apply the jenkins.client state on the Jenkins nodes
156 3. set the openstack_upgrade_enabled parameter to true
157 4. Refresh pillars
158 5. Add repositories with new Galera packages
159 6. Start job from Jenkins
160 """
161 salt = salt_actions
162 reclass = reclass_actions
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300163 dt = drivetrain_actions
Hanna Arhipova94a8abe2019-08-22 14:11:46 +0300164 # ################### Enable pipeline #################################
165 show_step(1)
166 reclass.add_class(
167 "system.jenkins.client.job.deploy.update.upgrade_galera",
168 "cluster/*/cicd/control/leader.yml")
169 show_step(2)
170 salt.enforce_state("I@jenkins:client", "jenkins.client")
171
172 # ############### Enable automatic upgrade ############################
173 show_step(3)
174 reclass.add_bool_key("parameters._param.openstack_upgrade_enabled",
175 "True",
176 "cluster/*/infra/init.yml")
177
178 show_step(4)
179 salt.enforce_state("dbs*", "saltutil.refresh_pillar")
180
181 # ############# Add repositories with new Galera packages #######
182 show_step(5)
183 salt.enforce_state("dbs*", "linux.system.repo")
184 salt.enforce_state("cfg*", "salt.master")
185
Hanna Arhipova94a8abe2019-08-22 14:11:46 +0300186 # #################### Login Jenkins on cid01 node ###################
187 show_step(6)
188
Hanna Arhipova94a8abe2019-08-22 14:11:46 +0300189 job_name = 'deploy-upgrade-galera'
190 job_parameters = {
191 'INTERACTIVE': 'false'
192 }
193
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300194 update_galera = dt.start_job_on_cid_jenkins(
Hanna Arhipova94a8abe2019-08-22 14:11:46 +0300195 job_name=job_name,
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300196 job_parameters=job_parameters,
197 build_timeout=40 * 60)
Hanna Arhipova94a8abe2019-08-22 14:11:46 +0300198
Hanna Arhipova17b2c102019-09-06 16:44:17 +0300199 assert update_galera == 'SUCCESS'