From 5ec47f3f73521a54064bf1d13ea69c728a688459 Mon Sep 17 00:00:00 2001 From: Dmitry Kalashnik Date: Tue, 29 Mar 2016 11:13:35 +0300 Subject: [PATCH] Fix pylint issues in test_cgroups Change-Id: I223394c4721598859837e2bf623d9edd57ccdc0b Related: blueprint cgroups-tests --- fuelweb_test/tests/test_cgroups.py | 55 ++++++++++++++++-------------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/fuelweb_test/tests/test_cgroups.py b/fuelweb_test/tests/test_cgroups.py index f62c333c6..4ce67bf0d 100644 --- a/fuelweb_test/tests/test_cgroups.py +++ b/fuelweb_test/tests/test_cgroups.py @@ -31,7 +31,8 @@ from fuelweb_test.helpers import utils class TestCgroupHa(TestBasic): """Tests for verification deployment with enabled cgroup.""" - def generate_attributes(self, cgroups): + @staticmethod + def generate_attributes(cgroups): """Generate cluster attributes structure from cgroups dicts.""" attributes = {} @@ -55,6 +56,32 @@ class TestCgroupHa(TestBasic): return {"editable": {"cgroups": attributes}} + @staticmethod + def check_cgconfig_setup(config, process, controller, + limit=None, value=None): + """Check /etc/cgconfig.conf contains properly configured cgroup.""" + + actual_limit = config[process][controller] + + if limit is None and value is None: + asserts.assert_equal(actual_limit, {}, + "Actual limit is not empty: {}" + .format(actual_limit)) + else: + asserts.assert_equal(actual_limit[limit], value, + "Actual value limit is not as expected for " + "process {}, controller {}, limit {}, " + "expected value = {}, actual == {}" + .format(process, controller, limit, value, + actual_limit[limit])) + + @staticmethod + def generate_lscgroups(cgroups): + """Generate a list of lscgroups entities from cgroups dicts.""" + + return ["{}:/{}".format(cgroup["controller"], cgroup["process"]) + for cgroup in cgroups] + def apply_cgroups(self, cgroups, node_ids): cluster_id = self.fuel_web.get_last_created_cluster() @@ -134,30 +161,6 @@ class TestCgroupHa(TestBasic): return json.loads(cgroups_config) - def check_cgconfig_setup(self, config, process, controller, - limit=None, value=None): - """Check /etc/cgconfig.conf contains properly configured cgroup.""" - - actual_limit = config[process][controller] - - if limit is None and value is None: - asserts.assert_equal(actual_limit, {}, - "Actual limit is not empty: {}" - .format(actual_limit)) - else: - asserts.assert_equal(actual_limit[limit], value, - "Actual value limit is not as expected for " - "process {}, controller {}, limit {}, " - "expected value = {}, actual == {}" - .format(process, controller, limit, value, - actual_limit[limit])) - - def generate_lscgroups(self, cgroups): - """Generate a list of lscgroups entities from cgroups dicts.""" - - return ["{}:/{}".format(cgroup["controller"], cgroup["process"]) - for cgroup in cgroups] - def check_cgroups_on_node(self, nailgun_node, cgroups): """Complex validation of cgroups on particular node.""" @@ -407,7 +410,9 @@ class TestCgroupHa(TestBasic): for cgroup in cgroups: if cgroup["limit"] == "memory.soft_limit_in_bytes": + # pylint: disable=no-member percent, min_mem, max_mem = cgroup["value"].split(",") + # pylint: enable=no-member percent = int(percent.replace("%", "")) * memory / 100 min_mem, max_mem = int(min_mem), int(max_mem)