{"action":"created","comment":{"url":"https://api.github.com/repos/code-dot-org/code-dot-org/pulls/comments/39568307","id":39568307,"diff_hunk":"@@ -571,6 +572,114 @@ def test_parse_ids_from_query_string\n                  'Nonnumeric IDs should be ignored')\n   end\n \n+  def test_can_only_insert_known_node_types\n+    # Allow client nodes\n+    create_node(type: NODE_TYPES[:client])\n+    assert_equal(201, @net_sim_api.last_response.status)\n+\n+    # Allow router nodes\n+    create_node(type: NODE_TYPES[:router])\n+    assert_equal(201, @net_sim_api.last_response.status)\n+\n+    # Reject nodes with other \"types\"\n+    create_node(type: 'some_random_type')\n+    assert_equal(400, @net_sim_api.last_response.status)\n+\n+    # Reject nodes with no type\n+    create_node({})\n+    assert_equal(400, @net_sim_api.last_response.status)\n+  end\n+\n+  def test_limit_shard_routers_to_max_routers\n+    CDO.netsim_max_routers.times do\n+      create_node(type: NODE_TYPES[:router])\n+      assert_equal 201, @net_sim_api.last_response.status\n+    end\n+    assert_equal(CDO.netsim_max_routers,\n+                 read_records(TABLE_NAMES[:node]).count,\n+                 \"Didn't create #{CDO.netsim_max_routers} nodes\")\n+\n+    # We want the 21st node to fail\n+    create_node(type: NODE_TYPES[:router])\n+    assert_equal(400, @net_sim_api.last_response.status,\n+                 \"Went over router limit!\")\n+    assert_equal(CDO.netsim_max_routers,\n+                 read_records(TABLE_NAMES[:node]).count,\n+                 \"Went over router limit!\")\n+  end\n+\n+  def test_do_not_limit_shard_clients_to_max_routers\n+    CDO.netsim_max_routers.times do\n+      create_node(type: NODE_TYPES[:client])\n+      assert_equal 201, @net_sim_api.last_response.status\n+    end\n+    assert_equal(CDO.netsim_max_routers,\n+                 read_records(TABLE_NAMES[:node]).count,\n+                 \"Didn't create #{CDO.netsim_max_routers} nodes\")\n+\n+    # We want the 21st node to fail","path":"shared/test/test_net_sim_api.rb","position":205,"original_position":205,"commit_id":"ca37d79e4538a034e5c5f13eaaf212b278870229","original_commit_id":"ca37d79e4538a034e5c5f13eaaf212b278870229","user":{"login":"Hamms","id":244100,"avatar_url":"https://avatars.githubusercontent.com/u/244100?v=3","gravatar_id":"","url":"https://api.github.com/users/Hamms","html_url":"https://github.com/Hamms","followers_url":"https://api.github.com/users/Hamms/followers","following_url":"https://api.github.com/users/Hamms/following{/other_user}","gists_url":"https://api.github.com/users/Hamms/gists{/gist_id}","starred_url":"https://api.github.com/users/Hamms/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Hamms/subscriptions","organizations_url":"https://api.github.com/users/Hamms/orgs","repos_url":"https://api.github.com/users/Hamms/repos","events_url":"https://api.github.com/users/Hamms/events{/privacy}","received_events_url":"https://api.github.com/users/Hamms/received_events","type":"User","site_admin":false},"body":"nit: `s/fail/succeed`","created_at":"2015-09-15T21:31:42Z","updated_at":"2015-09-15T21:31:42Z","html_url":"https://github.com/code-dot-org/code-dot-org/pull/3991#discussion_r39568307","pull_request_url":"https://api.github.com/repos/code-dot-org/code-dot-org/pulls/3991","_links":{"self":{"href":"https://api.github.com/repos/code-dot-org/code-dot-org/pulls/comments/39568307"},"html":{"href":"https://github.com/code-dot-org/code-dot-org/pull/3991#discussion_r39568307"},"pull_request":{"href":"https://api.github.com/repos/code-dot-org/code-dot-org/pulls/3991"}}},"pull_request":{"url":"https://api.github.com/repos/code-dot-org/code-dot-org/pulls/3991","id":45100997,"html_url":"https://github.com/code-dot-org/code-dot-org/pull/3991","diff_url":"https://github.com/code-dot-org/code-dot-org/pull/3991.diff","patch_url":"https://github.com/code-dot-org/code-dot-org/pull/3991.patch","issue_url":"https://api.github.com/repos/code-dot-org/code-dot-org/issues/3991","number":3991,"state":"open","locked":false,"title":"NetSim: Limit router count","user":{"login":"islemaster","id":1615761,"avatar_url":"https://avatars.githubusercontent.com/u/1615761?v=3","gravatar_id":"","url":"https://api.github.com/users/islemaster","html_url":"https://github.com/islemaster","followers_url":"https://api.github.com/users/islemaster/followers","following_url":"https://api.github.com/users/islemaster/following{/other_user}","gists_url":"https://api.github.com/users/islemaster/gists{/gist_id}","starred_url":"https://api.github.com/users/islemaster/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/islemaster/subscriptions","organizations_url":"https://api.github.com/users/islemaster/orgs","repos_url":"https://api.github.com/users/islemaster/repos","events_url":"https://api.github.com/users/islemaster/events{/privacy}","received_events_url":"https://api.github.com/users/islemaster/received_events","type":"User","site_admin":false},"body":"Limit the number of routers that can be created in a class section.\r\n\r\nThe maximum number of routers that may be created is the minimum of:\r\n* A global router limit, currently 20, stored as `CDO.netsim_max_routers`\r\n* The maximum number of addressable routers for the level, if applicable.  The number of addressable routers is determined by the bit-width of the second-to-last part of the address format.\r\n\r\nSome examples:\r\n* In a level with address format \"4\" (a single, four-bit part e.g. \"0011\") there is no router addressing, so we use the global limit of 20 routers.\r\n* In a level with address format \"4.4\" (two four-bit parts e.g. \"0110 0011\") we can provide addresses for up to 16 routers.  Since this is lower than the global limit of 20, we allow up to 16 routers.\r\n* In a level with address format \"8.8.8.8\" we can address up to 256 routers.  Since this is higher than the global limit of 20, we allow up to 20 routers.\r\n\r\nWhen the limit is reached, the \"Add Router\" button is hidden from the lobby so that no more routers may be created via the client UI.\r\n\r\nThe server only does partial enforcement of this policy; it has limited knowledge of the level configuration so for now it simply enforces the global router limit of 20.\r\n\r\nFinishes [Pivotal #100996328](https://www.pivotaltracker.com/story/show/100996328).","created_at":"2015-09-15T20:54:27Z","updated_at":"2015-09-15T21:31:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"615275119d3a54e8dfc79b42f859a6199fb722d4","assignee":{"login":"Hamms","id":244100,"avatar_url":"https://avatars.githubusercontent.com/u/244100?v=3","gravatar_id":"","url":"https://api.github.com/users/Hamms","html_url":"https://github.com/Hamms","followers_url":"https://api.github.com/users/Hamms/followers","following_url":"https://api.github.com/users/Hamms/following{/other_user}","gists_url":"https://api.github.com/users/Hamms/gists{/gist_id}","starred_url":"https://api.github.com/users/Hamms/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Hamms/subscriptions","organizations_url":"https://api.github.com/users/Hamms/orgs","repos_url":"https://api.github.com/users/Hamms/repos","events_url":"https://api.github.com/users/Hamms/events{/privacy}","received_events_url":"https://api.github.com/users/Hamms/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/code-dot-org/code-dot-org/pulls/3991/commits","review_comments_url":"https://api.github.com/repos/code-dot-org/code-dot-org/pulls/3991/comments","review_comment_url":"https://api.github.com/repos/code-dot-org/code-dot-org/pulls/comments{/number}","comments_url":"https://api.github.com/repos/code-dot-org/code-dot-org/issues/3991/comments","statuses_url":"https://api.github.com/repos/code-dot-org/code-dot-org/statuses/ca37d79e4538a034e5c5f13eaaf212b278870229","head":{"label":"code-dot-org:netsim-limit-routers","ref":"netsim-limit-routers","sha":"ca37d79e4538a034e5c5f13eaaf212b278870229","user":{"login":"code-dot-org","id":5124627,"avatar_url":"https://avatars.githubusercontent.com/u/5124627?v=3","gravatar_id":"","url":"https://api.github.com/users/code-dot-org","html_url":"https://github.com/code-dot-org","followers_url":"https://api.github.com/users/code-dot-org/followers","following_url":"https://api.github.com/users/code-dot-org/following{/other_user}","gists_url":"https://api.github.com/users/code-dot-org/gists{/gist_id}","starred_url":"https://api.github.com/users/code-dot-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/code-dot-org/subscriptions","organizations_url":"https://api.github.com/users/code-dot-org/orgs","repos_url":"https://api.github.com/users/code-dot-org/repos","events_url":"https://api.github.com/users/code-dot-org/events{/privacy}","received_events_url":"https://api.github.com/users/code-dot-org/received_events","type":"Organization","site_admin":false},"repo":{"id":24250009,"name":"code-dot-org","full_name":"code-dot-org/code-dot-org","owner":{"login":"code-dot-org","id":5124627,"avatar_url":"https://avatars.githubusercontent.com/u/5124627?v=3","gravatar_id":"","url":"https://api.github.com/users/code-dot-org","html_url":"https://github.com/code-dot-org","followers_url":"https://api.github.com/users/code-dot-org/followers","following_url":"https://api.github.com/users/code-dot-org/following{/other_user}","gists_url":"https://api.github.com/users/code-dot-org/gists{/gist_id}","starred_url":"https://api.github.com/users/code-dot-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/code-dot-org/subscriptions","organizations_url":"https://api.github.com/users/code-dot-org/orgs","repos_url":"https://api.github.com/users/code-dot-org/repos","events_url":"https://api.github.com/users/code-dot-org/events{/privacy}","received_events_url":"https://api.github.com/users/code-dot-org/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/code-dot-org/code-dot-org","description":"The code powering code.org and studio.code.org","fork":false,"url":"https://api.github.com/repos/code-dot-org/code-dot-org","forks_url":"https://api.github.com/repos/code-dot-org/code-dot-org/forks","keys_url":"https://api.github.com/repos/code-dot-org/code-dot-org/keys{/key_id}","collaborators_url":"https://api.github.com/repos/code-dot-org/code-dot-org/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/code-dot-org/code-dot-org/teams","hooks_url":"https://api.github.com/repos/code-dot-org/code-dot-org/hooks","issue_events_url":"https://api.github.com/repos/code-dot-org/code-dot-org/issues/events{/number}","events_url":"https://api.github.com/repos/code-dot-org/code-dot-org/events","assignees_url":"https://api.github.com/repos/code-dot-org/code-dot-org/assignees{/user}","branches_url":"https://api.github.com/repos/code-dot-org/code-dot-org/branches{/branch}","tags_url":"https://api.github.com/repos/code-dot-org/code-dot-org/tags","blobs_url":"https://api.github.com/repos/code-dot-org/code-dot-org/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/code-dot-org/code-dot-org/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/code-dot-org/code-dot-org/git/refs{/sha}","trees_url":"https://api.github.com/repos/code-dot-org/code-dot-org/git/trees{/sha}","statuses_url":"https://api.github.com/repos/code-dot-org/code-dot-org/statuses/{sha}","languages_url":"https://api.github.com/repos/code-dot-org/code-dot-org/languages","stargazers_url":"https://api.github.com/repos/code-dot-org/code-dot-org/stargazers","contributors_url":"https://api.github.com/repos/code-dot-org/code-dot-org/contributors","subscribers_url":"https://api.github.com/repos/code-dot-org/code-dot-org/subscribers","subscription_url":"https://api.github.com/repos/code-dot-org/code-dot-org/subscription","commits_url":"https://api.github.com/repos/code-dot-org/code-dot-org/commits{/sha}","git_commits_url":"https://api.github.com/repos/code-dot-org/code-dot-org/git/commits{/sha}","comments_url":"https://api.github.com/repos/code-dot-org/code-dot-org/comments{/number}","issue_comment_url":"https://api.github.com/repos/code-dot-org/code-dot-org/issues/comments{/number}","contents_url":"https://api.github.com/repos/code-dot-org/code-dot-org/contents/{+path}","compare_url":"https://api.github.com/repos/code-dot-org/code-dot-org/compare/{base}...{head}","merges_url":"https://api.github.com/repos/code-dot-org/code-dot-org/merges","archive_url":"https://api.github.com/repos/code-dot-org/code-dot-org/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/code-dot-org/code-dot-org/downloads","issues_url":"https://api.github.com/repos/code-dot-org/code-dot-org/issues{/number}","pulls_url":"https://api.github.com/repos/code-dot-org/code-dot-org/pulls{/number}","milestones_url":"https://api.github.com/repos/code-dot-org/code-dot-org/milestones{/number}","notifications_url":"https://api.github.com/repos/code-dot-org/code-dot-org/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/code-dot-org/code-dot-org/labels{/name}","releases_url":"https://api.github.com/repos/code-dot-org/code-dot-org/releases{/id}","created_at":"2014-09-20T00:46:11Z","updated_at":"2015-09-15T17:23:30Z","pushed_at":"2015-09-15T21:31:22Z","git_url":"git://github.com/code-dot-org/code-dot-org.git","ssh_url":"git@github.com:code-dot-org/code-dot-org.git","clone_url":"https://github.com/code-dot-org/code-dot-org.git","svn_url":"https://github.com/code-dot-org/code-dot-org","homepage":"http://code.org","size":2621609,"stargazers_count":57,"watchers_count":57,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":38,"mirror_url":null,"open_issues_count":34,"forks":38,"open_issues":34,"watchers":57,"default_branch":"staging"}},"base":{"label":"code-dot-org:staging","ref":"staging","sha":"fbc0c71a2c6c6038b2276feb6d2bb7b21bfb5194","user":{"login":"code-dot-org","id":5124627,"avatar_url":"https://avatars.githubusercontent.com/u/5124627?v=3","gravatar_id":"","url":"https://api.github.com/users/code-dot-org","html_url":"https://github.com/code-dot-org","followers_url":"https://api.github.com/users/code-dot-org/followers","following_url":"https://api.github.com/users/code-dot-org/following{/other_user}","gists_url":"https://api.github.com/users/code-dot-org/gists{/gist_id}","starred_url":"https://api.github.com/users/code-dot-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/code-dot-org/subscriptions","organizations_url":"https://api.github.com/users/code-dot-org/orgs","repos_url":"https://api.github.com/users/code-dot-org/repos","events_url":"https://api.github.com/users/code-dot-org/events{/privacy}","received_events_url":"https://api.github.com/users/code-dot-org/received_events","type":"Organization","site_admin":false},"repo":{"id":24250009,"name":"code-dot-org","full_name":"code-dot-org/code-dot-org","owner":{"login":"code-dot-org","id":5124627,"avatar_url":"https://avatars.githubusercontent.com/u/5124627?v=3","gravatar_id":"","url":"https://api.github.com/users/code-dot-org","html_url":"https://github.com/code-dot-org","followers_url":"https://api.github.com/users/code-dot-org/followers","following_url":"https://api.github.com/users/code-dot-org/following{/other_user}","gists_url":"https://api.github.com/users/code-dot-org/gists{/gist_id}","starred_url":"https://api.github.com/users/code-dot-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/code-dot-org/subscriptions","organizations_url":"https://api.github.com/users/code-dot-org/orgs","repos_url":"https://api.github.com/users/code-dot-org/repos","events_url":"https://api.github.com/users/code-dot-org/events{/privacy}","received_events_url":"https://api.github.com/users/code-dot-org/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/code-dot-org/code-dot-org","description":"The code powering code.org and studio.code.org","fork":false,"url":"https://api.github.com/repos/code-dot-org/code-dot-org","forks_url":"https://api.github.com/repos/code-dot-org/code-dot-org/forks","keys_url":"https://api.github.com/repos/code-dot-org/code-dot-org/keys{/key_id}","collaborators_url":"https://api.github.com/repos/code-dot-org/code-dot-org/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/code-dot-org/code-dot-org/teams","hooks_url":"https://api.github.com/repos/code-dot-org/code-dot-org/hooks","issue_events_url":"https://api.github.com/repos/code-dot-org/code-dot-org/issues/events{/number}","events_url":"https://api.github.com/repos/code-dot-org/code-dot-org/events","assignees_url":"https://api.github.com/repos/code-dot-org/code-dot-org/assignees{/user}","branches_url":"https://api.github.com/repos/code-dot-org/code-dot-org/branches{/branch}","tags_url":"https://api.github.com/repos/code-dot-org/code-dot-org/tags","blobs_url":"https://api.github.com/repos/code-dot-org/code-dot-org/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/code-dot-org/code-dot-org/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/code-dot-org/code-dot-org/git/refs{/sha}","trees_url":"https://api.github.com/repos/code-dot-org/code-dot-org/git/trees{/sha}","statuses_url":"https://api.github.com/repos/code-dot-org/code-dot-org/statuses/{sha}","languages_url":"https://api.github.com/repos/code-dot-org/code-dot-org/languages","stargazers_url":"https://api.github.com/repos/code-dot-org/code-dot-org/stargazers","contributors_url":"https://api.github.com/repos/code-dot-org/code-dot-org/contributors","subscribers_url":"https://api.github.com/repos/code-dot-org/code-dot-org/subscribers","subscription_url":"https://api.github.com/repos/code-dot-org/code-dot-org/subscription","commits_url":"https://api.github.com/repos/code-dot-org/code-dot-org/commits{/sha}","git_commits_url":"https://api.github.com/repos/code-dot-org/code-dot-org/git/commits{/sha}","comments_url":"https://api.github.com/repos/code-dot-org/code-dot-org/comments{/number}","issue_comment_url":"https://api.github.com/repos/code-dot-org/code-dot-org/issues/comments{/number}","contents_url":"https://api.github.com/repos/code-dot-org/code-dot-org/contents/{+path}","compare_url":"https://api.github.com/repos/code-dot-org/code-dot-org/compare/{base}...{head}","merges_url":"https://api.github.com/repos/code-dot-org/code-dot-org/merges","archive_url":"https://api.github.com/repos/code-dot-org/code-dot-org/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/code-dot-org/code-dot-org/downloads","issues_url":"https://api.github.com/repos/code-dot-org/code-dot-org/issues{/number}","pulls_url":"https://api.github.com/repos/code-dot-org/code-dot-org/pulls{/number}","milestones_url":"https://api.github.com/repos/code-dot-org/code-dot-org/milestones{/number}","notifications_url":"https://api.github.com/repos/code-dot-org/code-dot-org/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/code-dot-org/code-dot-org/labels{/name}","releases_url":"https://api.github.com/repos/code-dot-org/code-dot-org/releases{/id}","created_at":"2014-09-20T00:46:11Z","updated_at":"2015-09-15T17:23:30Z","pushed_at":"2015-09-15T21:31:22Z","git_url":"git://github.com/code-dot-org/code-dot-org.git","ssh_url":"git@github.com:code-dot-org/code-dot-org.git","clone_url":"https://github.com/code-dot-org/code-dot-org.git","svn_url":"https://github.com/code-dot-org/code-dot-org","homepage":"http://code.org","size":2621609,"stargazers_count":57,"watchers_count":57,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":38,"mirror_url":null,"open_issues_count":34,"forks":38,"open_issues":34,"watchers":57,"default_branch":"staging"}},"_links":{"self":{"href":"https://api.github.com/repos/code-dot-org/code-dot-org/pulls/3991"},"html":{"href":"https://github.com/code-dot-org/code-dot-org/pull/3991"},"issue":{"href":"https://api.github.com/repos/code-dot-org/code-dot-org/issues/3991"},"comments":{"href":"https://api.github.com/repos/code-dot-org/code-dot-org/issues/3991/comments"},"review_comments":{"href":"https://api.github.com/repos/code-dot-org/code-dot-org/pulls/3991/comments"},"review_comment":{"href":"https://api.github.com/repos/code-dot-org/code-dot-org/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/code-dot-org/code-dot-org/pulls/3991/commits"},"statuses":{"href":"https://api.github.com/repos/code-dot-org/code-dot-org/statuses/ca37d79e4538a034e5c5f13eaaf212b278870229"}}}}