{"action":"created","comment":{"url":"https://api.github.com/repos/openshift/origin/pulls/comments/49127224","id":49127224,"diff_hunk":"@@ -0,0 +1,160 @@\n+package jenkins\n+\n+import (\n+\tg \"github.com/onsi/ginkgo\"\n+\to \"github.com/onsi/gomega\"\n+\n+\t\"bytes\"\n+\t\"fmt\"\n+\t\"io\"\n+\t\"io/ioutil\"\n+\t\"net/http\"\n+\t\"strings\"\n+\t\"time\"\n+\n+\t\"k8s.io/kubernetes/pkg/util/wait\"\n+\n+\texutil \"github.com/openshift/origin/test/extended/util\"\n+)\n+\n+func immediateInteractionWithJenkins(uri, method string, body io.Reader, status int) {\n+\treq, err := http.NewRequest(method, uri, body)\n+\to.Expect(err).NotTo(o.HaveOccurred())\n+\n+\tif body != nil {\n+\t\treq.Header.Set(\"Content-Type\", \"application/xml\")\n+\t\t// jenkins will return 417 if we have an expect hdr\n+\t\treq.Header.Del(\"Expect\")\n+\t}\n+\treq.SetBasicAuth(\"admin\", \"password\")\n+\n+\tclient := &http.Client{}\n+\tresp, err := client.Do(req)\n+\tdefer resp.Body.Close()\n+\n+\to.Expect(err).NotTo(o.HaveOccurred())\n+\to.Expect(resp.StatusCode).To(o.BeEquivalentTo(status))\n+\n+}\n+\n+func waitForJenkinsActivity(uri, verificationString string, status int) error {\n+\tconsoleLogs := \"\"\n+\n+\terr := wait.Poll(1*time.Second, 3*time.Minute, func() (bool, error) {\n+\t\treq, err := http.NewRequest(\"GET\", uri, nil)\n+\t\tif err != nil {\n+\t\t\treturn false, err\n+\t\t}\n+\t\treq.SetBasicAuth(\"admin\", \"password\")\n+\t\tclient := &http.Client{}\n+\t\tresp, err := client.Do(req)\n+\t\tdefer resp.Body.Close()\n+\t\tif err != nil {\n+\t\t\treturn false, err\n+\t\t}\n+\t\tif resp.StatusCode == status {\n+\t\t\tif len(verificationString) > 0 {\n+\t\t\t\tcontents, err := ioutil.ReadAll(resp.Body)\n+\t\t\t\tif err != nil {\n+\t\t\t\t\treturn false, err\n+\t\t\t\t}\n+\t\t\t\tconsoleLogs = string(contents)\n+\t\t\t\tif strings.Contains(consoleLogs, verificationString) {\n+\t\t\t\t\treturn true, nil\n+\t\t\t\t} else {\n+\t\t\t\t\treturn false, nil\n+\t\t\t\t}\n+\t\t\t} else {\n+\t\t\t\treturn true, nil\n+\t\t\t}\n+\t\t}\n+\t\treturn false, nil\n+\t})\n+\n+\tif err != nil {\n+\t\treturn fmt.Errorf(\"got error %v waiting on uri %s with verificationString %s and last set of console logs %s\", err, uri, verificationString, consoleLogs)\n+\t} else {\n+\t\treturn nil\n+\t}\n+}\n+\n+// as g.It's are added conceivably will be with new jenkins job def's\n+func jenkinsJobBytes(filename, namespace string) []byte {\n+\tpre := exutil.FixturePath(\"fixtures\", filename)\n+\tpost := exutil.ArtifactPath(filename)\n+\terr := exutil.VarSubOnFile(pre, post, \"PROJECT_NAME\", namespace)\n+\to.Expect(err).NotTo(o.HaveOccurred())\n+\tdata, err := ioutil.ReadFile(post)\n+\to.Expect(err).NotTo(o.HaveOccurred())\n+\treturn data\n+}\n+\n+var _ = g.Describe(\"jenkins: plugin: run job leverging openshift pipeline plugin\", func() {\n+\tdefer g.GinkgoRecover()\n+\tvar oc = exutil.NewCLI(\"jenkins-plugin\", exutil.KubeConfigPath())\n+\tvar hostPort string\n+\n+\tg.BeforeEach(func() {\n+\n+\t\tg.By(\"set up policy for jenkins jobs\")\n+\t\terr := oc.Run(\"policy\").Args(\"add-role-to-user\", \"edit\", \"system:serviceaccount:\"+oc.Namespace()+\":default\").Execute()\n+\t\to.Expect(err).NotTo(o.HaveOccurred())\n+\n+\t\tg.By(\"kick off the build for the jenkins ephermeral and application templates\")\n+\t\tjenkinsEphemeralPath := exutil.FixturePath(\"fixtures\", \"jenkins-ephemeral-template.json\")\n+\t\terr = exutil.NewApp(jenkinsEphemeralPath, oc)\n+\t\to.Expect(err).NotTo(o.HaveOccurred())\n+\t\tjenkinsApplicationPath := exutil.FixturePath(\"fixtures\", \"application-template.json\")\n+\t\terr = exutil.NewApp(jenkinsApplicationPath, oc)\n+\t\to.Expect(err).NotTo(o.HaveOccurred())\n+\n+\t\tg.By(\"tag the app image stream\")\n+\t\terr = exutil.TagImageStream(\"nodejs-010-centos7\", \"openshift/nodejs-010-centos7:latest\", oc)\n+\t\to.Expect(err).NotTo(o.HaveOccurred())\n+\n+\t\tg.By(\"waiting for jenkins deployment\")\n+\t\terr = exutil.WaitForADeployment(oc.KubeREST().ReplicationControllers(oc.Namespace()), \"jenkins\", exutil.CheckDeploymentCompletedFn, exutil.CheckDeploymentFailedFn)\n+\t\to.Expect(err).NotTo(o.HaveOccurred())\n+\n+\t\tg.By(\"get ip and port for jenkins service\")\n+\t\tserviceIP, err := oc.Run(\"get\").Args(\"svc\", \"jenkins\", \"--config\", exutil.KubeConfigPath()).Template(\"{{.spec.clusterIP}}\").Output()\n+\t\to.Expect(err).NotTo(o.HaveOccurred())\n+\t\tport, err := oc.Run(\"get\").Args(\"svc\", \"jenkins\", \"--config\", exutil.KubeConfigPath()).Template(\"{{ $x := index .spec.ports 0}}{{$x.port}}\").Output()\n+\t\to.Expect(err).NotTo(o.HaveOccurred())\n+\t\thostPort = fmt.Sprintf(\"%s:%s\", serviceIP, port)\n+\n+\t\tg.By(\"wait for jenkins to come up\")\n+\t\terr = waitForJenkinsActivity(fmt.Sprintf(\"http://%s\", hostPort), \"\", 200)\n+\t\to.Expect(err).NotTo(o.HaveOccurred())\n+\n+\t})\n+\n+\tg.Context(\"jenkins-plugin test context  \", func() {\n+\n+\t\tg.It(\"jenkins-plugin test case execution\", func() {\n+\n+\t\t\tg.By(\"create jenkins job config xml file, convert to bytes for http post\")\n+\t\t\tdata := jenkinsJobBytes(\"testjob-plugin.xml\", oc.Namespace())\n+\n+\t\t\tg.By(\"make http request to create job\")\n+\t\t\timmediateInteractionWithJenkins(fmt.Sprintf(\"http://%s/createItem?name=test-plugin-job\", hostPort), \"POST\", bytes.NewBuffer(data), 200)\n+\n+\t\t\tg.By(\"make http request to kick off build\")\n+\t\t\timmediateInteractionWithJenkins(fmt.Sprintf(\"http://%s/job/test-plugin-job/build?delay=0sec\", hostPort), \"POST\", nil, 201)\n+\n+\t\t\t// the build and deployment is by far the most time consuming portion of the test jenkins job;\n+\t\t\t// we leverage some of the openshift utilities for waiting for the deployment before we poll\n+\t\t\t// jenkins for the sucessful job completion\n+\t\t\tg.By(\"waiting for frontend deployment as sign that the build has finished\")\n+\t\t\terr := exutil.WaitForADeployment(oc.KubeREST().ReplicationControllers(oc.Namespace()), \"frontend\", exutil.CheckDeploymentCompletedFn, exutil.CheckDeploymentFailedFn)","path":"test/extended/jenkins/jenkins_plugin.go","position":148,"original_position":149,"commit_id":"d23a24f89c30d792b7a679e7caf0c6431b1e94b9","original_commit_id":"6020f06b2a9c5e9181aff611cc42eef139a3e9d2","user":{"login":"bparees","id":4974046,"avatar_url":"https://avatars.githubusercontent.com/u/4974046?v=3","gravatar_id":"","url":"https://api.github.com/users/bparees","html_url":"https://github.com/bparees","followers_url":"https://api.github.com/users/bparees/followers","following_url":"https://api.github.com/users/bparees/following{/other_user}","gists_url":"https://api.github.com/users/bparees/gists{/gist_id}","starred_url":"https://api.github.com/users/bparees/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bparees/subscriptions","organizations_url":"https://api.github.com/users/bparees/orgs","repos_url":"https://api.github.com/users/bparees/repos","events_url":"https://api.github.com/users/bparees/events{/privacy}","received_events_url":"https://api.github.com/users/bparees/received_events","type":"User","site_admin":false},"body":"1) Did this question get resolved (whether it's going to wait forever)?\r\n2) Shouldn't this be checking the frontend-prod deployment, not the frontend deployment?\r\n\r\n","created_at":"2016-01-07T21:19:22Z","updated_at":"2016-01-07T21:19:22Z","html_url":"https://github.com/openshift/origin/pull/6329#discussion_r49127224","pull_request_url":"https://api.github.com/repos/openshift/origin/pulls/6329","_links":{"self":{"href":"https://api.github.com/repos/openshift/origin/pulls/comments/49127224"},"html":{"href":"https://github.com/openshift/origin/pull/6329#discussion_r49127224"},"pull_request":{"href":"https://api.github.com/repos/openshift/origin/pulls/6329"}}},"pull_request":{"url":"https://api.github.com/repos/openshift/origin/pulls/6329","id":53760237,"html_url":"https://github.com/openshift/origin/pull/6329","diff_url":"https://github.com/openshift/origin/pull/6329.diff","patch_url":"https://github.com/openshift/origin/pull/6329.patch","issue_url":"https://api.github.com/repos/openshift/origin/issues/6329","number":6329,"state":"open","locked":false,"title":"extended tests for jenkins openshift V3 plugin","user":{"login":"gabemontero","id":3594868,"avatar_url":"https://avatars.githubusercontent.com/u/3594868?v=3","gravatar_id":"","url":"https://api.github.com/users/gabemontero","html_url":"https://github.com/gabemontero","followers_url":"https://api.github.com/users/gabemontero/followers","following_url":"https://api.github.com/users/gabemontero/following{/other_user}","gists_url":"https://api.github.com/users/gabemontero/gists{/gist_id}","starred_url":"https://api.github.com/users/gabemontero/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gabemontero/subscriptions","organizations_url":"https://api.github.com/users/gabemontero/orgs","repos_url":"https://api.github.com/users/gabemontero/repos","events_url":"https://api.github.com/users/gabemontero/events{/privacy}","received_events_url":"https://api.github.com/users/gabemontero/received_events","type":"User","site_admin":false},"body":"@bparees @mfojtik PTAL","created_at":"2015-12-15T20:51:15Z","updated_at":"2016-01-07T21:19:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"303e4d0468f2ea86de3780ba76662de7044d12c7","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/openshift/origin/pulls/6329/commits","review_comments_url":"https://api.github.com/repos/openshift/origin/pulls/6329/comments","review_comment_url":"https://api.github.com/repos/openshift/origin/pulls/comments{/number}","comments_url":"https://api.github.com/repos/openshift/origin/issues/6329/comments","statuses_url":"https://api.github.com/repos/openshift/origin/statuses/d23a24f89c30d792b7a679e7caf0c6431b1e94b9","head":{"label":"gabemontero:jenkinsExtendedTests","ref":"jenkinsExtendedTests","sha":"d23a24f89c30d792b7a679e7caf0c6431b1e94b9","user":{"login":"gabemontero","id":3594868,"avatar_url":"https://avatars.githubusercontent.com/u/3594868?v=3","gravatar_id":"","url":"https://api.github.com/users/gabemontero","html_url":"https://github.com/gabemontero","followers_url":"https://api.github.com/users/gabemontero/followers","following_url":"https://api.github.com/users/gabemontero/following{/other_user}","gists_url":"https://api.github.com/users/gabemontero/gists{/gist_id}","starred_url":"https://api.github.com/users/gabemontero/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gabemontero/subscriptions","organizations_url":"https://api.github.com/users/gabemontero/orgs","repos_url":"https://api.github.com/users/gabemontero/repos","events_url":"https://api.github.com/users/gabemontero/events{/privacy}","received_events_url":"https://api.github.com/users/gabemontero/received_events","type":"User","site_admin":false},"repo":{"id":36941154,"name":"origin","full_name":"gabemontero/origin","owner":{"login":"gabemontero","id":3594868,"avatar_url":"https://avatars.githubusercontent.com/u/3594868?v=3","gravatar_id":"","url":"https://api.github.com/users/gabemontero","html_url":"https://github.com/gabemontero","followers_url":"https://api.github.com/users/gabemontero/followers","following_url":"https://api.github.com/users/gabemontero/following{/other_user}","gists_url":"https://api.github.com/users/gabemontero/gists{/gist_id}","starred_url":"https://api.github.com/users/gabemontero/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gabemontero/subscriptions","organizations_url":"https://api.github.com/users/gabemontero/orgs","repos_url":"https://api.github.com/users/gabemontero/repos","events_url":"https://api.github.com/users/gabemontero/events{/privacy}","received_events_url":"https://api.github.com/users/gabemontero/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/gabemontero/origin","description":"OpenShift 3 - build, deploy, and manage your applications with Docker and Kubernetes","fork":true,"url":"https://api.github.com/repos/gabemontero/origin","forks_url":"https://api.github.com/repos/gabemontero/origin/forks","keys_url":"https://api.github.com/repos/gabemontero/origin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gabemontero/origin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gabemontero/origin/teams","hooks_url":"https://api.github.com/repos/gabemontero/origin/hooks","issue_events_url":"https://api.github.com/repos/gabemontero/origin/issues/events{/number}","events_url":"https://api.github.com/repos/gabemontero/origin/events","assignees_url":"https://api.github.com/repos/gabemontero/origin/assignees{/user}","branches_url":"https://api.github.com/repos/gabemontero/origin/branches{/branch}","tags_url":"https://api.github.com/repos/gabemontero/origin/tags","blobs_url":"https://api.github.com/repos/gabemontero/origin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gabemontero/origin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gabemontero/origin/git/refs{/sha}","trees_url":"https://api.github.com/repos/gabemontero/origin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gabemontero/origin/statuses/{sha}","languages_url":"https://api.github.com/repos/gabemontero/origin/languages","stargazers_url":"https://api.github.com/repos/gabemontero/origin/stargazers","contributors_url":"https://api.github.com/repos/gabemontero/origin/contributors","subscribers_url":"https://api.github.com/repos/gabemontero/origin/subscribers","subscription_url":"https://api.github.com/repos/gabemontero/origin/subscription","commits_url":"https://api.github.com/repos/gabemontero/origin/commits{/sha}","git_commits_url":"https://api.github.com/repos/gabemontero/origin/git/commits{/sha}","comments_url":"https://api.github.com/repos/gabemontero/origin/comments{/number}","issue_comment_url":"https://api.github.com/repos/gabemontero/origin/issues/comments{/number}","contents_url":"https://api.github.com/repos/gabemontero/origin/contents/{+path}","compare_url":"https://api.github.com/repos/gabemontero/origin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gabemontero/origin/merges","archive_url":"https://api.github.com/repos/gabemontero/origin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gabemontero/origin/downloads","issues_url":"https://api.github.com/repos/gabemontero/origin/issues{/number}","pulls_url":"https://api.github.com/repos/gabemontero/origin/pulls{/number}","milestones_url":"https://api.github.com/repos/gabemontero/origin/milestones{/number}","notifications_url":"https://api.github.com/repos/gabemontero/origin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gabemontero/origin/labels{/name}","releases_url":"https://api.github.com/repos/gabemontero/origin/releases{/id}","created_at":"2015-06-05T15:48:08Z","updated_at":"2015-06-05T15:48:12Z","pushed_at":"2016-01-07T21:00:09Z","git_url":"git://github.com/gabemontero/origin.git","ssh_url":"git@github.com:gabemontero/origin.git","clone_url":"https://github.com/gabemontero/origin.git","svn_url":"https://github.com/gabemontero/origin","homepage":"http://www.openshift.org","size":190138,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"openshift:master","ref":"master","sha":"e883f1b367855b370f5ec60c8d01c833e85b98c7","user":{"login":"openshift","id":792337,"avatar_url":"https://avatars.githubusercontent.com/u/792337?v=3","gravatar_id":"","url":"https://api.github.com/users/openshift","html_url":"https://github.com/openshift","followers_url":"https://api.github.com/users/openshift/followers","following_url":"https://api.github.com/users/openshift/following{/other_user}","gists_url":"https://api.github.com/users/openshift/gists{/gist_id}","starred_url":"https://api.github.com/users/openshift/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openshift/subscriptions","organizations_url":"https://api.github.com/users/openshift/orgs","repos_url":"https://api.github.com/users/openshift/repos","events_url":"https://api.github.com/users/openshift/events{/privacy}","received_events_url":"https://api.github.com/users/openshift/received_events","type":"Organization","site_admin":false},"repo":{"id":22442668,"name":"origin","full_name":"openshift/origin","owner":{"login":"openshift","id":792337,"avatar_url":"https://avatars.githubusercontent.com/u/792337?v=3","gravatar_id":"","url":"https://api.github.com/users/openshift","html_url":"https://github.com/openshift","followers_url":"https://api.github.com/users/openshift/followers","following_url":"https://api.github.com/users/openshift/following{/other_user}","gists_url":"https://api.github.com/users/openshift/gists{/gist_id}","starred_url":"https://api.github.com/users/openshift/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openshift/subscriptions","organizations_url":"https://api.github.com/users/openshift/orgs","repos_url":"https://api.github.com/users/openshift/repos","events_url":"https://api.github.com/users/openshift/events{/privacy}","received_events_url":"https://api.github.com/users/openshift/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/openshift/origin","description":"OpenShift 3 - build, deploy, and manage your applications with Docker and Kubernetes","fork":false,"url":"https://api.github.com/repos/openshift/origin","forks_url":"https://api.github.com/repos/openshift/origin/forks","keys_url":"https://api.github.com/repos/openshift/origin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/openshift/origin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/openshift/origin/teams","hooks_url":"https://api.github.com/repos/openshift/origin/hooks","issue_events_url":"https://api.github.com/repos/openshift/origin/issues/events{/number}","events_url":"https://api.github.com/repos/openshift/origin/events","assignees_url":"https://api.github.com/repos/openshift/origin/assignees{/user}","branches_url":"https://api.github.com/repos/openshift/origin/branches{/branch}","tags_url":"https://api.github.com/repos/openshift/origin/tags","blobs_url":"https://api.github.com/repos/openshift/origin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/openshift/origin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/openshift/origin/git/refs{/sha}","trees_url":"https://api.github.com/repos/openshift/origin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/openshift/origin/statuses/{sha}","languages_url":"https://api.github.com/repos/openshift/origin/languages","stargazers_url":"https://api.github.com/repos/openshift/origin/stargazers","contributors_url":"https://api.github.com/repos/openshift/origin/contributors","subscribers_url":"https://api.github.com/repos/openshift/origin/subscribers","subscription_url":"https://api.github.com/repos/openshift/origin/subscription","commits_url":"https://api.github.com/repos/openshift/origin/commits{/sha}","git_commits_url":"https://api.github.com/repos/openshift/origin/git/commits{/sha}","comments_url":"https://api.github.com/repos/openshift/origin/comments{/number}","issue_comment_url":"https://api.github.com/repos/openshift/origin/issues/comments{/number}","contents_url":"https://api.github.com/repos/openshift/origin/contents/{+path}","compare_url":"https://api.github.com/repos/openshift/origin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/openshift/origin/merges","archive_url":"https://api.github.com/repos/openshift/origin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/openshift/origin/downloads","issues_url":"https://api.github.com/repos/openshift/origin/issues{/number}","pulls_url":"https://api.github.com/repos/openshift/origin/pulls{/number}","milestones_url":"https://api.github.com/repos/openshift/origin/milestones{/number}","notifications_url":"https://api.github.com/repos/openshift/origin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/openshift/origin/labels{/name}","releases_url":"https://api.github.com/repos/openshift/origin/releases{/id}","created_at":"2014-07-30T20:04:05Z","updated_at":"2016-01-07T03:28:45Z","pushed_at":"2016-01-07T21:15:08Z","git_url":"git://github.com/openshift/origin.git","ssh_url":"git@github.com:openshift/origin.git","clone_url":"https://github.com/openshift/origin.git","svn_url":"https://github.com/openshift/origin","homepage":"http://www.openshift.org","size":248881,"stargazers_count":903,"watchers_count":903,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":568,"mirror_url":null,"open_issues_count":780,"forks":568,"open_issues":780,"watchers":903,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/openshift/origin/pulls/6329"},"html":{"href":"https://github.com/openshift/origin/pull/6329"},"issue":{"href":"https://api.github.com/repos/openshift/origin/issues/6329"},"comments":{"href":"https://api.github.com/repos/openshift/origin/issues/6329/comments"},"review_comments":{"href":"https://api.github.com/repos/openshift/origin/pulls/6329/comments"},"review_comment":{"href":"https://api.github.com/repos/openshift/origin/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/openshift/origin/pulls/6329/commits"},"statuses":{"href":"https://api.github.com/repos/openshift/origin/statuses/d23a24f89c30d792b7a679e7caf0c6431b1e94b9"}}}}