{"action":"created","comment":{"url":"https://api.github.com/repos/dcos/dcos/pulls/comments/92480484","pull_request_review_id":12997094,"id":92480484,"diff_hunk":"@@ -71,5 +72,143 @@ def test_log_proxy(cluster):\n     for slave_id in slaves_ids:\n         response = cluster.get('/system/v1/agent/{}/logs/v1/range/?skip_prev=10'.format(slave_id))\n         check_response_ok(response, {'Content-Type': 'text/plain'})\n-        lines = filter(lambda x: x != '', response.content.decode().split('\\n'))\n+        lines = filter(lambda x: x != '', response.text.split('\\n'))\n         assert len(list(lines)) == 10, 'Expect 10 log entries. Got {}. All lines {}'.format(len(lines), lines)\n+\n+\n+def test_task_logs(cluster):\n+    test_uuid = uuid.uuid4().hex\n+\n+    task_id = \"integration-test-task-logs-{}\".format(test_uuid)\n+\n+    task_definition = {\n+        \"id\": \"/{}\".format(task_id),\n+        \"cpus\": 0.1,\n+        \"instances\": 1,\n+        \"mem\": 128,\n+        \"cmd\": \"echo STDOUT_LOG; echo STDERR_LOG >&2;sleep 999\"\n+    }\n+\n+    with cluster.marathon.deploy_and_cleanup(task_definition, check_health=False):\n+        url = get_task_url(cluster, task_id)\n+        task_stdout_response = cluster.get('{}?filter=STREAM:STDOUT'.format(url))\n+        check_response_ok(task_stdout_response, {})\n+        task_stdout = task_stdout_response.text\n+        assert 'STDOUT_LOG' in task_stdout, 'Missing `STDOUT_LOG` in response. Got {}'.format(task_stdout)\n+\n+        task_stderr_response = cluster.get('{}?filter=STREAM:STDERR'.format(url))\n+        check_response_ok(task_stderr_response, {})\n+        task_stderr = task_stderr_response.text\n+        assert 'STDERR_LOG' in task_stderr, 'Missing `STDERR_LOG` in response. Got {}'.format(task_stderr)\n+\n+\n+def get_task_url(cluster, task_name, stream=False):\n+    \"\"\" The function returns a logging URL for a given task\n+\n+    :param cluster: cluster fixture\n+    :param task_name: task name\n+    :param stream: use range or stream endpoint\n+    :return: url to get the logs for a task\n+    \"\"\"\n+    state_response = cluster.get('/mesos/state')\n+    check_response_ok(state_response, {})\n+\n+    framework_id = None\n+    executor_id = None\n+    slave_id = None\n+    container_id = None\n+\n+    state_response_json = state_response.json()\n+    assert 'frameworks' in state_response_json, 'Missing field `framework` in {}'.format(state_response_json)\n+    assert isinstance(state_response_json['frameworks'], list), '`framework` must be list. Got {}'.format(\n+        state_response_json)\n+\n+    for framework in state_response_json['frameworks']:\n+        assert 'name' in framework, 'Missing field `name` in `frameworks`. Got {}'.format(state_response_json)\n+        # search for marathon framework\n+        if framework['name'] != 'marathon':\n+            continue\n+\n+        assert 'tasks' in framework, 'Missing field `tasks`. Got {}'.format(state_response_json)\n+        assert isinstance(framework['tasks'], list), '`tasks` must be list. Got {}'.format(state_response_json)\n+        for task in framework['tasks']:\n+            assert 'id' in task, 'Missing field `id` in task. Got {}'.format(state_response_json)\n+            if not task['id'].startswith(task_name):\n+                continue\n+\n+            assert 'framework_id' in task, 'Missing `framework_id` in task. Got {}'.format(state_response_json)\n+            assert 'executor_id' in task, 'Missing `executor_id` in task. Got {}'.format(state_response_json)\n+            assert 'id' in task, 'Missing `id` in task. Got {}'.format(state_response_json)\n+            assert 'slave_id' in task, 'Missing `slave_id` in task. Got {}'.format(state_response_json)\n+\n+            framework_id = task['framework_id']\n+            # if task['executor_id'] is empty, we should use task['id']\n+            executor_id = task['executor_id']\n+            if not executor_id:\n+                executor_id = task['id']\n+            slave_id = task['slave_id']\n+\n+            assert task['statuses'], 'Invalid field `statuses`. Got {}'.format(state_response_json)\n+            statuses = task['statuses']\n+            assert isinstance(statuses, list), 'Invalid field `statuses`. Got {}'.format(state_response_json)\n+            assert len(statuses) == 1, 'Must have only one status TASK_RUNNING. Got {}'.format(state_response_json)\n+            status = statuses[0]\n+            assert status['container_status'], 'Invalid field `container_status`. Got {}'.format(state_response_json)\n+            container_status = status['container_status']\n+            assert container_status['container_id'], 'Invalid field `container_id`. Got {}'.format(state_response_json)\n+            container_id_field = container_status['container_id']\n+\n+            # traverse nested container_id fields\n+            container_ids = [container_id_field['value']]\n+            while 'parent' in container_id_field:\n+                container_id_field = container_id_field['parent']\n+                container_ids.append([container_id_field['value']])","path":"packages/dcos-integration-test/extra/test_dcos_log.py","position":128,"original_position":128,"commit_id":"bc8513ba78e9227db61f1cfb3e703c1abe1a2b55","original_commit_id":"bc8513ba78e9227db61f1cfb3e703c1abe1a2b55","user":{"login":"mellenburg","id":14269783,"avatar_url":"https://avatars.githubusercontent.com/u/14269783?v=3","gravatar_id":"","url":"https://api.github.com/users/mellenburg","html_url":"https://github.com/mellenburg","followers_url":"https://api.github.com/users/mellenburg/followers","following_url":"https://api.github.com/users/mellenburg/following{/other_user}","gists_url":"https://api.github.com/users/mellenburg/gists{/gist_id}","starred_url":"https://api.github.com/users/mellenburg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mellenburg/subscriptions","organizations_url":"https://api.github.com/users/mellenburg/orgs","repos_url":"https://api.github.com/users/mellenburg/repos","events_url":"https://api.github.com/users/mellenburg/events{/privacy}","received_events_url":"https://api.github.com/users/mellenburg/received_events","type":"User","site_admin":false},"body":"This should not be appending a list.","created_at":"2016-12-14T20:19:30Z","updated_at":"2016-12-14T20:20:51Z","html_url":"https://github.com/dcos/dcos/pull/1045#discussion_r92480484","pull_request_url":"https://api.github.com/repos/dcos/dcos/pulls/1045","_links":{"self":{"href":"https://api.github.com/repos/dcos/dcos/pulls/comments/92480484"},"html":{"href":"https://github.com/dcos/dcos/pull/1045#discussion_r92480484"},"pull_request":{"href":"https://api.github.com/repos/dcos/dcos/pulls/1045"}}},"pull_request":{"url":"https://api.github.com/repos/dcos/dcos/pulls/1045","id":97178834,"html_url":"https://github.com/dcos/dcos/pull/1045","diff_url":"https://github.com/dcos/dcos/pull/1045.diff","patch_url":"https://github.com/dcos/dcos/pull/1045.patch","issue_url":"https://api.github.com/repos/dcos/dcos/issues/1045","number":1045,"state":"open","locked":false,"title":"enable dcos-log service on all hosts","user":{"login":"darkonie","id":1162766,"avatar_url":"https://avatars.githubusercontent.com/u/1162766?v=3","gravatar_id":"","url":"https://api.github.com/users/darkonie","html_url":"https://github.com/darkonie","followers_url":"https://api.github.com/users/darkonie/followers","following_url":"https://api.github.com/users/darkonie/following{/other_user}","gists_url":"https://api.github.com/users/darkonie/gists{/gist_id}","starred_url":"https://api.github.com/users/darkonie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/darkonie/subscriptions","organizations_url":"https://api.github.com/users/darkonie/orgs","repos_url":"https://api.github.com/users/darkonie/repos","events_url":"https://api.github.com/users/darkonie/events{/privacy}","received_events_url":"https://api.github.com/users/darkonie/received_events","type":"User","site_admin":false},"body":"High level description including:\r\n - Stop writing STDOUT and STDERR to sandbox\r\n - Start writing STDOUT and STDERR to sd journal\r\n - Add integration tests\r\n\r\nThis PR includes:\r\n - https://github.com/dcos/dcos/pull/877 write container logs to sd journal\r\n# Checklist\r\n\r\n - [x] Included a test which will fail if code is reverted but test is not\r\n - [x] Followed relevant code rules [Rules for Packages and Systemd](https://github.com/dcos/dcos/tree/master/docs)\r\n\r\nIf this is a component/package update, include\r\n\r\n - [x] Change Log from last: [add sse ping](https://github.com/dcos/dcos-log/pull/27)\r\n - [x] Test Results: [build & test](https://jenkins.mesosphere.com/service/jenkins/view/DCOS/job/dcos-log%20pull%20requests/64/console)\r\n - [x] Code Coverage: [build & coverage](https://jenkins.mesosphere.com/service/jenkins/view/DCOS/job/dcos-log%20pull%20requests/64/console)\r\n\r\n","created_at":"2016-12-08T18:51:46Z","updated_at":"2016-12-14T20:20:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"52b7207f09a74b1bd04f66d9a31061b900ab6c2b","assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/dcos/dcos/milestones/5","html_url":"https://github.com/dcos/dcos/milestone/5","labels_url":"https://api.github.com/repos/dcos/dcos/milestones/5/labels","id":1970672,"number":5,"title":"1.9","description":"Targeted for DC/OS 1.9","creator":{"login":"cmaloney","id":751088,"avatar_url":"https://avatars.githubusercontent.com/u/751088?v=3","gravatar_id":"","url":"https://api.github.com/users/cmaloney","html_url":"https://github.com/cmaloney","followers_url":"https://api.github.com/users/cmaloney/followers","following_url":"https://api.github.com/users/cmaloney/following{/other_user}","gists_url":"https://api.github.com/users/cmaloney/gists{/gist_id}","starred_url":"https://api.github.com/users/cmaloney/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cmaloney/subscriptions","organizations_url":"https://api.github.com/users/cmaloney/orgs","repos_url":"https://api.github.com/users/cmaloney/repos","events_url":"https://api.github.com/users/cmaloney/events{/privacy}","received_events_url":"https://api.github.com/users/cmaloney/received_events","type":"User","site_admin":false},"open_issues":20,"closed_issues":33,"state":"open","created_at":"2016-08-29T20:17:07Z","updated_at":"2016-12-14T19:21:14Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/dcos/dcos/pulls/1045/commits","review_comments_url":"https://api.github.com/repos/dcos/dcos/pulls/1045/comments","review_comment_url":"https://api.github.com/repos/dcos/dcos/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dcos/dcos/issues/1045/comments","statuses_url":"https://api.github.com/repos/dcos/dcos/statuses/bc8513ba78e9227db61f1cfb3e703c1abe1a2b55","head":{"label":"mesosphere:mnaboka/dcos-log-test","ref":"mnaboka/dcos-log-test","sha":"bc8513ba78e9227db61f1cfb3e703c1abe1a2b55","user":{"login":"mesosphere","id":3458585,"avatar_url":"https://avatars.githubusercontent.com/u/3458585?v=3","gravatar_id":"","url":"https://api.github.com/users/mesosphere","html_url":"https://github.com/mesosphere","followers_url":"https://api.github.com/users/mesosphere/followers","following_url":"https://api.github.com/users/mesosphere/following{/other_user}","gists_url":"https://api.github.com/users/mesosphere/gists{/gist_id}","starred_url":"https://api.github.com/users/mesosphere/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mesosphere/subscriptions","organizations_url":"https://api.github.com/users/mesosphere/orgs","repos_url":"https://api.github.com/users/mesosphere/repos","events_url":"https://api.github.com/users/mesosphere/events{/privacy}","received_events_url":"https://api.github.com/users/mesosphere/received_events","type":"Organization","site_admin":false},"repo":{"id":62745648,"name":"dcos","full_name":"mesosphere/dcos","owner":{"login":"mesosphere","id":3458585,"avatar_url":"https://avatars.githubusercontent.com/u/3458585?v=3","gravatar_id":"","url":"https://api.github.com/users/mesosphere","html_url":"https://github.com/mesosphere","followers_url":"https://api.github.com/users/mesosphere/followers","following_url":"https://api.github.com/users/mesosphere/following{/other_user}","gists_url":"https://api.github.com/users/mesosphere/gists{/gist_id}","starred_url":"https://api.github.com/users/mesosphere/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mesosphere/subscriptions","organizations_url":"https://api.github.com/users/mesosphere/orgs","repos_url":"https://api.github.com/users/mesosphere/repos","events_url":"https://api.github.com/users/mesosphere/events{/privacy}","received_events_url":"https://api.github.com/users/mesosphere/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mesosphere/dcos","description":"DC/OS Build and Release tools","fork":true,"url":"https://api.github.com/repos/mesosphere/dcos","forks_url":"https://api.github.com/repos/mesosphere/dcos/forks","keys_url":"https://api.github.com/repos/mesosphere/dcos/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mesosphere/dcos/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mesosphere/dcos/teams","hooks_url":"https://api.github.com/repos/mesosphere/dcos/hooks","issue_events_url":"https://api.github.com/repos/mesosphere/dcos/issues/events{/number}","events_url":"https://api.github.com/repos/mesosphere/dcos/events","assignees_url":"https://api.github.com/repos/mesosphere/dcos/assignees{/user}","branches_url":"https://api.github.com/repos/mesosphere/dcos/branches{/branch}","tags_url":"https://api.github.com/repos/mesosphere/dcos/tags","blobs_url":"https://api.github.com/repos/mesosphere/dcos/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mesosphere/dcos/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mesosphere/dcos/git/refs{/sha}","trees_url":"https://api.github.com/repos/mesosphere/dcos/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mesosphere/dcos/statuses/{sha}","languages_url":"https://api.github.com/repos/mesosphere/dcos/languages","stargazers_url":"https://api.github.com/repos/mesosphere/dcos/stargazers","contributors_url":"https://api.github.com/repos/mesosphere/dcos/contributors","subscribers_url":"https://api.github.com/repos/mesosphere/dcos/subscribers","subscription_url":"https://api.github.com/repos/mesosphere/dcos/subscription","commits_url":"https://api.github.com/repos/mesosphere/dcos/commits{/sha}","git_commits_url":"https://api.github.com/repos/mesosphere/dcos/git/commits{/sha}","comments_url":"https://api.github.com/repos/mesosphere/dcos/comments{/number}","issue_comment_url":"https://api.github.com/repos/mesosphere/dcos/issues/comments{/number}","contents_url":"https://api.github.com/repos/mesosphere/dcos/contents/{+path}","compare_url":"https://api.github.com/repos/mesosphere/dcos/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mesosphere/dcos/merges","archive_url":"https://api.github.com/repos/mesosphere/dcos/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mesosphere/dcos/downloads","issues_url":"https://api.github.com/repos/mesosphere/dcos/issues{/number}","pulls_url":"https://api.github.com/repos/mesosphere/dcos/pulls{/number}","milestones_url":"https://api.github.com/repos/mesosphere/dcos/milestones{/number}","notifications_url":"https://api.github.com/repos/mesosphere/dcos/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mesosphere/dcos/labels{/name}","releases_url":"https://api.github.com/repos/mesosphere/dcos/releases{/id}","deployments_url":"https://api.github.com/repos/mesosphere/dcos/deployments","created_at":"2016-07-06T18:52:22Z","updated_at":"2016-11-19T06:03:23Z","pushed_at":"2016-12-14T20:19:26Z","git_url":"git://github.com/mesosphere/dcos.git","ssh_url":"git@github.com:mesosphere/dcos.git","clone_url":"https://github.com/mesosphere/dcos.git","svn_url":"https://github.com/mesosphere/dcos","homepage":"https://dcos.io","size":2616,"stargazers_count":6,"watchers_count":6,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":0,"forks":3,"open_issues":0,"watchers":6,"default_branch":"master"}},"base":{"label":"dcos:master","ref":"master","sha":"06462bd116053270c407f15a5e2728e3ac99f341","user":{"login":"dcos","id":17648048,"avatar_url":"https://avatars.githubusercontent.com/u/17648048?v=3","gravatar_id":"","url":"https://api.github.com/users/dcos","html_url":"https://github.com/dcos","followers_url":"https://api.github.com/users/dcos/followers","following_url":"https://api.github.com/users/dcos/following{/other_user}","gists_url":"https://api.github.com/users/dcos/gists{/gist_id}","starred_url":"https://api.github.com/users/dcos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dcos/subscriptions","organizations_url":"https://api.github.com/users/dcos/orgs","repos_url":"https://api.github.com/users/dcos/repos","events_url":"https://api.github.com/users/dcos/events{/privacy}","received_events_url":"https://api.github.com/users/dcos/received_events","type":"Organization","site_admin":false},"repo":{"id":56184050,"name":"dcos","full_name":"dcos/dcos","owner":{"login":"dcos","id":17648048,"avatar_url":"https://avatars.githubusercontent.com/u/17648048?v=3","gravatar_id":"","url":"https://api.github.com/users/dcos","html_url":"https://github.com/dcos","followers_url":"https://api.github.com/users/dcos/followers","following_url":"https://api.github.com/users/dcos/following{/other_user}","gists_url":"https://api.github.com/users/dcos/gists{/gist_id}","starred_url":"https://api.github.com/users/dcos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dcos/subscriptions","organizations_url":"https://api.github.com/users/dcos/orgs","repos_url":"https://api.github.com/users/dcos/repos","events_url":"https://api.github.com/users/dcos/events{/privacy}","received_events_url":"https://api.github.com/users/dcos/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dcos/dcos","description":"DC/OS Build and Release tools","fork":false,"url":"https://api.github.com/repos/dcos/dcos","forks_url":"https://api.github.com/repos/dcos/dcos/forks","keys_url":"https://api.github.com/repos/dcos/dcos/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dcos/dcos/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dcos/dcos/teams","hooks_url":"https://api.github.com/repos/dcos/dcos/hooks","issue_events_url":"https://api.github.com/repos/dcos/dcos/issues/events{/number}","events_url":"https://api.github.com/repos/dcos/dcos/events","assignees_url":"https://api.github.com/repos/dcos/dcos/assignees{/user}","branches_url":"https://api.github.com/repos/dcos/dcos/branches{/branch}","tags_url":"https://api.github.com/repos/dcos/dcos/tags","blobs_url":"https://api.github.com/repos/dcos/dcos/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dcos/dcos/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dcos/dcos/git/refs{/sha}","trees_url":"https://api.github.com/repos/dcos/dcos/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dcos/dcos/statuses/{sha}","languages_url":"https://api.github.com/repos/dcos/dcos/languages","stargazers_url":"https://api.github.com/repos/dcos/dcos/stargazers","contributors_url":"https://api.github.com/repos/dcos/dcos/contributors","subscribers_url":"https://api.github.com/repos/dcos/dcos/subscribers","subscription_url":"https://api.github.com/repos/dcos/dcos/subscription","commits_url":"https://api.github.com/repos/dcos/dcos/commits{/sha}","git_commits_url":"https://api.github.com/repos/dcos/dcos/git/commits{/sha}","comments_url":"https://api.github.com/repos/dcos/dcos/comments{/number}","issue_comment_url":"https://api.github.com/repos/dcos/dcos/issues/comments{/number}","contents_url":"https://api.github.com/repos/dcos/dcos/contents/{+path}","compare_url":"https://api.github.com/repos/dcos/dcos/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dcos/dcos/merges","archive_url":"https://api.github.com/repos/dcos/dcos/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dcos/dcos/downloads","issues_url":"https://api.github.com/repos/dcos/dcos/issues{/number}","pulls_url":"https://api.github.com/repos/dcos/dcos/pulls{/number}","milestones_url":"https://api.github.com/repos/dcos/dcos/milestones{/number}","notifications_url":"https://api.github.com/repos/dcos/dcos/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dcos/dcos/labels{/name}","releases_url":"https://api.github.com/repos/dcos/dcos/releases{/id}","deployments_url":"https://api.github.com/repos/dcos/dcos/deployments","created_at":"2016-04-13T20:31:58Z","updated_at":"2016-12-14T18:49:05Z","pushed_at":"2016-12-14T19:52:33Z","git_url":"git://github.com/dcos/dcos.git","ssh_url":"git@github.com:dcos/dcos.git","clone_url":"https://github.com/dcos/dcos.git","svn_url":"https://github.com/dcos/dcos","homepage":"https://dcos.io","size":2429,"stargazers_count":1176,"watchers_count":1176,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":199,"mirror_url":null,"open_issues_count":40,"forks":199,"open_issues":40,"watchers":1176,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dcos/dcos/pulls/1045"},"html":{"href":"https://github.com/dcos/dcos/pull/1045"},"issue":{"href":"https://api.github.com/repos/dcos/dcos/issues/1045"},"comments":{"href":"https://api.github.com/repos/dcos/dcos/issues/1045/comments"},"review_comments":{"href":"https://api.github.com/repos/dcos/dcos/pulls/1045/comments"},"review_comment":{"href":"https://api.github.com/repos/dcos/dcos/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dcos/dcos/pulls/1045/commits"},"statuses":{"href":"https://api.github.com/repos/dcos/dcos/statuses/bc8513ba78e9227db61f1cfb3e703c1abe1a2b55"}}}}
{"actor":{"display_login":"mellenburg"}}