{"action":"created","comment":{"url":"https://api.github.com/repos/inetCatapult/service-maker/pulls/comments/36461338","id":36461338,"diff_hunk":"@@ -564,6 +565,157 @@ describe(\"The AwsAdapter class \", function () {\n \t\t\t\texpect(result.message).to.be.equal(\"Simulated Failure.\");\n \t\t\t});\n \t\t});\n+\n+\t\tdescribe(\"gets IP address and tries to update an instance which has already been modified\", function () {\n+\t\t\tvar SshPollingStub;\n+\t\t\tvar getPublicIPAddressStub;\n+\t\t\tvar instanceProp;\n+\t\t\tvar result;\n+\n+\t\t\tbefore(function () {\n+\t\t\t\tSshPollingStub = Sinon.stub(sshAdapter,\"SshPolling\", function () {\n+\t\t\t\t\treturn Bluebird.resolve();\n+\t\t\t\t});\n+\n+\t\t\t\tgetPublicIPAddressStub = Sinon.stub(awsAdapter,\"getPublicIPAddress\", function () {\n+\t\t\t\t\treturn Bluebird.resolve(VALID_IP_ADDRESS);\n+\t\t\t\t});\n+\n+\t\t\t\treturn instances.createInstance(\"ami-d05e75b8\",\"t2.micro\")\n+\t\t\t\t.then(function (data) {\n+\t\t\t\t\tvar updatedInstance = new Instance({\n+\t\t\t\t\t\tid    : data.id,\n+\t\t\t\t\t\ttype  : data.type,\n+\t\t\t\t\t\tami   : data.ami,\n+\t\t\t\t\t\tstate : \"terminating\",\n+\t\t\t\t\t\turi   : data.uri\n+\t\t\t\t\t});\n+\t\t\t\t\tinstances.updateInstance(updatedInstance);\n+\t\t\t\t\tinstanceProp  = JSON.parse(JSON.stringify(data));\n+\t\t\t\t\tinstanceProp.instanceID = VALID_EC2_INSTANCE;\n+\t\t\t\t\treturn awsAdapter.beginPolling(instanceProp);\n+\t\t\t\t})\n+\t\t\t\t.then(function (response) {\n+\t\t\t\t\tresult = response;\n+\t\t\t\t});\n+\t\t\t});\n+\n+\t\t\tafter(function () {\n+\t\t\t\tSshPollingStub.restore();\n+\t\t\t\tgetPublicIPAddressStub.restore();\n+\t\t\t});\n+\n+\t\t\tit(\"does not update the current instance status\", function () {\n+\t\t\t\texpect(result.id).to.equal(instanceProp.id);\n+\t\t\t\texpect(result.type).to.equal(instanceProp.type);\n+\t\t\t\texpect(result.ami).to.equal(instanceProp.ami);\n+\t\t\t\texpect(result.state).to.equal(\"terminating\");\n+\t\t\t\texpect(result.uri).to.be.null;\n+\t\t\t});\n+\t\t});\n+\n+\t\tdescribe(\"faces an error while polling and tries to update an instance which has already been modified\",\n+\t\tfunction () {\n+\t\t\tvar SshPollingStub;\n+\t\t\tvar getPublicIPAddressStub;\n+\t\t\tvar instanceProp;\n+\t\t\tvar result;\n+\n+\t\t\tbefore(function () {\n+\t\t\t\tSshPollingStub = Sinon.stub(sshAdapter,\"SshPolling\", function () {\n+\t\t\t\t\treturn Bluebird.reject(\"Simulated Failure.\");\n+\t\t\t\t});\n+\n+\t\t\t\tgetPublicIPAddressStub = Sinon.stub(awsAdapter,\"getPublicIPAddress\", function () {\n+\t\t\t\t\treturn Bluebird.resolve(VALID_IP_ADDRESS);\n+\t\t\t\t});\n+\n+\t\t\t\treturn instances.createInstance(\"ami-d05e75b8\",\"t2.micro\")\n+\t\t\t\t.then(function (data) {\n+\t\t\t\t\tvar updatedInstance = new Instance({\n+\t\t\t\t\t\tid    : data.id,\n+\t\t\t\t\t\ttype  : data.type,\n+\t\t\t\t\t\tami   : data.ami,\n+\t\t\t\t\t\tstate : \"terminating\",\n+\t\t\t\t\t\turi   : data.uri\n+\t\t\t\t\t});\n+\t\t\t\t\tinstances.updateInstance(updatedInstance);\n+\t\t\t\t\tinstanceProp  = JSON.parse(JSON.stringify(data));\n+\t\t\t\t\tinstanceProp.instanceID = VALID_EC2_INSTANCE;\n+\t\t\t\t\treturn awsAdapter.beginPolling(instanceProp);\n+\t\t\t\t})\n+\t\t\t\t.then(function (response) {\n+\t\t\t\t\tresult = response;\n+\t\t\t\t});\n+\t\t\t});\n+\n+\t\t\tafter(function () {\n+\t\t\t\tSshPollingStub.restore();\n+\t\t\t\tgetPublicIPAddressStub.restore();\n+\t\t\t});\n+\n+\t\t\tit(\"does not update the current instance status\", function () {\n+\t\t\t\texpect(result.id).to.equal(instanceProp.id);\n+\t\t\t\texpect(result.type).to.equal(instanceProp.type);\n+\t\t\t\texpect(result.ami).to.equal(instanceProp.ami);\n+\t\t\t\texpect(result.state).to.equal(\"terminating\");\n+\t\t\t\texpect(result.uri).to.be.null;\n+\t\t\t});\n+\t\t});\n+\n+\t\tdescribe(\"faces an error while polling and getInstance does not show state has been updated\",\n+\t\tfunction () {\n+\t\t\tvar SshPollingStub;\n+\t\t\tvar getPublicIPAddressStub;\n+\t\t\tvar getInstanceStub;\n+\t\t\tvar instanceProp;\n+\t\t\tvar result;\n+\n+\t\t\tbefore(function () {\n+\t\t\t\treturn instances.createInstance()\n+\t\t\t\t.then(function (instance) {\n+\t\t\t\t\tinstanceProp = instance;\n+\t\t\t\t\tSshPollingStub = Sinon.stub(sshAdapter,\"SshPolling\", function () {\n+\t\t\t\t\t\treturn Bluebird.reject(\"Simulated Failure.\");\n+\t\t\t\t\t});\n+\n+\t\t\t\t\tgetPublicIPAddressStub = Sinon.stub(awsAdapter,\"getPublicIPAddress\", function () {\n+\t\t\t\t\t\treturn Bluebird.resolve(VALID_IP_ADDRESS);\n+\t\t\t\t\t});\n+\n+\t\t\t\t\tgetInstanceStub = Sinon.stub(instances, \"getInstance\", function () {\n+\t\t\t\t\t\treturn instances.updateInstance(instance)","path":"test/unit/services/awsAdapter_spec.js","position":131,"original_position":131,"commit_id":"0f0dff6f53df068efd5f9ac17de1c6cbe47bc7ee","original_commit_id":"0f0dff6f53df068efd5f9ac17de1c6cbe47bc7ee","user":{"login":"a-type","id":2829772,"avatar_url":"https://avatars.githubusercontent.com/u/2829772?v=3","gravatar_id":"","url":"https://api.github.com/users/a-type","html_url":"https://github.com/a-type","followers_url":"https://api.github.com/users/a-type/followers","following_url":"https://api.github.com/users/a-type/following{/other_user}","gists_url":"https://api.github.com/users/a-type/gists{/gist_id}","starred_url":"https://api.github.com/users/a-type/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/a-type/subscriptions","organizations_url":"https://api.github.com/users/a-type/orgs","repos_url":"https://api.github.com/users/a-type/repos","events_url":"https://api.github.com/users/a-type/events{/privacy}","received_events_url":"https://api.github.com/users/a-type/received_events","type":"User","site_admin":false},"body":"Would be nice to have some inline documentation here to explain what is happening.","created_at":"2015-08-06T20:28:46Z","updated_at":"2015-08-06T20:28:46Z","html_url":"https://github.com/inetCatapult/service-maker/pull/98#discussion_r36461338","pull_request_url":"https://api.github.com/repos/inetCatapult/service-maker/pulls/98","_links":{"self":{"href":"https://api.github.com/repos/inetCatapult/service-maker/pulls/comments/36461338"},"html":{"href":"https://github.com/inetCatapult/service-maker/pull/98#discussion_r36461338"},"pull_request":{"href":"https://api.github.com/repos/inetCatapult/service-maker/pulls/98"}}},"pull_request":{"url":"https://api.github.com/repos/inetCatapult/service-maker/pulls/98","id":41806820,"html_url":"https://github.com/inetCatapult/service-maker/pull/98","diff_url":"https://github.com/inetCatapult/service-maker/pull/98.diff","patch_url":"https://github.com/inetCatapult/service-maker/pull/98.patch","issue_url":"https://api.github.com/repos/inetCatapult/service-maker/issues/98","number":98,"state":"open","locked":false,"title":"Added Cases to handle concurrency during sshpolling","user":{"login":"rrpod","id":6464042,"avatar_url":"https://avatars.githubusercontent.com/u/6464042?v=3","gravatar_id":"","url":"https://api.github.com/users/rrpod","html_url":"https://github.com/rrpod","followers_url":"https://api.github.com/users/rrpod/followers","following_url":"https://api.github.com/users/rrpod/following{/other_user}","gists_url":"https://api.github.com/users/rrpod/gists{/gist_id}","starred_url":"https://api.github.com/users/rrpod/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rrpod/subscriptions","organizations_url":"https://api.github.com/users/rrpod/orgs","repos_url":"https://api.github.com/users/rrpod/repos","events_url":"https://api.github.com/users/rrpod/events{/privacy}","received_events_url":"https://api.github.com/users/rrpod/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-08-06T16:22:02Z","updated_at":"2015-08-06T20:28:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0e23e9e242644b1c173d9a34825d4a838d5f6d72","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/inetCatapult/service-maker/pulls/98/commits","review_comments_url":"https://api.github.com/repos/inetCatapult/service-maker/pulls/98/comments","review_comment_url":"https://api.github.com/repos/inetCatapult/service-maker/pulls/comments{/number}","comments_url":"https://api.github.com/repos/inetCatapult/service-maker/issues/98/comments","statuses_url":"https://api.github.com/repos/inetCatapult/service-maker/statuses/0f0dff6f53df068efd5f9ac17de1c6cbe47bc7ee","head":{"label":"rrpod:sshpolling","ref":"sshpolling","sha":"0f0dff6f53df068efd5f9ac17de1c6cbe47bc7ee","user":{"login":"rrpod","id":6464042,"avatar_url":"https://avatars.githubusercontent.com/u/6464042?v=3","gravatar_id":"","url":"https://api.github.com/users/rrpod","html_url":"https://github.com/rrpod","followers_url":"https://api.github.com/users/rrpod/followers","following_url":"https://api.github.com/users/rrpod/following{/other_user}","gists_url":"https://api.github.com/users/rrpod/gists{/gist_id}","starred_url":"https://api.github.com/users/rrpod/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rrpod/subscriptions","organizations_url":"https://api.github.com/users/rrpod/orgs","repos_url":"https://api.github.com/users/rrpod/repos","events_url":"https://api.github.com/users/rrpod/events{/privacy}","received_events_url":"https://api.github.com/users/rrpod/received_events","type":"User","site_admin":false},"repo":{"id":38839759,"name":"service-maker","full_name":"rrpod/service-maker","owner":{"login":"rrpod","id":6464042,"avatar_url":"https://avatars.githubusercontent.com/u/6464042?v=3","gravatar_id":"","url":"https://api.github.com/users/rrpod","html_url":"https://github.com/rrpod","followers_url":"https://api.github.com/users/rrpod/followers","following_url":"https://api.github.com/users/rrpod/following{/other_user}","gists_url":"https://api.github.com/users/rrpod/gists{/gist_id}","starred_url":"https://api.github.com/users/rrpod/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rrpod/subscriptions","organizations_url":"https://api.github.com/users/rrpod/orgs","repos_url":"https://api.github.com/users/rrpod/repos","events_url":"https://api.github.com/users/rrpod/events{/privacy}","received_events_url":"https://api.github.com/users/rrpod/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rrpod/service-maker","description":"","fork":true,"url":"https://api.github.com/repos/rrpod/service-maker","forks_url":"https://api.github.com/repos/rrpod/service-maker/forks","keys_url":"https://api.github.com/repos/rrpod/service-maker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rrpod/service-maker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rrpod/service-maker/teams","hooks_url":"https://api.github.com/repos/rrpod/service-maker/hooks","issue_events_url":"https://api.github.com/repos/rrpod/service-maker/issues/events{/number}","events_url":"https://api.github.com/repos/rrpod/service-maker/events","assignees_url":"https://api.github.com/repos/rrpod/service-maker/assignees{/user}","branches_url":"https://api.github.com/repos/rrpod/service-maker/branches{/branch}","tags_url":"https://api.github.com/repos/rrpod/service-maker/tags","blobs_url":"https://api.github.com/repos/rrpod/service-maker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rrpod/service-maker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rrpod/service-maker/git/refs{/sha}","trees_url":"https://api.github.com/repos/rrpod/service-maker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rrpod/service-maker/statuses/{sha}","languages_url":"https://api.github.com/repos/rrpod/service-maker/languages","stargazers_url":"https://api.github.com/repos/rrpod/service-maker/stargazers","contributors_url":"https://api.github.com/repos/rrpod/service-maker/contributors","subscribers_url":"https://api.github.com/repos/rrpod/service-maker/subscribers","subscription_url":"https://api.github.com/repos/rrpod/service-maker/subscription","commits_url":"https://api.github.com/repos/rrpod/service-maker/commits{/sha}","git_commits_url":"https://api.github.com/repos/rrpod/service-maker/git/commits{/sha}","comments_url":"https://api.github.com/repos/rrpod/service-maker/comments{/number}","issue_comment_url":"https://api.github.com/repos/rrpod/service-maker/issues/comments{/number}","contents_url":"https://api.github.com/repos/rrpod/service-maker/contents/{+path}","compare_url":"https://api.github.com/repos/rrpod/service-maker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rrpod/service-maker/merges","archive_url":"https://api.github.com/repos/rrpod/service-maker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rrpod/service-maker/downloads","issues_url":"https://api.github.com/repos/rrpod/service-maker/issues{/number}","pulls_url":"https://api.github.com/repos/rrpod/service-maker/pulls{/number}","milestones_url":"https://api.github.com/repos/rrpod/service-maker/milestones{/number}","notifications_url":"https://api.github.com/repos/rrpod/service-maker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rrpod/service-maker/labels{/name}","releases_url":"https://api.github.com/repos/rrpod/service-maker/releases{/id}","created_at":"2015-07-09T19:05:50Z","updated_at":"2015-07-09T19:05:51Z","pushed_at":"2015-08-06T16:21:02Z","git_url":"git://github.com/rrpod/service-maker.git","ssh_url":"git@github.com:rrpod/service-maker.git","clone_url":"https://github.com/rrpod/service-maker.git","svn_url":"https://github.com/rrpod/service-maker","homepage":null,"size":379,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"inetCatapult:v1.0","ref":"v1.0","sha":"1c8afeb88e415d64d01520b060db56f81d3d11c6","user":{"login":"inetCatapult","id":1799831,"avatar_url":"https://avatars.githubusercontent.com/u/1799831?v=3","gravatar_id":"","url":"https://api.github.com/users/inetCatapult","html_url":"https://github.com/inetCatapult","followers_url":"https://api.github.com/users/inetCatapult/followers","following_url":"https://api.github.com/users/inetCatapult/following{/other_user}","gists_url":"https://api.github.com/users/inetCatapult/gists{/gist_id}","starred_url":"https://api.github.com/users/inetCatapult/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/inetCatapult/subscriptions","organizations_url":"https://api.github.com/users/inetCatapult/orgs","repos_url":"https://api.github.com/users/inetCatapult/repos","events_url":"https://api.github.com/users/inetCatapult/events{/privacy}","received_events_url":"https://api.github.com/users/inetCatapult/received_events","type":"Organization","site_admin":false},"repo":{"id":29730754,"name":"service-maker","full_name":"inetCatapult/service-maker","owner":{"login":"inetCatapult","id":1799831,"avatar_url":"https://avatars.githubusercontent.com/u/1799831?v=3","gravatar_id":"","url":"https://api.github.com/users/inetCatapult","html_url":"https://github.com/inetCatapult","followers_url":"https://api.github.com/users/inetCatapult/followers","following_url":"https://api.github.com/users/inetCatapult/following{/other_user}","gists_url":"https://api.github.com/users/inetCatapult/gists{/gist_id}","starred_url":"https://api.github.com/users/inetCatapult/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/inetCatapult/subscriptions","organizations_url":"https://api.github.com/users/inetCatapult/orgs","repos_url":"https://api.github.com/users/inetCatapult/repos","events_url":"https://api.github.com/users/inetCatapult/events{/privacy}","received_events_url":"https://api.github.com/users/inetCatapult/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/inetCatapult/service-maker","description":"","fork":false,"url":"https://api.github.com/repos/inetCatapult/service-maker","forks_url":"https://api.github.com/repos/inetCatapult/service-maker/forks","keys_url":"https://api.github.com/repos/inetCatapult/service-maker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/inetCatapult/service-maker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/inetCatapult/service-maker/teams","hooks_url":"https://api.github.com/repos/inetCatapult/service-maker/hooks","issue_events_url":"https://api.github.com/repos/inetCatapult/service-maker/issues/events{/number}","events_url":"https://api.github.com/repos/inetCatapult/service-maker/events","assignees_url":"https://api.github.com/repos/inetCatapult/service-maker/assignees{/user}","branches_url":"https://api.github.com/repos/inetCatapult/service-maker/branches{/branch}","tags_url":"https://api.github.com/repos/inetCatapult/service-maker/tags","blobs_url":"https://api.github.com/repos/inetCatapult/service-maker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/inetCatapult/service-maker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/inetCatapult/service-maker/git/refs{/sha}","trees_url":"https://api.github.com/repos/inetCatapult/service-maker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/inetCatapult/service-maker/statuses/{sha}","languages_url":"https://api.github.com/repos/inetCatapult/service-maker/languages","stargazers_url":"https://api.github.com/repos/inetCatapult/service-maker/stargazers","contributors_url":"https://api.github.com/repos/inetCatapult/service-maker/contributors","subscribers_url":"https://api.github.com/repos/inetCatapult/service-maker/subscribers","subscription_url":"https://api.github.com/repos/inetCatapult/service-maker/subscription","commits_url":"https://api.github.com/repos/inetCatapult/service-maker/commits{/sha}","git_commits_url":"https://api.github.com/repos/inetCatapult/service-maker/git/commits{/sha}","comments_url":"https://api.github.com/repos/inetCatapult/service-maker/comments{/number}","issue_comment_url":"https://api.github.com/repos/inetCatapult/service-maker/issues/comments{/number}","contents_url":"https://api.github.com/repos/inetCatapult/service-maker/contents/{+path}","compare_url":"https://api.github.com/repos/inetCatapult/service-maker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/inetCatapult/service-maker/merges","archive_url":"https://api.github.com/repos/inetCatapult/service-maker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/inetCatapult/service-maker/downloads","issues_url":"https://api.github.com/repos/inetCatapult/service-maker/issues{/number}","pulls_url":"https://api.github.com/repos/inetCatapult/service-maker/pulls{/number}","milestones_url":"https://api.github.com/repos/inetCatapult/service-maker/milestones{/number}","notifications_url":"https://api.github.com/repos/inetCatapult/service-maker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/inetCatapult/service-maker/labels{/name}","releases_url":"https://api.github.com/repos/inetCatapult/service-maker/releases{/id}","created_at":"2015-01-23T11:57:25Z","updated_at":"2015-06-26T19:55:03Z","pushed_at":"2015-08-06T16:36:06Z","git_url":"git://github.com/inetCatapult/service-maker.git","ssh_url":"git@github.com:inetCatapult/service-maker.git","clone_url":"https://github.com/inetCatapult/service-maker.git","svn_url":"https://github.com/inetCatapult/service-maker","homepage":null,"size":800,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":10,"forks":2,"open_issues":10,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/inetCatapult/service-maker/pulls/98"},"html":{"href":"https://github.com/inetCatapult/service-maker/pull/98"},"issue":{"href":"https://api.github.com/repos/inetCatapult/service-maker/issues/98"},"comments":{"href":"https://api.github.com/repos/inetCatapult/service-maker/issues/98/comments"},"review_comments":{"href":"https://api.github.com/repos/inetCatapult/service-maker/pulls/98/comments"},"review_comment":{"href":"https://api.github.com/repos/inetCatapult/service-maker/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/inetCatapult/service-maker/pulls/98/commits"},"statuses":{"href":"https://api.github.com/repos/inetCatapult/service-maker/statuses/0f0dff6f53df068efd5f9ac17de1c6cbe47bc7ee"}}}}