This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Compare to the earliest known stream pos in the stream change cache. (#…
…14435) The internal methods of the StreamChangeCache were inconsistently treating the earliest known stream position as valid. It is now treated as invalid, meaning the cache cannot determine if an entity at the earliest known stream position has changed or not.
- Loading branch information
Showing
5 changed files
with
133 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fix a long-standing bug where a device list update might not be sent to clients in certain circumstances. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,6 +51,8 @@ def test_has_entity_changed(self) -> None: | |
# return True, whether it's a known entity or not. | ||
self.assertTrue(cache.has_entity_changed("[email protected]", 0)) | ||
self.assertTrue(cache.has_entity_changed("[email protected]", 0)) | ||
self.assertTrue(cache.has_entity_changed("[email protected]", 3)) | ||
self.assertTrue(cache.has_entity_changed("[email protected]", 3)) | ||
|
||
def test_entity_has_changed_pops_off_start(self) -> None: | ||
""" | ||
|
@@ -65,26 +67,25 @@ def test_entity_has_changed_pops_off_start(self) -> None: | |
|
||
# The cache is at the max size, 2 | ||
self.assertEqual(len(cache._cache), 2) | ||
# The cache's earliest known position is 2. | ||
self.assertEqual(cache._earliest_known_stream_pos, 2) | ||
|
||
# The oldest item has been popped off | ||
self.assertTrue("[email protected]" not in cache._entity_to_key) | ||
|
||
self.assertEqual( | ||
cache.get_all_entities_changed(2), | ||
["[email protected]", "[email protected]"], | ||
) | ||
self.assertIsNone(cache.get_all_entities_changed(1)) | ||
self.assertEqual(cache.get_all_entities_changed(3), ["[email protected]"]) | ||
self.assertIsNone(cache.get_all_entities_changed(2)) | ||
|
||
# If we update an existing entity, it keeps the two existing entities | ||
cache.entity_has_changed("[email protected]", 5) | ||
self.assertEqual( | ||
{"[email protected]", "[email protected]"}, set(cache._entity_to_key) | ||
) | ||
self.assertEqual( | ||
cache.get_all_entities_changed(2), | ||
cache.get_all_entities_changed(3), | ||
["[email protected]", "[email protected]"], | ||
) | ||
self.assertIsNone(cache.get_all_entities_changed(1)) | ||
self.assertIsNone(cache.get_all_entities_changed(2)) | ||
|
||
def test_get_all_entities_changed(self) -> None: | ||
""" | ||
|
@@ -99,28 +100,15 @@ def test_get_all_entities_changed(self) -> None: | |
cache.entity_has_changed("[email protected]", 3) | ||
cache.entity_has_changed("[email protected]", 4) | ||
|
||
r = cache.get_all_entities_changed(1) | ||
r = cache.get_all_entities_changed(2) | ||
|
||
# either of these are valid | ||
ok1 = [ | ||
"[email protected]", | ||
"[email protected]", | ||
"[email protected]", | ||
"[email protected]", | ||
] | ||
ok2 = [ | ||
"[email protected]", | ||
"[email protected]", | ||
"[email protected]", | ||
"[email protected]", | ||
] | ||
# Results are ordered so either of these are valid. | ||
ok1 = ["[email protected]", "[email protected]", "[email protected]"] | ||
ok2 = ["[email protected]", "[email protected]", "[email protected]"] | ||
self.assertTrue(r == ok1 or r == ok2) | ||
|
||
r = cache.get_all_entities_changed(2) | ||
self.assertTrue(r == ok1[1:] or r == ok2[1:]) | ||
|
||
self.assertEqual(cache.get_all_entities_changed(3), ["[email protected]"]) | ||
self.assertEqual(cache.get_all_entities_changed(0), None) | ||
self.assertEqual(cache.get_all_entities_changed(1), None) | ||
|
||
# ... later, things gest more updates | ||
cache.entity_has_changed("[email protected]", 5) | ||
|