{"action":"created","comment":{"url":"https://api.github.com/repos/autotest/tp-qemu/pulls/comments/139110435","pull_request_review_id":62998465,"id":139110435,"diff_hunk":"@@ -1,133 +1,182 @@\n import logging\n+import aexpect\n \n from autotest.client.shared import error\n from autotest.client import utils\n \n from virttest import utils_test\n from virttest import utils_net\n+from virttest import error_context\n \n \n-@error.context_aware\n+@error_context.context_aware\n def run(test, params, env):\n     \"\"\"\n     Ping the guest with different size of packets.\n \n     1) Login to guest\n-    2) Ping test on nic(s) from host\n+    2) Ping test on nic(s) from host - default_ping/multi_nics\n         2.1) Ping with packet size from 0 to 65507\n-        2.2) Flood ping test\n-        2.3) Ping test after flood ping, Check if the network is still alive\n-    3) Ping test from guest side, packet size is from 0 to 65507\n-       (win guest is up to 65500) (Optional)\n+        2.2) Ping with exceed packet size (65508)\n+        2.3) Flood ping test\n+        2.4) Ping test after flood ping, Check if the network is still alive\n+    3) Ping test from guest side to external host - ext_host\n+        3.1) Ping with packet size from 0 to 65507 (win guest is up to 65500)\n+        3.2) Ping with exceed packet size (65508)\n+        3.3) Flood ping test\n+        3.4) Ping test after flood ping, Check if the network is still alive\n \n     :param test: QEMU test object.\n     :param params: Dictionary with the test parameters.\n     :param env: Dictionary with test environment.\n     \"\"\"\n-    def _get_loss_ratio(output):\n+    def _check_result(status, output):\n         if params.get(\"strict_check\", \"no\") == \"yes\":\n             ratio = utils_test.get_loss_ratio(output)\n             if ratio != 0:\n-                raise error.TestFail(\"Loss ratio is %s\" % ratio)\n+                test.fail(\"Loss ratio is %s\" % ratio)\n+        if status != 0:\n+            test.fail(\"Ping failed, status: %s,\"\n+                      \" output: %s\" % (status, output))\n \n     timeout = int(params.get(\"login_timeout\", 360))\n     ping_ext_host = params.get(\"ping_ext_host\", \"no\") == \"yes\"\n \n     vm = env.get_vm(params[\"main_vm\"])\n     vm.verify_alive()\n-    error.context(\"Login to guest\", logging.info)\n+    error_context.context(\"Login to guest\", logging.info)\n     session = vm.wait_for_login(timeout=timeout)\n \n     # most of linux distribution don't add IP configuration for extra nics,\n     # so get IP for extra nics via pre_cmd;\n     if params.get(\"pre_cmd\"):\n         session.cmd(params[\"pre_cmd\"], timeout=600)\n \n+    ext_host = \"www.redhat.com\"\n     if ping_ext_host:\n-        default_host = \"www.redhat.com\"\n         ext_host_get_cmd = params.get(\"ext_host_get_cmd\", \"\")\n         try:\n             ext_host = utils.system_output(ext_host_get_cmd)\n         except error.CmdError:\n             logging.warn(\"Can't get specified host with cmd '%s',\"\n                          \" Fallback to default host '%s'\",\n-                         ext_host_get_cmd, default_host)\n-            ext_host = default_host\n-\n-        if not ext_host:\n-            # Fallback to a hardcode host, eg:\n-            ext_host = default_host\n+                         ext_host_get_cmd, ext_host)\n \n-    counts = params.get(\"ping_counts\", 100)\n+    counts = params.get(\"counts\", 10)\n     flood_minutes = float(params.get(\"flood_minutes\", 10))\n \n     packet_sizes = params.get(\"packet_size\", \"\").split()\n-\n-    for i, nic in enumerate(vm.virtnet):\n-        ip = vm.get_address(i)\n-        if ip.upper().startswith(\"FE80\"):\n-            interface = utils_net.get_neigh_attch_interface(ip)\n-        else:\n-            interface = None\n-        nic_name = nic.get(\"nic_name\")\n-        if not ip:\n-            logging.error(\"Could not get the ip of nic index %d: %s\",\n+    interval_times = params.get(\"interval_time\", \"\").split()\n+    host_result_str = params.get(\"host_exceeded_res\", \"\")\n+    result_str = params.get(\"guest_exceeded_res\", \"\")\n+\n+    def _ping_with_params(dest=ext_host, interface=None,\n+                          packet_size=None, interval=None,\n+                          count=counts, session=None,\n+                          flood=False, timeout=float(counts) * 1.5):\n+        if flood:\n+            count = None\n+        return utils_test.ping(dest, count, interval, interface,\n+                               packet_size, session=session,\n+                               flood=flood, timeout=timeout)\n+\n+    if params.get(\"ping_default\", \"no\") == \"yes\":\n+        for i, nic in enumerate(vm.virtnet):\n+            ip = vm.get_address(i)\n+            if ip.upper().startswith(\"FE80\"):\n+                interface = utils_net.get_neigh_attch_interface(ip)\n+            else:\n+                interface = None\n+            nic_name = nic.get(\"nic_name\")\n+            if not ip:\n+                test.fail(\"Could not get the ip of nic index %d: %s\",","path":"generic/tests/ping.py","position":119,"original_position":119,"commit_id":"e0157e20f7976022db2723c2580fde20e9409e65","original_commit_id":"e0157e20f7976022db2723c2580fde20e9409e65","user":{"login":"kimi1978wy","id":12727794,"avatar_url":"https://avatars2.githubusercontent.com/u/12727794?v=4","gravatar_id":"","url":"https://api.github.com/users/kimi1978wy","html_url":"https://github.com/kimi1978wy","followers_url":"https://api.github.com/users/kimi1978wy/followers","following_url":"https://api.github.com/users/kimi1978wy/following{/other_user}","gists_url":"https://api.github.com/users/kimi1978wy/gists{/gist_id}","starred_url":"https://api.github.com/users/kimi1978wy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kimi1978wy/subscriptions","organizations_url":"https://api.github.com/users/kimi1978wy/orgs","repos_url":"https://api.github.com/users/kimi1978wy/repos","events_url":"https://api.github.com/users/kimi1978wy/events{/privacy}","received_events_url":"https://api.github.com/users/kimi1978wy/received_events","type":"User","site_admin":false},"body":"In line52 and line53, it get a pre_cmd in cfg (pre_cmd = \"for nic in ls /sys/class/net|grep -v lo;do arp -a|grep -v $nic && dhclient $nic;done\"), it can dhclient ip for multi_nics. and then judge the ip in line91 is enough. If add a ifcfg, it maybe the same function as line91.","created_at":"2017-09-15T10:03:03Z","updated_at":"2017-09-15T10:03:03Z","html_url":"https://github.com/autotest/tp-qemu/pull/1077#discussion_r139110435","pull_request_url":"https://api.github.com/repos/autotest/tp-qemu/pulls/1077","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/autotest/tp-qemu/pulls/comments/139110435"},"html":{"href":"https://github.com/autotest/tp-qemu/pull/1077#discussion_r139110435"},"pull_request":{"href":"https://api.github.com/repos/autotest/tp-qemu/pulls/1077"}},"in_reply_to_id":139075870},"pull_request":{"url":"https://api.github.com/repos/autotest/tp-qemu/pulls/1077","id":139075681,"html_url":"https://github.com/autotest/tp-qemu/pull/1077","diff_url":"https://github.com/autotest/tp-qemu/pull/1077.diff","patch_url":"https://github.com/autotest/tp-qemu/pull/1077.patch","issue_url":"https://api.github.com/repos/autotest/tp-qemu/issues/1077","number":1077,"state":"open","locked":false,"title":"fix some bugs and add steps for ping.py ","user":{"login":"kimi1978wy","id":12727794,"avatar_url":"https://avatars2.githubusercontent.com/u/12727794?v=4","gravatar_id":"","url":"https://api.github.com/users/kimi1978wy","html_url":"https://github.com/kimi1978wy","followers_url":"https://api.github.com/users/kimi1978wy/followers","following_url":"https://api.github.com/users/kimi1978wy/following{/other_user}","gists_url":"https://api.github.com/users/kimi1978wy/gists{/gist_id}","starred_url":"https://api.github.com/users/kimi1978wy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kimi1978wy/subscriptions","organizations_url":"https://api.github.com/users/kimi1978wy/orgs","repos_url":"https://api.github.com/users/kimi1978wy/repos","events_url":"https://api.github.com/users/kimi1978wy/events{/privacy}","received_events_url":"https://api.github.com/users/kimi1978wy/received_events","type":"User","site_admin":false},"body":"improve ping from host to guest, add ping exceed/flood for guest to host, and fix some bugs in this patch.\r\n\r\nSigned-off-by: Yu Wang <wyu@redhat.com>\r\n\r\nid: 1479695 1479696 ","created_at":"2017-09-04T03:02:39Z","updated_at":"2017-09-15T10:03:03Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5b7f1ab586bdede5899456f056d677759325afae","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/autotest/tp-qemu/pulls/1077/commits","review_comments_url":"https://api.github.com/repos/autotest/tp-qemu/pulls/1077/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/1077/comments","statuses_url":"https://api.github.com/repos/autotest/tp-qemu/statuses/e0157e20f7976022db2723c2580fde20e9409e65","head":{"label":"kimi1978wy:1479696","ref":"1479696","sha":"e0157e20f7976022db2723c2580fde20e9409e65","user":{"login":"kimi1978wy","id":12727794,"avatar_url":"https://avatars2.githubusercontent.com/u/12727794?v=4","gravatar_id":"","url":"https://api.github.com/users/kimi1978wy","html_url":"https://github.com/kimi1978wy","followers_url":"https://api.github.com/users/kimi1978wy/followers","following_url":"https://api.github.com/users/kimi1978wy/following{/other_user}","gists_url":"https://api.github.com/users/kimi1978wy/gists{/gist_id}","starred_url":"https://api.github.com/users/kimi1978wy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kimi1978wy/subscriptions","organizations_url":"https://api.github.com/users/kimi1978wy/orgs","repos_url":"https://api.github.com/users/kimi1978wy/repos","events_url":"https://api.github.com/users/kimi1978wy/events{/privacy}","received_events_url":"https://api.github.com/users/kimi1978wy/received_events","type":"User","site_admin":false},"repo":{"id":98955110,"name":"tp-qemu","full_name":"kimi1978wy/tp-qemu","owner":{"login":"kimi1978wy","id":12727794,"avatar_url":"https://avatars2.githubusercontent.com/u/12727794?v=4","gravatar_id":"","url":"https://api.github.com/users/kimi1978wy","html_url":"https://github.com/kimi1978wy","followers_url":"https://api.github.com/users/kimi1978wy/followers","following_url":"https://api.github.com/users/kimi1978wy/following{/other_user}","gists_url":"https://api.github.com/users/kimi1978wy/gists{/gist_id}","starred_url":"https://api.github.com/users/kimi1978wy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kimi1978wy/subscriptions","organizations_url":"https://api.github.com/users/kimi1978wy/orgs","repos_url":"https://api.github.com/users/kimi1978wy/repos","events_url":"https://api.github.com/users/kimi1978wy/events{/privacy}","received_events_url":"https://api.github.com/users/kimi1978wy/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kimi1978wy/tp-qemu","description":"Virt Test Provider for qemu and other related virtualization backends","fork":true,"url":"https://api.github.com/repos/kimi1978wy/tp-qemu","forks_url":"https://api.github.com/repos/kimi1978wy/tp-qemu/forks","keys_url":"https://api.github.com/repos/kimi1978wy/tp-qemu/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kimi1978wy/tp-qemu/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kimi1978wy/tp-qemu/teams","hooks_url":"https://api.github.com/repos/kimi1978wy/tp-qemu/hooks","issue_events_url":"https://api.github.com/repos/kimi1978wy/tp-qemu/issues/events{/number}","events_url":"https://api.github.com/repos/kimi1978wy/tp-qemu/events","assignees_url":"https://api.github.com/repos/kimi1978wy/tp-qemu/assignees{/user}","branches_url":"https://api.github.com/repos/kimi1978wy/tp-qemu/branches{/branch}","tags_url":"https://api.github.com/repos/kimi1978wy/tp-qemu/tags","blobs_url":"https://api.github.com/repos/kimi1978wy/tp-qemu/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kimi1978wy/tp-qemu/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kimi1978wy/tp-qemu/git/refs{/sha}","trees_url":"https://api.github.com/repos/kimi1978wy/tp-qemu/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kimi1978wy/tp-qemu/statuses/{sha}","languages_url":"https://api.github.com/repos/kimi1978wy/tp-qemu/languages","stargazers_url":"https://api.github.com/repos/kimi1978wy/tp-qemu/stargazers","contributors_url":"https://api.github.com/repos/kimi1978wy/tp-qemu/contributors","subscribers_url":"https://api.github.com/repos/kimi1978wy/tp-qemu/subscribers","subscription_url":"https://api.github.com/repos/kimi1978wy/tp-qemu/subscription","commits_url":"https://api.github.com/repos/kimi1978wy/tp-qemu/commits{/sha}","git_commits_url":"https://api.github.com/repos/kimi1978wy/tp-qemu/git/commits{/sha}","comments_url":"https://api.github.com/repos/kimi1978wy/tp-qemu/comments{/number}","issue_comment_url":"https://api.github.com/repos/kimi1978wy/tp-qemu/issues/comments{/number}","contents_url":"https://api.github.com/repos/kimi1978wy/tp-qemu/contents/{+path}","compare_url":"https://api.github.com/repos/kimi1978wy/tp-qemu/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kimi1978wy/tp-qemu/merges","archive_url":"https://api.github.com/repos/kimi1978wy/tp-qemu/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kimi1978wy/tp-qemu/downloads","issues_url":"https://api.github.com/repos/kimi1978wy/tp-qemu/issues{/number}","pulls_url":"https://api.github.com/repos/kimi1978wy/tp-qemu/pulls{/number}","milestones_url":"https://api.github.com/repos/kimi1978wy/tp-qemu/milestones{/number}","notifications_url":"https://api.github.com/repos/kimi1978wy/tp-qemu/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kimi1978wy/tp-qemu/labels{/name}","releases_url":"https://api.github.com/repos/kimi1978wy/tp-qemu/releases{/id}","deployments_url":"https://api.github.com/repos/kimi1978wy/tp-qemu/deployments","created_at":"2017-08-01T03:25:41Z","updated_at":"2017-08-01T03:29:22Z","pushed_at":"2017-09-14T07:31:45Z","git_url":"git://github.com/kimi1978wy/tp-qemu.git","ssh_url":"git@github.com:kimi1978wy/tp-qemu.git","clone_url":"https://github.com/kimi1978wy/tp-qemu.git","svn_url":"https://github.com/kimi1978wy/tp-qemu","homepage":null,"size":13814,"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":"7666da4490c3d286910086014170daca4cbe655d","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-08-18T12:10:46Z","pushed_at":"2017-09-15T09:19:01Z","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":13833,"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":102,"mirror_url":null,"open_issues_count":58,"forks":102,"open_issues":58,"watchers":14,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/autotest/tp-qemu/pulls/1077"},"html":{"href":"https://github.com/autotest/tp-qemu/pull/1077"},"issue":{"href":"https://api.github.com/repos/autotest/tp-qemu/issues/1077"},"comments":{"href":"https://api.github.com/repos/autotest/tp-qemu/issues/1077/comments"},"review_comments":{"href":"https://api.github.com/repos/autotest/tp-qemu/pulls/1077/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/1077/commits"},"statuses":{"href":"https://api.github.com/repos/autotest/tp-qemu/statuses/e0157e20f7976022db2723c2580fde20e9409e65"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"kimi1978wy"}}