Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F7163771
D5017.id17889.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
D5017.id17889.diff
View Options
diff --git a/swh/storage/tests/test_buffer.py b/swh/storage/tests/test_buffer.py
--- a/swh/storage/tests/test_buffer.py
+++ b/swh/storage/tests/test_buffer.py
@@ -3,6 +3,8 @@
# License: GNU General Public License version 3, or any later version
# See top-level LICENSE file for more information
+from unittest.mock import Mock
+
from swh.storage import get_storage
from swh.storage.buffer import BufferingProxyStorage
@@ -481,3 +483,43 @@
storage = get_storage_with_buffer_config()
assert storage is not None
+
+
+def test_buffer_operation_order(sample_data) -> None:
+ storage = get_storage_with_buffer_config()
+
+ # Wrap the inner storage in a mock to track all method calls.
+ storage.storage = mocked_storage = Mock(wraps=storage.storage)
+
+ # Simulate a loader: add contents, directories, revisions, releases, then
+ # snapshots.
+ storage.content_add(sample_data.contents)
+ storage.skipped_content_add(sample_data.skipped_contents)
+ storage.directory_add(sample_data.directories)
+ storage.revision_add(sample_data.revisions)
+ storage.release_add(sample_data.releases)
+ storage.snapshot_add(sample_data.snapshots)
+
+ # Check that nothing has been flushed yet
+ assert mocked_storage.method_calls == []
+
+ # Flush all the things
+ storage.flush()
+
+ methods_called = [c[0] for c in mocked_storage.method_calls]
+ prev = 0
+ for method in [
+ "content_add",
+ "skipped_content_add",
+ "directory_add",
+ "revision_add",
+ "release_add",
+ "snapshot_add",
+ ]:
+ cur = methods_called.index(method)
+ assert cur is not None, "Method %s not called" % method
+ assert cur > prev, "Method %s called out of order; all calls were: %s" % (
+ method,
+ methods_called,
+ )
+ prev = cur
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Jan 30, 3:13 PM (7 h, 9 m ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3235092
Attached To
D5017: buffer: ensure objects are added in topological order
Event Timeline
Log In to Comment