{"action":"created","comment":{"url":"https://api.github.com/repos/avocado-framework/avocado/pulls/comments/241521564","pull_request_review_id":184816577,"id":241521564,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI0MTUyMTU2NA==","diff_hunk":"@@ -33,5 +35,64 @@ def test_release_port(self):\n         self.assertNotIn(22, tracker.retained_ports)\n \n \n+def get_all_local_addrs():\n+    \"\"\"\n+    Returns all ipv4/ipv6 addresses that are associated with this machine\n+    \"\"\"\n+    ipv4_addrs = []\n+    ipv6_addrs = []\n+    for interface in netifaces.interfaces():\n+        ifaddresses = netifaces.ifaddresses(interface)\n+        ipv4_addrs += [_['addr']\n+                       for _ in ifaddresses.get(netifaces.AF_INET, [])]\n+        ipv6_addrs += [_['addr']\n+                       for _ in ifaddresses.get(netifaces.AF_INET6, [])]\n+    return ipv4_addrs, ipv6_addrs\n+\n+\n+class FreePort(unittest.TestCase):\n+\n+    def test_is_port_free(self):","path":"selftests/unit/test_utils_network.py","position":27,"original_position":27,"commit_id":"6c63153fc03a92b32bc73ed2b2365e6b2b693f90","original_commit_id":"6c63153fc03a92b32bc73ed2b2365e6b2b693f90","user":{"login":"ldoktor","id":1074021,"node_id":"MDQ6VXNlcjEwNzQwMjE=","avatar_url":"https://avatars3.githubusercontent.com/u/1074021?v=4","gravatar_id":"","url":"https://api.github.com/users/ldoktor","html_url":"https://github.com/ldoktor","followers_url":"https://api.github.com/users/ldoktor/followers","following_url":"https://api.github.com/users/ldoktor/following{/other_user}","gists_url":"https://api.github.com/users/ldoktor/gists{/gist_id}","starred_url":"https://api.github.com/users/ldoktor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ldoktor/subscriptions","organizations_url":"https://api.github.com/users/ldoktor/orgs","repos_url":"https://api.github.com/users/ldoktor/repos","events_url":"https://api.github.com/users/ldoktor/events{/privacy}","received_events_url":"https://api.github.com/users/ldoktor/received_events","type":"User","site_admin":false},"body":"I'd prefer this way because with the use of mocking we would only test our perception of ports handling, but for years it was wrong. And even my first version developed on system with IPv6 was way different than the one I tried with docker. Last when I ran it in travis it generated even more exceptions I needed to address, which only increases the need for a functional test, what do you think?\r\n\r\nBtw what do you mean by long? It takes near to zero seconds on my machine...","created_at":"2018-12-13T18:56:38Z","updated_at":"2018-12-13T18:56:39Z","html_url":"https://github.com/avocado-framework/avocado/pull/2957#discussion_r241521564","pull_request_url":"https://api.github.com/repos/avocado-framework/avocado/pulls/2957","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/avocado-framework/avocado/pulls/comments/241521564"},"html":{"href":"https://github.com/avocado-framework/avocado/pull/2957#discussion_r241521564"},"pull_request":{"href":"https://api.github.com/repos/avocado-framework/avocado/pulls/2957"}},"in_reply_to_id":241505203},"pull_request":{"url":"https://api.github.com/repos/avocado-framework/avocado/pulls/2957","id":237060698,"node_id":"MDExOlB1bGxSZXF1ZXN0MjM3MDYwNjk4","html_url":"https://github.com/avocado-framework/avocado/pull/2957","diff_url":"https://github.com/avocado-framework/avocado/pull/2957.diff","patch_url":"https://github.com/avocado-framework/avocado/pull/2957.patch","issue_url":"https://api.github.com/repos/avocado-framework/avocado/issues/2957","number":2957,"state":"open","locked":false,"title":"Improve is_port_free [v2]","user":{"login":"ldoktor","id":1074021,"node_id":"MDQ6VXNlcjEwNzQwMjE=","avatar_url":"https://avatars3.githubusercontent.com/u/1074021?v=4","gravatar_id":"","url":"https://api.github.com/users/ldoktor","html_url":"https://github.com/ldoktor","followers_url":"https://api.github.com/users/ldoktor/followers","following_url":"https://api.github.com/users/ldoktor/following{/other_user}","gists_url":"https://api.github.com/users/ldoktor/gists{/gist_id}","starred_url":"https://api.github.com/users/ldoktor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ldoktor/subscriptions","organizations_url":"https://api.github.com/users/ldoktor/orgs","repos_url":"https://api.github.com/users/ldoktor/repos","events_url":"https://api.github.com/users/ldoktor/events{/privacy}","received_events_url":"https://api.github.com/users/ldoktor/received_events","type":"User","site_admin":false},"body":"Hello guys, it took me quite long to find out our is_port_free function is seriously insufficient (first I blamed qemu, but it's us). The first commit fixes the issue where ipv4 address is already freed, but ipv6 address is still occupied, the second commit makes sure we don't allow using port that is already used by UDP (not sure why but at least on my system it allows that without complaint). Third replaces \"localhost\" with \"\", because on \"localhost\" python binds only to 127.0.0.1/::1 but on \"\" it binds to all localhost interfaces (like 192.168.122.1, ...), which is commonly used by programs and we were not detectin these. After that follows fixes and optimization.\r\n\r\nPS: This (hopefully) fixes (or at least decreases probability) very rare Avocado-vt migration issue where ports are not free even though we claim they are.\r\nPPS: It just decreases the probability (down from 15 to 1)\r\n\r\nv1: https://github.com/avocado-framework/avocado/pull/2937\r\n\r\nChanges:\r\n\r\n```yaml\r\nv2: Spelled correctly IPvX\r\nv2: Use sequent=False to decrease probability of clashes in selftests\r\nv2: Fixed remote check (connect always passes with UDP)\r\nv2: Added netifaces to BuildRequires in rpm SPEC file\r\n```\r\n\r\nNot changed:\r\n\r\n```yaml\r\nv2: Not added family/protocol arguments as people never needed them.\r\n    Let's provide best out of the box experience and wait for people\r\n    to request this.\r\n```","created_at":"2018-12-08T10:38:41Z","updated_at":"2018-12-13T18:56:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7cf001f686f04c677d074b52990caae14936806a","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/avocado-framework/avocado/pulls/2957/commits","review_comments_url":"https://api.github.com/repos/avocado-framework/avocado/pulls/2957/comments","review_comment_url":"https://api.github.com/repos/avocado-framework/avocado/pulls/comments{/number}","comments_url":"https://api.github.com/repos/avocado-framework/avocado/issues/2957/comments","statuses_url":"https://api.github.com/repos/avocado-framework/avocado/statuses/6c63153fc03a92b32bc73ed2b2365e6b2b693f90","head":{"label":"ldoktor:is_port_free2","ref":"is_port_free2","sha":"6c63153fc03a92b32bc73ed2b2365e6b2b693f90","user":{"login":"ldoktor","id":1074021,"node_id":"MDQ6VXNlcjEwNzQwMjE=","avatar_url":"https://avatars3.githubusercontent.com/u/1074021?v=4","gravatar_id":"","url":"https://api.github.com/users/ldoktor","html_url":"https://github.com/ldoktor","followers_url":"https://api.github.com/users/ldoktor/followers","following_url":"https://api.github.com/users/ldoktor/following{/other_user}","gists_url":"https://api.github.com/users/ldoktor/gists{/gist_id}","starred_url":"https://api.github.com/users/ldoktor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ldoktor/subscriptions","organizations_url":"https://api.github.com/users/ldoktor/orgs","repos_url":"https://api.github.com/users/ldoktor/repos","events_url":"https://api.github.com/users/ldoktor/events{/privacy}","received_events_url":"https://api.github.com/users/ldoktor/received_events","type":"User","site_admin":false},"repo":{"id":26808700,"node_id":"MDEwOlJlcG9zaXRvcnkyNjgwODcwMA==","name":"avocado","full_name":"ldoktor/avocado","private":false,"owner":{"login":"ldoktor","id":1074021,"node_id":"MDQ6VXNlcjEwNzQwMjE=","avatar_url":"https://avatars3.githubusercontent.com/u/1074021?v=4","gravatar_id":"","url":"https://api.github.com/users/ldoktor","html_url":"https://github.com/ldoktor","followers_url":"https://api.github.com/users/ldoktor/followers","following_url":"https://api.github.com/users/ldoktor/following{/other_user}","gists_url":"https://api.github.com/users/ldoktor/gists{/gist_id}","starred_url":"https://api.github.com/users/ldoktor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ldoktor/subscriptions","organizations_url":"https://api.github.com/users/ldoktor/orgs","repos_url":"https://api.github.com/users/ldoktor/repos","events_url":"https://api.github.com/users/ldoktor/events{/privacy}","received_events_url":"https://api.github.com/users/ldoktor/received_events","type":"User","site_admin":false},"html_url":"https://github.com/ldoktor/avocado","description":"Avocado Test Framework","fork":true,"url":"https://api.github.com/repos/ldoktor/avocado","forks_url":"https://api.github.com/repos/ldoktor/avocado/forks","keys_url":"https://api.github.com/repos/ldoktor/avocado/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ldoktor/avocado/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ldoktor/avocado/teams","hooks_url":"https://api.github.com/repos/ldoktor/avocado/hooks","issue_events_url":"https://api.github.com/repos/ldoktor/avocado/issues/events{/number}","events_url":"https://api.github.com/repos/ldoktor/avocado/events","assignees_url":"https://api.github.com/repos/ldoktor/avocado/assignees{/user}","branches_url":"https://api.github.com/repos/ldoktor/avocado/branches{/branch}","tags_url":"https://api.github.com/repos/ldoktor/avocado/tags","blobs_url":"https://api.github.com/repos/ldoktor/avocado/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ldoktor/avocado/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ldoktor/avocado/git/refs{/sha}","trees_url":"https://api.github.com/repos/ldoktor/avocado/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ldoktor/avocado/statuses/{sha}","languages_url":"https://api.github.com/repos/ldoktor/avocado/languages","stargazers_url":"https://api.github.com/repos/ldoktor/avocado/stargazers","contributors_url":"https://api.github.com/repos/ldoktor/avocado/contributors","subscribers_url":"https://api.github.com/repos/ldoktor/avocado/subscribers","subscription_url":"https://api.github.com/repos/ldoktor/avocado/subscription","commits_url":"https://api.github.com/repos/ldoktor/avocado/commits{/sha}","git_commits_url":"https://api.github.com/repos/ldoktor/avocado/git/commits{/sha}","comments_url":"https://api.github.com/repos/ldoktor/avocado/comments{/number}","issue_comment_url":"https://api.github.com/repos/ldoktor/avocado/issues/comments{/number}","contents_url":"https://api.github.com/repos/ldoktor/avocado/contents/{+path}","compare_url":"https://api.github.com/repos/ldoktor/avocado/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ldoktor/avocado/merges","archive_url":"https://api.github.com/repos/ldoktor/avocado/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ldoktor/avocado/downloads","issues_url":"https://api.github.com/repos/ldoktor/avocado/issues{/number}","pulls_url":"https://api.github.com/repos/ldoktor/avocado/pulls{/number}","milestones_url":"https://api.github.com/repos/ldoktor/avocado/milestones{/number}","notifications_url":"https://api.github.com/repos/ldoktor/avocado/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ldoktor/avocado/labels{/name}","releases_url":"https://api.github.com/repos/ldoktor/avocado/releases{/id}","deployments_url":"https://api.github.com/repos/ldoktor/avocado/deployments","created_at":"2014-11-18T12:42:43Z","updated_at":"2018-05-30T04:26:53Z","pushed_at":"2018-12-11T16:09:47Z","git_url":"git://github.com/ldoktor/avocado.git","ssh_url":"git@github.com:ldoktor/avocado.git","clone_url":"https://github.com/ldoktor/avocado.git","svn_url":"https://github.com/ldoktor/avocado","homepage":"http://avocado-framework.readthedocs.org/en/latest/","size":13802,"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,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"avocado-framework:master","ref":"master","sha":"5e98ae7d6cf4d3d21dd03c6d549ad19428c0d3ea","user":{"login":"avocado-framework","id":7245719,"node_id":"MDEyOk9yZ2FuaXphdGlvbjcyNDU3MTk=","avatar_url":"https://avatars3.githubusercontent.com/u/7245719?v=4","gravatar_id":"","url":"https://api.github.com/users/avocado-framework","html_url":"https://github.com/avocado-framework","followers_url":"https://api.github.com/users/avocado-framework/followers","following_url":"https://api.github.com/users/avocado-framework/following{/other_user}","gists_url":"https://api.github.com/users/avocado-framework/gists{/gist_id}","starred_url":"https://api.github.com/users/avocado-framework/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/avocado-framework/subscriptions","organizations_url":"https://api.github.com/users/avocado-framework/orgs","repos_url":"https://api.github.com/users/avocado-framework/repos","events_url":"https://api.github.com/users/avocado-framework/events{/privacy}","received_events_url":"https://api.github.com/users/avocado-framework/received_events","type":"Organization","site_admin":false},"repo":{"id":17449498,"node_id":"MDEwOlJlcG9zaXRvcnkxNzQ0OTQ5OA==","name":"avocado","full_name":"avocado-framework/avocado","private":false,"owner":{"login":"avocado-framework","id":7245719,"node_id":"MDEyOk9yZ2FuaXphdGlvbjcyNDU3MTk=","avatar_url":"https://avatars3.githubusercontent.com/u/7245719?v=4","gravatar_id":"","url":"https://api.github.com/users/avocado-framework","html_url":"https://github.com/avocado-framework","followers_url":"https://api.github.com/users/avocado-framework/followers","following_url":"https://api.github.com/users/avocado-framework/following{/other_user}","gists_url":"https://api.github.com/users/avocado-framework/gists{/gist_id}","starred_url":"https://api.github.com/users/avocado-framework/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/avocado-framework/subscriptions","organizations_url":"https://api.github.com/users/avocado-framework/orgs","repos_url":"https://api.github.com/users/avocado-framework/repos","events_url":"https://api.github.com/users/avocado-framework/events{/privacy}","received_events_url":"https://api.github.com/users/avocado-framework/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/avocado-framework/avocado","description":"Avocado Test Framework","fork":false,"url":"https://api.github.com/repos/avocado-framework/avocado","forks_url":"https://api.github.com/repos/avocado-framework/avocado/forks","keys_url":"https://api.github.com/repos/avocado-framework/avocado/keys{/key_id}","collaborators_url":"https://api.github.com/repos/avocado-framework/avocado/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/avocado-framework/avocado/teams","hooks_url":"https://api.github.com/repos/avocado-framework/avocado/hooks","issue_events_url":"https://api.github.com/repos/avocado-framework/avocado/issues/events{/number}","events_url":"https://api.github.com/repos/avocado-framework/avocado/events","assignees_url":"https://api.github.com/repos/avocado-framework/avocado/assignees{/user}","branches_url":"https://api.github.com/repos/avocado-framework/avocado/branches{/branch}","tags_url":"https://api.github.com/repos/avocado-framework/avocado/tags","blobs_url":"https://api.github.com/repos/avocado-framework/avocado/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/avocado-framework/avocado/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/avocado-framework/avocado/git/refs{/sha}","trees_url":"https://api.github.com/repos/avocado-framework/avocado/git/trees{/sha}","statuses_url":"https://api.github.com/repos/avocado-framework/avocado/statuses/{sha}","languages_url":"https://api.github.com/repos/avocado-framework/avocado/languages","stargazers_url":"https://api.github.com/repos/avocado-framework/avocado/stargazers","contributors_url":"https://api.github.com/repos/avocado-framework/avocado/contributors","subscribers_url":"https://api.github.com/repos/avocado-framework/avocado/subscribers","subscription_url":"https://api.github.com/repos/avocado-framework/avocado/subscription","commits_url":"https://api.github.com/repos/avocado-framework/avocado/commits{/sha}","git_commits_url":"https://api.github.com/repos/avocado-framework/avocado/git/commits{/sha}","comments_url":"https://api.github.com/repos/avocado-framework/avocado/comments{/number}","issue_comment_url":"https://api.github.com/repos/avocado-framework/avocado/issues/comments{/number}","contents_url":"https://api.github.com/repos/avocado-framework/avocado/contents/{+path}","compare_url":"https://api.github.com/repos/avocado-framework/avocado/compare/{base}...{head}","merges_url":"https://api.github.com/repos/avocado-framework/avocado/merges","archive_url":"https://api.github.com/repos/avocado-framework/avocado/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/avocado-framework/avocado/downloads","issues_url":"https://api.github.com/repos/avocado-framework/avocado/issues{/number}","pulls_url":"https://api.github.com/repos/avocado-framework/avocado/pulls{/number}","milestones_url":"https://api.github.com/repos/avocado-framework/avocado/milestones{/number}","notifications_url":"https://api.github.com/repos/avocado-framework/avocado/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/avocado-framework/avocado/labels{/name}","releases_url":"https://api.github.com/repos/avocado-framework/avocado/releases{/id}","deployments_url":"https://api.github.com/repos/avocado-framework/avocado/deployments","created_at":"2014-03-05T17:52:27Z","updated_at":"2018-12-13T17:32:14Z","pushed_at":"2018-12-13T18:25:52Z","git_url":"git://github.com/avocado-framework/avocado.git","ssh_url":"git@github.com:avocado-framework/avocado.git","clone_url":"https://github.com/avocado-framework/avocado.git","svn_url":"https://github.com/avocado-framework/avocado","homepage":"http://avocado-framework.github.io/","size":13029,"stargazers_count":168,"watchers_count":168,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":185,"mirror_url":null,"archived":false,"open_issues_count":22,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":185,"open_issues":22,"watchers":168,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/avocado-framework/avocado/pulls/2957"},"html":{"href":"https://github.com/avocado-framework/avocado/pull/2957"},"issue":{"href":"https://api.github.com/repos/avocado-framework/avocado/issues/2957"},"comments":{"href":"https://api.github.com/repos/avocado-framework/avocado/issues/2957/comments"},"review_comments":{"href":"https://api.github.com/repos/avocado-framework/avocado/pulls/2957/comments"},"review_comment":{"href":"https://api.github.com/repos/avocado-framework/avocado/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/avocado-framework/avocado/pulls/2957/commits"},"statuses":{"href":"https://api.github.com/repos/avocado-framework/avocado/statuses/6c63153fc03a92b32bc73ed2b2365e6b2b693f90"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"ldoktor"}}