Add fix for upgrade galera with mysql 5.7
--add update-mysql-version parametr for major upgrade
Related-Prod: PROD-36708
Change-Id: Ic1eb785c7f42a7532f55946aa6c024430810e0bf
diff --git a/jobs/templates/test-scenarios.yml b/jobs/templates/test-scenarios.yml
index 71e3643..4224901 100644
--- a/jobs/templates/test-scenarios.yml
+++ b/jobs/templates/test-scenarios.yml
@@ -126,7 +126,7 @@
--keep-duplicates --maxfail=1 \
tcp_tests/tests/system/test_mcp_update.py::TestUpdateMcpCluster::test_update_drivetrain \
tcp_tests/tests/system/test_mcp_update.py::TestOpenstackUpdate \
- tcp_tests/tests/system/test_mcp_update.py::TestUpdateMcpCluster::test_update_galera \
+ tcp_tests/tests/system/test_mcp_update.py::TestUpdateMcpCluster::test_update_galera --update-mysql-version 5.7 \
tcp_tests/tests/system/test_mcp_update.py::TestUpdateMcpCluster::test_update_rabbit \
tcp_tests/tests/system/test_mcp_update.py::TestUpdateMcpCluster::test_update_stacklight \
tcp_tests/tests/system/test_mcp_update.py::TestUpdateMcpCluster::test_update_ceph \
diff --git a/tcp_tests/managers/reclass_manager.py b/tcp_tests/managers/reclass_manager.py
index 3952b5f..c7ec298 100644
--- a/tcp_tests/managers/reclass_manager.py
+++ b/tcp_tests/managers/reclass_manager.py
@@ -215,6 +215,26 @@
path=short_path
))
+ def create_yaml_with_context(self, yaml_context, short_path):
+ """
+ Create yaml file with context
+
+ :param yaml_context: string, yaml with extra context
+ :param short_path: string, path to reclass yaml file.
+ """
+ tmp_file = "/tmp/extra_context.yaml"
+ with open(tmp_file, "w") as f:
+ f.write(yaml_context)
+
+ self.ssh.upload(tmp_file, tmp_file)
+ self.ssh.check_call(
+ "cat {yaml} > \
+ /srv/salt/reclass/classes/{path}".format(
+ reclass_tools=self.reclass_tools_cmd,
+ yaml=tmp_file,
+ path=short_path
+ ))
+
def commit(self, text_commit):
self.ssh.check_call(
"cd /srv/salt/reclass; git add -u && git commit --allow-empty "
diff --git a/tcp_tests/tests/system/conftest.py b/tcp_tests/tests/system/conftest.py
index 0dabd4d..74b3ea3 100644
--- a/tcp_tests/tests/system/conftest.py
+++ b/tcp_tests/tests/system/conftest.py
@@ -84,6 +84,7 @@
def pytest_addoption(parser):
parser.addoption("--update-to-tag",
+ "--update-mysql-version",
action="store",
default=None,
help="For mcp_update test")
diff --git a/tcp_tests/tests/system/test_mcp_update.py b/tcp_tests/tests/system/test_mcp_update.py
index b617528..ffbccf5 100644
--- a/tcp_tests/tests/system/test_mcp_update.py
+++ b/tcp_tests/tests/system/test_mcp_update.py
@@ -72,6 +72,11 @@
@pytest.fixture(scope='class')
+def update_mysql_to_version(request):
+ return request.config.getoption("--update-mysql-version")
+
+
+@pytest.fixture(scope='class')
def switch_to_proposed_pipelines(reclass_actions, salt_actions,
update_to_tag):
if update_to_tag:
@@ -300,7 +305,8 @@
@pytest.mark.parametrize("_", [settings.ENV_NAME])
@pytest.mark.run_mcp_update
def test_update_glusterfs(self, salt_actions, reclass_actions,
- drivetrain_actions, show_step, _):
+ drivetrain_actions, show_step,
+ update_mysql_to_version, _):
""" Upgrade GlusterFS
Scenario:
1. In infra/init.yml in Reclass, add the glusterfs_version parameter
@@ -310,6 +316,7 @@
5. Check version for GlusterFS clients
"""
+
salt = salt_actions
reclass = reclass_actions
dt = drivetrain_actions
@@ -357,16 +364,18 @@
@pytest.mark.parametrize("_", [settings.ENV_NAME])
@pytest.mark.run_mcp_update
def test_update_galera(self, salt_actions, reclass_actions,
- drivetrain_actions, show_step, _):
+ drivetrain_actions, show_step,
+ update_mysql_to_version, _):
""" Upgrade Galera automatically
Scenario:
1. Include the Galera upgrade pipeline job to DriveTrain
- 2. Apply the jenkins.client state on the Jenkins nodes
- 3. set the openstack_upgrade_enabled parameter to true
- 4. Refresh pillars
- 5. Add repositories with new Galera packages
- 6. Start job from Jenkins
+ 2. Add fix for mysql 5.7
+ 3. Apply the jenkins.client state on the Jenkins nodes
+ 4. set the openstack_upgrade_enabled parameter to true
+ 5. Refresh pillars
+ 6. Add repositories with new Galera packages
+ 7. Start job from Jenkins
"""
salt = salt_actions
reclass = reclass_actions
@@ -376,32 +385,68 @@
reclass.add_class(
"system.jenkins.client.job.deploy.update.upgrade_galera",
"cluster/*/cicd/control/leader.yml")
+ # ################### Fix for Mysql 5.7 ##############################
show_step(2)
- salt.enforce_state("I@jenkins:client", "jenkins.client")
+ if (update_mysql_to_version == '5.7'):
+ mysql_update_bool = "True"
+ mysql_class = "cluster.{env_name}.openstack." \
+ "database.mysql_version"\
+ .format(env_name=settings.ENV_NAME)
+ reclass.add_class(
+ mysql_class,
+ "cluster/*/openstack/database/master.yml")
+ reclass.add_class(
+ mysql_class,
+ "cluster/*/openstack/database/slave.yml")
+ mysql_path = "cluster/{env_name}" \
+ "/openstack/database/mysql_version.yml"\
+ .format(env_name=settings.ENV_NAME)
+ galera_mysql_version = '5.7'
+ if update_mysql_to_version != '5.7':
+ galera_mysql_version = update_mysql_to_version
+ mysql_version = "parameters:\n" \
+ " _param:\n" \
+ " galera_mysql_version: {}"\
+ .format(galera_mysql_version)
+ if not os.path.isfile("/srv/salt/reclass/classes/{path}".format(
+ path=mysql_path)):
+ reclass.create_yaml_with_context(mysql_version,
+ mysql_path)
+ else:
+ reclass.merge_context(mysql_version,
+ mysql_path)
+ reclass_actions.commit(
+ "[from TCP-QA] Change for mysql new version")
+ show_step(3)
+ salt.enforce_state("I@jenkins:client", "jenkins.client")
+ else:
+ LOG.info("Skip mysql upgrade fix")
# ############### Enable automatic upgrade ############################
- show_step(3)
+ show_step(4)
reclass.add_bool_key("parameters._param.openstack_upgrade_enabled",
"True",
"cluster/*/infra/init.yml")
- show_step(4)
+ show_step(5)
salt.run_state("dbs*", "saltutil.refresh_pillar")
# ############# Add repositories with new Galera packages #######
- show_step(5)
+ show_step(6)
salt.enforce_state("dbs*", "linux.system.repo")
salt.enforce_state("cfg*", "salt.master")
# #################### Login Jenkins on cid01 node ###################
- show_step(6)
+ show_step(7)
job_name = 'deploy-upgrade-galera'
job_parameters = {
'INTERACTIVE': 'false',
'OS_DIST_UPGRADE': 'true',
- 'OS_UPGRADE': 'true'
+ 'OS_UPGRADE': 'true',
}
+ if mysql_update_bool:
+ job_parameters.update({'UPDATE_TO_MYSQL57': 'true'})
job_result, job_description = dt.start_job_on_jenkins(
job_name=job_name,