{"action":"created","comment":{"url":"https://api.github.com/repos/flynn/flynn/pulls/comments/29096416","id":29096416,"diff_hunk":"@@ -0,0 +1,369 @@\n+package backend\n+\n+import (\n+\t\"bufio\"\n+\t\"fmt\"\n+\t\"io\"\n+\t\"io/ioutil\"\n+\t\"math\"\n+\t\"os\"\n+\t\"path/filepath\"\n+\t\"sort\"\n+\t\"strconv\"\n+\t\"strings\"\n+\n+\t. \"github.com/flynn/flynn/Godeps/_workspace/src/github.com/flynn/go-check\"\n+\tzfs \"github.com/flynn/flynn/Godeps/_workspace/src/github.com/mistifyio/go-zfs\"\n+\t\"github.com/flynn/flynn/Godeps/_workspace/src/github.com/mitchellh/go-ps\"\n+\t\"github.com/flynn/flynn/Godeps/_workspace/src/github.com/syndtr/gocapability/capability\"\n+\n+\t\"github.com/flynn/flynn/host/logmux\"\n+\t\"github.com/flynn/flynn/host/types\"\n+\t\"github.com/flynn/flynn/host/volume\"\n+\t\"github.com/flynn/flynn/host/volume/manager\"\n+\tzfsVolume \"github.com/flynn/flynn/host/volume/zfs\"\n+\t\"github.com/flynn/flynn/pkg/random\"\n+)\n+\n+type ContainerSuite struct {\n+\tid, runDir  string\n+\tbackendName string\n+\tbackend     Backend\n+\tjob         *host.Job\n+\tcontainer   Container\n+\ttty         io.ReadWriteCloser\n+\tvman        *volumemanager.Manager\n+}\n+\n+func (s *ContainerSuite) setup(c *C, backendName string) {\n+\tif os.Getuid() != 0 {\n+\t\tc.Skip(\"backend tests must be run as root\")\n+\t}\n+\n+\tvar err error\n+\ts.id = random.String(12)\n+\n+\ts.runDir, err = ioutil.TempDir(\"\", fmt.Sprintf(\"flynn-test-%s.\", s.id))\n+\tc.Assert(err, IsNil)\n+\n+\tvdevFile := filepath.Join(s.runDir, fmt.Sprintf(\"flynn-test-zpool-%s.vdev\", s.id))\n+\n+\tvman, err := volumemanager.New(\n+\t\tfilepath.Join(s.runDir, \"volumes.bolt\"),\n+\t\tfunc() (volume.Provider, error) {\n+\t\t\treturn zfsVolume.NewProvider(&zfsVolume.ProviderConfig{\n+\t\t\t\tDatasetName: fmt.Sprintf(\"flynn-test-zpool-%s\", s.id),\n+\t\t\t\tMake: &zfsVolume.MakeDev{\n+\t\t\t\t\tBackingFilename: vdevFile,\n+\t\t\t\t\tSize:            int64(math.Pow(2, float64(30))),\n+\t\t\t\t},\n+\t\t\t\tWorkingDir: filepath.Join(s.runDir, \"zfs\"),\n+\t\t\t})\n+\t\t})\n+\tc.Assert(err, IsNil)\n+\n+\tpwd, err := os.Getwd()\n+\tc.Assert(err, IsNil)\n+\n+\tstate := NewState(\"test-host\", filepath.Join(s.runDir, \"host-state.bolt\"))\n+\n+\ts.backend, err = New(backendName, Config{\n+\t\tState:    state,\n+\t\tManager:  vman,\n+\t\tVolPath:  filepath.Join(s.runDir, \"host-volumes\"),\n+\t\tLogPath:  filepath.Join(s.runDir, \"host-logs\"),\n+\t\tInitPath: filepath.Join(pwd, \"../bin/flynn-init\"),\n+\t\tMux:      logmux.New(1000),\n+\t})\n+\tc.Assert(err, IsNil)\n+\n+\ts.job = &host.Job{\n+\t\tID: s.id,\n+\t\tArtifact: host.Artifact{\n+\t\t\tURI: \"https://registry.hub.docker.com?name=flynn/busybox&id=184af8860f22e7a87f1416bb12a32b20d0d2c142f719653d87809a6122b04663\",\n+\t\t},\n+\t\tConfig: host.ContainerConfig{\n+\t\t\tEntrypoint:  []string{\"/bin/sh\", \"-\"},\n+\t\t\tHostNetwork: true,\n+\t\t\tStdin:       true,\n+\t\t},\n+\t}\n+\n+\tattachWait := make(chan struct{})\n+\tstate.AddAttacher(s.job.ID, attachWait)\n+\n+\terr = s.backend.Run(s.job, nil)\n+\tc.Assert(err, IsNil)\n+\n+\tstdinr, stdinw := io.Pipe()\n+\tstdoutr, stdoutw := io.Pipe()\n+\n+\ts.tty = struct {\n+\t\tio.WriteCloser\n+\t\tio.Reader\n+\t}{stdinw, stdoutr}\n+\n+\t<-attachWait\n+\tjob := state.GetJob(s.job.ID)\n+\n+\tattached := make(chan struct{})\n+\tattachReq := &AttachRequest{\n+\t\tJob:      job,\n+\t\tHeight:   80,\n+\t\tWidth:    80,","path":"host/backend/container_test.go","position":113,"original_position":113,"commit_id":"4bb6e0e259ee83e93a527902f2ebb125ba377064","original_commit_id":"4bb6e0e259ee83e93a527902f2ebb125ba377064","user":{"login":"titanous","id":13026,"avatar_url":"https://avatars.githubusercontent.com/u/13026?v=3","gravatar_id":"","url":"https://api.github.com/users/titanous","html_url":"https://github.com/titanous","followers_url":"https://api.github.com/users/titanous/followers","following_url":"https://api.github.com/users/titanous/following{/other_user}","gists_url":"https://api.github.com/users/titanous/gists{/gist_id}","starred_url":"https://api.github.com/users/titanous/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/titanous/subscriptions","organizations_url":"https://api.github.com/users/titanous/orgs","repos_url":"https://api.github.com/users/titanous/repos","events_url":"https://api.github.com/users/titanous/events{/privacy}","received_events_url":"https://api.github.com/users/titanous/received_events","type":"User","site_admin":false},"body":"Height/Width can be omitted since we're not using a TTH.","created_at":"2015-04-25T01:22:41Z","updated_at":"2015-04-25T01:22:41Z","html_url":"https://github.com/flynn/flynn/pull/1476#discussion_r29096416","pull_request_url":"https://api.github.com/repos/flynn/flynn/pulls/1476","_links":{"self":{"href":"https://api.github.com/repos/flynn/flynn/pulls/comments/29096416"},"html":{"href":"https://github.com/flynn/flynn/pull/1476#discussion_r29096416"},"pull_request":{"href":"https://api.github.com/repos/flynn/flynn/pulls/1476"}}},"pull_request":{"url":"https://api.github.com/repos/flynn/flynn/pulls/1476","id":33924988,"html_url":"https://github.com/flynn/flynn/pull/1476","diff_url":"https://github.com/flynn/flynn/pull/1476.diff","patch_url":"https://github.com/flynn/flynn/pull/1476.patch","issue_url":"https://api.github.com/repos/flynn/flynn/issues/1476","number":1476,"state":"open","locked":false,"title":"host: add container tests for libvirt-lxc","user":{"login":"benburkert","id":77,"avatar_url":"https://avatars.githubusercontent.com/u/77?v=3","gravatar_id":"","url":"https://api.github.com/users/benburkert","html_url":"https://github.com/benburkert","followers_url":"https://api.github.com/users/benburkert/followers","following_url":"https://api.github.com/users/benburkert/following{/other_user}","gists_url":"https://api.github.com/users/benburkert/gists{/gist_id}","starred_url":"https://api.github.com/users/benburkert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benburkert/subscriptions","organizations_url":"https://api.github.com/users/benburkert/orgs","repos_url":"https://api.github.com/users/benburkert/repos","events_url":"https://api.github.com/users/benburkert/events{/privacy}","received_events_url":"https://api.github.com/users/benburkert/received_events","type":"User","site_admin":false},"body":"This adds container test for the libvirt-lxc backend that assert the cgroups, capabilities, devices, namespaces, env, mounts, and memory info for container processes. The libvirt-lxc related code has been moved to the `host/backend` package too.","created_at":"2015-04-23T05:22:34Z","updated_at":"2015-04-25T01:22:41Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9704ceb2be72567cd53ccad7b7385ddb60a3d983","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/flynn/flynn/pulls/1476/commits","review_comments_url":"https://api.github.com/repos/flynn/flynn/pulls/1476/comments","review_comment_url":"https://api.github.com/repos/flynn/flynn/pulls/comments{/number}","comments_url":"https://api.github.com/repos/flynn/flynn/issues/1476/comments","statuses_url":"https://api.github.com/repos/flynn/flynn/statuses/4bb6e0e259ee83e93a527902f2ebb125ba377064","head":{"label":"flynn:host-libvirt-lxc-tests","ref":"host-libvirt-lxc-tests","sha":"4bb6e0e259ee83e93a527902f2ebb125ba377064","user":{"login":"flynn","id":4973613,"avatar_url":"https://avatars.githubusercontent.com/u/4973613?v=3","gravatar_id":"","url":"https://api.github.com/users/flynn","html_url":"https://github.com/flynn","followers_url":"https://api.github.com/users/flynn/followers","following_url":"https://api.github.com/users/flynn/following{/other_user}","gists_url":"https://api.github.com/users/flynn/gists{/gist_id}","starred_url":"https://api.github.com/users/flynn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flynn/subscriptions","organizations_url":"https://api.github.com/users/flynn/orgs","repos_url":"https://api.github.com/users/flynn/repos","events_url":"https://api.github.com/users/flynn/events{/privacy}","received_events_url":"https://api.github.com/users/flynn/received_events","type":"Organization","site_admin":false},"repo":{"id":11290232,"name":"flynn","full_name":"flynn/flynn","owner":{"login":"flynn","id":4973613,"avatar_url":"https://avatars.githubusercontent.com/u/4973613?v=3","gravatar_id":"","url":"https://api.github.com/users/flynn","html_url":"https://github.com/flynn","followers_url":"https://api.github.com/users/flynn/followers","following_url":"https://api.github.com/users/flynn/following{/other_user}","gists_url":"https://api.github.com/users/flynn/gists{/gist_id}","starred_url":"https://api.github.com/users/flynn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flynn/subscriptions","organizations_url":"https://api.github.com/users/flynn/orgs","repos_url":"https://api.github.com/users/flynn/repos","events_url":"https://api.github.com/users/flynn/events{/privacy}","received_events_url":"https://api.github.com/users/flynn/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/flynn/flynn","description":"A next generation open source platform as a service (PaaS)","fork":false,"url":"https://api.github.com/repos/flynn/flynn","forks_url":"https://api.github.com/repos/flynn/flynn/forks","keys_url":"https://api.github.com/repos/flynn/flynn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/flynn/flynn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/flynn/flynn/teams","hooks_url":"https://api.github.com/repos/flynn/flynn/hooks","issue_events_url":"https://api.github.com/repos/flynn/flynn/issues/events{/number}","events_url":"https://api.github.com/repos/flynn/flynn/events","assignees_url":"https://api.github.com/repos/flynn/flynn/assignees{/user}","branches_url":"https://api.github.com/repos/flynn/flynn/branches{/branch}","tags_url":"https://api.github.com/repos/flynn/flynn/tags","blobs_url":"https://api.github.com/repos/flynn/flynn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/flynn/flynn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/flynn/flynn/git/refs{/sha}","trees_url":"https://api.github.com/repos/flynn/flynn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/flynn/flynn/statuses/{sha}","languages_url":"https://api.github.com/repos/flynn/flynn/languages","stargazers_url":"https://api.github.com/repos/flynn/flynn/stargazers","contributors_url":"https://api.github.com/repos/flynn/flynn/contributors","subscribers_url":"https://api.github.com/repos/flynn/flynn/subscribers","subscription_url":"https://api.github.com/repos/flynn/flynn/subscription","commits_url":"https://api.github.com/repos/flynn/flynn/commits{/sha}","git_commits_url":"https://api.github.com/repos/flynn/flynn/git/commits{/sha}","comments_url":"https://api.github.com/repos/flynn/flynn/comments{/number}","issue_comment_url":"https://api.github.com/repos/flynn/flynn/issues/comments{/number}","contents_url":"https://api.github.com/repos/flynn/flynn/contents/{+path}","compare_url":"https://api.github.com/repos/flynn/flynn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/flynn/flynn/merges","archive_url":"https://api.github.com/repos/flynn/flynn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/flynn/flynn/downloads","issues_url":"https://api.github.com/repos/flynn/flynn/issues{/number}","pulls_url":"https://api.github.com/repos/flynn/flynn/pulls{/number}","milestones_url":"https://api.github.com/repos/flynn/flynn/milestones{/number}","notifications_url":"https://api.github.com/repos/flynn/flynn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/flynn/flynn/labels{/name}","releases_url":"https://api.github.com/repos/flynn/flynn/releases{/id}","created_at":"2013-07-09T18:22:06Z","updated_at":"2015-04-23T23:17:28Z","pushed_at":"2015-04-24T22:00:23Z","git_url":"git://github.com/flynn/flynn.git","ssh_url":"git@github.com:flynn/flynn.git","clone_url":"https://github.com/flynn/flynn.git","svn_url":"https://github.com/flynn/flynn","homepage":"https://flynn.io","size":51337,"stargazers_count":3484,"watchers_count":3484,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":244,"mirror_url":null,"open_issues_count":187,"forks":244,"open_issues":187,"watchers":3484,"default_branch":"master"}},"base":{"label":"flynn:master","ref":"master","sha":"cb19fa2c6d298dfc46d2019b886f61522c5f05f3","user":{"login":"flynn","id":4973613,"avatar_url":"https://avatars.githubusercontent.com/u/4973613?v=3","gravatar_id":"","url":"https://api.github.com/users/flynn","html_url":"https://github.com/flynn","followers_url":"https://api.github.com/users/flynn/followers","following_url":"https://api.github.com/users/flynn/following{/other_user}","gists_url":"https://api.github.com/users/flynn/gists{/gist_id}","starred_url":"https://api.github.com/users/flynn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flynn/subscriptions","organizations_url":"https://api.github.com/users/flynn/orgs","repos_url":"https://api.github.com/users/flynn/repos","events_url":"https://api.github.com/users/flynn/events{/privacy}","received_events_url":"https://api.github.com/users/flynn/received_events","type":"Organization","site_admin":false},"repo":{"id":11290232,"name":"flynn","full_name":"flynn/flynn","owner":{"login":"flynn","id":4973613,"avatar_url":"https://avatars.githubusercontent.com/u/4973613?v=3","gravatar_id":"","url":"https://api.github.com/users/flynn","html_url":"https://github.com/flynn","followers_url":"https://api.github.com/users/flynn/followers","following_url":"https://api.github.com/users/flynn/following{/other_user}","gists_url":"https://api.github.com/users/flynn/gists{/gist_id}","starred_url":"https://api.github.com/users/flynn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flynn/subscriptions","organizations_url":"https://api.github.com/users/flynn/orgs","repos_url":"https://api.github.com/users/flynn/repos","events_url":"https://api.github.com/users/flynn/events{/privacy}","received_events_url":"https://api.github.com/users/flynn/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/flynn/flynn","description":"A next generation open source platform as a service (PaaS)","fork":false,"url":"https://api.github.com/repos/flynn/flynn","forks_url":"https://api.github.com/repos/flynn/flynn/forks","keys_url":"https://api.github.com/repos/flynn/flynn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/flynn/flynn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/flynn/flynn/teams","hooks_url":"https://api.github.com/repos/flynn/flynn/hooks","issue_events_url":"https://api.github.com/repos/flynn/flynn/issues/events{/number}","events_url":"https://api.github.com/repos/flynn/flynn/events","assignees_url":"https://api.github.com/repos/flynn/flynn/assignees{/user}","branches_url":"https://api.github.com/repos/flynn/flynn/branches{/branch}","tags_url":"https://api.github.com/repos/flynn/flynn/tags","blobs_url":"https://api.github.com/repos/flynn/flynn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/flynn/flynn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/flynn/flynn/git/refs{/sha}","trees_url":"https://api.github.com/repos/flynn/flynn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/flynn/flynn/statuses/{sha}","languages_url":"https://api.github.com/repos/flynn/flynn/languages","stargazers_url":"https://api.github.com/repos/flynn/flynn/stargazers","contributors_url":"https://api.github.com/repos/flynn/flynn/contributors","subscribers_url":"https://api.github.com/repos/flynn/flynn/subscribers","subscription_url":"https://api.github.com/repos/flynn/flynn/subscription","commits_url":"https://api.github.com/repos/flynn/flynn/commits{/sha}","git_commits_url":"https://api.github.com/repos/flynn/flynn/git/commits{/sha}","comments_url":"https://api.github.com/repos/flynn/flynn/comments{/number}","issue_comment_url":"https://api.github.com/repos/flynn/flynn/issues/comments{/number}","contents_url":"https://api.github.com/repos/flynn/flynn/contents/{+path}","compare_url":"https://api.github.com/repos/flynn/flynn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/flynn/flynn/merges","archive_url":"https://api.github.com/repos/flynn/flynn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/flynn/flynn/downloads","issues_url":"https://api.github.com/repos/flynn/flynn/issues{/number}","pulls_url":"https://api.github.com/repos/flynn/flynn/pulls{/number}","milestones_url":"https://api.github.com/repos/flynn/flynn/milestones{/number}","notifications_url":"https://api.github.com/repos/flynn/flynn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/flynn/flynn/labels{/name}","releases_url":"https://api.github.com/repos/flynn/flynn/releases{/id}","created_at":"2013-07-09T18:22:06Z","updated_at":"2015-04-23T23:17:28Z","pushed_at":"2015-04-24T22:00:23Z","git_url":"git://github.com/flynn/flynn.git","ssh_url":"git@github.com:flynn/flynn.git","clone_url":"https://github.com/flynn/flynn.git","svn_url":"https://github.com/flynn/flynn","homepage":"https://flynn.io","size":51337,"stargazers_count":3484,"watchers_count":3484,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":244,"mirror_url":null,"open_issues_count":187,"forks":244,"open_issues":187,"watchers":3484,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/flynn/flynn/pulls/1476"},"html":{"href":"https://github.com/flynn/flynn/pull/1476"},"issue":{"href":"https://api.github.com/repos/flynn/flynn/issues/1476"},"comments":{"href":"https://api.github.com/repos/flynn/flynn/issues/1476/comments"},"review_comments":{"href":"https://api.github.com/repos/flynn/flynn/pulls/1476/comments"},"review_comment":{"href":"https://api.github.com/repos/flynn/flynn/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/flynn/flynn/pulls/1476/commits"},"statuses":{"href":"https://api.github.com/repos/flynn/flynn/statuses/4bb6e0e259ee83e93a527902f2ebb125ba377064"}}}}