def test(config): result = consts.TEST_PASSED cause = None ret = Cgroup.configparser(config, cghelp=True) if 'Parse and load the specified cgroups' not in ret: result = consts.TEST_FAILED cause = 'Failed to print cgconfigparser help text' return result, cause try: Cgroup.configparser(config, load_file=CONFIG_FILE_NAME) except RunError as re: if 'Invalid argument' not in re.stderr: result = consts.TEST_FAILED cause = "Expected 'Invalid argument' to be in stderr" return result, cause if re.ret != 96: result = consts.TEST_FAILED cause = 'Expected return code of 96 but received {}'.format(re.ret) return result, cause else: result = consts.TEST_FAILED cause = 'Test case erroneously passed' return result, cause return result, cause
def test(config): Cgroup.configparser(config, load_file=CONFIG_FILE_NAME) Cgroup.get_and_validate(config, CGNAME, 'cpu.cfs_period_us', CFS_PERIOD) Cgroup.get_and_validate(config, CGNAME, 'cpu.cfs_quota_us', CFS_QUOTA) Cgroup.get_and_validate(config, CGNAME, 'cpu.shares', SHARES) return consts.TEST_PASSED, None
def test(config): Cgroup.configparser(config, load_dir=CONFIG_FILE_DIR) Cgroup.get_and_validate(config, CGNAME, 'cpu.cfs_period_us', CFS_PERIOD) Cgroup.get_and_validate(config, CGNAME, 'cpu.cfs_quota_us', CFS_QUOTA) Cgroup.get_and_validate(config, CGNAME, 'cpu.shares', SHARES) Cgroup.get_and_validate(config, CGNAME, 'memory.limit_in_bytes', LIMIT_IN_BYTES) Cgroup.get_and_validate(config, CGNAME, 'memory.soft_limit_in_bytes', SOFT_LIMIT_IN_BYTES) return consts.TEST_PASSED, None
def test(config): result = consts.TEST_PASSED cause = None Cgroup.configparser(config, load_file=CONFIG_FILE_NAME, dflt_usr=USER, dflt_grp=GROUP, dperm=DPERM, fperm=FPERM) mnt_path = Cgroup.get_controller_mount_point(CONTROLLER) cpus_path = os.path.join(mnt_path, CGNAME, 'cpuset.cpus') user = utils.get_file_owner_username(config, cpus_path) group = utils.get_file_owner_group_name(config, cpus_path) if user != USER: result = consts.TEST_FAILED cause = ('Owner name failed. Expected {}, received {}\n' ''.format(USER, user)) return result, cause if group != GROUP: result = consts.TEST_FAILED cause = ('Owner group failed. Expected {}, received {}\n' ''.format(GROUP, group)) return result, cause fperm = utils.get_file_permissions(config, cpus_path) if fperm != FPERM: result = consts.TEST_FAILED cause = ('File permissions failed. Expected {}, received {}\n' ''.format(FPERM, fperm)) return result, cause dperm = utils.get_file_permissions(config, os.path.join(mnt_path, CGNAME)) if dperm != DPERM: result = consts.TEST_FAILED cause = ('Directory permissions failed. Expected {}, received {}\n' ''.format(DPERM, dperm)) return result, cause return result, cause
def test(config): result = consts.TEST_PASSED cause = None Cgroup.configparser(config, load_file=CONFIG_FILE_NAME, tperm=TPERM, tasks_usr=USER, tasks_grp=GROUP) mnt_path = Cgroup.get_controller_mount_point(CONTROLLER) tasks_path = os.path.join(mnt_path, CGNAME, 'tasks') user = utils.get_file_owner_username(config, tasks_path) group = utils.get_file_owner_group_name(config, tasks_path) if user != USER: result = consts.TEST_FAILED cause = ( 'Owner name failed. Expected {}, received {}\n' ''.format(USER, user) ) return result, cause if group != GROUP: result = consts.TEST_FAILED cause = ( 'Owner group failed. Expected {}, received {}\n' ''.format(GROUP, group) ) return result, cause tperm = utils.get_file_permissions(config, tasks_path) if tperm != TPERM: result = consts.TEST_FAILED cause = ( 'File permissions failed. Expected {}, received {}\n' ''.format(TPERM, tperm) ) return result, cause return result, cause