示例#1
0
def test_pods_info():
    stdout = run_dcos_cli_cmd('hello-world pods info world-1')
    jsonobj = json.loads(stdout)
    assert len(jsonobj) == 1
    task = jsonobj[0]
    assert len(task) == 2
    assert task['info']['name'] == 'world-1-server'
    assert task['info']['taskId']['value'] == task['status']['taskId']['value']
    assert task['status']['state'] == 'TASK_RUNNING'
示例#2
0
def test_pods_status_one():
    stdout = run_dcos_cli_cmd('hello-world pods status hello-0')
    jsonobj = json.loads(stdout)
    assert len(jsonobj) == 1
    task = jsonobj[0]
    assert len(task) == 3
    assert re.match('hello-0-server__[0-9a-f-]+', task['id'])
    assert task['name'] == 'hello-0-server'
    assert task['state'] == 'TASK_RUNNING'
示例#3
0
def test_pods_replace():
    world_ids = get_task_ids('world-0')

    # get current agent id:
    stdout = run_dcos_cli_cmd('hello-world pods info world-0')
    old_agent = json.loads(stdout)[0]['info']['slaveId']['value']

    jsonobj = json.loads(run_dcos_cli_cmd('hello-world pods replace world-0'))
    assert len(jsonobj) == 2
    assert jsonobj['pod'] == 'world-0'
    assert len(jsonobj['tasks']) == 1
    assert jsonobj['tasks'][0] == 'world-0-server'

    tasks_updated('world-0', world_ids)
    check_health()

    # check agent moved:
    stdout = run_dcos_cli_cmd('hello-world pods info world-0')
    new_agent = json.loads(stdout)[0]['info']['slaveId']['value']
示例#4
0
def test_pods_status_all():
    stdout = run_dcos_cli_cmd('hello-world pods status')
    jsonobj = json.loads(stdout)
    assert len(jsonobj) == get_task_count()
    for k, v in jsonobj.items():
        assert re.match('(hello|world)-[0-9]+', k)
        assert len(v) == 1
        task = v[0]
        assert len(task) == 3
        assert re.match('(hello|world)-[0-9]+-server__[0-9a-f-]+', task['id'])
        assert re.match('(hello|world)-[0-9]+-server', task['name'])
        assert task['state'] == 'TASK_RUNNING'
示例#5
0
def test_pods_restart():
    hello_ids = get_task_ids('hello-0')

    # get current agent id:
    stdout = run_dcos_cli_cmd('hello-world pods info hello-0')
    old_agent = json.loads(stdout)[0]['info']['slaveId']['value']

    stdout = run_dcos_cli_cmd('hello-world pods restart hello-0')
    jsonobj = json.loads(stdout)
    assert len(jsonobj) == 2
    assert jsonobj['pod'] == 'hello-0'
    assert len(jsonobj['tasks']) == 1
    assert jsonobj['tasks'][0] == 'hello-0-server'

    tasks_updated('hello', hello_ids)
    check_health()

    # check agent didn't move:
    stdout = run_dcos_cli_cmd('hello-world pods info hello-0')
    new_agent = json.loads(stdout)[0]['info']['slaveId']['value']
    assert old_agent == new_agent
示例#6
0
def test_pods_list():
    stdout = run_dcos_cli_cmd('hello-world pods list')
    jsonobj = json.loads(stdout)
    assert len(jsonobj) == get_task_count()
    # expect: X instances of 'hello-#' followed by Y instances of 'world-#',
    # in alphanumerical order
    first_world = -1
    for i in range(len(jsonobj)):
        entry = jsonobj[i]
        if first_world < 0:
            if entry.startswith('world-'):
                first_world = i
        if first_world == -1:
            assert jsonobj[i] == 'hello-{}'.format(i)
        else:
            assert jsonobj[i] == 'world-{}'.format(i - first_world)
示例#7
0
def get_pkg_version():
    cmd = 'dcos package describe {}'.format(PACKAGE_NAME)
    pkg_description = run_dcos_cli_cmd(cmd)
    regex = r'"version": "(\S+)"'
    match = re.search(regex, pkg_description)
    return match.group(1)