{"action":"created","comment":{"url":"https://api.github.com/repos/ClusterHQ/powerstrip/pulls/comments/24746471","id":24746471,"diff_hunk":"@@ -0,0 +1,297 @@\n+# Copyright ClusterHQ Limited. See LICENSE file for details.\n+\n+\"\"\"\n+Tests that verify that Docker behaviour is unchanged when running through\n+Powerstrip.\n+\n+Run these tests as so. Ensure Docker is running on /var/run/docker.sock.\n+\n+$ TEST_PASSTHRU=1 trial powerstrip.test.test_passthru\n+\"\"\"\n+\n+import os\n+from twisted.internet import defer\n+from twisted.trial.unittest import TestCase\n+from ..testtools import GenerallyUsefulPowerstripTestMixin\n+\n+\n+def CompareDockerAndPowerstrip(test_case, cmd, usePTY=False,\n+        expectDifferentResults=False):\n+    \"\"\"\n+    Compare the output of a real Docker server against a Powerstrip passthu.\n+\n+    There will be environment variables set which determine whether any\n+    ``docker`` execs will talk to Docker or Powerstrip.\n+\n+    :param test_case: The current ``TestCase`` context.\n+\n+    :param cmd: A shell command. E.g. ``echo ls | docker run -i ubuntu bash``.\n+        This command should include at least one call to Docker.\n+\n+    :return: A ``Deferred`` which fires when the test has been completed.\n+    \"\"\"\n+    DOCKER = b\"unix:///var/run/docker.sock\"\n+    POWERSTRIP = b\"tcp://localhost:%(proxyPort)d\"\n+\n+    d = getProcessOutputPTY(b\"/bin/bash\", [\"-c\", cmd], { b\"DOCKER_HOST\": DOCKER },\n+        errortoo=True, usePTY=usePTY)\n+\n+    def got_result(docker_result):\n+        if not docker_result:\n+            raise ValueError(\"Command did not produce any output when sent to \"\n+                    \"Docker daemon.\")\n+        d = getProcessOutputPTY(b\"/bin/bash\", [\"-c\", cmd],\n+                { b\"DOCKER_HOST\": POWERSTRIP % dict(proxyPort=test_case.proxyPort) },\n+            errortoo=True, usePTY=usePTY)\n+\n+        def compare_result(powerstrip_result, docker_result):\n+            if not expectDifferentResults:\n+                test_case.assertEquals(docker_result, powerstrip_result)\n+            return powerstrip_result, docker_result\n+\n+        d.addCallback(compare_result, docker_result)\n+        return d\n+\n+    d.addCallback(got_result)\n+    return d\n+\n+\n+class BasicTests(TestCase, GenerallyUsefulPowerstripTestMixin):\n+    \"\"\"\n+    Tests for basic Docker functionality.\n+    \"\"\"\n+\n+    if \"TEST_PASSTHRU\" not in os.environ:\n+        skip = \"Skipping passthru tests.\"\n+\n+    def tearDown(self):\n+        shutdowns = [\n+            self.proxyServer.stopListening()]\n+        if hasattr(self, \"nullServer\"):\n+            shutdowns.append(self.nullServer.stopListening())\n+        return defer.gatherResults(shutdowns)\n+\n+    def test_run(self):\n+        \"\"\"\n+        Test basic ``docker run`` functionality.\n+        \"\"\"\n+        # XXX this will need to prime the Docker instance in most cases, e.g.\n+        # docker pull\n+\n+        # Actually run the current (local) version of powerstrip on\n+        # localhost:something.\n+        self._configure(\"endpoints: {}\\nadapters: {}\", dockerOnSocket=True,\n+                realDockerSocket=\"/var/run/docker.sock\")\n+        self.config.read_and_parse()\n+        return CompareDockerAndPowerstrip(self,\n+            \"docker run ubuntu echo hello\")\n+\n+    def test_run_post_hook(self):\n+        \"\"\"\n+        Test basic ``docker run`` functionality when there's a post-hook (the\n+        post-hook should get skipped).","path":"powerstrip/test/test_passthru.py","position":92,"original_position":92,"commit_id":"cbef7fca7283ddfa59ed34821b6899a642c4e86a","original_commit_id":"1c9953601c8d0c8dfc7ef75ee3b3ddab2c9028c9","user":{"login":"lukemarsden","id":264658,"avatar_url":"https://avatars.githubusercontent.com/u/264658?v=3","gravatar_id":"","url":"https://api.github.com/users/lukemarsden","html_url":"https://github.com/lukemarsden","followers_url":"https://api.github.com/users/lukemarsden/followers","following_url":"https://api.github.com/users/lukemarsden/following{/other_user}","gists_url":"https://api.github.com/users/lukemarsden/gists{/gist_id}","starred_url":"https://api.github.com/users/lukemarsden/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lukemarsden/subscriptions","organizations_url":"https://api.github.com/users/lukemarsden/orgs","repos_url":"https://api.github.com/users/lukemarsden/repos","events_url":"https://api.github.com/users/lukemarsden/events{/privacy}","received_events_url":"https://api.github.com/users/lukemarsden/received_events","type":"User","site_admin":false},"body":"done","created_at":"2015-02-16T11:56:05Z","updated_at":"2015-02-16T11:56:05Z","html_url":"https://github.com/ClusterHQ/powerstrip/pull/47#discussion_r24746471","pull_request_url":"https://api.github.com/repos/ClusterHQ/powerstrip/pulls/47","_links":{"self":{"href":"https://api.github.com/repos/ClusterHQ/powerstrip/pulls/comments/24746471"},"html":{"href":"https://github.com/ClusterHQ/powerstrip/pull/47#discussion_r24746471"},"pull_request":{"href":"https://api.github.com/repos/ClusterHQ/powerstrip/pulls/47"}}},"pull_request":{"url":"https://api.github.com/repos/ClusterHQ/powerstrip/pulls/47","id":28985410,"html_url":"https://github.com/ClusterHQ/powerstrip/pull/47","diff_url":"https://github.com/ClusterHQ/powerstrip/pull/47.diff","patch_url":"https://github.com/ClusterHQ/powerstrip/pull/47.patch","issue_url":"https://api.github.com/repos/ClusterHQ/powerstrip/issues/47","number":47,"state":"open","locked":false,"title":"acceptance tests, bugfixes & features","user":{"login":"lukemarsden","id":264658,"avatar_url":"https://avatars.githubusercontent.com/u/264658?v=3","gravatar_id":"","url":"https://api.github.com/users/lukemarsden","html_url":"https://github.com/lukemarsden","followers_url":"https://api.github.com/users/lukemarsden/followers","following_url":"https://api.github.com/users/lukemarsden/following{/other_user}","gists_url":"https://api.github.com/users/lukemarsden/gists{/gist_id}","starred_url":"https://api.github.com/users/lukemarsden/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lukemarsden/subscriptions","organizations_url":"https://api.github.com/users/lukemarsden/orgs","repos_url":"https://api.github.com/users/lukemarsden/repos","events_url":"https://api.github.com/users/lukemarsden/events{/privacy}","received_events_url":"https://api.github.com/users/lukemarsden/received_events","type":"User","site_admin":false},"body":"* Docker acceptance tests against real Docker.\r\n* Fix GET bug (unable to proxy GET requests).\r\n* Support streaming streamed responses when there are no matching post-hooks (instead of buffering).\r\n* Stdin support, so `docker run`, `-t`, `-i`, and `-ti` all work.\r\n* Documentation fixes and clarifications on modified semantics & limitations.\r\n\r\nThis is a clear set of improvements which is IMO worthy of a v0.0.2 release.","created_at":"2015-02-10T07:07:59Z","updated_at":"2015-02-16T11:56:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f6c2dad125cf66356d1409a0c516dd605f1d36bf","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ClusterHQ/powerstrip/pulls/47/commits","review_comments_url":"https://api.github.com/repos/ClusterHQ/powerstrip/pulls/47/comments","review_comment_url":"https://api.github.com/repos/ClusterHQ/powerstrip/pulls/comments/{number}","comments_url":"https://api.github.com/repos/ClusterHQ/powerstrip/issues/47/comments","statuses_url":"https://api.github.com/repos/ClusterHQ/powerstrip/statuses/cbef7fca7283ddfa59ed34821b6899a642c4e86a","head":{"label":"ClusterHQ:docker-compat-tests","ref":"docker-compat-tests","sha":"cbef7fca7283ddfa59ed34821b6899a642c4e86a","user":{"login":"ClusterHQ","id":7913449,"avatar_url":"https://avatars.githubusercontent.com/u/7913449?v=3","gravatar_id":"","url":"https://api.github.com/users/ClusterHQ","html_url":"https://github.com/ClusterHQ","followers_url":"https://api.github.com/users/ClusterHQ/followers","following_url":"https://api.github.com/users/ClusterHQ/following{/other_user}","gists_url":"https://api.github.com/users/ClusterHQ/gists{/gist_id}","starred_url":"https://api.github.com/users/ClusterHQ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ClusterHQ/subscriptions","organizations_url":"https://api.github.com/users/ClusterHQ/orgs","repos_url":"https://api.github.com/users/ClusterHQ/repos","events_url":"https://api.github.com/users/ClusterHQ/events{/privacy}","received_events_url":"https://api.github.com/users/ClusterHQ/received_events","type":"Organization","site_admin":false},"repo":{"id":28910752,"name":"powerstrip","full_name":"ClusterHQ/powerstrip","owner":{"login":"ClusterHQ","id":7913449,"avatar_url":"https://avatars.githubusercontent.com/u/7913449?v=3","gravatar_id":"","url":"https://api.github.com/users/ClusterHQ","html_url":"https://github.com/ClusterHQ","followers_url":"https://api.github.com/users/ClusterHQ/followers","following_url":"https://api.github.com/users/ClusterHQ/following{/other_user}","gists_url":"https://api.github.com/users/ClusterHQ/gists{/gist_id}","starred_url":"https://api.github.com/users/ClusterHQ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ClusterHQ/subscriptions","organizations_url":"https://api.github.com/users/ClusterHQ/orgs","repos_url":"https://api.github.com/users/ClusterHQ/repos","events_url":"https://api.github.com/users/ClusterHQ/events{/privacy}","received_events_url":"https://api.github.com/users/ClusterHQ/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ClusterHQ/powerstrip","description":"Powerstrip: A tool for prototyping Docker extensions","fork":false,"url":"https://api.github.com/repos/ClusterHQ/powerstrip","forks_url":"https://api.github.com/repos/ClusterHQ/powerstrip/forks","keys_url":"https://api.github.com/repos/ClusterHQ/powerstrip/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ClusterHQ/powerstrip/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ClusterHQ/powerstrip/teams","hooks_url":"https://api.github.com/repos/ClusterHQ/powerstrip/hooks","issue_events_url":"https://api.github.com/repos/ClusterHQ/powerstrip/issues/events{/number}","events_url":"https://api.github.com/repos/ClusterHQ/powerstrip/events","assignees_url":"https://api.github.com/repos/ClusterHQ/powerstrip/assignees{/user}","branches_url":"https://api.github.com/repos/ClusterHQ/powerstrip/branches{/branch}","tags_url":"https://api.github.com/repos/ClusterHQ/powerstrip/tags","blobs_url":"https://api.github.com/repos/ClusterHQ/powerstrip/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ClusterHQ/powerstrip/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ClusterHQ/powerstrip/git/refs{/sha}","trees_url":"https://api.github.com/repos/ClusterHQ/powerstrip/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ClusterHQ/powerstrip/statuses/{sha}","languages_url":"https://api.github.com/repos/ClusterHQ/powerstrip/languages","stargazers_url":"https://api.github.com/repos/ClusterHQ/powerstrip/stargazers","contributors_url":"https://api.github.com/repos/ClusterHQ/powerstrip/contributors","subscribers_url":"https://api.github.com/repos/ClusterHQ/powerstrip/subscribers","subscription_url":"https://api.github.com/repos/ClusterHQ/powerstrip/subscription","commits_url":"https://api.github.com/repos/ClusterHQ/powerstrip/commits{/sha}","git_commits_url":"https://api.github.com/repos/ClusterHQ/powerstrip/git/commits{/sha}","comments_url":"https://api.github.com/repos/ClusterHQ/powerstrip/comments{/number}","issue_comment_url":"https://api.github.com/repos/ClusterHQ/powerstrip/issues/comments/{number}","contents_url":"https://api.github.com/repos/ClusterHQ/powerstrip/contents/{+path}","compare_url":"https://api.github.com/repos/ClusterHQ/powerstrip/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ClusterHQ/powerstrip/merges","archive_url":"https://api.github.com/repos/ClusterHQ/powerstrip/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ClusterHQ/powerstrip/downloads","issues_url":"https://api.github.com/repos/ClusterHQ/powerstrip/issues{/number}","pulls_url":"https://api.github.com/repos/ClusterHQ/powerstrip/pulls{/number}","milestones_url":"https://api.github.com/repos/ClusterHQ/powerstrip/milestones{/number}","notifications_url":"https://api.github.com/repos/ClusterHQ/powerstrip/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ClusterHQ/powerstrip/labels{/name}","releases_url":"https://api.github.com/repos/ClusterHQ/powerstrip/releases{/id}","created_at":"2015-01-07T10:57:26Z","updated_at":"2015-02-15T23:41:10Z","pushed_at":"2015-02-16T11:56:04Z","git_url":"git://github.com/ClusterHQ/powerstrip.git","ssh_url":"git@github.com:ClusterHQ/powerstrip.git","clone_url":"https://github.com/ClusterHQ/powerstrip.git","svn_url":"https://github.com/ClusterHQ/powerstrip","homepage":"https://clusterhq.com/","size":1339,"stargazers_count":142,"watchers_count":142,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":37,"forks":9,"open_issues":37,"watchers":142,"default_branch":"master"}},"base":{"label":"ClusterHQ:master","ref":"master","sha":"ad21219ac806c7b9b81a729227ff115c650570f8","user":{"login":"ClusterHQ","id":7913449,"avatar_url":"https://avatars.githubusercontent.com/u/7913449?v=3","gravatar_id":"","url":"https://api.github.com/users/ClusterHQ","html_url":"https://github.com/ClusterHQ","followers_url":"https://api.github.com/users/ClusterHQ/followers","following_url":"https://api.github.com/users/ClusterHQ/following{/other_user}","gists_url":"https://api.github.com/users/ClusterHQ/gists{/gist_id}","starred_url":"https://api.github.com/users/ClusterHQ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ClusterHQ/subscriptions","organizations_url":"https://api.github.com/users/ClusterHQ/orgs","repos_url":"https://api.github.com/users/ClusterHQ/repos","events_url":"https://api.github.com/users/ClusterHQ/events{/privacy}","received_events_url":"https://api.github.com/users/ClusterHQ/received_events","type":"Organization","site_admin":false},"repo":{"id":28910752,"name":"powerstrip","full_name":"ClusterHQ/powerstrip","owner":{"login":"ClusterHQ","id":7913449,"avatar_url":"https://avatars.githubusercontent.com/u/7913449?v=3","gravatar_id":"","url":"https://api.github.com/users/ClusterHQ","html_url":"https://github.com/ClusterHQ","followers_url":"https://api.github.com/users/ClusterHQ/followers","following_url":"https://api.github.com/users/ClusterHQ/following{/other_user}","gists_url":"https://api.github.com/users/ClusterHQ/gists{/gist_id}","starred_url":"https://api.github.com/users/ClusterHQ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ClusterHQ/subscriptions","organizations_url":"https://api.github.com/users/ClusterHQ/orgs","repos_url":"https://api.github.com/users/ClusterHQ/repos","events_url":"https://api.github.com/users/ClusterHQ/events{/privacy}","received_events_url":"https://api.github.com/users/ClusterHQ/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ClusterHQ/powerstrip","description":"Powerstrip: A tool for prototyping Docker extensions","fork":false,"url":"https://api.github.com/repos/ClusterHQ/powerstrip","forks_url":"https://api.github.com/repos/ClusterHQ/powerstrip/forks","keys_url":"https://api.github.com/repos/ClusterHQ/powerstrip/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ClusterHQ/powerstrip/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ClusterHQ/powerstrip/teams","hooks_url":"https://api.github.com/repos/ClusterHQ/powerstrip/hooks","issue_events_url":"https://api.github.com/repos/ClusterHQ/powerstrip/issues/events{/number}","events_url":"https://api.github.com/repos/ClusterHQ/powerstrip/events","assignees_url":"https://api.github.com/repos/ClusterHQ/powerstrip/assignees{/user}","branches_url":"https://api.github.com/repos/ClusterHQ/powerstrip/branches{/branch}","tags_url":"https://api.github.com/repos/ClusterHQ/powerstrip/tags","blobs_url":"https://api.github.com/repos/ClusterHQ/powerstrip/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ClusterHQ/powerstrip/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ClusterHQ/powerstrip/git/refs{/sha}","trees_url":"https://api.github.com/repos/ClusterHQ/powerstrip/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ClusterHQ/powerstrip/statuses/{sha}","languages_url":"https://api.github.com/repos/ClusterHQ/powerstrip/languages","stargazers_url":"https://api.github.com/repos/ClusterHQ/powerstrip/stargazers","contributors_url":"https://api.github.com/repos/ClusterHQ/powerstrip/contributors","subscribers_url":"https://api.github.com/repos/ClusterHQ/powerstrip/subscribers","subscription_url":"https://api.github.com/repos/ClusterHQ/powerstrip/subscription","commits_url":"https://api.github.com/repos/ClusterHQ/powerstrip/commits{/sha}","git_commits_url":"https://api.github.com/repos/ClusterHQ/powerstrip/git/commits{/sha}","comments_url":"https://api.github.com/repos/ClusterHQ/powerstrip/comments{/number}","issue_comment_url":"https://api.github.com/repos/ClusterHQ/powerstrip/issues/comments/{number}","contents_url":"https://api.github.com/repos/ClusterHQ/powerstrip/contents/{+path}","compare_url":"https://api.github.com/repos/ClusterHQ/powerstrip/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ClusterHQ/powerstrip/merges","archive_url":"https://api.github.com/repos/ClusterHQ/powerstrip/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ClusterHQ/powerstrip/downloads","issues_url":"https://api.github.com/repos/ClusterHQ/powerstrip/issues{/number}","pulls_url":"https://api.github.com/repos/ClusterHQ/powerstrip/pulls{/number}","milestones_url":"https://api.github.com/repos/ClusterHQ/powerstrip/milestones{/number}","notifications_url":"https://api.github.com/repos/ClusterHQ/powerstrip/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ClusterHQ/powerstrip/labels{/name}","releases_url":"https://api.github.com/repos/ClusterHQ/powerstrip/releases{/id}","created_at":"2015-01-07T10:57:26Z","updated_at":"2015-02-15T23:41:10Z","pushed_at":"2015-02-16T11:56:04Z","git_url":"git://github.com/ClusterHQ/powerstrip.git","ssh_url":"git@github.com:ClusterHQ/powerstrip.git","clone_url":"https://github.com/ClusterHQ/powerstrip.git","svn_url":"https://github.com/ClusterHQ/powerstrip","homepage":"https://clusterhq.com/","size":1339,"stargazers_count":142,"watchers_count":142,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":37,"forks":9,"open_issues":37,"watchers":142,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ClusterHQ/powerstrip/pulls/47"},"html":{"href":"https://github.com/ClusterHQ/powerstrip/pull/47"},"issue":{"href":"https://api.github.com/repos/ClusterHQ/powerstrip/issues/47"},"comments":{"href":"https://api.github.com/repos/ClusterHQ/powerstrip/issues/47/comments"},"review_comments":{"href":"https://api.github.com/repos/ClusterHQ/powerstrip/pulls/47/comments"},"review_comment":{"href":"https://api.github.com/repos/ClusterHQ/powerstrip/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/ClusterHQ/powerstrip/pulls/47/commits"},"statuses":{"href":"https://api.github.com/repos/ClusterHQ/powerstrip/statuses/cbef7fca7283ddfa59ed34821b6899a642c4e86a"}}}}