Skip to content

Commit

Permalink
Undo reverted changes that cause dcos task exec to break. (#993)
Browse files Browse the repository at this point in the history
This commit:
8971ccd

Inadvertently undid changes originally introduced in this commit:
f33a45e

Unfortunately, the integration tests didn't catch this because all
`task exec` integration tests were hidden behind an environment variable:

    @pytest.mark.skipif('DCOS_DEBUGGING_ENABLED' not in os.environ,
                        reason="Requires Agent Debugging APIs")

This commit reintroduces the changes that were inadvertently undone and
enables the `task exec` integration tests by default so that something
like this doesn't occur in the future.
  • Loading branch information
klueska authored and tamarrow committed May 16, 2017
1 parent 3abf575 commit c5dee79
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cli/dcoscli/task/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ def _metrics(summary, task_id, json_):
'Error finding agent associated with task: {}'.format(task_id))

slave_id = task['slave_id']
container_id = master.get_container_id(task_id)
container_id = master.get_container_id(task_id)["value"]

endpoint = '/system/v1/agent/{}/metrics/v0/containers/{}'.format(
slave_id, container_id
Expand Down
4 changes: 0 additions & 4 deletions cli/tests/integrations/test_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,6 @@ def test_ls_completed():
assert stderr == b''


@pytest.mark.skipif('DCOS_DEBUGGING_ENABLED' not in os.environ,
reason="Requires Agent Debugging APIs")
def test_exec_non_interactive():
with open('tests/data/tasks/lorem-ipsum.txt') as text:
content = text.read()
Expand All @@ -337,8 +335,6 @@ def test_exec_non_interactive():
stdout=bytes(content, 'UTF-8'))


@pytest.mark.skipif('DCOS_DEBUGGING_ENABLED' not in os.environ,
reason="Requires Agent Debugging APIs")
def test_exec_interactive():
with open('tests/data/tasks/lorem-ipsum.txt') as text:
content = bytes(text.read(), 'UTF-8')
Expand Down
5 changes: 4 additions & 1 deletion cli/tests/unit/test_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,10 @@ def test_dcos_task_metrics_agent_details(mocked_get_config_val,

mock_master = MagicMock()
mock_master.task = lambda _: {'slave_id': 'slave_id'}
mock_master.get_container_id = lambda _: 'container_id'
mock_master.get_container_id = lambda _: {
'parent': {},
'value': 'container_id'
}
mocked_get_master.return_value = mock_master

_metrics(True, 'task_id', False)
Expand Down
2 changes: 1 addition & 1 deletion dcos/mesos.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ def _get_container_status(task):
def _get_container_id(container_status):
if 'container_id' in container_status:
if 'value' in container_status['container_id']:
return container_status['container_id']['value']
return container_status['container_id']

raise DCOSException(
"No container found for the specified task."
Expand Down

0 comments on commit c5dee79

Please sign in to comment.