From 01a9ea52d1129bee341d21efb6e9077889ab59da Mon Sep 17 00:00:00 2001 From: Vladimir Khlyunev Date: Thu, 25 Aug 2016 15:11:47 +0300 Subject: [PATCH] Replace StrictVersion in upgrade tests We are used both LooseVersion and StrictVersion classes which produces errors in tests. Unify all verstion-related actions with LooseVersion. Change-Id: I1744197f9be0b5283b0843f2358631c9e6e71111 --- .../tests_upgrade/test_data_driven_upgrade_base.py | 11 +++++------ fuelweb_test/tests/tests_upgrade/upgrader_tool.py | 14 +++++++------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/fuelweb_test/tests/tests_upgrade/test_data_driven_upgrade_base.py b/fuelweb_test/tests/tests_upgrade/test_data_driven_upgrade_base.py index fc1a060ae..1473c461d 100644 --- a/fuelweb_test/tests/tests_upgrade/test_data_driven_upgrade_base.py +++ b/fuelweb_test/tests/tests_upgrade/test_data_driven_upgrade_base.py @@ -19,7 +19,6 @@ import os # pylint: disable=import-error # pylint: disable=no-name-in-module from distutils.version import LooseVersion -from distutils.version import StrictVersion # pylint: enable=no-name-in-module # pylint: enable=import-error @@ -107,7 +106,7 @@ class DataDrivenUpgradeBase(TestBasic): @property def fuel_version(self): version = self.fuel_web.client.get_api_version()['release'] - return StrictVersion(version) + return LooseVersion(version) @property def repos_local_path(self): @@ -186,7 +185,7 @@ class DataDrivenUpgradeBase(TestBasic): self.admin_remote.check_call( "rm -rf /usr/lib/python2.*/site-packages/octane", raise_on_err=False) - if LooseVersion(self.fuel_version) >= LooseVersion("9.0"): + if self.fuel_version >= LooseVersion("9.0"): self.admin_remote.check_call( "yum remove -y fuel-nailgun-extension-cluster-upgrade", raise_on_err=False) @@ -312,12 +311,12 @@ class DataDrivenUpgradeBase(TestBasic): logger.info("Applying backup from {}".format(repos_backup_path)) self.octane_action("repo-restore", repos_backup_path) - if self.fuel_version in (StrictVersion('7.0'), StrictVersion('8.0')): + if self.fuel_version in (LooseVersion('7.0'), LooseVersion('8.0')): logger.info( "Update CentOS bootstrap image with restored ssh keys") self.octane_action('update-bootstrap-centos') - if self.fuel_version >= StrictVersion('8.0'): + if self.fuel_version >= LooseVersion('8.0'): self.fuel_web.change_default_network_settings() n_nodes = self.fuel_web.client.list_nodes() @@ -470,7 +469,7 @@ class DataDrivenUpgradeBase(TestBasic): cmd = 'bash -c "cobbler system list" | grep ' \ '-w "node-{0}"'.format(node_id) - if self.fuel_version <= StrictVersion('8.0'): + if self.fuel_version <= LooseVersion('8.0'): cmd = "dockerctl shell cobbler {}".format(cmd) admin_remote.check_call(cmd) diff --git a/fuelweb_test/tests/tests_upgrade/upgrader_tool.py b/fuelweb_test/tests/tests_upgrade/upgrader_tool.py index 22b95e75c..797f15af9 100644 --- a/fuelweb_test/tests/tests_upgrade/upgrader_tool.py +++ b/fuelweb_test/tests/tests_upgrade/upgrader_tool.py @@ -16,7 +16,7 @@ from __future__ import unicode_literals # pylint: disable=import-error # pylint: disable=no-name-in-module -from distutils.version import StrictVersion +from distutils.version import LooseVersion # pylint: enable=no-name-in-module # pylint: enable=import-error import os @@ -85,11 +85,11 @@ class UpgradeCustom(DataDrivenUpgradeBase): self.revert_source() assert_equal( - StrictVersion(current_step['fuel_version']), + LooseVersion(current_step['fuel_version']), self.fuel_version, "Wrong fuel version in current step; " "should be {!r}, actual {!r}".format( - StrictVersion(current_step['fuel_version']), + LooseVersion(current_step['fuel_version']), self.fuel_version)) # clean up existing files for avoiding "No space left" self.env.d_env.get_admin_remote().check_call( @@ -126,11 +126,11 @@ class UpgradeCustom(DataDrivenUpgradeBase): self.revert_backup() assert_equal( - StrictVersion(current_step['source_fuel_version']), + LooseVersion(current_step['source_fuel_version']), self.fuel_version, "Wrong fuel version in current step; " "should be {!r}, actual {!r}".format( - StrictVersion(current_step['source_fuel_version']), + LooseVersion(current_step['source_fuel_version']), self.fuel_version)) assert_true(os.path.exists(self.repos_local_path)) @@ -150,11 +150,11 @@ class UpgradeCustom(DataDrivenUpgradeBase): self.do_restore(self.backup_path, self.local_path, self.repos_backup_path, self.repos_local_path) assert_equal( - StrictVersion(current_step['target_fuel_version']), + LooseVersion(current_step['target_fuel_version']), self.fuel_version, "Wrong fuel version in current step; " "should be {!r}, actual {!r}".format( - StrictVersion(current_step['target_fuel_version']), + LooseVersion(current_step['target_fuel_version']), self.fuel_version)) self.env.make_snapshot(self.restore_snapshot_name, is_make=True)