{"action":"created","comment":{"url":"https://api.github.com/repos/rackerlabs/blueflood/pulls/comments/33601451","id":33601451,"diff_hunk":"@@ -0,0 +1,159 @@\n+/*\n+ * Copyright 2013-2015 Rackspace\n+ *\n+ *    Licensed under the Apache License, Version 2.0 (the \"License\");\n+ *    you may not use this file except in compliance with the License.\n+ *    You may obtain a copy of the License at\n+ *\n+ *        http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ *    Unless required by applicable law or agreed to in writing, software\n+ *    distributed under the License is distributed on an \"AS IS\" BASIS,\n+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ *    See the License for the specific language governing permissions and\n+ *    limitations under the License.\n+ */\n+package com.rackspacecloud.blueflood.inputs.handlers;\n+\n+import com.github.tlrx.elasticsearch.test.EsSetup;\n+import com.rackspacecloud.blueflood.http.HttpClientVendor;\n+import com.rackspacecloud.blueflood.io.AstyanaxMetricsWriter;\n+import com.rackspacecloud.blueflood.io.EventElasticSearchIO;\n+import com.rackspacecloud.blueflood.io.EventsIO;\n+import com.rackspacecloud.blueflood.outputs.handlers.HttpMetricDataQueryServer;\n+import com.rackspacecloud.blueflood.service.*;\n+import com.rackspacecloud.blueflood.types.Event;\n+import org.apache.http.HttpEntity;\n+import org.apache.http.HttpResponse;\n+import org.apache.http.client.methods.HttpGet;\n+import org.apache.http.client.methods.HttpPost;\n+import org.apache.http.client.utils.URIBuilder;\n+import org.apache.http.entity.ContentType;\n+import org.apache.http.entity.StringEntity;\n+import org.apache.http.impl.client.DefaultHttpClient;\n+import org.apache.http.util.EntityUtils;\n+import org.codehaus.jackson.map.ObjectMapper;\n+import org.junit.AfterClass;\n+import org.junit.Assert;\n+import org.junit.BeforeClass;\n+import org.junit.Test;\n+\n+import java.net.URI;\n+import java.net.URISyntaxException;\n+import java.util.*;\n+\n+import static org.mockito.Mockito.spy;\n+\n+public class HttpAnnotationsEndToEndTest {\n+    private static HttpIngestionService httpIngestionService;\n+    private static HttpClientVendor vendor;\n+    private static DefaultHttpClient client;\n+    private static Collection<Integer> manageShards = new HashSet<Integer>();\n+    private static int httpPort;\n+    private static int queryPort;\n+    private static ScheduleContext context;\n+    private static EventsIO eventsSearchIO;\n+    private static HttpQueryService httpQueryService;\n+    private static  Map <String, String> parameterMap;\n+    private final String tenant_id = \"333333\";\n+    private static EsSetup esSetup;\n+    //A time stamp 2 days ago\n+    private final long baseMillis = Calendar.getInstance().getTimeInMillis() - 172800000;\n+\n+    @BeforeClass\n+    public static void setUp() throws Exception {\n+        System.setProperty(CoreConfig.EVENTS_MODULES.name(), \"com.rackspacecloud.blueflood.io.EventElasticSearchIO\");\n+        Configuration.getInstance().init();\n+        httpPort = Configuration.getInstance().getIntegerProperty(HttpConfig.HTTP_INGESTION_PORT);\n+        queryPort = Configuration.getInstance().getIntegerProperty(HttpConfig.HTTP_METRIC_DATA_QUERY_PORT);\n+        manageShards.add(1); manageShards.add(5); manageShards.add(6);\n+        context = spy(new ScheduleContext(System.currentTimeMillis(), manageShards));\n+\n+        esSetup = new EsSetup();\n+        esSetup.execute(EsSetup.deleteAll());\n+        esSetup.execute(EsSetup.createIndex(EventElasticSearchIO.EVENT_INDEX)\n+                .withSettings(EsSetup.fromClassPath(\"index_settings.json\"))\n+                .withMapping(\"metrics\", EsSetup.fromClassPath(\"events_mapping.json\")));\n+        eventsSearchIO = new EventElasticSearchIO(esSetup.client());\n+        HttpMetricsIngestionServer server = new HttpMetricsIngestionServer(context, new AstyanaxMetricsWriter());\n+        server.setHttpEventsIngestionHandler(new HttpEventsIngestionHandler(eventsSearchIO));\n+\n+        httpIngestionService = new HttpIngestionService();\n+        httpIngestionService.setMetricsIngestionServer(server);\n+        httpIngestionService.startService(context, new AstyanaxMetricsWriter());\n+\n+        httpQueryService = new HttpQueryService();\n+        HttpMetricDataQueryServer queryServer = new HttpMetricDataQueryServer();\n+        queryServer.setEventsIO(eventsSearchIO);\n+        httpQueryService.setServer(queryServer);\n+        httpQueryService.startService();\n+\n+        vendor = new HttpClientVendor();\n+        client = vendor.getClient();\n+    }\n+\n+    @Test\n+    public void testAnnotationsEndToEndHappyCase() throws Exception {\n+        final int batchSize = 1;\n+        String event = createTestEvent(batchSize);\n+        HttpResponse response = postEvent(event, tenant_id);\n+        Assert.assertEquals(200, response.getStatusLine().getStatusCode());\n+        Thread.sleep(1000);\n+\n+        parameterMap = new HashMap<String, String>();\n+        parameterMap.put(Event.fromParameterName, String.valueOf(baseMillis - 86400000));\n+        parameterMap.put(Event.untilParameterName, String.valueOf(baseMillis + (86400000*3)));\n+        HttpGet get = new HttpGet(getAnnotationsQueryURI());\n+        response = client.execute(get);\n+\n+        String responseString = EntityUtils.toString(response.getEntity());\n+        Assert.assertEquals(200, response.getStatusLine().getStatusCode());\n+        Assert.assertFalse(responseString.equals(\"[]\"));\n+        Assert.assertTrue(responseString.contains(\"deployment 0\"));\n+    }\n+\n+    @AfterClass","path":"blueflood-http/src/integration-test/java/com/rackspacecloud/blueflood/inputs/handlers/HttpAnnotationsEndToEndTest.java","position":115,"original_position":115,"commit_id":"645f3b09294877d09d903778172ea7c65933fda1","original_commit_id":"645f3b09294877d09d903778172ea7c65933fda1","user":{"login":"chinmay-gupte","id":4722931,"avatar_url":"https://avatars.githubusercontent.com/u/4722931?v=3","gravatar_id":"","url":"https://api.github.com/users/chinmay-gupte","html_url":"https://github.com/chinmay-gupte","followers_url":"https://api.github.com/users/chinmay-gupte/followers","following_url":"https://api.github.com/users/chinmay-gupte/following{/other_user}","gists_url":"https://api.github.com/users/chinmay-gupte/gists{/gist_id}","starred_url":"https://api.github.com/users/chinmay-gupte/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chinmay-gupte/subscriptions","organizations_url":"https://api.github.com/users/chinmay-gupte/orgs","repos_url":"https://api.github.com/users/chinmay-gupte/repos","events_url":"https://api.github.com/users/chinmay-gupte/events{/privacy}","received_events_url":"https://api.github.com/users/chinmay-gupte/received_events","type":"User","site_admin":false},"body":"NIT: I usually prefer the teardown method at the bottom of the class.","created_at":"2015-06-30T17:43:44Z","updated_at":"2015-06-30T17:43:44Z","html_url":"https://github.com/rackerlabs/blueflood/pull/491#discussion_r33601451","pull_request_url":"https://api.github.com/repos/rackerlabs/blueflood/pulls/491","_links":{"self":{"href":"https://api.github.com/repos/rackerlabs/blueflood/pulls/comments/33601451"},"html":{"href":"https://github.com/rackerlabs/blueflood/pull/491#discussion_r33601451"},"pull_request":{"href":"https://api.github.com/repos/rackerlabs/blueflood/pulls/491"}}},"pull_request":{"url":"https://api.github.com/repos/rackerlabs/blueflood/pulls/491","id":38812063,"html_url":"https://github.com/rackerlabs/blueflood/pull/491","diff_url":"https://github.com/rackerlabs/blueflood/pull/491.diff","patch_url":"https://github.com/rackerlabs/blueflood/pull/491.patch","issue_url":"https://api.github.com/repos/rackerlabs/blueflood/issues/491","number":491,"state":"open","locked":false,"title":"RFR: Annotations integration tests","user":{"login":"tilogaat","id":8238570,"avatar_url":"https://avatars.githubusercontent.com/u/8238570?v=3","gravatar_id":"","url":"https://api.github.com/users/tilogaat","html_url":"https://github.com/tilogaat","followers_url":"https://api.github.com/users/tilogaat/followers","following_url":"https://api.github.com/users/tilogaat/following{/other_user}","gists_url":"https://api.github.com/users/tilogaat/gists{/gist_id}","starred_url":"https://api.github.com/users/tilogaat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tilogaat/subscriptions","organizations_url":"https://api.github.com/users/tilogaat/orgs","repos_url":"https://api.github.com/users/tilogaat/repos","events_url":"https://api.github.com/users/tilogaat/events{/privacy}","received_events_url":"https://api.github.com/users/tilogaat/received_events","type":"User","site_admin":false},"body":"Continuation of PR #484 \r\n\r\nAdding a lot of integration tests for the annotations API. ","created_at":"2015-06-29T20:09:19Z","updated_at":"2015-06-30T17:43:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1e22776007c32971cc64f6594aaebc30b690b903","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/rackerlabs/blueflood/pulls/491/commits","review_comments_url":"https://api.github.com/repos/rackerlabs/blueflood/pulls/491/comments","review_comment_url":"https://api.github.com/repos/rackerlabs/blueflood/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rackerlabs/blueflood/issues/491/comments","statuses_url":"https://api.github.com/repos/rackerlabs/blueflood/statuses/645f3b09294877d09d903778172ea7c65933fda1","head":{"label":"tilogaat:annotations-integration-tests","ref":"annotations-integration-tests","sha":"645f3b09294877d09d903778172ea7c65933fda1","user":{"login":"tilogaat","id":8238570,"avatar_url":"https://avatars.githubusercontent.com/u/8238570?v=3","gravatar_id":"","url":"https://api.github.com/users/tilogaat","html_url":"https://github.com/tilogaat","followers_url":"https://api.github.com/users/tilogaat/followers","following_url":"https://api.github.com/users/tilogaat/following{/other_user}","gists_url":"https://api.github.com/users/tilogaat/gists{/gist_id}","starred_url":"https://api.github.com/users/tilogaat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tilogaat/subscriptions","organizations_url":"https://api.github.com/users/tilogaat/orgs","repos_url":"https://api.github.com/users/tilogaat/repos","events_url":"https://api.github.com/users/tilogaat/events{/privacy}","received_events_url":"https://api.github.com/users/tilogaat/received_events","type":"User","site_admin":false},"repo":{"id":22357256,"name":"blueflood","full_name":"tilogaat/blueflood","owner":{"login":"tilogaat","id":8238570,"avatar_url":"https://avatars.githubusercontent.com/u/8238570?v=3","gravatar_id":"","url":"https://api.github.com/users/tilogaat","html_url":"https://github.com/tilogaat","followers_url":"https://api.github.com/users/tilogaat/followers","following_url":"https://api.github.com/users/tilogaat/following{/other_user}","gists_url":"https://api.github.com/users/tilogaat/gists{/gist_id}","starred_url":"https://api.github.com/users/tilogaat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tilogaat/subscriptions","organizations_url":"https://api.github.com/users/tilogaat/orgs","repos_url":"https://api.github.com/users/tilogaat/repos","events_url":"https://api.github.com/users/tilogaat/events{/privacy}","received_events_url":"https://api.github.com/users/tilogaat/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tilogaat/blueflood","description":"A distributed system designed to ingest and process time series data","fork":true,"url":"https://api.github.com/repos/tilogaat/blueflood","forks_url":"https://api.github.com/repos/tilogaat/blueflood/forks","keys_url":"https://api.github.com/repos/tilogaat/blueflood/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tilogaat/blueflood/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tilogaat/blueflood/teams","hooks_url":"https://api.github.com/repos/tilogaat/blueflood/hooks","issue_events_url":"https://api.github.com/repos/tilogaat/blueflood/issues/events{/number}","events_url":"https://api.github.com/repos/tilogaat/blueflood/events","assignees_url":"https://api.github.com/repos/tilogaat/blueflood/assignees{/user}","branches_url":"https://api.github.com/repos/tilogaat/blueflood/branches{/branch}","tags_url":"https://api.github.com/repos/tilogaat/blueflood/tags","blobs_url":"https://api.github.com/repos/tilogaat/blueflood/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tilogaat/blueflood/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tilogaat/blueflood/git/refs{/sha}","trees_url":"https://api.github.com/repos/tilogaat/blueflood/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tilogaat/blueflood/statuses/{sha}","languages_url":"https://api.github.com/repos/tilogaat/blueflood/languages","stargazers_url":"https://api.github.com/repos/tilogaat/blueflood/stargazers","contributors_url":"https://api.github.com/repos/tilogaat/blueflood/contributors","subscribers_url":"https://api.github.com/repos/tilogaat/blueflood/subscribers","subscription_url":"https://api.github.com/repos/tilogaat/blueflood/subscription","commits_url":"https://api.github.com/repos/tilogaat/blueflood/commits{/sha}","git_commits_url":"https://api.github.com/repos/tilogaat/blueflood/git/commits{/sha}","comments_url":"https://api.github.com/repos/tilogaat/blueflood/comments{/number}","issue_comment_url":"https://api.github.com/repos/tilogaat/blueflood/issues/comments{/number}","contents_url":"https://api.github.com/repos/tilogaat/blueflood/contents/{+path}","compare_url":"https://api.github.com/repos/tilogaat/blueflood/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tilogaat/blueflood/merges","archive_url":"https://api.github.com/repos/tilogaat/blueflood/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tilogaat/blueflood/downloads","issues_url":"https://api.github.com/repos/tilogaat/blueflood/issues{/number}","pulls_url":"https://api.github.com/repos/tilogaat/blueflood/pulls{/number}","milestones_url":"https://api.github.com/repos/tilogaat/blueflood/milestones{/number}","notifications_url":"https://api.github.com/repos/tilogaat/blueflood/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tilogaat/blueflood/labels{/name}","releases_url":"https://api.github.com/repos/tilogaat/blueflood/releases{/id}","created_at":"2014-07-28T20:44:27Z","updated_at":"2014-07-28T21:21:07Z","pushed_at":"2015-06-29T22:37:50Z","git_url":"git://github.com/tilogaat/blueflood.git","ssh_url":"git@github.com:tilogaat/blueflood.git","clone_url":"https://github.com/tilogaat/blueflood.git","svn_url":"https://github.com/tilogaat/blueflood","homepage":"http://www.blueflood.io","size":5028,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"rackerlabs:annotations-feature","ref":"annotations-feature","sha":"a367585fde3fb20525a3615f8327708fe689b73a","user":{"login":"rackerlabs","id":84293,"avatar_url":"https://avatars.githubusercontent.com/u/84293?v=3","gravatar_id":"","url":"https://api.github.com/users/rackerlabs","html_url":"https://github.com/rackerlabs","followers_url":"https://api.github.com/users/rackerlabs/followers","following_url":"https://api.github.com/users/rackerlabs/following{/other_user}","gists_url":"https://api.github.com/users/rackerlabs/gists{/gist_id}","starred_url":"https://api.github.com/users/rackerlabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rackerlabs/subscriptions","organizations_url":"https://api.github.com/users/rackerlabs/orgs","repos_url":"https://api.github.com/users/rackerlabs/repos","events_url":"https://api.github.com/users/rackerlabs/events{/privacy}","received_events_url":"https://api.github.com/users/rackerlabs/received_events","type":"Organization","site_admin":false},"repo":{"id":10081109,"name":"blueflood","full_name":"rackerlabs/blueflood","owner":{"login":"rackerlabs","id":84293,"avatar_url":"https://avatars.githubusercontent.com/u/84293?v=3","gravatar_id":"","url":"https://api.github.com/users/rackerlabs","html_url":"https://github.com/rackerlabs","followers_url":"https://api.github.com/users/rackerlabs/followers","following_url":"https://api.github.com/users/rackerlabs/following{/other_user}","gists_url":"https://api.github.com/users/rackerlabs/gists{/gist_id}","starred_url":"https://api.github.com/users/rackerlabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rackerlabs/subscriptions","organizations_url":"https://api.github.com/users/rackerlabs/orgs","repos_url":"https://api.github.com/users/rackerlabs/repos","events_url":"https://api.github.com/users/rackerlabs/events{/privacy}","received_events_url":"https://api.github.com/users/rackerlabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rackerlabs/blueflood","description":"A distributed system designed to ingest and process time series data","fork":false,"url":"https://api.github.com/repos/rackerlabs/blueflood","forks_url":"https://api.github.com/repos/rackerlabs/blueflood/forks","keys_url":"https://api.github.com/repos/rackerlabs/blueflood/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rackerlabs/blueflood/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rackerlabs/blueflood/teams","hooks_url":"https://api.github.com/repos/rackerlabs/blueflood/hooks","issue_events_url":"https://api.github.com/repos/rackerlabs/blueflood/issues/events{/number}","events_url":"https://api.github.com/repos/rackerlabs/blueflood/events","assignees_url":"https://api.github.com/repos/rackerlabs/blueflood/assignees{/user}","branches_url":"https://api.github.com/repos/rackerlabs/blueflood/branches{/branch}","tags_url":"https://api.github.com/repos/rackerlabs/blueflood/tags","blobs_url":"https://api.github.com/repos/rackerlabs/blueflood/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rackerlabs/blueflood/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rackerlabs/blueflood/git/refs{/sha}","trees_url":"https://api.github.com/repos/rackerlabs/blueflood/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rackerlabs/blueflood/statuses/{sha}","languages_url":"https://api.github.com/repos/rackerlabs/blueflood/languages","stargazers_url":"https://api.github.com/repos/rackerlabs/blueflood/stargazers","contributors_url":"https://api.github.com/repos/rackerlabs/blueflood/contributors","subscribers_url":"https://api.github.com/repos/rackerlabs/blueflood/subscribers","subscription_url":"https://api.github.com/repos/rackerlabs/blueflood/subscription","commits_url":"https://api.github.com/repos/rackerlabs/blueflood/commits{/sha}","git_commits_url":"https://api.github.com/repos/rackerlabs/blueflood/git/commits{/sha}","comments_url":"https://api.github.com/repos/rackerlabs/blueflood/comments{/number}","issue_comment_url":"https://api.github.com/repos/rackerlabs/blueflood/issues/comments{/number}","contents_url":"https://api.github.com/repos/rackerlabs/blueflood/contents/{+path}","compare_url":"https://api.github.com/repos/rackerlabs/blueflood/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rackerlabs/blueflood/merges","archive_url":"https://api.github.com/repos/rackerlabs/blueflood/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rackerlabs/blueflood/downloads","issues_url":"https://api.github.com/repos/rackerlabs/blueflood/issues{/number}","pulls_url":"https://api.github.com/repos/rackerlabs/blueflood/pulls{/number}","milestones_url":"https://api.github.com/repos/rackerlabs/blueflood/milestones{/number}","notifications_url":"https://api.github.com/repos/rackerlabs/blueflood/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rackerlabs/blueflood/labels{/name}","releases_url":"https://api.github.com/repos/rackerlabs/blueflood/releases{/id}","created_at":"2013-05-15T14:50:39Z","updated_at":"2015-06-26T22:41:22Z","pushed_at":"2015-06-30T16:41:27Z","git_url":"git://github.com/rackerlabs/blueflood.git","ssh_url":"git@github.com:rackerlabs/blueflood.git","clone_url":"https://github.com/rackerlabs/blueflood.git","svn_url":"https://github.com/rackerlabs/blueflood","homepage":"http://www.blueflood.io","size":11202,"stargazers_count":331,"watchers_count":331,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":43,"mirror_url":null,"open_issues_count":31,"forks":43,"open_issues":31,"watchers":331,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rackerlabs/blueflood/pulls/491"},"html":{"href":"https://github.com/rackerlabs/blueflood/pull/491"},"issue":{"href":"https://api.github.com/repos/rackerlabs/blueflood/issues/491"},"comments":{"href":"https://api.github.com/repos/rackerlabs/blueflood/issues/491/comments"},"review_comments":{"href":"https://api.github.com/repos/rackerlabs/blueflood/pulls/491/comments"},"review_comment":{"href":"https://api.github.com/repos/rackerlabs/blueflood/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rackerlabs/blueflood/pulls/491/commits"},"statuses":{"href":"https://api.github.com/repos/rackerlabs/blueflood/statuses/645f3b09294877d09d903778172ea7c65933fda1"}}}}