{"action":"created","comment":{"url":"https://api.github.com/repos/C5T/Current/pulls/comments/62431397","id":62431397,"diff_hunk":"@@ -312,6 +318,144 @@ TEST(Karl, Deregister) {\n         EXPECT_EQ(\"is_prime\", per_ip_services[is_prime.ClaireCodename()].service);\n       }\n     }\n+    // The `generator` should be the only service registered.\n+    {\n+      unittest_karl_status_t status;\n+      ASSERT_NO_THROW(\n+          status = ParseJSON<unittest_karl_status_t>(\n+              HTTP(GET(Printf(\"http://localhost:%d?from=0&full&active_only\", FLAGS_karl_test_port))).body));\n+      EXPECT_EQ(1u, status.size());\n+      ASSERT_TRUE(status.count(\"127.0.0.1\")) << JSON(status);\n+      auto& per_ip_services = status[\"127.0.0.1\"].services;\n+      EXPECT_EQ(1u, per_ip_services.size());\n+      EXPECT_EQ(\"generator\", per_ip_services[generator.ClaireCodename()].service);\n+    }\n+  }\n+\n+  // All services should be deregistered at this moment.\n+  {\n+    unittest_karl_status_t status;\n+    ASSERT_NO_THROW(\n+        status = ParseJSON<unittest_karl_status_t>(\n+            HTTP(GET(Printf(\"http://localhost:%d?from=0&full&active_only\", FLAGS_karl_test_port))).body));\n+    EXPECT_EQ(0u, status.size()) << JSON(status);\n+  }\n+}\n+\n+TEST(Karl, DeregisterWithNginx) {\n+  current::time::ResetToZero();\n+\n+  // Run the test only if `karl_nginx_config_file` flag is set.\n+  if (FLAGS_karl_nginx_config_file.empty()) {\n+    return;\n+  }\n+\n+  const auto stream_file_remover = current::FileSystem::ScopedRmFile(FLAGS_karl_test_stream_persistence_file);\n+  const auto storage_file_remover = current::FileSystem::ScopedRmFile(FLAGS_karl_test_storage_persistence_file);\n+\n+  const current::karl::KarlNginxParameters nginx_parameters(FLAGS_karl_nginx_port,\n+                                                            FLAGS_karl_nginx_config_file);\n+  const std::string karl_nginx_base_url = \"http://localhost:\" + current::ToString(FLAGS_karl_nginx_port);\n+  const unittest_karl_t karl(FLAGS_karl_test_port,\n+                             FLAGS_karl_test_stream_persistence_file,\n+                             FLAGS_karl_test_storage_persistence_file,\n+                             \"/\",\n+                             karl_nginx_base_url,\n+                             nginx_parameters);\n+  const current::karl::Locator karl_locator(Printf(\"http://localhost:%d\", FLAGS_karl_test_port));\n+\n+  // No services registered.\n+  {\n+    unittest_karl_status_t status;\n+    ASSERT_NO_THROW(\n+        status = ParseJSON<unittest_karl_status_t>(\n+            HTTP(GET(Printf(\"http://localhost:%d?from=0&full&active_only\", FLAGS_karl_test_port))).body));\n+    EXPECT_EQ(0u, status.size());\n+  }\n+\n+  std::string generator_proxied_status_url;\n+  std::string is_prime_proxied_status_url;\n+  {\n+    const karl_unittest::ServiceGenerator generator(\n+        FLAGS_karl_generator_test_port, std::chrono::microseconds(1000), karl_locator);\n+    // The `generator` service is registered.\n+    {\n+      unittest_karl_status_t status;\n+      ASSERT_NO_THROW(\n+          status = ParseJSON<unittest_karl_status_t>(\n+              HTTP(GET(Printf(\"http://localhost:%d?from=0&full&active_only\", FLAGS_karl_test_port))).body));\n+      EXPECT_EQ(1u, status.size());","path":"Karl/test.cc","position":32,"original_position":92,"commit_id":"b5a83d6d28d36ff3d69366e49623d5f753ef98b0","original_commit_id":"b5a83d6d28d36ff3d69366e49623d5f753ef98b0","user":{"login":"mzhurovich","id":11226961,"avatar_url":"https://avatars.githubusercontent.com/u/11226961?v=3","gravatar_id":"","url":"https://api.github.com/users/mzhurovich","html_url":"https://github.com/mzhurovich","followers_url":"https://api.github.com/users/mzhurovich/followers","following_url":"https://api.github.com/users/mzhurovich/following{/other_user}","gists_url":"https://api.github.com/users/mzhurovich/gists{/gist_id}","starred_url":"https://api.github.com/users/mzhurovich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mzhurovich/subscriptions","organizations_url":"https://api.github.com/users/mzhurovich/orgs","repos_url":"https://api.github.com/users/mzhurovich/repos","events_url":"https://api.github.com/users/mzhurovich/events{/privacy}","received_events_url":"https://api.github.com/users/mzhurovich/received_events","type":"User","site_admin":false},"body":":+1: ","created_at":"2016-05-08T12:45:45Z","updated_at":"2016-05-08T12:45:45Z","html_url":"https://github.com/C5T/Current/pull/495#discussion_r62431397","pull_request_url":"https://api.github.com/repos/C5T/Current/pulls/495","_links":{"self":{"href":"https://api.github.com/repos/C5T/Current/pulls/comments/62431397"},"html":{"href":"https://github.com/C5T/Current/pull/495#discussion_r62431397"},"pull_request":{"href":"https://api.github.com/repos/C5T/Current/pulls/495"}}},"pull_request":{"url":"https://api.github.com/repos/C5T/Current/pulls/495","id":69266768,"html_url":"https://github.com/C5T/Current/pull/495","diff_url":"https://github.com/C5T/Current/pull/495.diff","patch_url":"https://github.com/C5T/Current/pull/495.patch","issue_url":"https://api.github.com/repos/C5T/Current/issues/495","number":495,"state":"open","locked":false,"title":"Karl + Nginx.","user":{"login":"mzhurovich","id":11226961,"avatar_url":"https://avatars.githubusercontent.com/u/11226961?v=3","gravatar_id":"","url":"https://api.github.com/users/mzhurovich","html_url":"https://github.com/mzhurovich","followers_url":"https://api.github.com/users/mzhurovich/followers","following_url":"https://api.github.com/users/mzhurovich/following{/other_user}","gists_url":"https://api.github.com/users/mzhurovich/gists{/gist_id}","starred_url":"https://api.github.com/users/mzhurovich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mzhurovich/subscriptions","organizations_url":"https://api.github.com/users/mzhurovich/orgs","repos_url":"https://api.github.com/users/mzhurovich/repos","events_url":"https://api.github.com/users/mzhurovich/events{/privacy}","received_events_url":"https://api.github.com/users/mzhurovich/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-05-08T11:31:53Z","updated_at":"2016-05-08T12:45:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"71eaf8e425685dbf6b7f99fc0bbdc54f2b2e2cc6","assignee":{"login":"dkorolev","id":2159447,"avatar_url":"https://avatars.githubusercontent.com/u/2159447?v=3","gravatar_id":"","url":"https://api.github.com/users/dkorolev","html_url":"https://github.com/dkorolev","followers_url":"https://api.github.com/users/dkorolev/followers","following_url":"https://api.github.com/users/dkorolev/following{/other_user}","gists_url":"https://api.github.com/users/dkorolev/gists{/gist_id}","starred_url":"https://api.github.com/users/dkorolev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dkorolev/subscriptions","organizations_url":"https://api.github.com/users/dkorolev/orgs","repos_url":"https://api.github.com/users/dkorolev/repos","events_url":"https://api.github.com/users/dkorolev/events{/privacy}","received_events_url":"https://api.github.com/users/dkorolev/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/C5T/Current/pulls/495/commits","review_comments_url":"https://api.github.com/repos/C5T/Current/pulls/495/comments","review_comment_url":"https://api.github.com/repos/C5T/Current/pulls/comments{/number}","comments_url":"https://api.github.com/repos/C5T/Current/issues/495/comments","statuses_url":"https://api.github.com/repos/C5T/Current/statuses/b5a83d6d28d36ff3d69366e49623d5f753ef98b0","head":{"label":"mzhurovich:karl","ref":"karl","sha":"b5a83d6d28d36ff3d69366e49623d5f753ef98b0","user":{"login":"mzhurovich","id":11226961,"avatar_url":"https://avatars.githubusercontent.com/u/11226961?v=3","gravatar_id":"","url":"https://api.github.com/users/mzhurovich","html_url":"https://github.com/mzhurovich","followers_url":"https://api.github.com/users/mzhurovich/followers","following_url":"https://api.github.com/users/mzhurovich/following{/other_user}","gists_url":"https://api.github.com/users/mzhurovich/gists{/gist_id}","starred_url":"https://api.github.com/users/mzhurovich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mzhurovich/subscriptions","organizations_url":"https://api.github.com/users/mzhurovich/orgs","repos_url":"https://api.github.com/users/mzhurovich/repos","events_url":"https://api.github.com/users/mzhurovich/events{/privacy}","received_events_url":"https://api.github.com/users/mzhurovich/received_events","type":"User","site_admin":false},"repo":{"id":31462826,"name":"Current","full_name":"mzhurovich/Current","owner":{"login":"mzhurovich","id":11226961,"avatar_url":"https://avatars.githubusercontent.com/u/11226961?v=3","gravatar_id":"","url":"https://api.github.com/users/mzhurovich","html_url":"https://github.com/mzhurovich","followers_url":"https://api.github.com/users/mzhurovich/followers","following_url":"https://api.github.com/users/mzhurovich/following{/other_user}","gists_url":"https://api.github.com/users/mzhurovich/gists{/gist_id}","starred_url":"https://api.github.com/users/mzhurovich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mzhurovich/subscriptions","organizations_url":"https://api.github.com/users/mzhurovich/orgs","repos_url":"https://api.github.com/users/mzhurovich/repos","events_url":"https://api.github.com/users/mzhurovich/events{/privacy}","received_events_url":"https://api.github.com/users/mzhurovich/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mzhurovich/Current","description":"Our own core pieces to reuse.","fork":true,"url":"https://api.github.com/repos/mzhurovich/Current","forks_url":"https://api.github.com/repos/mzhurovich/Current/forks","keys_url":"https://api.github.com/repos/mzhurovich/Current/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mzhurovich/Current/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mzhurovich/Current/teams","hooks_url":"https://api.github.com/repos/mzhurovich/Current/hooks","issue_events_url":"https://api.github.com/repos/mzhurovich/Current/issues/events{/number}","events_url":"https://api.github.com/repos/mzhurovich/Current/events","assignees_url":"https://api.github.com/repos/mzhurovich/Current/assignees{/user}","branches_url":"https://api.github.com/repos/mzhurovich/Current/branches{/branch}","tags_url":"https://api.github.com/repos/mzhurovich/Current/tags","blobs_url":"https://api.github.com/repos/mzhurovich/Current/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mzhurovich/Current/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mzhurovich/Current/git/refs{/sha}","trees_url":"https://api.github.com/repos/mzhurovich/Current/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mzhurovich/Current/statuses/{sha}","languages_url":"https://api.github.com/repos/mzhurovich/Current/languages","stargazers_url":"https://api.github.com/repos/mzhurovich/Current/stargazers","contributors_url":"https://api.github.com/repos/mzhurovich/Current/contributors","subscribers_url":"https://api.github.com/repos/mzhurovich/Current/subscribers","subscription_url":"https://api.github.com/repos/mzhurovich/Current/subscription","commits_url":"https://api.github.com/repos/mzhurovich/Current/commits{/sha}","git_commits_url":"https://api.github.com/repos/mzhurovich/Current/git/commits{/sha}","comments_url":"https://api.github.com/repos/mzhurovich/Current/comments{/number}","issue_comment_url":"https://api.github.com/repos/mzhurovich/Current/issues/comments{/number}","contents_url":"https://api.github.com/repos/mzhurovich/Current/contents/{+path}","compare_url":"https://api.github.com/repos/mzhurovich/Current/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mzhurovich/Current/merges","archive_url":"https://api.github.com/repos/mzhurovich/Current/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mzhurovich/Current/downloads","issues_url":"https://api.github.com/repos/mzhurovich/Current/issues{/number}","pulls_url":"https://api.github.com/repos/mzhurovich/Current/pulls{/number}","milestones_url":"https://api.github.com/repos/mzhurovich/Current/milestones{/number}","notifications_url":"https://api.github.com/repos/mzhurovich/Current/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mzhurovich/Current/labels{/name}","releases_url":"https://api.github.com/repos/mzhurovich/Current/releases{/id}","deployments_url":"https://api.github.com/repos/mzhurovich/Current/deployments","created_at":"2015-02-28T13:03:55Z","updated_at":"2016-01-23T14:57:37Z","pushed_at":"2016-05-08T11:30:37Z","git_url":"git://github.com/mzhurovich/Current.git","ssh_url":"git@github.com:mzhurovich/Current.git","clone_url":"https://github.com/mzhurovich/Current.git","svn_url":"https://github.com/mzhurovich/Current","homepage":null,"size":10907,"stargazers_count":0,"watchers_count":0,"language":"C++","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":"C5T:master","ref":"master","sha":"869df6a8a5c76999523a8bd7b9e06146896e3344","user":{"login":"C5T","id":12224789,"avatar_url":"https://avatars.githubusercontent.com/u/12224789?v=3","gravatar_id":"","url":"https://api.github.com/users/C5T","html_url":"https://github.com/C5T","followers_url":"https://api.github.com/users/C5T/followers","following_url":"https://api.github.com/users/C5T/following{/other_user}","gists_url":"https://api.github.com/users/C5T/gists{/gist_id}","starred_url":"https://api.github.com/users/C5T/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/C5T/subscriptions","organizations_url":"https://api.github.com/users/C5T/orgs","repos_url":"https://api.github.com/users/C5T/repos","events_url":"https://api.github.com/users/C5T/events{/privacy}","received_events_url":"https://api.github.com/users/C5T/received_events","type":"Organization","site_admin":false},"repo":{"id":27625425,"name":"Current","full_name":"C5T/Current","owner":{"login":"C5T","id":12224789,"avatar_url":"https://avatars.githubusercontent.com/u/12224789?v=3","gravatar_id":"","url":"https://api.github.com/users/C5T","html_url":"https://github.com/C5T","followers_url":"https://api.github.com/users/C5T/followers","following_url":"https://api.github.com/users/C5T/following{/other_user}","gists_url":"https://api.github.com/users/C5T/gists{/gist_id}","starred_url":"https://api.github.com/users/C5T/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/C5T/subscriptions","organizations_url":"https://api.github.com/users/C5T/orgs","repos_url":"https://api.github.com/users/C5T/repos","events_url":"https://api.github.com/users/C5T/events{/privacy}","received_events_url":"https://api.github.com/users/C5T/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/C5T/Current","description":"Data Infrastructure in a Box:","fork":false,"url":"https://api.github.com/repos/C5T/Current","forks_url":"https://api.github.com/repos/C5T/Current/forks","keys_url":"https://api.github.com/repos/C5T/Current/keys{/key_id}","collaborators_url":"https://api.github.com/repos/C5T/Current/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/C5T/Current/teams","hooks_url":"https://api.github.com/repos/C5T/Current/hooks","issue_events_url":"https://api.github.com/repos/C5T/Current/issues/events{/number}","events_url":"https://api.github.com/repos/C5T/Current/events","assignees_url":"https://api.github.com/repos/C5T/Current/assignees{/user}","branches_url":"https://api.github.com/repos/C5T/Current/branches{/branch}","tags_url":"https://api.github.com/repos/C5T/Current/tags","blobs_url":"https://api.github.com/repos/C5T/Current/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/C5T/Current/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/C5T/Current/git/refs{/sha}","trees_url":"https://api.github.com/repos/C5T/Current/git/trees{/sha}","statuses_url":"https://api.github.com/repos/C5T/Current/statuses/{sha}","languages_url":"https://api.github.com/repos/C5T/Current/languages","stargazers_url":"https://api.github.com/repos/C5T/Current/stargazers","contributors_url":"https://api.github.com/repos/C5T/Current/contributors","subscribers_url":"https://api.github.com/repos/C5T/Current/subscribers","subscription_url":"https://api.github.com/repos/C5T/Current/subscription","commits_url":"https://api.github.com/repos/C5T/Current/commits{/sha}","git_commits_url":"https://api.github.com/repos/C5T/Current/git/commits{/sha}","comments_url":"https://api.github.com/repos/C5T/Current/comments{/number}","issue_comment_url":"https://api.github.com/repos/C5T/Current/issues/comments{/number}","contents_url":"https://api.github.com/repos/C5T/Current/contents/{+path}","compare_url":"https://api.github.com/repos/C5T/Current/compare/{base}...{head}","merges_url":"https://api.github.com/repos/C5T/Current/merges","archive_url":"https://api.github.com/repos/C5T/Current/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/C5T/Current/downloads","issues_url":"https://api.github.com/repos/C5T/Current/issues{/number}","pulls_url":"https://api.github.com/repos/C5T/Current/pulls{/number}","milestones_url":"https://api.github.com/repos/C5T/Current/milestones{/number}","notifications_url":"https://api.github.com/repos/C5T/Current/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/C5T/Current/labels{/name}","releases_url":"https://api.github.com/repos/C5T/Current/releases{/id}","deployments_url":"https://api.github.com/repos/C5T/Current/deployments","created_at":"2014-12-06T06:52:23Z","updated_at":"2016-04-03T19:52:16Z","pushed_at":"2016-05-08T11:31:53Z","git_url":"git://github.com/C5T/Current.git","ssh_url":"git@github.com:C5T/Current.git","clone_url":"https://github.com/C5T/Current.git","svn_url":"https://github.com/C5T/Current","homepage":"https://j.mp/currentintelligence","size":10969,"stargazers_count":27,"watchers_count":27,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":11,"mirror_url":null,"open_issues_count":37,"forks":11,"open_issues":37,"watchers":27,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/C5T/Current/pulls/495"},"html":{"href":"https://github.com/C5T/Current/pull/495"},"issue":{"href":"https://api.github.com/repos/C5T/Current/issues/495"},"comments":{"href":"https://api.github.com/repos/C5T/Current/issues/495/comments"},"review_comments":{"href":"https://api.github.com/repos/C5T/Current/pulls/495/comments"},"review_comment":{"href":"https://api.github.com/repos/C5T/Current/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/C5T/Current/pulls/495/commits"},"statuses":{"href":"https://api.github.com/repos/C5T/Current/statuses/b5a83d6d28d36ff3d69366e49623d5f753ef98b0"}}}}