{"action":"created","comment":{"url":"https://api.github.com/repos/edx/edx-load-tests/pulls/comments/43536123","id":43536123,"diff_hunk":"@@ -0,0 +1,424 @@\n+\"\"\"\n+This file holds the different tasks used for the Discussion API tests\n+\"\"\"\n+import random\n+\n+from locust import task\n+\n+from dapi import DiscussionsApiTasks\n+import dapi_constants\n+\n+\n+class GetThreadsTask(DiscussionsApiTasks):\n+    \"\"\"\n+    Task for GETting a single thread\n+    \"\"\"\n+    @task\n+    def get_thread(self):\n+        \"\"\"\n+        GET a thread\n+\n+        /api/discussion/v1/threads/{thread_id}\n+\n+        Calls made:\n+        GET_thread\n+        \"\"\"\n+        choice = random.choice(self.thread_id_list)\n+        url = \"/api/discussion/v1/threads/{}\".format(choice)\n+        self.client.get(url=url, verify=False, name=\"GET_thread\")\n+        self.wait_then_stop()\n+\n+\n+class GetThreadListTask(DiscussionsApiTasks):\n+\n+    @task\n+    def get_thread_list(self, return_id=False):\n+        \"\"\"\n+        GET a thread list\n+\n+        /api/discussion/v1/threads/?course_id={}...\n+\n+        Calls made:\n+        GET_thread_list\n+        \"\"\"\n+        self.get_random_thread(verbose=self.verbose)\n+        self.wait_then_stop()\n+\n+\n+class GetThreadWithCommentsTask(DiscussionsApiTasks):\n+    \"\"\"\n+    Task for GETting a thread list and reporting it's comment_count\n+    \"\"\"\n+    @task\n+    def get_thread_with_comments(self):\n+        \"\"\"\n+        GET a thread and then report it's comment_count\n+\n+        /api/discussion/v1/threads/?course_id={}...\n+\n+        Calls made:\n+        GET_thread_list\n+        GET_thread\n+        \"\"\"\n+        thread = self.get_random_thread(verbose=self.verbose, prioritize_comments=True)\n+        url = \"/api/discussion/v1/threads/{}\".format(thread[\"id\"])\n+        comment_count = thread[\"comment_count\"]\n+        rounded_count = int(round(comment_count / 25) * 25)\n+        name = \"Comment_Range:{}-{}\".format(rounded_count, rounded_count + 25)\n+        self.client.get(url=url, verify=False, name=name)\n+        self.wait_then_stop()\n+\n+\n+class GetCommentsTask(DiscussionsApiTasks):\n+    \"\"\"\n+    Tasks for GETting comments\n+    \"\"\"\n+    @task\n+    def get_comment_list(self):\n+        \"\"\"\n+        GET the comment_list\n+\n+        /api/discussion/v1/comments/?thread_id={}...\n+\n+        Calls made:\n+        GET_thread_list\n+        GET_comment_list\n+        \"\"\"\n+        thread = self.get_random_thread(page=1, page_size=100, prioritize_comments=True)\n+        self.wait()\n+        self.get_random_comment(thread=thread, verbose=self.verbose)\n+        self.wait_then_stop()\n+\n+\n+class PatchThreadsTask(DiscussionsApiTasks):\n+    \"\"\"\n+    Task for PATCH requests for threads\n+\n+    /api/discussion/v1/threads/{thread_id}\n+\n+    EditThread uses the staff role to edit while student roles vote, flag,\n+    and follow.\n+    \"\"\"\n+    def _get_thread_id(self):\n+        thread = self.get_random_thread(self, page=1, page_size=100)\n+        self.wait()\n+        if not thread:\n+            self.stop()\n+        return thread[\"id\"]\n+\n+    @task(51)\n+    def patch_edit_thread(self):\n+        \"\"\"\n+        Edit a thread's raw_body\n+\n+        Calls made:\n+        GET_thread_list\n+        PATCH_thread\n+        \"\"\"\n+        new_body_size = random.choice(dapi_constants.BODY.keys())\n+        data = {\"raw_body\": dapi_constants.BODY[new_body_size]}\n+        name = \"edit_thread_with_{}\".format(new_body_size) if self.verbose else \"PATCH_thread\"\n+        thread_id = self._get_thread_id()\n+        self.patch_thread(\n+            thread_id=thread_id,\n+            data=data,\n+            name=name\n+        )\n+        self.wait_then_stop()\n+\n+    @task(3)\n+    def follow_thread(self):\n+        \"\"\"\n+        Follow a thread\n+\n+        Calls made:\n+        GET_thread_list\n+        PATCH_thread\n+        \"\"\"\n+        data = {\"following\": random.choice([\"true\", \"false\"])}\n+        name = \"following_thread\" if self.verbose else \"PATCH_thread\"\n+        thread_id = self._get_thread_id()\n+        self.edit_thread(\n+            thread_id=thread_id,\n+            data=data,\n+            name=name,\n+        )\n+        self.wait_then_stop()\n+\n+    @task(1)\n+    def abuse_flag_thread(self):\n+        \"\"\"\n+        Flag a thread with\n+\n+        Calls made:\n+        GET_thread_list\n+        PATCH_thread\n+        \"\"\"\n+        data = {\"abuse_flagged\": random.choice([\"true\", \"false\"])}","path":"discussions_api/tasks/dapi_tasks.py","position":157,"original_position":157,"commit_id":"86b4341b45b9653ee643f7af69a8fdcea55d6cb9","original_commit_id":"86b4341b45b9653ee643f7af69a8fdcea55d6cb9","user":{"login":"macdiesel","id":67862,"avatar_url":"https://avatars.githubusercontent.com/u/67862?v=3","gravatar_id":"","url":"https://api.github.com/users/macdiesel","html_url":"https://github.com/macdiesel","followers_url":"https://api.github.com/users/macdiesel/followers","following_url":"https://api.github.com/users/macdiesel/following{/other_user}","gists_url":"https://api.github.com/users/macdiesel/gists{/gist_id}","starred_url":"https://api.github.com/users/macdiesel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/macdiesel/subscriptions","organizations_url":"https://api.github.com/users/macdiesel/orgs","repos_url":"https://api.github.com/users/macdiesel/repos","events_url":"https://api.github.com/users/macdiesel/events{/privacy}","received_events_url":"https://api.github.com/users/macdiesel/received_events","type":"User","site_admin":false},"body":"The relative number of threads marked as abuse_flagged in the system are most likely very low. When this code is called it will start flagging ~50% of the threads as abuse_flagged. Could this have an effect on pagination/filtering and the number of threads returned for a user during the tests? I'm not sure this is really representative of the behavior of the users on the site.","created_at":"2015-10-30T18:25:06Z","updated_at":"2015-10-30T18:25:06Z","html_url":"https://github.com/edx/edx-load-tests/pull/27#discussion_r43536123","pull_request_url":"https://api.github.com/repos/edx/edx-load-tests/pulls/27","_links":{"self":{"href":"https://api.github.com/repos/edx/edx-load-tests/pulls/comments/43536123"},"html":{"href":"https://github.com/edx/edx-load-tests/pull/27#discussion_r43536123"},"pull_request":{"href":"https://api.github.com/repos/edx/edx-load-tests/pulls/27"}}},"pull_request":{"url":"https://api.github.com/repos/edx/edx-load-tests/pulls/27","id":48253364,"html_url":"https://github.com/edx/edx-load-tests/pull/27","diff_url":"https://github.com/edx/edx-load-tests/pull/27.diff","patch_url":"https://github.com/edx/edx-load-tests/pull/27.patch","issue_url":"https://api.github.com/repos/edx/edx-load-tests/issues/27","number":27,"state":"open","locked":false,"title":"Clee/dapi locust","user":{"login":"BenjiLee","id":7101723,"avatar_url":"https://avatars.githubusercontent.com/u/7101723?v=3","gravatar_id":"","url":"https://api.github.com/users/BenjiLee","html_url":"https://github.com/BenjiLee","followers_url":"https://api.github.com/users/BenjiLee/followers","following_url":"https://api.github.com/users/BenjiLee/following{/other_user}","gists_url":"https://api.github.com/users/BenjiLee/gists{/gist_id}","starred_url":"https://api.github.com/users/BenjiLee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BenjiLee/subscriptions","organizations_url":"https://api.github.com/users/BenjiLee/orgs","repos_url":"https://api.github.com/users/BenjiLee/repos","events_url":"https://api.github.com/users/BenjiLee/events{/privacy}","received_events_url":"https://api.github.com/users/BenjiLee/received_events","type":"User","site_admin":false},"body":"@benpatterson @macdiesel \r\n\r\nOptional: @jimabramson \r\n\r\nThis is a new loadtest for the new Discussions API.\r\n\r\nData seeding scripts were removed from this PR. \r\n\r\nFYI @nasthagiri ","created_at":"2015-10-20T20:29:37Z","updated_at":"2015-10-30T18:25:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9a86d29e2002445ddcfca021383d752a6eb04851","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/edx/edx-load-tests/pulls/27/commits","review_comments_url":"https://api.github.com/repos/edx/edx-load-tests/pulls/27/comments","review_comment_url":"https://api.github.com/repos/edx/edx-load-tests/pulls/comments{/number}","comments_url":"https://api.github.com/repos/edx/edx-load-tests/issues/27/comments","statuses_url":"https://api.github.com/repos/edx/edx-load-tests/statuses/86b4341b45b9653ee643f7af69a8fdcea55d6cb9","head":{"label":"edx:clee/dapi_locust","ref":"clee/dapi_locust","sha":"86b4341b45b9653ee643f7af69a8fdcea55d6cb9","user":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"repo":{"id":39958996,"name":"edx-load-tests","full_name":"edx/edx-load-tests","owner":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/edx/edx-load-tests","description":"Open source load tests for edX software components","fork":false,"url":"https://api.github.com/repos/edx/edx-load-tests","forks_url":"https://api.github.com/repos/edx/edx-load-tests/forks","keys_url":"https://api.github.com/repos/edx/edx-load-tests/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx/edx-load-tests/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx/edx-load-tests/teams","hooks_url":"https://api.github.com/repos/edx/edx-load-tests/hooks","issue_events_url":"https://api.github.com/repos/edx/edx-load-tests/issues/events{/number}","events_url":"https://api.github.com/repos/edx/edx-load-tests/events","assignees_url":"https://api.github.com/repos/edx/edx-load-tests/assignees{/user}","branches_url":"https://api.github.com/repos/edx/edx-load-tests/branches{/branch}","tags_url":"https://api.github.com/repos/edx/edx-load-tests/tags","blobs_url":"https://api.github.com/repos/edx/edx-load-tests/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx/edx-load-tests/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx/edx-load-tests/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx/edx-load-tests/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx/edx-load-tests/statuses/{sha}","languages_url":"https://api.github.com/repos/edx/edx-load-tests/languages","stargazers_url":"https://api.github.com/repos/edx/edx-load-tests/stargazers","contributors_url":"https://api.github.com/repos/edx/edx-load-tests/contributors","subscribers_url":"https://api.github.com/repos/edx/edx-load-tests/subscribers","subscription_url":"https://api.github.com/repos/edx/edx-load-tests/subscription","commits_url":"https://api.github.com/repos/edx/edx-load-tests/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx/edx-load-tests/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx/edx-load-tests/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx/edx-load-tests/issues/comments{/number}","contents_url":"https://api.github.com/repos/edx/edx-load-tests/contents/{+path}","compare_url":"https://api.github.com/repos/edx/edx-load-tests/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx/edx-load-tests/merges","archive_url":"https://api.github.com/repos/edx/edx-load-tests/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx/edx-load-tests/downloads","issues_url":"https://api.github.com/repos/edx/edx-load-tests/issues{/number}","pulls_url":"https://api.github.com/repos/edx/edx-load-tests/pulls{/number}","milestones_url":"https://api.github.com/repos/edx/edx-load-tests/milestones{/number}","notifications_url":"https://api.github.com/repos/edx/edx-load-tests/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx/edx-load-tests/labels{/name}","releases_url":"https://api.github.com/repos/edx/edx-load-tests/releases{/id}","created_at":"2015-07-30T15:52:54Z","updated_at":"2015-08-19T21:04:20Z","pushed_at":"2015-10-30T17:49:47Z","git_url":"git://github.com/edx/edx-load-tests.git","ssh_url":"git@github.com:edx/edx-load-tests.git","clone_url":"https://github.com/edx/edx-load-tests.git","svn_url":"https://github.com/edx/edx-load-tests","homepage":null,"size":874,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":2,"forks":2,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"edx:master","ref":"master","sha":"2a7855c102e5bc664c0d3fcb52ef87f0b3f8cc3a","user":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"repo":{"id":39958996,"name":"edx-load-tests","full_name":"edx/edx-load-tests","owner":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/edx/edx-load-tests","description":"Open source load tests for edX software components","fork":false,"url":"https://api.github.com/repos/edx/edx-load-tests","forks_url":"https://api.github.com/repos/edx/edx-load-tests/forks","keys_url":"https://api.github.com/repos/edx/edx-load-tests/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx/edx-load-tests/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx/edx-load-tests/teams","hooks_url":"https://api.github.com/repos/edx/edx-load-tests/hooks","issue_events_url":"https://api.github.com/repos/edx/edx-load-tests/issues/events{/number}","events_url":"https://api.github.com/repos/edx/edx-load-tests/events","assignees_url":"https://api.github.com/repos/edx/edx-load-tests/assignees{/user}","branches_url":"https://api.github.com/repos/edx/edx-load-tests/branches{/branch}","tags_url":"https://api.github.com/repos/edx/edx-load-tests/tags","blobs_url":"https://api.github.com/repos/edx/edx-load-tests/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx/edx-load-tests/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx/edx-load-tests/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx/edx-load-tests/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx/edx-load-tests/statuses/{sha}","languages_url":"https://api.github.com/repos/edx/edx-load-tests/languages","stargazers_url":"https://api.github.com/repos/edx/edx-load-tests/stargazers","contributors_url":"https://api.github.com/repos/edx/edx-load-tests/contributors","subscribers_url":"https://api.github.com/repos/edx/edx-load-tests/subscribers","subscription_url":"https://api.github.com/repos/edx/edx-load-tests/subscription","commits_url":"https://api.github.com/repos/edx/edx-load-tests/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx/edx-load-tests/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx/edx-load-tests/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx/edx-load-tests/issues/comments{/number}","contents_url":"https://api.github.com/repos/edx/edx-load-tests/contents/{+path}","compare_url":"https://api.github.com/repos/edx/edx-load-tests/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx/edx-load-tests/merges","archive_url":"https://api.github.com/repos/edx/edx-load-tests/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx/edx-load-tests/downloads","issues_url":"https://api.github.com/repos/edx/edx-load-tests/issues{/number}","pulls_url":"https://api.github.com/repos/edx/edx-load-tests/pulls{/number}","milestones_url":"https://api.github.com/repos/edx/edx-load-tests/milestones{/number}","notifications_url":"https://api.github.com/repos/edx/edx-load-tests/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx/edx-load-tests/labels{/name}","releases_url":"https://api.github.com/repos/edx/edx-load-tests/releases{/id}","created_at":"2015-07-30T15:52:54Z","updated_at":"2015-08-19T21:04:20Z","pushed_at":"2015-10-30T17:49:47Z","git_url":"git://github.com/edx/edx-load-tests.git","ssh_url":"git@github.com:edx/edx-load-tests.git","clone_url":"https://github.com/edx/edx-load-tests.git","svn_url":"https://github.com/edx/edx-load-tests","homepage":null,"size":874,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":2,"forks":2,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/edx/edx-load-tests/pulls/27"},"html":{"href":"https://github.com/edx/edx-load-tests/pull/27"},"issue":{"href":"https://api.github.com/repos/edx/edx-load-tests/issues/27"},"comments":{"href":"https://api.github.com/repos/edx/edx-load-tests/issues/27/comments"},"review_comments":{"href":"https://api.github.com/repos/edx/edx-load-tests/pulls/27/comments"},"review_comment":{"href":"https://api.github.com/repos/edx/edx-load-tests/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/edx/edx-load-tests/pulls/27/commits"},"statuses":{"href":"https://api.github.com/repos/edx/edx-load-tests/statuses/86b4341b45b9653ee643f7af69a8fdcea55d6cb9"}}}}