Title: Cache flush bit test fails because ServiceInfo will use expired records from the cache · Issue #738 · python-zeroconf/python-zeroconf · GitHub
Open Graph Title: Cache flush bit test fails because ServiceInfo will use expired records from the cache · Issue #738 · python-zeroconf/python-zeroconf
X Title: Cache flush bit test fails because ServiceInfo will use expired records from the cache · Issue #738 · python-zeroconf/python-zeroconf
Description: @pytest.mark.asyncio async def test_cache_flush_bit(): """Test that the cache flush bit sets the TTL to one for matching records.""" # instantiate a zeroconf instance aiozc = AsyncZeroconf(interfaces=['127.0.0.1']) zc = aiozc.zeroconf ty...
Open Graph Description: @pytest.mark.asyncio async def test_cache_flush_bit(): """Test that the cache flush bit sets the TTL to one for matching records.""" # instantiate a zeroconf instance aiozc = AsyncZeroconf(interfac...
X Description: @pytest.mark.asyncio async def test_cache_flush_bit(): """Test that the cache flush bit sets the TTL to one for matching records.""" # instantiate a zeroconf instance ...
Opengraph URL: https://github.com/python-zeroconf/python-zeroconf/issues/738
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Cache flush bit test fails because ServiceInfo will use expired records from the cache","articleBody":"```\r\n\r\n @pytest.mark.asyncio\r\n async def test_cache_flush_bit():\r\n \"\"\"Test that the cache flush bit sets the TTL to one for matching records.\"\"\"\r\n # instantiate a zeroconf instance\r\n aiozc = AsyncZeroconf(interfaces=['127.0.0.1'])\r\n zc = aiozc.zeroconf\r\n \r\n type_ = \"_cacheflush._tcp.local.\"\r\n name = \"knownname\"\r\n registration_name = \"%s.%s\" % (name, type_)\r\n desc = {'path': '/~paulsm/'}\r\n server_name = \"server-uu1.local.\"\r\n info = ServiceInfo(\r\n type_, registration_name, 80, 0, 0, desc, server_name, addresses=[socket.inet_aton(\"10.0.1.2\")]\r\n )\r\n a_record = info.dns_addresses()[0]\r\n zc.cache.async_add_records([info.dns_pointer(), a_record, info.dns_text(), info.dns_service()])\r\n \r\n info.addresses = [socket.inet_aton(\"10.0.1.5\"), socket.inet_aton(\"10.0.1.6\")]\r\n new_records = info.dns_addresses()\r\n for new_record in new_records:\r\n assert new_record.unique is True\r\n \r\n original_a_record = zc.cache.async_get_unique(a_record)\r\n # Do the run within 1s to verify the original record is not going to be expired\r\n out = r.DNSOutgoing(const._FLAGS_QR_RESPONSE | const._FLAGS_AA, multicast=True)\r\n for answer in new_records:\r\n out.add_answer_at_time(answer, 0)\r\n for packet in out.packets():\r\n zc.record_manager.async_updates_from_response(r.DNSIncoming(packet))\r\n assert zc.cache.async_get_unique(a_record) is original_a_record\r\n assert original_a_record.ttl != 1\r\n for record in new_records:\r\n assert zc.cache.async_get_unique(record) is not None\r\n \r\n original_a_record.created = current_time_millis() - 1001\r\n \r\n # Do the run within 1s to verify the original record is not going to be expired\r\n out = r.DNSOutgoing(const._FLAGS_QR_RESPONSE | const._FLAGS_AA, multicast=True)\r\n for answer in new_records:\r\n out.add_answer_at_time(answer, 0)\r\n for packet in out.packets():\r\n zc.record_manager.async_updates_from_response(r.DNSIncoming(packet))\r\n assert original_a_record.ttl == 1\r\n for record in new_records:\r\n assert zc.cache.async_get_unique(record) is not None\r\n \r\n cached_records = [zc.cache.async_get_unique(record) for record in new_records]\r\n for record in cached_records:\r\n record.created = current_time_millis() - 1001\r\n \r\n fresh_address = socket.inet_aton(\"4.4.4.4\")\r\n info.addresses = [fresh_address]\r\n # Do the run within 1s to verify the two new records get marked as expired\r\n out = r.DNSOutgoing(const._FLAGS_QR_RESPONSE | const._FLAGS_AA, multicast=True)\r\n for answer in info.dns_addresses():\r\n out.add_answer_at_time(answer, 0)\r\n for packet in out.packets():\r\n zc.record_manager.async_updates_from_response(r.DNSIncoming(packet))\r\n for record in cached_records:\r\n assert record.ttl == 1\r\n \r\n for entry in zc.cache.async_all_by_details(server_name, const._TYPE_A, const._CLASS_IN):\r\n if entry.address == fresh_address:\r\n assert entry.ttl > 1\r\n else:\r\n assert entry.ttl == 1\r\n \r\n # Wait for the ttl 1 records to expire\r\n await asyncio.sleep(1.01)\r\n \r\n loaded_info = r.ServiceInfo(type_, registration_name)\r\n loaded_info.load_from_cache(zc)\r\n> assert loaded_info.addresses == info.addresses\r\nE AssertionError: assert [b'\\n\\x00\\x01...\\x04\\x04\\x04'] == [b'\\x04\\x04\\x04\\x04']\r\nE At index 0 diff: b'\\n\\x00\\x01\\x02' != b'\\x04\\x04\\x04\\x04'\r\nE Left contains 3 more items, first extra item: b'\\n\\x00\\x01\\x05'\r\nE Full diff:\r\nE - [b'\\x04\\x04\\x04\\x04']\r\nE + [b'\\n\\x00\\x01\\x02', b'\\n\\x00\\x01\\x05', b'\\n\\x00\\x01\\x06', b'\\x04\\x04\\x04\\x04']\r\n\r\ntests\\test_handlers.py:915: AssertionError\r\n```","author":{"url":"https://github.com/bdraco","@type":"Person","name":"bdraco"},"datePublished":"2021-06-19T04:11:12Z","url":"https://github.com/python-zeroconf/python-zeroconf/issues/738"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:d9872b4a-0ae2-daf8-44fb-4da300ce99cc |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C948:2CAE80:9A4453:D406E5:6B00A673 |
| html-safe-nonce | 390ca5f5fdb79220291d85f7988189676d31693bd74879b4c0b7fea2ba353344 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDOTQ4OjJDQUU4MDo5QTQ0NTM6RDQwNkU1OjZCMDBBNjczIiwidmlzaXRvcl9pZCI6IjU5OTkyMTUxOTEzNDA5MTgzODciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 4c50c65cef2df83dd1714181bcc3c3b383c2874efb330dca2afeaac23fb9e5b5 |
| hovercard-subject-tag | issue:925310543 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python-zeroconf/python-zeroconf/738/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b0378ad84502cd4047bd6190973c6fdd83438d98f659529914bf6859ff7484de/python-zeroconf/python-zeroconf/issues/738 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b0378ad84502cd4047bd6190973c6fdd83438d98f659529914bf6859ff7484de/python-zeroconf/python-zeroconf/issues/738 |
| og:image:alt | @pytest.mark.asyncio async def test_cache_flush_bit(): """Test that the cache flush bit sets the TTL to one for matching records.""" # instantiate a zeroconf instance aiozc = AsyncZeroconf(interfac... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | bdraco |
| hostname | github.com |
| expected-hostname | github.com |
| None | 455b493e3402a3a3a06beac5d20bb7db3da060808b220aa48d6a7eca7c59863a |
| turbo-cache-control | no-preview |
| go-import | github.com/python-zeroconf/python-zeroconf git https://github.com/python-zeroconf/python-zeroconf.git |
| octolytics-dimension-user_id | 120192235 |
| octolytics-dimension-user_login | python-zeroconf |
| octolytics-dimension-repository_id | 21548731 |
| octolytics-dimension-repository_nwo | python-zeroconf/python-zeroconf |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 21548731 |
| octolytics-dimension-repository_network_root_nwo | python-zeroconf/python-zeroconf |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 2f575159976167242d488c0b062eb355c4e198b7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width