{"action":"created","comment":{"url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/comments/30956022","id":30956022,"diff_hunk":"@@ -0,0 +1,167 @@\n+package e2e\n+\n+import (\n+\t\"encoding/json\"\n+\t\"fmt\"\n+\t\"net/http\"\n+\t\"time\"\n+\n+\t\"github.com/GoogleCloudPlatform/kubernetes/pkg/api\"\n+\t\"github.com/GoogleCloudPlatform/kubernetes/pkg/client\"\n+\t\"github.com/GoogleCloudPlatform/kubernetes/pkg/util/wait\"\n+\n+\t. \"github.com/onsi/ginkgo\"\n+\t. \"github.com/onsi/gomega\"\n+)\n+\n+// partially cloned from webserver.go\n+type State struct {\n+\tReceived map[string]int\n+}\n+\n+func testPreStop(c *client.Client, ns string) {\n+\t// This is the server that will receive the preStop notification\n+\tpodDescr := &api.Pod{\n+\t\tObjectMeta: api.ObjectMeta{\n+\t\t\tName: \"server\",\n+\t\t},\n+\t\tSpec: api.PodSpec{\n+\t\t\tContainers: []api.Container{\n+\t\t\t\tapi.Container{\n+\t\t\t\t\tName:  \"server\",\n+\t\t\t\t\tImage: \"gcr.io/google_containers/nettest:1.3\",\n+\t\t\t\t\tPorts: []api.ContainerPort{{ContainerPort: 8080}},\n+\t\t\t\t},\n+\t\t\t},\n+\t\t},\n+\t}\n+\tBy(fmt.Sprintf(\"Creating server pod %s in namespace %s\", podDescr.Name, ns))\n+\t_, err := c.Pods(ns).Create(podDescr)\n+\texpectNoError(err, fmt.Sprintf(\"creating pod %s\", podDescr.Name))\n+\n+\t// At the end of the test, clean up by removing the pod.\n+\tdefer func() {\n+\t\tBy(\"deleting the server pod\")\n+\t\tc.Pods(ns).Delete(podDescr.Name, nil)\n+\t}()\n+\n+\tBy(\"Waiting for pods to come up.\")\n+\terr = waitForPodRunningInNamespace(c, podDescr.Name, ns)\n+\texpectNoError(err, fmt.Sprintf(\"waiting for server pod to start\"))\n+\n+\tval := \"{\\\"Source\\\": \\\"prestop\\\"}\"\n+\n+\tpodOut, err := c.Pods(ns).Get(podDescr.Name)\n+\texpectNoError(err, \"getting pod info\")\n+\n+\tpreStopDescr := &api.Pod{\n+\t\tObjectMeta: api.ObjectMeta{\n+\t\t\tName: \"tester\",\n+\t\t},\n+\t\tSpec: api.PodSpec{\n+\t\t\tContainers: []api.Container{\n+\t\t\t\tapi.Container{\n+\t\t\t\t\tName:    \"tester\",\n+\t\t\t\t\tImage:   \"busybox\",\n+\t\t\t\t\tCommand: []string{\"sleep\", \"600\"},\n+\t\t\t\t\tLifecycle: &api.Lifecycle{\n+\t\t\t\t\t\tPreStop: &api.Handler{\n+\t\t\t\t\t\t\tExec: &api.ExecAction{\n+\t\t\t\t\t\t\t\tCommand: []string{\n+\t\t\t\t\t\t\t\t\t\"wget\", \"-O-\", \"--post-data=\" + val, fmt.Sprintf(\"http://%s:8080/write\", podOut.Status.PodIP),\n+\t\t\t\t\t\t\t\t},\n+\t\t\t\t\t\t\t},\n+\t\t\t\t\t\t},\n+\t\t\t\t\t},\n+\t\t\t\t},\n+\t\t\t},\n+\t\t},\n+\t}\n+\n+\tBy(fmt.Sprintf(\"Creating tester pod %s in namespace %s\", podDescr.Name, ns))\n+\t_, err = c.Pods(ns).Create(preStopDescr)\n+\texpectNoError(err, fmt.Sprintf(\"creating pod %s\", preStopDescr.Name))\n+\tdeletePreStop := true\n+\n+\t// At the end of the test, clean up by removing the pod.\n+\tdefer func() {\n+\t\tif deletePreStop {\n+\t\t\tBy(\"deleting the tester pod\")\n+\t\t\tc.Pods(ns).Delete(preStopDescr.Name, nil)\n+\t\t}\n+\t}()\n+\n+\terr = waitForPodRunningInNamespace(c, preStopDescr.Name, ns)\n+\texpectNoError(err, fmt.Sprintf(\"waiting for tester pod to start\"))\n+\n+\t// Delete the pod with the preStop handler.\n+\tBy(\"Deleting pre-stop pod\")\n+\tif err := c.Pods(ns).Delete(preStopDescr.Name, nil); err == nil {\n+\t\tdeletePreStop = false\n+\t}\n+\texpectNoError(err, fmt.Sprintf(\"deleting pod: %s\", preStopDescr.Name))\n+\n+\t// Validate that the server received the web poke.\n+\terr = wait.Poll(time.Second*5, time.Second*60, func() (bool, error) {\n+\t\tif body, err := c.Get().\n+\t\t\tNamespace(ns).Prefix(\"proxy\").\n+\t\t\tResource(\"pods\").\n+\t\t\tName(podDescr.Name).\n+\t\t\tSuffix(\"read\").\n+\t\t\tDoRaw(); err != nil {\n+\t\t\tBy(fmt.Sprintf(\"error validating prestop: %v\", err))\n+\t\t} else {\n+\t\t\tstate := State{}\n+\t\t\terr := json.Unmarshal(body, &state)\n+\t\t\tif err != nil {\n+\t\t\t\tLogf(\"Error parsing: %v\", err)\n+\t\t\t\treturn false, nil\n+\t\t\t}\n+\t\t\tif state.Received[\"prestop\"] != 0 {\n+\t\t\t\treturn true, nil\n+\t\t\t}\n+\t\t\tLogf(\"Saw: %s\", string(body))\n+\t\t}\n+\t\treturn false, nil\n+\t})\n+\texpectNoError(err, fmt.Sprintf(\"validating pre-stop.\"))\n+}\n+\n+var _ = Describe(\"PreStop\", func() {\n+\t//This namespace is modified throughout the course of the test.\n+\tvar namespace *api.Namespace","path":"test/e2e/pre_stop.go","position":132,"original_position":132,"commit_id":"a34c3b713dd2842673ba3dca71875825c40a7055","original_commit_id":"a34c3b713dd2842673ba3dca71875825c40a7055","user":{"login":"lavalamp","id":647318,"avatar_url":"https://avatars.githubusercontent.com/u/647318?v=3","gravatar_id":"","url":"https://api.github.com/users/lavalamp","html_url":"https://github.com/lavalamp","followers_url":"https://api.github.com/users/lavalamp/followers","following_url":"https://api.github.com/users/lavalamp/following{/other_user}","gists_url":"https://api.github.com/users/lavalamp/gists{/gist_id}","starred_url":"https://api.github.com/users/lavalamp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lavalamp/subscriptions","organizations_url":"https://api.github.com/users/lavalamp/orgs","repos_url":"https://api.github.com/users/lavalamp/repos","events_url":"https://api.github.com/users/lavalamp/events{/privacy}","received_events_url":"https://api.github.com/users/lavalamp/received_events","type":"User","site_admin":false},"body":"Please use the framework I just added-- ```f := NewFramework(\"prestop\")```","created_at":"2015-05-24T21:20:45Z","updated_at":"2015-05-24T21:20:45Z","html_url":"https://github.com/GoogleCloudPlatform/kubernetes/pull/8747#discussion_r30956022","pull_request_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/8747","_links":{"self":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/comments/30956022"},"html":{"href":"https://github.com/GoogleCloudPlatform/kubernetes/pull/8747#discussion_r30956022"},"pull_request":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/8747"}}},"pull_request":{"url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/8747","id":36098317,"html_url":"https://github.com/GoogleCloudPlatform/kubernetes/pull/8747","diff_url":"https://github.com/GoogleCloudPlatform/kubernetes/pull/8747.diff","patch_url":"https://github.com/GoogleCloudPlatform/kubernetes/pull/8747.patch","issue_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/8747","number":8747,"state":"open","locked":false,"title":"Add a test for PreStop hooks.","user":{"login":"brendandburns","id":5751682,"avatar_url":"https://avatars.githubusercontent.com/u/5751682?v=3","gravatar_id":"","url":"https://api.github.com/users/brendandburns","html_url":"https://github.com/brendandburns","followers_url":"https://api.github.com/users/brendandburns/followers","following_url":"https://api.github.com/users/brendandburns/following{/other_user}","gists_url":"https://api.github.com/users/brendandburns/gists{/gist_id}","starred_url":"https://api.github.com/users/brendandburns/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brendandburns/subscriptions","organizations_url":"https://api.github.com/users/brendandburns/orgs","repos_url":"https://api.github.com/users/brendandburns/repos","events_url":"https://api.github.com/users/brendandburns/events{/privacy}","received_events_url":"https://api.github.com/users/brendandburns/received_events","type":"User","site_admin":false},"body":"Closes #7091 ","created_at":"2015-05-24T05:11:40Z","updated_at":"2015-05-24T21:20:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7591403221c8beb8b1cdf95676eec826b036cc04","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/8747/commits","review_comments_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/8747/comments","review_comment_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/comments{/number}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/8747/comments","statuses_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/statuses/a34c3b713dd2842673ba3dca71875825c40a7055","head":{"label":"brendandburns:e2e","ref":"e2e","sha":"a34c3b713dd2842673ba3dca71875825c40a7055","user":{"login":"brendandburns","id":5751682,"avatar_url":"https://avatars.githubusercontent.com/u/5751682?v=3","gravatar_id":"","url":"https://api.github.com/users/brendandburns","html_url":"https://github.com/brendandburns","followers_url":"https://api.github.com/users/brendandburns/followers","following_url":"https://api.github.com/users/brendandburns/following{/other_user}","gists_url":"https://api.github.com/users/brendandburns/gists{/gist_id}","starred_url":"https://api.github.com/users/brendandburns/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brendandburns/subscriptions","organizations_url":"https://api.github.com/users/brendandburns/orgs","repos_url":"https://api.github.com/users/brendandburns/repos","events_url":"https://api.github.com/users/brendandburns/events{/privacy}","received_events_url":"https://api.github.com/users/brendandburns/received_events","type":"User","site_admin":false},"repo":{"id":20748715,"name":"kubernetes","full_name":"brendandburns/kubernetes","owner":{"login":"brendandburns","id":5751682,"avatar_url":"https://avatars.githubusercontent.com/u/5751682?v=3","gravatar_id":"","url":"https://api.github.com/users/brendandburns","html_url":"https://github.com/brendandburns","followers_url":"https://api.github.com/users/brendandburns/followers","following_url":"https://api.github.com/users/brendandburns/following{/other_user}","gists_url":"https://api.github.com/users/brendandburns/gists{/gist_id}","starred_url":"https://api.github.com/users/brendandburns/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brendandburns/subscriptions","organizations_url":"https://api.github.com/users/brendandburns/orgs","repos_url":"https://api.github.com/users/brendandburns/repos","events_url":"https://api.github.com/users/brendandburns/events{/privacy}","received_events_url":"https://api.github.com/users/brendandburns/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/brendandburns/kubernetes","description":"Container Cluster Manager","fork":true,"url":"https://api.github.com/repos/brendandburns/kubernetes","forks_url":"https://api.github.com/repos/brendandburns/kubernetes/forks","keys_url":"https://api.github.com/repos/brendandburns/kubernetes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/brendandburns/kubernetes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/brendandburns/kubernetes/teams","hooks_url":"https://api.github.com/repos/brendandburns/kubernetes/hooks","issue_events_url":"https://api.github.com/repos/brendandburns/kubernetes/issues/events{/number}","events_url":"https://api.github.com/repos/brendandburns/kubernetes/events","assignees_url":"https://api.github.com/repos/brendandburns/kubernetes/assignees{/user}","branches_url":"https://api.github.com/repos/brendandburns/kubernetes/branches{/branch}","tags_url":"https://api.github.com/repos/brendandburns/kubernetes/tags","blobs_url":"https://api.github.com/repos/brendandburns/kubernetes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/brendandburns/kubernetes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/brendandburns/kubernetes/git/refs{/sha}","trees_url":"https://api.github.com/repos/brendandburns/kubernetes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/brendandburns/kubernetes/statuses/{sha}","languages_url":"https://api.github.com/repos/brendandburns/kubernetes/languages","stargazers_url":"https://api.github.com/repos/brendandburns/kubernetes/stargazers","contributors_url":"https://api.github.com/repos/brendandburns/kubernetes/contributors","subscribers_url":"https://api.github.com/repos/brendandburns/kubernetes/subscribers","subscription_url":"https://api.github.com/repos/brendandburns/kubernetes/subscription","commits_url":"https://api.github.com/repos/brendandburns/kubernetes/commits{/sha}","git_commits_url":"https://api.github.com/repos/brendandburns/kubernetes/git/commits{/sha}","comments_url":"https://api.github.com/repos/brendandburns/kubernetes/comments{/number}","issue_comment_url":"https://api.github.com/repos/brendandburns/kubernetes/issues/comments{/number}","contents_url":"https://api.github.com/repos/brendandburns/kubernetes/contents/{+path}","compare_url":"https://api.github.com/repos/brendandburns/kubernetes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/brendandburns/kubernetes/merges","archive_url":"https://api.github.com/repos/brendandburns/kubernetes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/brendandburns/kubernetes/downloads","issues_url":"https://api.github.com/repos/brendandburns/kubernetes/issues{/number}","pulls_url":"https://api.github.com/repos/brendandburns/kubernetes/pulls{/number}","milestones_url":"https://api.github.com/repos/brendandburns/kubernetes/milestones{/number}","notifications_url":"https://api.github.com/repos/brendandburns/kubernetes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/brendandburns/kubernetes/labels{/name}","releases_url":"https://api.github.com/repos/brendandburns/kubernetes/releases{/id}","created_at":"2014-06-12T00:13:18Z","updated_at":"2015-05-20T18:13:49Z","pushed_at":"2015-05-24T05:10:12Z","git_url":"git://github.com/brendandburns/kubernetes.git","ssh_url":"git@github.com:brendandburns/kubernetes.git","clone_url":"https://github.com/brendandburns/kubernetes.git","svn_url":"https://github.com/brendandburns/kubernetes","homepage":null,"size":61429,"stargazers_count":6,"watchers_count":6,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":1,"forks":3,"open_issues":1,"watchers":6,"default_branch":"master"}},"base":{"label":"GoogleCloudPlatform:master","ref":"master","sha":"cf7b0bdc2a41d38613ac7f8eeea91cae23553fa2","user":{"login":"GoogleCloudPlatform","id":2810941,"avatar_url":"https://avatars.githubusercontent.com/u/2810941?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCloudPlatform","html_url":"https://github.com/GoogleCloudPlatform","followers_url":"https://api.github.com/users/GoogleCloudPlatform/followers","following_url":"https://api.github.com/users/GoogleCloudPlatform/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCloudPlatform/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCloudPlatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCloudPlatform/subscriptions","organizations_url":"https://api.github.com/users/GoogleCloudPlatform/orgs","repos_url":"https://api.github.com/users/GoogleCloudPlatform/repos","events_url":"https://api.github.com/users/GoogleCloudPlatform/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCloudPlatform/received_events","type":"Organization","site_admin":false},"repo":{"id":20580498,"name":"kubernetes","full_name":"GoogleCloudPlatform/kubernetes","owner":{"login":"GoogleCloudPlatform","id":2810941,"avatar_url":"https://avatars.githubusercontent.com/u/2810941?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCloudPlatform","html_url":"https://github.com/GoogleCloudPlatform","followers_url":"https://api.github.com/users/GoogleCloudPlatform/followers","following_url":"https://api.github.com/users/GoogleCloudPlatform/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCloudPlatform/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCloudPlatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCloudPlatform/subscriptions","organizations_url":"https://api.github.com/users/GoogleCloudPlatform/orgs","repos_url":"https://api.github.com/users/GoogleCloudPlatform/repos","events_url":"https://api.github.com/users/GoogleCloudPlatform/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCloudPlatform/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/GoogleCloudPlatform/kubernetes","description":"Container Cluster Manager from Google","fork":false,"url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes","forks_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/forks","keys_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/teams","hooks_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/hooks","issue_events_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/events{/number}","events_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/events","assignees_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/assignees{/user}","branches_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/branches{/branch}","tags_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/tags","blobs_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/git/refs{/sha}","trees_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/statuses/{sha}","languages_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/languages","stargazers_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/stargazers","contributors_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/contributors","subscribers_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/subscribers","subscription_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/subscription","commits_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/commits{/sha}","git_commits_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/git/commits{/sha}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/comments{/number}","issue_comment_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/comments{/number}","contents_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/contents/{+path}","compare_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/merges","archive_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/downloads","issues_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues{/number}","pulls_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls{/number}","milestones_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/milestones{/number}","notifications_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/labels{/name}","releases_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/releases{/id}","created_at":"2014-06-06T22:56:04Z","updated_at":"2015-05-24T18:44:25Z","pushed_at":"2015-05-24T15:27:38Z","git_url":"git://github.com/GoogleCloudPlatform/kubernetes.git","ssh_url":"git@github.com:GoogleCloudPlatform/kubernetes.git","clone_url":"https://github.com/GoogleCloudPlatform/kubernetes.git","svn_url":"https://github.com/GoogleCloudPlatform/kubernetes","homepage":"http://kubernetes.io","size":285466,"stargazers_count":7894,"watchers_count":7894,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1636,"mirror_url":null,"open_issues_count":1218,"forks":1636,"open_issues":1218,"watchers":7894,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/8747"},"html":{"href":"https://github.com/GoogleCloudPlatform/kubernetes/pull/8747"},"issue":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/8747"},"comments":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/8747/comments"},"review_comments":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/8747/comments"},"review_comment":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/8747/commits"},"statuses":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/statuses/a34c3b713dd2842673ba3dca71875825c40a7055"}}}}