{"action":"created","comment":{"url":"https://api.github.com/repos/autotest/tp-qemu/pulls/comments/133127676","pull_request_review_id":56273010,"id":133127676,"diff_hunk":"@@ -1,94 +1,62 @@\n import time\n import logging\n \n-from autotest.client.shared import error\n-from autotest.client import utils\n-\n from virttest import utils_misc\n+from virttest import utils_test\n+from virttest import error_context\n \n from qemu.tests import drive_mirror\n \n \n class DriveMirrorStress(drive_mirror.DriveMirror):\n \n-    def __init__(self, test, params, env, tag):\n-        super(DriveMirrorStress, self).__init__(test, params, env, tag)\n-\n-    @error.context_aware\n-    def install_stress_app(self):\n-        params = self.parser_test_args()\n-        session = self.get_session()\n-        if session.cmd_status(params.get(\"app_check_cmd\", \"true\")) == 0:\n-            return True\n-        error.context(\"install stress app in guest\", logging.info)\n-        link = params.get(\"download_link\")\n-        md5sum = params.get(\"pkg_md5sum\")\n-        tmp_dir = params.get(\"tmp_dir\")\n-        install_cmd = params.get(\"install_cmd\")\n-        config_cmd = params.get(\"config_cmd\")\n-        logging.info(\"Fetch package: %s\" % link)\n-        pkg = utils.unmap_url_cache(self.test.tmpdir, link, md5sum)\n-        self.vm.copy_files_to(pkg, tmp_dir)\n-        logging.info(\"Install app: %s\" % install_cmd)\n-        s, o = session.cmd_status_output(install_cmd, timeout=300)\n-        if s != 0:\n-            raise error.TestError(\"Fail to install stress app(%s)\" % o)\n-        logging.info(\"Configure app: %s\" % config_cmd)\n-        s, o = session.cmd_status_output(config_cmd, timeout=300)\n-        if s != 0:\n-            raise error.TestError(\"Fail to conifg stress app(%s)\" % o)\n-\n-    @error.context_aware\n     def load_stress(self):\n         \"\"\"\n         load IO/CPU/Memory stress in guest;\n         \"\"\"\n-        params = self.parser_test_args()\n-        self.install_stress_app()\n-        cmd = params.get(\"start_cmd\")\n-        session = self.get_session()\n-        error.context(\"launch stress app in guest\", logging.info)\n-        session.sendline(cmd)\n-        logging.info(\"Start command: %s\" % cmd)\n-        running = utils_misc.wait_for(self.app_runing, timeout=150, step=5)\n-        if not running:\n-            raise error.TestFail(\"stress app isn't running\")\n+        error_context.context(\"launch stress app in guest\", logging.info)\n+        args = (self.test, self.params, self.env, self.params[\"stress_test\"])\n+        bg_test = utils_test.BackgroundTest(utils_test.run_virt_sub_test, args)\n+        bg_test.start()\n+        if not utils_misc.wait_for(bg_test.is_alive, first=10, step=3, timeout=100):\n+            self.test.fail(\"background test start failed\")\n+        if not utils_misc.wait_for(self.app_running, timeout=360, step=5):\n+            self.test.fail(\"stress app isn't running\")\n+        # sleep 10s to ensure heavyload.exe make guest under heayload really;\n+        time.sleep(10)\n         return None\n \n-    @error.context_aware\n     def unload_stress(self):\n         \"\"\"\n         stop stress app\n         \"\"\"\n         def _unload_stress():\n-            params = self.parser_test_args()\n             session = self.get_session()\n-            cmd = params.get(\"stop_cmd\")\n+            cmd = self.params.get(\"stop_cmd\")\n             session.sendline(cmd)\n-            if not self.app_runing():\n-                return True\n-            return False\n+            return self.app_running()\n \n-        error.context(\"stop stress app in guest\", logging.info)\n-        utils_misc.wait_for(_unload_stress, first=2.0,\n-                            text=\"wait stress app quit\", step=1.0, timeout=120)\n+        error_context.context(\"stop stress app in guest\", logging.info)\n+        stopped = utils_misc.wait_for(_unload_stress, first=2.0,\n+                                      text=\"wait stress app quit\",\n+                                      step=1.0, timeout=120)\n+        if not stopped:\n+            logging.warn(\"stress app is still running\")\n \n-    def app_runing(self):\n+    def app_running(self):\n         \"\"\"\n         check stress app really run in background;\n         \"\"\"\n         session = self.get_session()\n-        params = self.parser_test_args()\n-        cmd = params.get(\"check_cmd\")\n+        cmd = self.params.get(\"check_cmd\")","path":"qemu/tests/drive_mirror_stress.py","position":104,"original_position":104,"commit_id":"eeae08751e7b26898e18b55247e3ae9031439e35","original_commit_id":"eeae08751e7b26898e18b55247e3ae9031439e35","user":{"login":"luckyh","id":7801589,"avatar_url":"https://avatars1.githubusercontent.com/u/7801589?v=4","gravatar_id":"","url":"https://api.github.com/users/luckyh","html_url":"https://github.com/luckyh","followers_url":"https://api.github.com/users/luckyh/followers","following_url":"https://api.github.com/users/luckyh/following{/other_user}","gists_url":"https://api.github.com/users/luckyh/gists{/gist_id}","starred_url":"https://api.github.com/users/luckyh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/luckyh/subscriptions","organizations_url":"https://api.github.com/users/luckyh/orgs","repos_url":"https://api.github.com/users/luckyh/repos","events_url":"https://api.github.com/users/luckyh/events{/privacy}","received_events_url":"https://api.github.com/users/luckyh/received_events","type":"User","site_admin":false},"body":"Better to close the session if no longer using, to avoid file descriptor leak.","created_at":"2017-08-15T07:03:20Z","updated_at":"2017-08-15T07:03:32Z","html_url":"https://github.com/autotest/tp-qemu/pull/762#discussion_r133127676","pull_request_url":"https://api.github.com/repos/autotest/tp-qemu/pulls/762","_links":{"self":{"href":"https://api.github.com/repos/autotest/tp-qemu/pulls/comments/133127676"},"html":{"href":"https://github.com/autotest/tp-qemu/pull/762#discussion_r133127676"},"pull_request":{"href":"https://api.github.com/repos/autotest/tp-qemu/pulls/762"}}},"pull_request":{"url":"https://api.github.com/repos/autotest/tp-qemu/pulls/762","id":88606893,"html_url":"https://github.com/autotest/tp-qemu/pull/762","diff_url":"https://github.com/autotest/tp-qemu/pull/762.diff","patch_url":"https://github.com/autotest/tp-qemu/pull/762.patch","issue_url":"https://api.github.com/repos/autotest/tp-qemu/issues/762","number":762,"state":"open","locked":false,"title":"block_commit: Add test case 'Basic block commit test' to block commit","user":{"login":"xiywang","id":22315657,"avatar_url":"https://avatars3.githubusercontent.com/u/22315657?v=4","gravatar_id":"","url":"https://api.github.com/users/xiywang","html_url":"https://github.com/xiywang","followers_url":"https://api.github.com/users/xiywang/followers","following_url":"https://api.github.com/users/xiywang/following{/other_user}","gists_url":"https://api.github.com/users/xiywang/gists{/gist_id}","starred_url":"https://api.github.com/users/xiywang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xiywang/subscriptions","organizations_url":"https://api.github.com/users/xiywang/orgs","repos_url":"https://api.github.com/users/xiywang/repos","events_url":"https://api.github.com/users/xiywang/events{/privacy}","received_events_url":"https://api.github.com/users/xiywang/received_events","type":"User","site_admin":false},"body":"id: 1380234\nSigned-off-by: Xiyue Wang xiywang@redhat.com\n","created_at":"2016-10-10T03:30:35Z","updated_at":"2017-08-15T07:03:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e6dcd490db6a7c005f61bc4f3d1ecba4bacf14ee","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/autotest/tp-qemu/pulls/762/commits","review_comments_url":"https://api.github.com/repos/autotest/tp-qemu/pulls/762/comments","review_comment_url":"https://api.github.com/repos/autotest/tp-qemu/pulls/comments{/number}","comments_url":"https://api.github.com/repos/autotest/tp-qemu/issues/762/comments","statuses_url":"https://api.github.com/repos/autotest/tp-qemu/statuses/eeae08751e7b26898e18b55247e3ae9031439e35","head":{"label":"xiywang:live_commit","ref":"live_commit","sha":"eeae08751e7b26898e18b55247e3ae9031439e35","user":{"login":"xiywang","id":22315657,"avatar_url":"https://avatars3.githubusercontent.com/u/22315657?v=4","gravatar_id":"","url":"https://api.github.com/users/xiywang","html_url":"https://github.com/xiywang","followers_url":"https://api.github.com/users/xiywang/followers","following_url":"https://api.github.com/users/xiywang/following{/other_user}","gists_url":"https://api.github.com/users/xiywang/gists{/gist_id}","starred_url":"https://api.github.com/users/xiywang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xiywang/subscriptions","organizations_url":"https://api.github.com/users/xiywang/orgs","repos_url":"https://api.github.com/users/xiywang/repos","events_url":"https://api.github.com/users/xiywang/events{/privacy}","received_events_url":"https://api.github.com/users/xiywang/received_events","type":"User","site_admin":false},"repo":{"id":69521066,"name":"tp-qemu","full_name":"xiywang/tp-qemu","owner":{"login":"xiywang","id":22315657,"avatar_url":"https://avatars3.githubusercontent.com/u/22315657?v=4","gravatar_id":"","url":"https://api.github.com/users/xiywang","html_url":"https://github.com/xiywang","followers_url":"https://api.github.com/users/xiywang/followers","following_url":"https://api.github.com/users/xiywang/following{/other_user}","gists_url":"https://api.github.com/users/xiywang/gists{/gist_id}","starred_url":"https://api.github.com/users/xiywang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xiywang/subscriptions","organizations_url":"https://api.github.com/users/xiywang/orgs","repos_url":"https://api.github.com/users/xiywang/repos","events_url":"https://api.github.com/users/xiywang/events{/privacy}","received_events_url":"https://api.github.com/users/xiywang/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/xiywang/tp-qemu","description":"Virt Test Provider for qemu and other related virtualization backends","fork":true,"url":"https://api.github.com/repos/xiywang/tp-qemu","forks_url":"https://api.github.com/repos/xiywang/tp-qemu/forks","keys_url":"https://api.github.com/repos/xiywang/tp-qemu/keys{/key_id}","collaborators_url":"https://api.github.com/repos/xiywang/tp-qemu/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/xiywang/tp-qemu/teams","hooks_url":"https://api.github.com/repos/xiywang/tp-qemu/hooks","issue_events_url":"https://api.github.com/repos/xiywang/tp-qemu/issues/events{/number}","events_url":"https://api.github.com/repos/xiywang/tp-qemu/events","assignees_url":"https://api.github.com/repos/xiywang/tp-qemu/assignees{/user}","branches_url":"https://api.github.com/repos/xiywang/tp-qemu/branches{/branch}","tags_url":"https://api.github.com/repos/xiywang/tp-qemu/tags","blobs_url":"https://api.github.com/repos/xiywang/tp-qemu/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/xiywang/tp-qemu/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/xiywang/tp-qemu/git/refs{/sha}","trees_url":"https://api.github.com/repos/xiywang/tp-qemu/git/trees{/sha}","statuses_url":"https://api.github.com/repos/xiywang/tp-qemu/statuses/{sha}","languages_url":"https://api.github.com/repos/xiywang/tp-qemu/languages","stargazers_url":"https://api.github.com/repos/xiywang/tp-qemu/stargazers","contributors_url":"https://api.github.com/repos/xiywang/tp-qemu/contributors","subscribers_url":"https://api.github.com/repos/xiywang/tp-qemu/subscribers","subscription_url":"https://api.github.com/repos/xiywang/tp-qemu/subscription","commits_url":"https://api.github.com/repos/xiywang/tp-qemu/commits{/sha}","git_commits_url":"https://api.github.com/repos/xiywang/tp-qemu/git/commits{/sha}","comments_url":"https://api.github.com/repos/xiywang/tp-qemu/comments{/number}","issue_comment_url":"https://api.github.com/repos/xiywang/tp-qemu/issues/comments{/number}","contents_url":"https://api.github.com/repos/xiywang/tp-qemu/contents/{+path}","compare_url":"https://api.github.com/repos/xiywang/tp-qemu/compare/{base}...{head}","merges_url":"https://api.github.com/repos/xiywang/tp-qemu/merges","archive_url":"https://api.github.com/repos/xiywang/tp-qemu/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/xiywang/tp-qemu/downloads","issues_url":"https://api.github.com/repos/xiywang/tp-qemu/issues{/number}","pulls_url":"https://api.github.com/repos/xiywang/tp-qemu/pulls{/number}","milestones_url":"https://api.github.com/repos/xiywang/tp-qemu/milestones{/number}","notifications_url":"https://api.github.com/repos/xiywang/tp-qemu/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/xiywang/tp-qemu/labels{/name}","releases_url":"https://api.github.com/repos/xiywang/tp-qemu/releases{/id}","deployments_url":"https://api.github.com/repos/xiywang/tp-qemu/deployments","created_at":"2016-09-29T02:05:08Z","updated_at":"2016-09-29T02:05:11Z","pushed_at":"2017-08-14T07:44:51Z","git_url":"git://github.com/xiywang/tp-qemu.git","ssh_url":"git@github.com:xiywang/tp-qemu.git","clone_url":"https://github.com/xiywang/tp-qemu.git","svn_url":"https://github.com/xiywang/tp-qemu","homepage":null,"size":13551,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"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":"autotest:master","ref":"master","sha":"8186ee67b252dbee4f08bd2c4ac75c8b789cf962","user":{"login":"autotest","id":472856,"avatar_url":"https://avatars1.githubusercontent.com/u/472856?v=4","gravatar_id":"","url":"https://api.github.com/users/autotest","html_url":"https://github.com/autotest","followers_url":"https://api.github.com/users/autotest/followers","following_url":"https://api.github.com/users/autotest/following{/other_user}","gists_url":"https://api.github.com/users/autotest/gists{/gist_id}","starred_url":"https://api.github.com/users/autotest/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/autotest/subscriptions","organizations_url":"https://api.github.com/users/autotest/orgs","repos_url":"https://api.github.com/users/autotest/repos","events_url":"https://api.github.com/users/autotest/events{/privacy}","received_events_url":"https://api.github.com/users/autotest/received_events","type":"Organization","site_admin":false},"repo":{"id":16180304,"name":"tp-qemu","full_name":"autotest/tp-qemu","owner":{"login":"autotest","id":472856,"avatar_url":"https://avatars1.githubusercontent.com/u/472856?v=4","gravatar_id":"","url":"https://api.github.com/users/autotest","html_url":"https://github.com/autotest","followers_url":"https://api.github.com/users/autotest/followers","following_url":"https://api.github.com/users/autotest/following{/other_user}","gists_url":"https://api.github.com/users/autotest/gists{/gist_id}","starred_url":"https://api.github.com/users/autotest/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/autotest/subscriptions","organizations_url":"https://api.github.com/users/autotest/orgs","repos_url":"https://api.github.com/users/autotest/repos","events_url":"https://api.github.com/users/autotest/events{/privacy}","received_events_url":"https://api.github.com/users/autotest/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/autotest/tp-qemu","description":"Virt Test Provider for qemu and other related virtualization backends","fork":false,"url":"https://api.github.com/repos/autotest/tp-qemu","forks_url":"https://api.github.com/repos/autotest/tp-qemu/forks","keys_url":"https://api.github.com/repos/autotest/tp-qemu/keys{/key_id}","collaborators_url":"https://api.github.com/repos/autotest/tp-qemu/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/autotest/tp-qemu/teams","hooks_url":"https://api.github.com/repos/autotest/tp-qemu/hooks","issue_events_url":"https://api.github.com/repos/autotest/tp-qemu/issues/events{/number}","events_url":"https://api.github.com/repos/autotest/tp-qemu/events","assignees_url":"https://api.github.com/repos/autotest/tp-qemu/assignees{/user}","branches_url":"https://api.github.com/repos/autotest/tp-qemu/branches{/branch}","tags_url":"https://api.github.com/repos/autotest/tp-qemu/tags","blobs_url":"https://api.github.com/repos/autotest/tp-qemu/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/autotest/tp-qemu/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/autotest/tp-qemu/git/refs{/sha}","trees_url":"https://api.github.com/repos/autotest/tp-qemu/git/trees{/sha}","statuses_url":"https://api.github.com/repos/autotest/tp-qemu/statuses/{sha}","languages_url":"https://api.github.com/repos/autotest/tp-qemu/languages","stargazers_url":"https://api.github.com/repos/autotest/tp-qemu/stargazers","contributors_url":"https://api.github.com/repos/autotest/tp-qemu/contributors","subscribers_url":"https://api.github.com/repos/autotest/tp-qemu/subscribers","subscription_url":"https://api.github.com/repos/autotest/tp-qemu/subscription","commits_url":"https://api.github.com/repos/autotest/tp-qemu/commits{/sha}","git_commits_url":"https://api.github.com/repos/autotest/tp-qemu/git/commits{/sha}","comments_url":"https://api.github.com/repos/autotest/tp-qemu/comments{/number}","issue_comment_url":"https://api.github.com/repos/autotest/tp-qemu/issues/comments{/number}","contents_url":"https://api.github.com/repos/autotest/tp-qemu/contents/{+path}","compare_url":"https://api.github.com/repos/autotest/tp-qemu/compare/{base}...{head}","merges_url":"https://api.github.com/repos/autotest/tp-qemu/merges","archive_url":"https://api.github.com/repos/autotest/tp-qemu/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/autotest/tp-qemu/downloads","issues_url":"https://api.github.com/repos/autotest/tp-qemu/issues{/number}","pulls_url":"https://api.github.com/repos/autotest/tp-qemu/pulls{/number}","milestones_url":"https://api.github.com/repos/autotest/tp-qemu/milestones{/number}","notifications_url":"https://api.github.com/repos/autotest/tp-qemu/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/autotest/tp-qemu/labels{/name}","releases_url":"https://api.github.com/repos/autotest/tp-qemu/releases{/id}","deployments_url":"https://api.github.com/repos/autotest/tp-qemu/deployments","created_at":"2014-01-23T17:51:34Z","updated_at":"2017-07-08T11:13:02Z","pushed_at":"2017-08-15T02:38:05Z","git_url":"git://github.com/autotest/tp-qemu.git","ssh_url":"git@github.com:autotest/tp-qemu.git","clone_url":"https://github.com/autotest/tp-qemu.git","svn_url":"https://github.com/autotest/tp-qemu","homepage":null,"size":13545,"stargazers_count":14,"watchers_count":14,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":100,"mirror_url":null,"open_issues_count":48,"forks":100,"open_issues":48,"watchers":14,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/autotest/tp-qemu/pulls/762"},"html":{"href":"https://github.com/autotest/tp-qemu/pull/762"},"issue":{"href":"https://api.github.com/repos/autotest/tp-qemu/issues/762"},"comments":{"href":"https://api.github.com/repos/autotest/tp-qemu/issues/762/comments"},"review_comments":{"href":"https://api.github.com/repos/autotest/tp-qemu/pulls/762/comments"},"review_comment":{"href":"https://api.github.com/repos/autotest/tp-qemu/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/autotest/tp-qemu/pulls/762/commits"},"statuses":{"href":"https://api.github.com/repos/autotest/tp-qemu/statuses/eeae08751e7b26898e18b55247e3ae9031439e35"}}}}
{"actor":{"display_login":"luckyh"}}