{"action":"created","comment":{"url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/pulls/comments/67883854","id":67883854,"diff_hunk":"@@ -0,0 +1,92 @@\n+'use strict';\n+\n+var request = require('supertest');  \n+var expect = require('chai').expect;\n+var app = require('../../../app.js');\n+var logger = require('../../../lib/log/logger');\n+var fakePolicy = {\n+\t\"instance_min_count\" : 1,\n+\t\"instance_max_count\" : 5,\n+\t\"scaling_rules\" : [ {\n+\t\t\"metric_type\" : \"MemoryUsage\",\n+\t\t\"stat_window_secs\" : 300,\n+\t\t\"breach_duration_secs\" : 600,\n+\t\t\"threshold\" : 30,\n+\t\t\"operator\" : \"<\",\n+\t\t\"cool_down_secs\" : 300,\n+\t\t\"adjustment\" : \"-1%\"\n+\t}, {\n+\t\t\"metric_type\" : \"MemoryUsage\",\n+\t\t\"stat_window_secs\" : 300,\n+\t\t\"breach_duration_secs\" : 600,\n+\t\t\"threshold\" : 90,\n+\t\t\"operator\" : \">=\",\n+\t\t\"cool_down_secs\" : 300,\n+\t\t\"adjustment\" : \"+1\"\n+\t} ],\n+\t\"schedules\" : {\n+\t\t\"timezone\" : \"(GMT+08: 00)Asia/Shanghai\",\n+\t\t\"recurring_schedule\" : [ {\n+\t\t\t\"start_time\" : \"00: 00\",\n+\t\t\t\"end_time\" : \"08: 00\",\n+\t\t\t\"days_of_week\" : [ 1, 2, 3 ],\n+\t\t\t\"days_of_month\" : [ 1, 28 ],\n+\t\t\t\"instance_min_count\" : 2,\n+\t\t\t\"instance_max_count\" : 10\n+\t\t} ],\n+\t\t\"specific_date\" : [ {\n+\t\t\t\"start_date\" : \"2015-06-19\",\n+\t\t\t\"start_time\" : \"00: 00\",\n+\t\t\t\"end_date\" : \"2015-06-19\",\n+\t\t\t\"end_time\" : \"23: 59\",\n+\t\t\t\"instance_min_count\" : 15,\n+\t\t\t\"instance_max_count\" : 40\n+\t\t} ]\n+\t}\n+};\n+\n+describe('Routing Policy', function() {\n+  before(function() {\n+    this.models = require('../../../lib/models')();\n+    this.Policy = this.models.policy_json;\n+    this.Policy.sequelize.sync().then(function() {\n+      logger.info('creating the table structure');\n+    });\n+  });\n+  describe('Policy Creation', function() {\n+    it('should create a policy for app id 12345', function(done) {\n+      request(app)\n+      .put('/v1/apps/12345/policy')\n+      .send(fakePolicy)\n+      .end(function(error,result) {\n+        if (error) {\n+          expect(error).to.not.be.null;\n+          throw error;\n+        }\n+        expect(result.statusCode).to.equal(200);\n+        done();\n+      });\n+    \n+    });\n+\n+    it('should fail to create another policy for app id 12345', function(done) {\n+      request(app)\n+      .put('/v1/apps/12345/policy')\n+      .send(fakePolicy)\n+      .end(function(error,result) {\n+        if (error) {\n+          expect(error).to.not.be.null;\n+          throw error;\n+        }\n+        expect(result.statusCode).to.equal(400);","path":"api/test/unit/routes/policies.test.js","position":81,"original_position":81,"commit_id":"a8a1fb71c681ad64bc6c34bc53a52b708a4cf33f","original_commit_id":"a8a1fb71c681ad64bc6c34bc53a52b708a4cf33f","user":{"login":"fraenkel","id":929377,"avatar_url":"https://avatars.githubusercontent.com/u/929377?v=3","gravatar_id":"","url":"https://api.github.com/users/fraenkel","html_url":"https://github.com/fraenkel","followers_url":"https://api.github.com/users/fraenkel/followers","following_url":"https://api.github.com/users/fraenkel/following{/other_user}","gists_url":"https://api.github.com/users/fraenkel/gists{/gist_id}","starred_url":"https://api.github.com/users/fraenkel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fraenkel/subscriptions","organizations_url":"https://api.github.com/users/fraenkel/orgs","repos_url":"https://api.github.com/users/fraenkel/repos","events_url":"https://api.github.com/users/fraenkel/events{/privacy}","received_events_url":"https://api.github.com/users/fraenkel/received_events","type":"User","site_admin":false},"body":"See comment regarding body validation.","created_at":"2016-06-21T14:52:53Z","updated_at":"2016-06-21T14:52:53Z","html_url":"https://github.com/cloudfoundry-incubator/app-autoscaler/pull/37#discussion_r67883854","pull_request_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/pulls/37","_links":{"self":{"href":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/pulls/comments/67883854"},"html":{"href":"https://github.com/cloudfoundry-incubator/app-autoscaler/pull/37#discussion_r67883854"},"pull_request":{"href":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/pulls/37"}}},"pull_request":{"url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/pulls/37","id":73731892,"html_url":"https://github.com/cloudfoundry-incubator/app-autoscaler/pull/37","diff_url":"https://github.com/cloudfoundry-incubator/app-autoscaler/pull/37.diff","patch_url":"https://github.com/cloudfoundry-incubator/app-autoscaler/pull/37.patch","issue_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/issues/37","number":37,"state":"open","locked":false,"title":"Add api application to the autoscaler repo","user":{"login":"pradyutsarma","id":858802,"avatar_url":"https://avatars.githubusercontent.com/u/858802?v=3","gravatar_id":"","url":"https://api.github.com/users/pradyutsarma","html_url":"https://github.com/pradyutsarma","followers_url":"https://api.github.com/users/pradyutsarma/followers","following_url":"https://api.github.com/users/pradyutsarma/following{/other_user}","gists_url":"https://api.github.com/users/pradyutsarma/gists{/gist_id}","starred_url":"https://api.github.com/users/pradyutsarma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pradyutsarma/subscriptions","organizations_url":"https://api.github.com/users/pradyutsarma/orgs","repos_url":"https://api.github.com/users/pradyutsarma/repos","events_url":"https://api.github.com/users/pradyutsarma/events{/privacy}","received_events_url":"https://api.github.com/users/pradyutsarma/received_events","type":"User","site_admin":false},"body":"1. api application added to the autoscaler repo\r\n2. Added a manifest.yml to the repo to describe the deployment to cloudfoundry\r\n\r\nThe api application expects the DB_URI in the env (See manifest.yml) and not as a DB service instance. This enables the app to be deployed or used outside of CF (could be set via a bosh job tomorrow if and when we migrate to a bosh release) as long as the env variable is set.","created_at":"2016-06-14T12:37:41Z","updated_at":"2016-06-21T14:52:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3216d6576ccece0e94c3649ddd85070efe84bbc1","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/pulls/37/commits","review_comments_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/pulls/37/comments","review_comment_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/issues/37/comments","statuses_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/statuses/a8a1fb71c681ad64bc6c34bc53a52b708a4cf33f","head":{"label":"pradyutsarma:develop","ref":"develop","sha":"a8a1fb71c681ad64bc6c34bc53a52b708a4cf33f","user":{"login":"pradyutsarma","id":858802,"avatar_url":"https://avatars.githubusercontent.com/u/858802?v=3","gravatar_id":"","url":"https://api.github.com/users/pradyutsarma","html_url":"https://github.com/pradyutsarma","followers_url":"https://api.github.com/users/pradyutsarma/followers","following_url":"https://api.github.com/users/pradyutsarma/following{/other_user}","gists_url":"https://api.github.com/users/pradyutsarma/gists{/gist_id}","starred_url":"https://api.github.com/users/pradyutsarma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pradyutsarma/subscriptions","organizations_url":"https://api.github.com/users/pradyutsarma/orgs","repos_url":"https://api.github.com/users/pradyutsarma/repos","events_url":"https://api.github.com/users/pradyutsarma/events{/privacy}","received_events_url":"https://api.github.com/users/pradyutsarma/received_events","type":"User","site_admin":false},"repo":{"id":61120454,"name":"app-autoscaler","full_name":"pradyutsarma/app-autoscaler","owner":{"login":"pradyutsarma","id":858802,"avatar_url":"https://avatars.githubusercontent.com/u/858802?v=3","gravatar_id":"","url":"https://api.github.com/users/pradyutsarma","html_url":"https://github.com/pradyutsarma","followers_url":"https://api.github.com/users/pradyutsarma/followers","following_url":"https://api.github.com/users/pradyutsarma/following{/other_user}","gists_url":"https://api.github.com/users/pradyutsarma/gists{/gist_id}","starred_url":"https://api.github.com/users/pradyutsarma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pradyutsarma/subscriptions","organizations_url":"https://api.github.com/users/pradyutsarma/orgs","repos_url":"https://api.github.com/users/pradyutsarma/repos","events_url":"https://api.github.com/users/pradyutsarma/events{/privacy}","received_events_url":"https://api.github.com/users/pradyutsarma/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/pradyutsarma/app-autoscaler","description":"Auto Scaling for CF Applications","fork":true,"url":"https://api.github.com/repos/pradyutsarma/app-autoscaler","forks_url":"https://api.github.com/repos/pradyutsarma/app-autoscaler/forks","keys_url":"https://api.github.com/repos/pradyutsarma/app-autoscaler/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pradyutsarma/app-autoscaler/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pradyutsarma/app-autoscaler/teams","hooks_url":"https://api.github.com/repos/pradyutsarma/app-autoscaler/hooks","issue_events_url":"https://api.github.com/repos/pradyutsarma/app-autoscaler/issues/events{/number}","events_url":"https://api.github.com/repos/pradyutsarma/app-autoscaler/events","assignees_url":"https://api.github.com/repos/pradyutsarma/app-autoscaler/assignees{/user}","branches_url":"https://api.github.com/repos/pradyutsarma/app-autoscaler/branches{/branch}","tags_url":"https://api.github.com/repos/pradyutsarma/app-autoscaler/tags","blobs_url":"https://api.github.com/repos/pradyutsarma/app-autoscaler/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pradyutsarma/app-autoscaler/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pradyutsarma/app-autoscaler/git/refs{/sha}","trees_url":"https://api.github.com/repos/pradyutsarma/app-autoscaler/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pradyutsarma/app-autoscaler/statuses/{sha}","languages_url":"https://api.github.com/repos/pradyutsarma/app-autoscaler/languages","stargazers_url":"https://api.github.com/repos/pradyutsarma/app-autoscaler/stargazers","contributors_url":"https://api.github.com/repos/pradyutsarma/app-autoscaler/contributors","subscribers_url":"https://api.github.com/repos/pradyutsarma/app-autoscaler/subscribers","subscription_url":"https://api.github.com/repos/pradyutsarma/app-autoscaler/subscription","commits_url":"https://api.github.com/repos/pradyutsarma/app-autoscaler/commits{/sha}","git_commits_url":"https://api.github.com/repos/pradyutsarma/app-autoscaler/git/commits{/sha}","comments_url":"https://api.github.com/repos/pradyutsarma/app-autoscaler/comments{/number}","issue_comment_url":"https://api.github.com/repos/pradyutsarma/app-autoscaler/issues/comments{/number}","contents_url":"https://api.github.com/repos/pradyutsarma/app-autoscaler/contents/{+path}","compare_url":"https://api.github.com/repos/pradyutsarma/app-autoscaler/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pradyutsarma/app-autoscaler/merges","archive_url":"https://api.github.com/repos/pradyutsarma/app-autoscaler/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pradyutsarma/app-autoscaler/downloads","issues_url":"https://api.github.com/repos/pradyutsarma/app-autoscaler/issues{/number}","pulls_url":"https://api.github.com/repos/pradyutsarma/app-autoscaler/pulls{/number}","milestones_url":"https://api.github.com/repos/pradyutsarma/app-autoscaler/milestones{/number}","notifications_url":"https://api.github.com/repos/pradyutsarma/app-autoscaler/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pradyutsarma/app-autoscaler/labels{/name}","releases_url":"https://api.github.com/repos/pradyutsarma/app-autoscaler/releases{/id}","deployments_url":"https://api.github.com/repos/pradyutsarma/app-autoscaler/deployments","created_at":"2016-06-14T12:19:17Z","updated_at":"2016-06-14T12:19:18Z","pushed_at":"2016-06-21T10:44:34Z","git_url":"git://github.com/pradyutsarma/app-autoscaler.git","ssh_url":"git@github.com:pradyutsarma/app-autoscaler.git","clone_url":"https://github.com/pradyutsarma/app-autoscaler.git","svn_url":"https://github.com/pradyutsarma/app-autoscaler","homepage":"","size":759,"stargazers_count":0,"watchers_count":0,"language":"Java","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":"develop"}},"base":{"label":"cloudfoundry-incubator:develop","ref":"develop","sha":"bc5901a03ebad72c2caf96ba3342a81f3719250a","user":{"login":"cloudfoundry-incubator","id":5680605,"avatar_url":"https://avatars.githubusercontent.com/u/5680605?v=3","gravatar_id":"","url":"https://api.github.com/users/cloudfoundry-incubator","html_url":"https://github.com/cloudfoundry-incubator","followers_url":"https://api.github.com/users/cloudfoundry-incubator/followers","following_url":"https://api.github.com/users/cloudfoundry-incubator/following{/other_user}","gists_url":"https://api.github.com/users/cloudfoundry-incubator/gists{/gist_id}","starred_url":"https://api.github.com/users/cloudfoundry-incubator/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloudfoundry-incubator/subscriptions","organizations_url":"https://api.github.com/users/cloudfoundry-incubator/orgs","repos_url":"https://api.github.com/users/cloudfoundry-incubator/repos","events_url":"https://api.github.com/users/cloudfoundry-incubator/events{/privacy}","received_events_url":"https://api.github.com/users/cloudfoundry-incubator/received_events","type":"Organization","site_admin":false},"repo":{"id":55270767,"name":"app-autoscaler","full_name":"cloudfoundry-incubator/app-autoscaler","owner":{"login":"cloudfoundry-incubator","id":5680605,"avatar_url":"https://avatars.githubusercontent.com/u/5680605?v=3","gravatar_id":"","url":"https://api.github.com/users/cloudfoundry-incubator","html_url":"https://github.com/cloudfoundry-incubator","followers_url":"https://api.github.com/users/cloudfoundry-incubator/followers","following_url":"https://api.github.com/users/cloudfoundry-incubator/following{/other_user}","gists_url":"https://api.github.com/users/cloudfoundry-incubator/gists{/gist_id}","starred_url":"https://api.github.com/users/cloudfoundry-incubator/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloudfoundry-incubator/subscriptions","organizations_url":"https://api.github.com/users/cloudfoundry-incubator/orgs","repos_url":"https://api.github.com/users/cloudfoundry-incubator/repos","events_url":"https://api.github.com/users/cloudfoundry-incubator/events{/privacy}","received_events_url":"https://api.github.com/users/cloudfoundry-incubator/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cloudfoundry-incubator/app-autoscaler","description":"Auto Scaling for CF Applications","fork":false,"url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler","forks_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/forks","keys_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/teams","hooks_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/hooks","issue_events_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/issues/events{/number}","events_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/events","assignees_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/assignees{/user}","branches_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/branches{/branch}","tags_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/tags","blobs_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/git/refs{/sha}","trees_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/statuses/{sha}","languages_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/languages","stargazers_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/stargazers","contributors_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/contributors","subscribers_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/subscribers","subscription_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/subscription","commits_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/commits{/sha}","git_commits_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/git/commits{/sha}","comments_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/comments{/number}","issue_comment_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/issues/comments{/number}","contents_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/contents/{+path}","compare_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/merges","archive_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/downloads","issues_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/issues{/number}","pulls_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/pulls{/number}","milestones_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/milestones{/number}","notifications_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/labels{/name}","releases_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/releases{/id}","deployments_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/deployments","created_at":"2016-04-02T00:47:11Z","updated_at":"2016-06-13T18:26:54Z","pushed_at":"2016-06-21T13:26:02Z","git_url":"git://github.com/cloudfoundry-incubator/app-autoscaler.git","ssh_url":"git@github.com:cloudfoundry-incubator/app-autoscaler.git","clone_url":"https://github.com/cloudfoundry-incubator/app-autoscaler.git","svn_url":"https://github.com/cloudfoundry-incubator/app-autoscaler","homepage":"","size":1238,"stargazers_count":4,"watchers_count":4,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":7,"mirror_url":null,"open_issues_count":4,"forks":7,"open_issues":4,"watchers":4,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/pulls/37"},"html":{"href":"https://github.com/cloudfoundry-incubator/app-autoscaler/pull/37"},"issue":{"href":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/issues/37"},"comments":{"href":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/issues/37/comments"},"review_comments":{"href":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/pulls/37/comments"},"review_comment":{"href":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/pulls/37/commits"},"statuses":{"href":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/statuses/a8a1fb71c681ad64bc6c34bc53a52b708a4cf33f"}}}}
{"actor":{"display_login":"fraenkel"}}