{"action":"created","comment":{"url":"https://api.github.com/repos/wso2-dev/product-mb/pulls/comments/22854870","id":22854870,"diff_hunk":"@@ -0,0 +1,449 @@\n+/*\n+ * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.\n+ *\n+ * WSO2 Inc. licenses this file to you under the Apache License,\n+ * Version 2.0 (the \"License\"); you may not use this file except\n+ * 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,\n+ * software distributed under the License is distributed on an\n+ * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n+ * KIND, either express or implied.  See the License for the\n+ * specific language governing permissions and limitations\n+ * under the License.\n+ */\n+\n+package org.wso2.mb.platform.tests.clustering.topic;\n+\n+import org.testng.annotations.AfterClass;\n+import org.testng.annotations.BeforeClass;\n+import org.testng.annotations.Test;\n+import org.wso2.carbon.automation.engine.context.AutomationContext;\n+import org.wso2.carbon.automation.engine.context.TestUserMode;\n+import org.wso2.carbon.automation.test.utils.axis2client.ConfigurationContextProvider;\n+import org.wso2.carbon.event.stub.internal.xsd.TopicNode;\n+import org.wso2.mb.integration.common.clients.AndesClient;\n+import org.wso2.mb.integration.common.clients.operations.topic.TopicAdminClient;\n+import org.wso2.mb.integration.common.clients.operations.utils.AndesClientUtils;\n+import org.wso2.mb.platform.common.utils.MBPlatformBaseTest;\n+\n+import static org.testng.Assert.assertEquals;\n+import static org.testng.Assert.assertTrue;\n+\n+/**\n+ * This class includes tests subscribers/publishers with different rates for topics\n+ */\n+public class SingleSubscriberSinglePublisherTopicTestCase extends MBPlatformBaseTest {\n+\n+    private AutomationContext automationContext1;\n+    private AutomationContext automationContext2;\n+    private TopicAdminClient topicAdminClient1;\n+\n+    /**\n+     * Prepare environment for tests.\n+     *\n+     * @throws Exception\n+     */\n+    @BeforeClass(alwaysRun = true)\n+    public void init() throws Exception {\n+        super.initCluster(TestUserMode.SUPER_TENANT_ADMIN);\n+\n+        automationContext1 = getAutomationContextWithKey(\"mb002\");\n+        automationContext2 = getAutomationContextWithKey(\"mb003\");\n+\n+        topicAdminClient1 = new TopicAdminClient(automationContext1.getContextUrls().getBackEndUrl(),\n+                super.login(automationContext1), ConfigurationContextProvider.getInstance().getConfigurationContext());\n+\n+    }\n+\n+    /**\n+     * Publish message to a topic in a single node and receive from the same node\n+     *\n+     * @throws Exception\n+     */\n+    @Test(groups = \"wso2.mb\", description = \"Same node publisher subscriber test case\")\n+    public void testSameNodePubSub() throws Exception {\n+        // Max number of seconds to run the client\n+        Integer runTime = 80;\n+        // Expected message count\n+        Integer expectedCount = 2000;\n+        // Number of messages send\n+        Integer sendCount = 2000;\n+\n+        String hostinfo = automationContext1.getInstance().getHosts().get(\"default\") + \":\" +\n+                automationContext1.getInstance().getPorts().get(\"amqp\");\n+\n+        AndesClient receivingClient = new AndesClient(\"receive\", hostinfo\n+                , \"topic:singleTopic1\",\n+                \"100\", \"false\", runTime.toString(), expectedCount.toString(),\n+                \"1\", \"listener=true,ackMode=1,delayBetweenMsg=0,stopAfter=\" + expectedCount, \"\");\n+\n+        receivingClient.startWorking();\n+\n+        TopicNode topic = topicAdminClient1.getTopicByName(\"singleTopic1\");\n+\n+        assertTrue(topic.getTopicName().equalsIgnoreCase(\"singleTopic1\"), \"Topic created in MB node 1 not exist\");\n+\n+        AndesClient sendingClient = new AndesClient(\"send\", hostinfo\n+                , \"topic:singleTopic1\", \"100\", \"false\",\n+                runTime.toString(), sendCount.toString(), \"1\",\n+                \"ackMode=1,delayBetweenMsg=0,stopAfter=\" + sendCount, \"\");\n+\n+        sendingClient.startWorking();\n+\n+        boolean receiveSuccess = AndesClientUtils.waitUntilMessagesAreReceived(receivingClient, expectedCount, runTime);\n+\n+        boolean sendSuccess = AndesClientUtils.getIfSenderIsSuccess(sendingClient, sendCount);\n+\n+        assertEquals((receiveSuccess && sendSuccess), true);\n+    }\n+\n+    /**\n+     * Publish message to a topic in a node and receive from the same node at a slow rate.\n+     *\n+     * @throws Exception\n+     */\n+    @Test(groups = \"wso2.mb\", description = \"Same node publisher, slow subscriber test case\")\n+    public void testSameNodeSlowSubscriber() throws Exception {\n+        // Max number of seconds to run the client\n+        Integer runTime = 80;\n+        // Expected message count\n+        Integer expectedCount = 2000;\n+        // Number of messages send\n+        Integer sendCount = 2000;\n+\n+        String hostinfo = automationContext1.getInstance().getHosts().get(\"default\") + \":\" +\n+                automationContext1.getInstance().getPorts().get(\"amqp\");\n+\n+        AndesClient receivingClient = new AndesClient(\"receive\", hostinfo\n+                , \"topic:singleTopic2\",\n+                \"100\", \"false\", runTime.toString(), expectedCount.toString(),\n+                \"1\", \"listener=true,ackMode=1,delayBetweenMsg=10,stopAfter=\" + expectedCount, \"\");\n+\n+        receivingClient.startWorking();\n+\n+        TopicNode topic = topicAdminClient1.getTopicByName(\"singleTopic2\");\n+\n+        assertTrue(topic.getTopicName().equalsIgnoreCase(\"singleTopic2\"),\n+                \"Topic created in MB node 1 not exist\");\n+\n+        AndesClient sendingClient = new AndesClient(\"send\", hostinfo\n+                , \"topic:singleTopic2\", \"100\", \"false\",\n+                runTime.toString(), sendCount.toString(), \"1\",\n+                \"ackMode=1,delayBetweenMsg=0,stopAfter=\" + sendCount, \"\");\n+\n+        sendingClient.startWorking();\n+\n+        boolean receiveSuccess = AndesClientUtils.waitUntilMessagesAreReceived(receivingClient, expectedCount, runTime);\n+\n+        boolean sendSuccess = AndesClientUtils.getIfSenderIsSuccess(sendingClient, sendCount);\n+\n+        assertEquals((receiveSuccess && sendSuccess), true);","path":"modules/integration/tests-platform/tests-clustering/src/test/java/org/wso2/mb/platform/tests/clustering/topic/SingleSubscriberSinglePublisherTopicTestCase.java","position":144,"original_position":144,"commit_id":"9f53f676ec254270c7bed70eea8b7df45ae718f3","original_commit_id":"9f53f676ec254270c7bed70eea8b7df45ae718f3","user":{"login":"sajinidesilva","id":1833441,"avatar_url":"https://avatars.githubusercontent.com/u/1833441?v=3","gravatar_id":"","url":"https://api.github.com/users/sajinidesilva","html_url":"https://github.com/sajinidesilva","followers_url":"https://api.github.com/users/sajinidesilva/followers","following_url":"https://api.github.com/users/sajinidesilva/following{/other_user}","gists_url":"https://api.github.com/users/sajinidesilva/gists{/gist_id}","starred_url":"https://api.github.com/users/sajinidesilva/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sajinidesilva/subscriptions","organizations_url":"https://api.github.com/users/sajinidesilva/orgs","repos_url":"https://api.github.com/users/sajinidesilva/repos","events_url":"https://api.github.com/users/sajinidesilva/events{/privacy}","received_events_url":"https://api.github.com/users/sajinidesilva/received_events","type":"User","site_admin":false},"body":"Corrected with pull request https://github.com/wso2-dev/product-mb/pull/122","created_at":"2015-01-13T10:52:14Z","updated_at":"2015-01-13T10:52:14Z","html_url":"https://github.com/wso2-dev/product-mb/pull/117#discussion_r22854870","pull_request_url":"https://api.github.com/repos/wso2-dev/product-mb/pulls/117","_links":{"self":{"href":"https://api.github.com/repos/wso2-dev/product-mb/pulls/comments/22854870"},"html":{"href":"https://github.com/wso2-dev/product-mb/pull/117#discussion_r22854870"},"pull_request":{"href":"https://api.github.com/repos/wso2-dev/product-mb/pulls/117"}}},"pull_request":{"url":"https://api.github.com/repos/wso2-dev/product-mb/pulls/117","id":27179384,"html_url":"https://github.com/wso2-dev/product-mb/pull/117","diff_url":"https://github.com/wso2-dev/product-mb/pull/117.diff","patch_url":"https://github.com/wso2-dev/product-mb/pull/117.patch","issue_url":"https://api.github.com/repos/wso2-dev/product-mb/issues/117","number":117,"state":"closed","locked":false,"title":"Test cases added for cluster mode topic - single topic scenarios","user":{"login":"sajinidesilva","id":1833441,"avatar_url":"https://avatars.githubusercontent.com/u/1833441?v=3","gravatar_id":"","url":"https://api.github.com/users/sajinidesilva","html_url":"https://github.com/sajinidesilva","followers_url":"https://api.github.com/users/sajinidesilva/followers","following_url":"https://api.github.com/users/sajinidesilva/following{/other_user}","gists_url":"https://api.github.com/users/sajinidesilva/gists{/gist_id}","starred_url":"https://api.github.com/users/sajinidesilva/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sajinidesilva/subscriptions","organizations_url":"https://api.github.com/users/sajinidesilva/orgs","repos_url":"https://api.github.com/users/sajinidesilva/repos","events_url":"https://api.github.com/users/sajinidesilva/events{/privacy}","received_events_url":"https://api.github.com/users/sajinidesilva/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-01-12T08:12:51Z","updated_at":"2015-01-13T10:52:14Z","closed_at":"2015-01-12T08:13:12Z","merged_at":"2015-01-12T08:13:12Z","merge_commit_sha":"f2a7671896cb0155155fafb869a386761d1bbecb","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/wso2-dev/product-mb/pulls/117/commits","review_comments_url":"https://api.github.com/repos/wso2-dev/product-mb/pulls/117/comments","review_comment_url":"https://api.github.com/repos/wso2-dev/product-mb/pulls/comments/{number}","comments_url":"https://api.github.com/repos/wso2-dev/product-mb/issues/117/comments","statuses_url":"https://api.github.com/repos/wso2-dev/product-mb/statuses/9f53f676ec254270c7bed70eea8b7df45ae718f3","head":{"label":"sajinidesilva:topicTestCases","ref":"topicTestCases","sha":"9f53f676ec254270c7bed70eea8b7df45ae718f3","user":{"login":"sajinidesilva","id":1833441,"avatar_url":"https://avatars.githubusercontent.com/u/1833441?v=3","gravatar_id":"","url":"https://api.github.com/users/sajinidesilva","html_url":"https://github.com/sajinidesilva","followers_url":"https://api.github.com/users/sajinidesilva/followers","following_url":"https://api.github.com/users/sajinidesilva/following{/other_user}","gists_url":"https://api.github.com/users/sajinidesilva/gists{/gist_id}","starred_url":"https://api.github.com/users/sajinidesilva/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sajinidesilva/subscriptions","organizations_url":"https://api.github.com/users/sajinidesilva/orgs","repos_url":"https://api.github.com/users/sajinidesilva/repos","events_url":"https://api.github.com/users/sajinidesilva/events{/privacy}","received_events_url":"https://api.github.com/users/sajinidesilva/received_events","type":"User","site_admin":false},"repo":{"id":21540366,"name":"product-mb","full_name":"sajinidesilva/product-mb","owner":{"login":"sajinidesilva","id":1833441,"avatar_url":"https://avatars.githubusercontent.com/u/1833441?v=3","gravatar_id":"","url":"https://api.github.com/users/sajinidesilva","html_url":"https://github.com/sajinidesilva","followers_url":"https://api.github.com/users/sajinidesilva/followers","following_url":"https://api.github.com/users/sajinidesilva/following{/other_user}","gists_url":"https://api.github.com/users/sajinidesilva/gists{/gist_id}","starred_url":"https://api.github.com/users/sajinidesilva/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sajinidesilva/subscriptions","organizations_url":"https://api.github.com/users/sajinidesilva/orgs","repos_url":"https://api.github.com/users/sajinidesilva/repos","events_url":"https://api.github.com/users/sajinidesilva/events{/privacy}","received_events_url":"https://api.github.com/users/sajinidesilva/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sajinidesilva/product-mb","description":"","fork":true,"url":"https://api.github.com/repos/sajinidesilva/product-mb","forks_url":"https://api.github.com/repos/sajinidesilva/product-mb/forks","keys_url":"https://api.github.com/repos/sajinidesilva/product-mb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sajinidesilva/product-mb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sajinidesilva/product-mb/teams","hooks_url":"https://api.github.com/repos/sajinidesilva/product-mb/hooks","issue_events_url":"https://api.github.com/repos/sajinidesilva/product-mb/issues/events{/number}","events_url":"https://api.github.com/repos/sajinidesilva/product-mb/events","assignees_url":"https://api.github.com/repos/sajinidesilva/product-mb/assignees{/user}","branches_url":"https://api.github.com/repos/sajinidesilva/product-mb/branches{/branch}","tags_url":"https://api.github.com/repos/sajinidesilva/product-mb/tags","blobs_url":"https://api.github.com/repos/sajinidesilva/product-mb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sajinidesilva/product-mb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sajinidesilva/product-mb/git/refs{/sha}","trees_url":"https://api.github.com/repos/sajinidesilva/product-mb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sajinidesilva/product-mb/statuses/{sha}","languages_url":"https://api.github.com/repos/sajinidesilva/product-mb/languages","stargazers_url":"https://api.github.com/repos/sajinidesilva/product-mb/stargazers","contributors_url":"https://api.github.com/repos/sajinidesilva/product-mb/contributors","subscribers_url":"https://api.github.com/repos/sajinidesilva/product-mb/subscribers","subscription_url":"https://api.github.com/repos/sajinidesilva/product-mb/subscription","commits_url":"https://api.github.com/repos/sajinidesilva/product-mb/commits{/sha}","git_commits_url":"https://api.github.com/repos/sajinidesilva/product-mb/git/commits{/sha}","comments_url":"https://api.github.com/repos/sajinidesilva/product-mb/comments{/number}","issue_comment_url":"https://api.github.com/repos/sajinidesilva/product-mb/issues/comments/{number}","contents_url":"https://api.github.com/repos/sajinidesilva/product-mb/contents/{+path}","compare_url":"https://api.github.com/repos/sajinidesilva/product-mb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sajinidesilva/product-mb/merges","archive_url":"https://api.github.com/repos/sajinidesilva/product-mb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sajinidesilva/product-mb/downloads","issues_url":"https://api.github.com/repos/sajinidesilva/product-mb/issues{/number}","pulls_url":"https://api.github.com/repos/sajinidesilva/product-mb/pulls{/number}","milestones_url":"https://api.github.com/repos/sajinidesilva/product-mb/milestones{/number}","notifications_url":"https://api.github.com/repos/sajinidesilva/product-mb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sajinidesilva/product-mb/labels{/name}","releases_url":"https://api.github.com/repos/sajinidesilva/product-mb/releases{/id}","created_at":"2014-07-06T13:17:59Z","updated_at":"2014-07-08T04:45:12Z","pushed_at":"2015-01-13T10:51:35Z","git_url":"git://github.com/sajinidesilva/product-mb.git","ssh_url":"git@github.com:sajinidesilva/product-mb.git","clone_url":"https://github.com/sajinidesilva/product-mb.git","svn_url":"https://github.com/sajinidesilva/product-mb","homepage":null,"size":4574,"stargazers_count":0,"watchers_count":0,"language":"Python","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":"wso2-dev:master","ref":"master","sha":"915ed884bff60b5ef0c18acf40cbb91ff69a4d79","user":{"login":"wso2-dev","id":6744733,"avatar_url":"https://avatars.githubusercontent.com/u/6744733?v=3","gravatar_id":"","url":"https://api.github.com/users/wso2-dev","html_url":"https://github.com/wso2-dev","followers_url":"https://api.github.com/users/wso2-dev/followers","following_url":"https://api.github.com/users/wso2-dev/following{/other_user}","gists_url":"https://api.github.com/users/wso2-dev/gists{/gist_id}","starred_url":"https://api.github.com/users/wso2-dev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wso2-dev/subscriptions","organizations_url":"https://api.github.com/users/wso2-dev/orgs","repos_url":"https://api.github.com/users/wso2-dev/repos","events_url":"https://api.github.com/users/wso2-dev/events{/privacy}","received_events_url":"https://api.github.com/users/wso2-dev/received_events","type":"Organization","site_admin":false},"repo":{"id":20559230,"name":"product-mb","full_name":"wso2-dev/product-mb","owner":{"login":"wso2-dev","id":6744733,"avatar_url":"https://avatars.githubusercontent.com/u/6744733?v=3","gravatar_id":"","url":"https://api.github.com/users/wso2-dev","html_url":"https://github.com/wso2-dev","followers_url":"https://api.github.com/users/wso2-dev/followers","following_url":"https://api.github.com/users/wso2-dev/following{/other_user}","gists_url":"https://api.github.com/users/wso2-dev/gists{/gist_id}","starred_url":"https://api.github.com/users/wso2-dev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wso2-dev/subscriptions","organizations_url":"https://api.github.com/users/wso2-dev/orgs","repos_url":"https://api.github.com/users/wso2-dev/repos","events_url":"https://api.github.com/users/wso2-dev/events{/privacy}","received_events_url":"https://api.github.com/users/wso2-dev/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/wso2-dev/product-mb","description":"","fork":true,"url":"https://api.github.com/repos/wso2-dev/product-mb","forks_url":"https://api.github.com/repos/wso2-dev/product-mb/forks","keys_url":"https://api.github.com/repos/wso2-dev/product-mb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wso2-dev/product-mb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wso2-dev/product-mb/teams","hooks_url":"https://api.github.com/repos/wso2-dev/product-mb/hooks","issue_events_url":"https://api.github.com/repos/wso2-dev/product-mb/issues/events{/number}","events_url":"https://api.github.com/repos/wso2-dev/product-mb/events","assignees_url":"https://api.github.com/repos/wso2-dev/product-mb/assignees{/user}","branches_url":"https://api.github.com/repos/wso2-dev/product-mb/branches{/branch}","tags_url":"https://api.github.com/repos/wso2-dev/product-mb/tags","blobs_url":"https://api.github.com/repos/wso2-dev/product-mb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wso2-dev/product-mb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wso2-dev/product-mb/git/refs{/sha}","trees_url":"https://api.github.com/repos/wso2-dev/product-mb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wso2-dev/product-mb/statuses/{sha}","languages_url":"https://api.github.com/repos/wso2-dev/product-mb/languages","stargazers_url":"https://api.github.com/repos/wso2-dev/product-mb/stargazers","contributors_url":"https://api.github.com/repos/wso2-dev/product-mb/contributors","subscribers_url":"https://api.github.com/repos/wso2-dev/product-mb/subscribers","subscription_url":"https://api.github.com/repos/wso2-dev/product-mb/subscription","commits_url":"https://api.github.com/repos/wso2-dev/product-mb/commits{/sha}","git_commits_url":"https://api.github.com/repos/wso2-dev/product-mb/git/commits{/sha}","comments_url":"https://api.github.com/repos/wso2-dev/product-mb/comments{/number}","issue_comment_url":"https://api.github.com/repos/wso2-dev/product-mb/issues/comments/{number}","contents_url":"https://api.github.com/repos/wso2-dev/product-mb/contents/{+path}","compare_url":"https://api.github.com/repos/wso2-dev/product-mb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wso2-dev/product-mb/merges","archive_url":"https://api.github.com/repos/wso2-dev/product-mb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wso2-dev/product-mb/downloads","issues_url":"https://api.github.com/repos/wso2-dev/product-mb/issues{/number}","pulls_url":"https://api.github.com/repos/wso2-dev/product-mb/pulls{/number}","milestones_url":"https://api.github.com/repos/wso2-dev/product-mb/milestones{/number}","notifications_url":"https://api.github.com/repos/wso2-dev/product-mb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wso2-dev/product-mb/labels{/name}","releases_url":"https://api.github.com/repos/wso2-dev/product-mb/releases{/id}","created_at":"2014-06-06T10:02:55Z","updated_at":"2015-01-13T10:51:30Z","pushed_at":"2015-01-13T10:51:30Z","git_url":"git://github.com/wso2-dev/product-mb.git","ssh_url":"git@github.com:wso2-dev/product-mb.git","clone_url":"https://github.com/wso2-dev/product-mb.git","svn_url":"https://github.com/wso2-dev/product-mb","homepage":null,"size":5198,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":19,"mirror_url":null,"open_issues_count":5,"forks":19,"open_issues":5,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/wso2-dev/product-mb/pulls/117"},"html":{"href":"https://github.com/wso2-dev/product-mb/pull/117"},"issue":{"href":"https://api.github.com/repos/wso2-dev/product-mb/issues/117"},"comments":{"href":"https://api.github.com/repos/wso2-dev/product-mb/issues/117/comments"},"review_comments":{"href":"https://api.github.com/repos/wso2-dev/product-mb/pulls/117/comments"},"review_comment":{"href":"https://api.github.com/repos/wso2-dev/product-mb/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/wso2-dev/product-mb/pulls/117/commits"},"statuses":{"href":"https://api.github.com/repos/wso2-dev/product-mb/statuses/9f53f676ec254270c7bed70eea8b7df45ae718f3"}}}}