예제 #1
0
def test_node_log_lines():
    # since we are getting system logs, it's not guaranteed to get back
    # exactly 4 log entries. It must be >= 4
    assert_lines(
        ['dcos', 'node', 'log', '--leader', '--lines=4'],
        4,
        greater_than=True)
예제 #2
0
def test_node_metrics_agent_details():
    first_node_id = _node()[0]['id']
    assert_lines(
        ['dcos', 'node', 'metrics', 'details', first_node_id],
        100,
        greater_than=True
    )
예제 #3
0
def test_list_deployment_table():
    """Simple sanity check for listing deployments with a table output.
    The more specific testing is done in unit tests.

    """

    with _zero_instance_app():
        start_app('zero-instance-app', _ZERO_INSTANCE_APP_INSTANCES)
        assert_lines(['dcos', 'marathon', 'deployment', 'list'], 2)
예제 #4
0
def test_exec_interactive_long_output():
    task_id = _get_task_id('test-app1')

    # Pass the --interactive option and generate 10 000 random lines.
    # Then make sure the CLI can consume all the output. The input
    # connection should fail silently when the container terminates.
    # See https://jira.mesosphere.com/browse/DCOS_OSS-5432
    cmd = ['dcos', 'task', 'exec', '-i', task_id, 'sh', '-c',
           'cat /dev/urandom | tr -dc "a-zA-Z0-9" | fold | head -n 10000']

    assert_lines(cmd, 10000)
예제 #5
0
def test_log_follow():
    package_install('chronos', deploy=True)

    args = ['dcos', 'service', 'log', 'chronos', '--follow']

    if sys.platform == 'win32':
        proc = subprocess.Popen(
            args,
            creationflags=subprocess.CREATE_NEW_PROCESS_GROUP,
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE)
    else:
        # disable stdout/stderr buffering:
        # https://docs.python.org/3/using/cmdline.html#cmdoption-u
        my_env = os.environ.copy()
        my_env['PYTHONUNBUFFERED'] = 'x'

        # os.setsid is only available for Unix:
        # https://docs.python.org/2/library/os.html#os.setsid
        proc = subprocess.Popen(args,
                                preexec_fn=os.setsid,
                                stdout=subprocess.PIPE,
                                stderr=subprocess.PIPE,
                                env=my_env)

    time.sleep(10)

    proc.poll()
    assert proc.returncode is None

    if sys.platform == 'win32':
        os.kill(proc.pid, signal.CTRL_BREAK_EVENT)
    else:
        # using Unix-only commands os.killpg + os.getgid
        # https://docs.python.org/2/library/os.html#os.killpg
        # https://docs.python.org/2/library/os.html#os.getpgid
        os.killpg(os.getpgid(proc.pid), 15)

    stdout = proc.stdout.read()
    stderr = proc.stderr.read()

    print('STDOUT: {}'.format(stdout))
    print('STDERR: {}'.format(stderr))
    assert len(stdout.decode('utf-8').split('\n')) > 3

    assert_lines(['dcos', 'service', 'log', 'chronos', '--lines=4'], 4)

    exec_command(['dcos', 'package', 'uninstall', 'chronos', '--yes'])
예제 #6
0
def test_task_completed():
    assert_lines(
        ['dcos', 'task', 'list',
         '--completed', '--json', 'test-app-completed*'],
        1,
        greater_than=True)
예제 #7
0
def test_task_table():
    assert_lines(['dcos', 'task', 'list'], NUM_TASKS + 1)
예제 #8
0
def test_filter():
    assert_lines(['dcos', 'task', 'list', 'test-app2', '--json'],
                 1,
                 greater_than=True)
예제 #9
0
def test_list_table():
    with _helloworld():
        assert_lines(['dcos', 'package', 'list'], 2)
예제 #10
0
def test_node_log_slave():
    slave_id = _node()[0]['id']
    assert_lines(
        ['dcos', 'node', 'log', slave_id],
        10,
        greater_than=True)
예제 #11
0
def test_node_log_leader():
    assert_lines(['dcos', 'node', 'log', '--leader'], 10, greater_than=True)
예제 #12
0
def test_list_tasks_table():
    with _zero_instance_app():
        start_app('zero-instance-app', 3)
        watch_all_deployments()
        assert_lines(['dcos', 'marathon', 'task', 'list'], 4)
예제 #13
0
 def _test_node_metrics_agent_details():
     assert_lines(['dcos', 'node', 'metrics', 'details', first_node_id],
                  100,
                  greater_than=True)
예제 #14
0
 def _test_node_metrics_agent_summary():
     assert_lines(['dcos', 'node', 'metrics', 'summary', first_node_id], 2)
예제 #15
0
def test_log_lines():
    """ Test --lines """
    assert_lines(['dcos', 'task', 'log', 'test-app1', '--lines=2'], 2)
예제 #16
0
def test_task_list_all():
    assert_lines(
        ['dcos', 'task', 'list', '--json', '*-app*'],
        NUM_TASKS,
        greater_than=True)
예제 #17
0
def test_node_metrics_agent_summary():
    first_node_id = _node()[0]['id']
    assert_lines(['dcos', 'node', 'metrics', 'summary', first_node_id], 2)
예제 #18
0
def test_service_table():
    assert_lines(['dcos', 'service', 'list'], 3)
예제 #19
0
def test_node_log_slave():
    slave_id = _node()[0]['id']
    assert_lines(['dcos', 'node', 'log', '--mesos-id={}'.format(slave_id)],
                 10,
                 greater_than=True)
def test_group_list_table():
    with group(GOOD_GROUP, 'test-group'):
        assert_lines(['dcos', 'marathon', 'group', 'list'], 3)