Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9346639
D2049.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Subscribers
None
D2049.diff
View Options
diff --git a/swh/objstorage/tests/test_objstorage_azure.py b/swh/objstorage/tests/test_objstorage_azure.py
--- a/swh/objstorage/tests/test_objstorage_azure.py
+++ b/swh/objstorage/tests/test_objstorage_azure.py
@@ -14,6 +14,7 @@
from swh.objstorage import get_objstorage
from swh.objstorage.objstorage import decompressors
+from swh.objstorage.exc import Error
from .objstorage_testing import ObjStorageTestFixture
@@ -99,6 +100,23 @@
assert d.decompress(raw_blob.content) == content
assert d.unused_data == b''
+ def test_trailing_data_on_stored_blob(self):
+ content, obj_id = self.hash_content(b'test content without garbage')
+ self.storage.add(content, obj_id=obj_id)
+
+ blob_service, container = self.storage.get_blob_service(obj_id)
+ internal_id = self.storage._internal_id(obj_id)
+
+ blob_service._data[container][internal_id] += b'trailing garbage'
+
+ if self.compression is not None:
+ with self.assertRaises(Error) as e:
+ self.storage.get(obj_id)
+ assert 'trailing data' in e.exception.args[0]
+ else:
+ with self.assertRaises(Error) as e:
+ self.storage.check(obj_id)
+
class TestAzureCloudObjStorageGzip(TestAzureCloudObjStorage):
compression = 'gzip'
diff --git a/swh/objstorage/tests/test_objstorage_cloud.py b/swh/objstorage/tests/test_objstorage_cloud.py
--- a/swh/objstorage/tests/test_objstorage_cloud.py
+++ b/swh/objstorage/tests/test_objstorage_cloud.py
@@ -13,6 +13,7 @@
from swh.model import hashutil
from swh.objstorage.objstorage import decompressors
+from swh.objstorage.exc import Error
from swh.objstorage.backends.libcloud import CloudObjStorage
from .objstorage_testing import ObjStorageTestFixture
@@ -115,6 +116,23 @@
assert d.decompress(raw_content) == content
assert d.unused_data == b''
+ def test_trailing_data_on_stored_blob(self):
+ content, obj_id = self.hash_content(b'test content without garbage')
+ self.storage.add(content, obj_id=obj_id)
+
+ data = self.storage.driver.containers[CONTAINER_NAME]
+ obj_id = hashutil.hash_to_hex(obj_id)
+
+ data[obj_id].content.append(b'trailing garbage')
+
+ if self.compression is not None:
+ with self.assertRaises(Error) as e:
+ self.storage.get(obj_id)
+ assert 'trailing data' in e.exception.args[0]
+ else:
+ with self.assertRaises(Error) as e:
+ self.storage.check(obj_id)
+
class TestCloudObjStorageBz2(TestCloudObjStorage):
compression = 'bz2'
diff --git a/swh/objstorage/tests/test_objstorage_seaweedfs.py b/swh/objstorage/tests/test_objstorage_seaweedfs.py
--- a/swh/objstorage/tests/test_objstorage_seaweedfs.py
+++ b/swh/objstorage/tests/test_objstorage_seaweedfs.py
@@ -8,6 +8,7 @@
from typing import Optional
from swh.objstorage.objstorage import decompressors
+from swh.objstorage.exc import Error
from swh.objstorage.backends.seaweed import WeedObjStorage, DEFAULT_LIMIT
from swh.objstorage.tests.objstorage_testing import ObjStorageTestFixture
@@ -60,6 +61,21 @@
assert d.decompress(raw_content) == content
assert d.unused_data == b''
+ def test_trailing_data_on_stored_blob(self):
+ content, obj_id = self.hash_content(b'test content without garbage')
+ self.storage.add(content, obj_id=obj_id)
+
+ path = self.storage._path(obj_id)
+ self.storage.wf.content[path] += b'trailing garbage'
+
+ if self.compression is not None:
+ with self.assertRaises(Error) as e:
+ self.storage.get(obj_id)
+ assert 'trailing data' in e.exception.args[0]
+ else:
+ with self.assertRaises(Error) as e:
+ self.storage.check(obj_id)
+
class TestWeedObjStorageBz2(TestWeedObjStorage):
compression = 'bz2'
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Jul 3, 4:17 PM (2 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3214682
Attached To
D2049: Add tests for the behavior on trailing data after the compressed blob
Event Timeline
Log In to Comment