Skip to content

Commit

Permalink
Added load config file functionality, fix issue #4588 (#4595)
Browse files Browse the repository at this point in the history
* Added load config file functionality, fix issue #4588

Signed-off-by: aviadp <[email protected]>

* added docstring, fixed some wrong parameters names

Signed-off-by: aviadp <[email protected]>

* Fixed short_ocp_upgrade_version for 4.10 and above

Signed-off-by: aviadp <[email protected]>
  • Loading branch information
AviadP authored Aug 3, 2021
1 parent 59a03b4 commit 0ad0291
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions tests/ecosystem/upgrade/test_upgrade_ocp.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import logging
import os

from pkg_resources import parse_version
from semantic_version import Version

from ocs_ci.ocs import ocp
from ocs_ci.ocs import constants
from ocs_ci.framework import config
from ocs_ci.utility.utils import (
TimeoutSampler,
get_latest_ocp_version,
expose_ocp_version,
ceph_health_check,
load_config_file,
)
from ocs_ci.framework.testlib import ManageTest, ocp_upgrade, ignore_leftovers
from ocs_ci.ocs.cluster import CephCluster, CephHealthMonitor
Expand All @@ -26,6 +32,35 @@ class TestUpgradeOCP(ManageTest):
5. monitor cluster health
"""

def load_ocp_version_config_file(self, ocp_upgrade_version):
"""
Loads config file to the ocs-ci config with upgrade version
Args:
ocp_upgrade_version (str): version to be upgraded
"""

version = Version.coerce(ocp_upgrade_version)
short_ocp_upgrade_version = ".".join([str(version.major), str(version.minor)])
version_before_upgrade = parse_version(
config.DEPLOYMENT.get("installer_version")
)
version_post_upgrade = parse_version(ocp_upgrade_version)
version_change = version_post_upgrade > version_before_upgrade
if version_change:
version_config_file = os.path.join(
constants.OCP_VERSION_CONF_DIR,
f"ocp-{short_ocp_upgrade_version}-config.yaml",
)
logger.debug(f"config file to be loaded: {version_config_file}")
load_config_file(version_config_file)
else:
logger.info(
f"Upgrade version {version_post_upgrade} is not higher than old version:"
f" {version_before_upgrade}, new config file will not be loaded"
)

def test_upgrade_ocp(self, reduce_and_resume_cluster_load):
"""
Tests OCS stability when upgrading OCP
Expand Down Expand Up @@ -117,6 +152,9 @@ def test_upgrade_ocp(self, reduce_and_resume_cluster_load):
logger.info("Upgrade Completed Successfully!")
break

# load new config file
self.load_ocp_version_config_file(ocp_upgrade_version)

new_ceph_cluster = CephCluster()
new_ceph_cluster.wait_for_rebalance(timeout=1800)
ceph_health_check(tries=90, delay=30)

0 comments on commit 0ad0291

Please sign in to comment.