{"action":"created","comment":{"url":"https://api.github.com/repos/openshift/origin/pulls/comments/55234411","id":55234411,"diff_hunk":"@@ -0,0 +1,126 @@\n+package images\n+\n+import (\n+\t\"fmt\"\n+\t\"strconv\"\n+\t\"time\"\n+\n+\tg \"github.com/onsi/ginkgo\"\n+\to \"github.com/onsi/gomega\"\n+\n+\texutil \"github.com/openshift/origin/test/extended/util\"\n+\t\"github.com/openshift/origin/test/extended/util/db\"\n+)\n+\n+var _ = g.Describe(\"[images][mongodb] openshift mongodb replication\", func() {\n+\tdefer g.GinkgoRecover()\n+\n+\tconst (\n+\t\ttemplatePath         = \"https://raw.githubusercontent.com/openshift/mongodb/master/2.4/examples/replica/mongodb-clustered.json\"\n+\t\tdeploymentConfigName = \"mongodb\"\n+\t\tinsertCmd            = `db.bar.save({ \"status\": \"passed\" })`\n+\t)\n+\n+\tconst (\n+\t\texpectedReplicasAfterDeployment = 3\n+\t\texpectedReplicasAfterScalingUp  = expectedReplicasAfterDeployment + 2\n+\t)\n+\n+\toc := exutil.NewCLI(\"mongodb-replica\", exutil.KubeConfigPath()).Verbose()\n+\n+\tg.Describe(\"creating from a template\", func() {\n+\t\tg.It(fmt.Sprintf(\"should process and create the %q template\", templatePath), func() {\n+\n+\t\t\tg.By(\"creating a new app\")\n+\t\t\to.Expect(oc.Run(\"new-app\").Args(\"-f\", templatePath).Execute()).Should(o.Succeed())\n+\n+\t\t\tg.By(\"waiting for the deployment to complete\")\n+\t\t\twaitForDeploymentToComplete(oc, deploymentConfigName)\n+\n+\t\t\tpodNames := waitForNumberOfPodsWithLabel(oc, expectedReplicasAfterDeployment, \"mongodb-replica\")\n+\t\t\tmongo := db.NewMongoDB(podNames[0])\n+\n+\t\t\tg.By(fmt.Sprintf(\"expecting that replica set have %v members\", expectedReplicasAfterDeployment))\n+\t\t\tassertMembersInReplica(oc, mongo, expectedReplicasAfterDeployment)\n+\n+\t\t\tg.By(\"expecting that we can insert a new record on primary node\")\n+\t\t\t_, err := mongo.QueryPrimary(oc, insertCmd)\n+\t\t\to.Expect(err).ShouldNot(o.HaveOccurred())\n+\n+\t\t\tg.By(\"expecting that we can read a record from all members\")\n+\t\t\tfor _, podName := range podNames {\n+\t\t\t\ttryToreadFromPod(oc, podName)\n+\t\t\t}\n+\n+\t\t\tscale(oc, deploymentConfigName, expectedReplicasAfterScalingUp)\n+\n+\t\t\tpodNames = waitForNumberOfPodsWithLabel(oc, expectedReplicasAfterScalingUp, \"mongodb-replica\")\n+\t\t\tmongo = db.NewMongoDB(podNames[0])\n+\n+\t\t\tg.By(\"expecting that scaling replica set up should have more members\")\n+\t\t\tassertMembersInReplica(oc, mongo, expectedReplicasAfterScalingUp)\n+\t\t})\n+\t})\n+\n+})\n+\n+func waitForDeploymentToComplete(oc *exutil.CLI, deploymentConfigName string) {\n+\texutil.WaitForADeployment(\n+\t\toc.KubeREST().ReplicationControllers(oc.Namespace()),\n+\t\tdeploymentConfigName,\n+\t\texutil.CheckDeploymentCompletedFn,\n+\t\texutil.CheckDeploymentFailedFn,\n+\t)\n+}\n+\n+func tryToreadFromPod(oc *exutil.CLI, podName string) {\n+\t// don't include _id field to output because it changes every time\n+\tconst findCmd = \"rs.slaveOk(); printjson(db.bar.find({}, {_id: 0}).toArray())\"\n+\n+\tfmt.Fprintf(g.GinkgoWriter, \"DEBUG: reading record from pod %v\\n\", podName)\n+\n+\tmongoPod := db.NewMongoDB(podName)\n+\tresult, err := mongoPod.Query(oc, findCmd)\n+\to.Expect(err).ShouldNot(o.HaveOccurred())\n+\to.Expect(result).Should(o.ContainSubstring(`{ \"status\" : \"passed\" }`))\n+}\n+\n+func scale(oc *exutil.CLI, deploymentConfigName string, replicas int) {","path":"test/extended/images/mongodb_replica.go","position":88,"original_position":88,"commit_id":"8747e196117fbd61d95d9c626e0a33cd88aa1093","original_commit_id":"8747e196117fbd61d95d9c626e0a33cd88aa1093","user":{"login":"php-coder","id":87088,"avatar_url":"https://avatars.githubusercontent.com/u/87088?v=3","gravatar_id":"","url":"https://api.github.com/users/php-coder","html_url":"https://github.com/php-coder","followers_url":"https://api.github.com/users/php-coder/followers","following_url":"https://api.github.com/users/php-coder/following{/other_user}","gists_url":"https://api.github.com/users/php-coder/gists{/gist_id}","starred_url":"https://api.github.com/users/php-coder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/php-coder/subscriptions","organizations_url":"https://api.github.com/users/php-coder/orgs","repos_url":"https://api.github.com/users/php-coder/repos","events_url":"https://api.github.com/users/php-coder/events{/privacy}","received_events_url":"https://api.github.com/users/php-coder/received_events","type":"User","site_admin":false},"body":"IMHO it makes test shorter and a bit more readable by hiding some details.\r\n\r\n(Also before there was part of scaling down it also used this method. Maybe we will need it later?)","created_at":"2016-03-07T17:00:55Z","updated_at":"2016-03-07T17:00:55Z","html_url":"https://github.com/openshift/origin/pull/7393#discussion_r55234411","pull_request_url":"https://api.github.com/repos/openshift/origin/pulls/7393","_links":{"self":{"href":"https://api.github.com/repos/openshift/origin/pulls/comments/55234411"},"html":{"href":"https://github.com/openshift/origin/pull/7393#discussion_r55234411"},"pull_request":{"href":"https://api.github.com/repos/openshift/origin/pulls/7393"}}},"pull_request":{"url":"https://api.github.com/repos/openshift/origin/pulls/7393","id":59684770,"html_url":"https://github.com/openshift/origin/pull/7393","diff_url":"https://github.com/openshift/origin/pull/7393.diff","patch_url":"https://github.com/openshift/origin/pull/7393.patch","issue_url":"https://api.github.com/repos/openshift/origin/issues/7393","number":7393,"state":"open","locked":false,"title":"MongoDB replication tests","user":{"login":"php-coder","id":87088,"avatar_url":"https://avatars.githubusercontent.com/u/87088?v=3","gravatar_id":"","url":"https://api.github.com/users/php-coder","html_url":"https://github.com/php-coder","followers_url":"https://api.github.com/users/php-coder/followers","following_url":"https://api.github.com/users/php-coder/following{/other_user}","gists_url":"https://api.github.com/users/php-coder/gists{/gist_id}","starred_url":"https://api.github.com/users/php-coder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/php-coder/subscriptions","organizations_url":"https://api.github.com/users/php-coder/orgs","repos_url":"https://api.github.com/users/php-coder/repos","events_url":"https://api.github.com/users/php-coder/events{/privacy}","received_events_url":"https://api.github.com/users/php-coder/received_events","type":"User","site_admin":false},"body":"Summary:\r\n- Add replication test for MongoDB\r\n- `mongodb_ephemeral`: use `WaitForADeployment()`\r\n- `Database.TestRemoteLogin`: fix typo in godoc\r\n\r\nReplication test doesn't contain scenario for scaling down because it works when I run it manually and it always fails when it's running as part of the test, so I believe that this should be fixed independently.\r\n\r\nPTAL @bparees @rhcarvalho @mnagy\r\n\r\nTrello card: https://trello.com/c/KFl01HTE/775-5-extended-tests-for-mongo-replication\r\n","created_at":"2016-02-17T18:10:50Z","updated_at":"2016-03-07T17:00:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ca7f1e4b015e3e5d1ddba302546509d67290381b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/openshift/origin/pulls/7393/commits","review_comments_url":"https://api.github.com/repos/openshift/origin/pulls/7393/comments","review_comment_url":"https://api.github.com/repos/openshift/origin/pulls/comments{/number}","comments_url":"https://api.github.com/repos/openshift/origin/issues/7393/comments","statuses_url":"https://api.github.com/repos/openshift/origin/statuses/8747e196117fbd61d95d9c626e0a33cd88aa1093","head":{"label":"php-coder:mongo_replica_extended_tests","ref":"mongo_replica_extended_tests","sha":"8747e196117fbd61d95d9c626e0a33cd88aa1093","user":{"login":"php-coder","id":87088,"avatar_url":"https://avatars.githubusercontent.com/u/87088?v=3","gravatar_id":"","url":"https://api.github.com/users/php-coder","html_url":"https://github.com/php-coder","followers_url":"https://api.github.com/users/php-coder/followers","following_url":"https://api.github.com/users/php-coder/following{/other_user}","gists_url":"https://api.github.com/users/php-coder/gists{/gist_id}","starred_url":"https://api.github.com/users/php-coder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/php-coder/subscriptions","organizations_url":"https://api.github.com/users/php-coder/orgs","repos_url":"https://api.github.com/users/php-coder/repos","events_url":"https://api.github.com/users/php-coder/events{/privacy}","received_events_url":"https://api.github.com/users/php-coder/received_events","type":"User","site_admin":false},"repo":{"id":43544739,"name":"origin","full_name":"php-coder/origin","owner":{"login":"php-coder","id":87088,"avatar_url":"https://avatars.githubusercontent.com/u/87088?v=3","gravatar_id":"","url":"https://api.github.com/users/php-coder","html_url":"https://github.com/php-coder","followers_url":"https://api.github.com/users/php-coder/followers","following_url":"https://api.github.com/users/php-coder/following{/other_user}","gists_url":"https://api.github.com/users/php-coder/gists{/gist_id}","starred_url":"https://api.github.com/users/php-coder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/php-coder/subscriptions","organizations_url":"https://api.github.com/users/php-coder/orgs","repos_url":"https://api.github.com/users/php-coder/repos","events_url":"https://api.github.com/users/php-coder/events{/privacy}","received_events_url":"https://api.github.com/users/php-coder/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/php-coder/origin","description":"OpenShift 3 - build, deploy, and manage your applications with Docker and Kubernetes","fork":true,"url":"https://api.github.com/repos/php-coder/origin","forks_url":"https://api.github.com/repos/php-coder/origin/forks","keys_url":"https://api.github.com/repos/php-coder/origin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/php-coder/origin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/php-coder/origin/teams","hooks_url":"https://api.github.com/repos/php-coder/origin/hooks","issue_events_url":"https://api.github.com/repos/php-coder/origin/issues/events{/number}","events_url":"https://api.github.com/repos/php-coder/origin/events","assignees_url":"https://api.github.com/repos/php-coder/origin/assignees{/user}","branches_url":"https://api.github.com/repos/php-coder/origin/branches{/branch}","tags_url":"https://api.github.com/repos/php-coder/origin/tags","blobs_url":"https://api.github.com/repos/php-coder/origin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/php-coder/origin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/php-coder/origin/git/refs{/sha}","trees_url":"https://api.github.com/repos/php-coder/origin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/php-coder/origin/statuses/{sha}","languages_url":"https://api.github.com/repos/php-coder/origin/languages","stargazers_url":"https://api.github.com/repos/php-coder/origin/stargazers","contributors_url":"https://api.github.com/repos/php-coder/origin/contributors","subscribers_url":"https://api.github.com/repos/php-coder/origin/subscribers","subscription_url":"https://api.github.com/repos/php-coder/origin/subscription","commits_url":"https://api.github.com/repos/php-coder/origin/commits{/sha}","git_commits_url":"https://api.github.com/repos/php-coder/origin/git/commits{/sha}","comments_url":"https://api.github.com/repos/php-coder/origin/comments{/number}","issue_comment_url":"https://api.github.com/repos/php-coder/origin/issues/comments{/number}","contents_url":"https://api.github.com/repos/php-coder/origin/contents/{+path}","compare_url":"https://api.github.com/repos/php-coder/origin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/php-coder/origin/merges","archive_url":"https://api.github.com/repos/php-coder/origin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/php-coder/origin/downloads","issues_url":"https://api.github.com/repos/php-coder/origin/issues{/number}","pulls_url":"https://api.github.com/repos/php-coder/origin/pulls{/number}","milestones_url":"https://api.github.com/repos/php-coder/origin/milestones{/number}","notifications_url":"https://api.github.com/repos/php-coder/origin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/php-coder/origin/labels{/name}","releases_url":"https://api.github.com/repos/php-coder/origin/releases{/id}","deployments_url":"https://api.github.com/repos/php-coder/origin/deployments","created_at":"2015-10-02T09:21:06Z","updated_at":"2016-01-12T15:08:10Z","pushed_at":"2016-03-07T16:02:30Z","git_url":"git://github.com/php-coder/origin.git","ssh_url":"git@github.com:php-coder/origin.git","clone_url":"https://github.com/php-coder/origin.git","svn_url":"https://github.com/php-coder/origin","homepage":"http://www.openshift.org","size":227698,"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":"23ff23b40088cbd1bc4c2167a476d047c33f83ec","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}","deployments_url":"https://api.github.com/repos/openshift/origin/deployments","created_at":"2014-07-30T20:04:05Z","updated_at":"2016-03-07T14:28:13Z","pushed_at":"2016-03-07T16:55:32Z","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":279671,"stargazers_count":1099,"watchers_count":1099,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":676,"mirror_url":null,"open_issues_count":900,"forks":676,"open_issues":900,"watchers":1099,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/openshift/origin/pulls/7393"},"html":{"href":"https://github.com/openshift/origin/pull/7393"},"issue":{"href":"https://api.github.com/repos/openshift/origin/issues/7393"},"comments":{"href":"https://api.github.com/repos/openshift/origin/issues/7393/comments"},"review_comments":{"href":"https://api.github.com/repos/openshift/origin/pulls/7393/comments"},"review_comment":{"href":"https://api.github.com/repos/openshift/origin/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/openshift/origin/pulls/7393/commits"},"statuses":{"href":"https://api.github.com/repos/openshift/origin/statuses/8747e196117fbd61d95d9c626e0a33cd88aa1093"}}}}