def test(config):
    Cgroup.set(config, cgname=DST_CGNAME, copy_from=SRC_CGNAME)

    for i, setting in enumerate(SETTINGS):
        Cgroup.get_and_validate(config, DST_CGNAME, setting, VALUES[i])

    return consts.TEST_PASSED, None
示例#2
0
def test(config):
    Cgroup.set(config, cgname=[CGNAME1, CGNAME2], setting=SETTING, value=VALUE)

    Cgroup.get_and_validate(config, CGNAME1, SETTING, VALUE)
    Cgroup.get_and_validate(config, CGNAME2, SETTING, VALUE)

    return consts.TEST_PASSED, None
示例#3
0
def test(config):
    Cgroup.set(config, cgname=CGNAME, setting=SETTINGS, value=VALUES)

    for i, setting in enumerate(SETTINGS):
        Cgroup.get_and_validate(config, CGNAME, setting, VALUES[i])

    return consts.TEST_PASSED, None
示例#4
0
def setup(config):
    Cgroup.create(config, CONTROLLER, CGNAME1)
    Cgroup.create(config, CONTROLLER, CGNAME2)

    version = CgroupVersion.get_version(CONTROLLER)

    if version == CgroupVersion.CGROUP_V1:
        Cgroup.set(config, CGNAME1, SETTING_V1, VALUE)
        Cgroup.set(config, CGNAME2, SETTING_V1, VALUE)
    elif version == CgroupVersion.CGROUP_V2:
        Cgroup.set(config, CGNAME1, SETTING_V2, VALUE)
        Cgroup.set(config, CGNAME2, SETTING_V2, VALUE)
def setup(config):
    Cgroup.create(config, CONTROLLER, SRC_CGNAME)
    Cgroup.create(config, CONTROLLER, DST_CGNAME)
    Cgroup.set(config, cgname=SRC_CGNAME, setting=SETTINGS, value=VALUES)
示例#6
0
def setup(config):
    CgroupCli.create(config, CONTROLLER, CGNAME)
    if CgroupVersion.get_version('cpu') == CgroupVersion.CGROUP_V1:
        CgroupCli.set(config, CGNAME, SETTING1, VALUE1)
    else:
        CgroupCli.set(config, CGNAME, SETTING2, VALUE2)
示例#7
0
def setup(config):
    Cgroup.create(config, CONTROLLER, CGNAME)
    Cgroup.set(config, CGNAME, SETTING, VALUE)
def test(config):
    result = consts.TEST_PASSED
    cause = None

    try:
        # cgset -r cpu.shares=100 --copy-from 027cgset2 027cgset1
        Cgroup.set(config,
                   cgname=CGNAME1,
                   setting='cpu.shares',
                   value='100',
                   copy_from=CGNAME2)
    except RunError as re:
        if 'Wrong input parameters,' not in re.stderr:
            result = consts.TEST_FAILED
            cause = "#1 Expected 'Wrong input parameters' to be in stderr"
            return result, cause

        if re.ret != 255:
            result = consts.TEST_FAILED
            cause = ('#1 Expected return code of 255 but received {}'
                     ''.format(re.ret))
            return result, cause
    else:
        result = consts.TEST_FAILED
        cause = 'Test case #1 erroneously passed'
        return result, cause

    try:
        # cgset -r cpu.shares=100
        Cgroup.set(config, cgname=None, setting='cpu.shares', value='100')
    except RunError as re:
        if 'cgset: no cgroup specified' not in re.stderr:
            result = consts.TEST_FAILED
            cause = "#2 Expected 'no cgroup specified' to be in stderr"
            return result, cause

        if re.ret != 255:
            result = consts.TEST_FAILED
            cause = ('#2 Expected return code of 255 but received {}'
                     ''.format(re.ret))
            return result, cause
    else:
        result = consts.TEST_FAILED
        cause = 'Test case #2 erroneously passed'
        return result, cause

    try:
        # cgset 027cgset1
        Cgroup.set(config, cgname=CGNAME1)
    except RunError as re:
        if 'cgset: no name-value pair was set' not in re.stderr:
            result = consts.TEST_FAILED
            cause = "#3 Expected 'no name-value pair' to be in stderr"
            return result, cause

        if re.ret != 255:
            result = consts.TEST_FAILED
            cause = ('#3 Expected return code of 255 but received {}'
                     ''.format(re.ret))
            return result, cause
    else:
        result = consts.TEST_FAILED
        cause = 'Test case #3 erroneously passed'
        return result, cause

    try:
        # cgset - no flags provided
        Cgroup.set(config)
    except RunError as re:
        if 'Usage is' not in re.stderr:
            result = consts.TEST_FAILED
            cause = "#4 Expected 'Usage is' to be in stderr"
            return result, cause

        if re.ret != 255:
            result = consts.TEST_FAILED
            cause = ('#4 Expected return code of 255 but received {}'
                     ''.format(re.ret))
            return result, cause
    else:
        result = consts.TEST_FAILED
        cause = 'Test case #4 erroneously passed'
        return result, cause

    try:
        # cgset -r cpu.shares= 027cgset1
        Cgroup.set(config, cgname=CGNAME1, setting='cpu.shares', value='')
    except RunError as re:
        if 'wrong parameter of option -r' not in re.stderr:
            result = consts.TEST_FAILED
            cause = "#5 Expected 'Wrong parameter of option' to be in stderr"
            return result, cause

        if re.ret != 255:
            result = consts.TEST_FAILED
            cause = ('#5 Expected return code of 255 but received {}'
                     ''.format(re.ret))
            return result, cause
    else:
        result = consts.TEST_FAILED
        cause = 'Test case #5 erroneously passed'
        return result, cause

    # cgset -h
    ret = Cgroup.set(config, cghelp=True)
    if 'Usage:' not in ret:
        result = consts.TEST_FAILED
        cause = '#6 Failed to print help text'
        return result, cause

    return result, cause