summaryrefslogtreecommitdiff
path: root/tests/unit/utils.py
diff options
context:
space:
mode:
authorTimur Alperovich <timuralp@swiftstack.com>2017-06-28 12:02:21 -0700
committerTim Burke <tim.burke@gmail.com>2018-01-18 04:56:12 +0000
commit2faea932870956583f83226886d33304ee1eee46 (patch)
tree0d23a3d3389d506d5564613c296e0e92736f5cd6 /tests/unit/utils.py
parenta9b8f0a0d191873ac88b0c70166a2b889096fa69 (diff)
downloadpython-swiftclient-2faea932870956583f83226886d33304ee1eee46.tar.gz
Allow for object uploads > 5GB from stdin.
When uploading from standard input, swiftclient should turn the upload into an SLO in the case of large objects. This patch picks the threshold as 10MB (and uses that as the default segment size). The consumers can also supply the --segment-size option to alter that threshold and the SLO segment size. The patch does buffer one segment in memory (which is why 10MB default was chosen). (test is updated) Change-Id: Ib13e0b687bc85930c29fe9f151cf96bc53b2e594
Diffstat (limited to 'tests/unit/utils.py')
-rw-r--r--tests/unit/utils.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/unit/utils.py b/tests/unit/utils.py
index c05146e..2def73f 100644
--- a/tests/unit/utils.py
+++ b/tests/unit/utils.py
@@ -548,3 +548,24 @@ def _make_fake_import_keystone_client(fake_import):
return fake_import, fake_import
return _fake_import_keystone_client
+
+
+class FakeStream(object):
+ def __init__(self, size):
+ self.bytes_read = 0
+ self.size = size
+
+ def read(self, size=-1):
+ if self.bytes_read == self.size:
+ return b''
+
+ if size == -1 or size + self.bytes_read > self.size:
+ remaining = self.size - self.bytes_read
+ self.bytes_read = self.size
+ return b'A' * remaining
+
+ self.bytes_read += size
+ return b'A' * size
+
+ def __len__(self):
+ return self.size