From 31d4353bf19d00a786c9c3258a34c1189d1ef1a8 Mon Sep 17 00:00:00 2001 From: Kota Tsuyuzaki Date: Tue, 17 Jan 2017 18:12:52 -0800 Subject: [PATCH] Bump minimum Swift requirement to Ocata stable And this also removes redundant code to support Swift < 2.6.0. Change-Id: I978f9dcc1433f66e62cab76a05525714eba75c64 --- requirements.txt | 2 +- swift3/controllers/multi_upload.py | 18 ++++---------- swift3/test/unit/test_multi_upload.py | 35 ++++++++++----------------- tox.ini | 4 +-- 4 files changed, 21 insertions(+), 38 deletions(-) diff --git a/requirements.txt b/requirements.txt index d94d893c..4c0edf3c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -swift>=2.1.0 +swift>=2.13.0 lxml requests!=2.9.0,>=2.8.1 # Apache-2.0 six>=1.9.0 diff --git a/swift3/controllers/multi_upload.py b/swift3/controllers/multi_upload.py index 1039122e..106da0e6 100644 --- a/swift3/controllers/multi_upload.py +++ b/swift3/controllers/multi_upload.py @@ -566,11 +566,9 @@ class UploadController(Controller): if manifest[-1]['size_bytes'] == 0: empty_seg = manifest.pop() - # Ordinarily, we just let SLO check segment sizes. However, we - # just popped off a zero-byte segment; if there was a second - # zero-byte segment and it was at the end, it would succeed on - # Swift < 2.6.0 and fail on newer Swift. It seems reasonable that - # it should always fail. + # We'll check the sizes of all except the last segment below, but + # since we just popped off a zero-byte segment, we should check + # that last segment, too. if manifest and manifest[-1]['size_bytes'] < CONF.min_segment_size: raise EntityTooSmall() @@ -594,14 +592,8 @@ class UploadController(Controller): headers=headers) except BadSwiftRequest as e: msg = str(e) - msg_pre_260 = 'Each segment, except the last, must be at least ' - # see https://github.com/openstack/swift/commit/c0866ce - msg_260 = ('too small; each segment, except the last, must be ' - 'at least ') - # see https://github.com/openstack/swift/commit/7f636a5 - msg_post_260 = 'too small; each segment must be at least 1 byte' - if msg.startswith(msg_pre_260) or \ - msg_260 in msg or msg_post_260 in msg: + expected_msg = 'too small; each segment must be at least 1 byte' + if expected_msg in msg: # FIXME: AWS S3 allows a smaller object than 5 MB if there is # only one part. Use a COPY request to copy the part object # from the segments container instead. diff --git a/swift3/test/unit/test_multi_upload.py b/swift3/test/unit/test_multi_upload.py index 2423cdc9..020b4dd4 100644 --- a/swift3/test/unit/test_multi_upload.py +++ b/swift3/test/unit/test_multi_upload.py @@ -652,30 +652,21 @@ class TestSwift3MultiUpload(Swift3TestCase): self.assertEqual(headers.get('X-Object-Meta-Foo'), 'bar') def test_object_multipart_upload_complete_segment_too_small(self): - msgs = [ - # pre-2.6.0 swift - 'Each segment, except the last, must be at least 1234 bytes.', - # swift 2.6.0 - 'Index 0: too small; each segment, except the last, must be ' - 'at least 1234 bytes.', - # swift 2.7.0+ - 'Index 0: too small; each segment must be at least 1 byte.', - ] + msg = 'Index 0: too small; each segment must be at least 1 byte.' - for msg in msgs: - req = Request.blank( - '/bucket/object?uploadId=X', - environ={'REQUEST_METHOD': 'POST'}, - headers={'Authorization': 'AWS test:tester:hmac', - 'Date': self.get_date_header(), }, - body=xml) + req = Request.blank( + '/bucket/object?uploadId=X', + environ={'REQUEST_METHOD': 'POST'}, + headers={'Authorization': 'AWS test:tester:hmac', + 'Date': self.get_date_header(), }, + body=xml) - self.swift.register('PUT', '/v1/AUTH_test/bucket/object', - swob.HTTPBadRequest, {}, msg) - status, headers, body = self.call_swift3(req) - self.assertEqual(status.split()[0], '400') - self.assertEqual(self._get_error_code(body), 'EntityTooSmall') - self.assertEqual(self._get_error_message(body), msg) + self.swift.register('PUT', '/v1/AUTH_test/bucket/object', + swob.HTTPBadRequest, {}, msg) + status, headers, body = self.call_swift3(req) + self.assertEqual(status.split()[0], '400') + self.assertEqual(self._get_error_code(body), 'EntityTooSmall') + self.assertEqual(self._get_error_message(body), msg) self.swift.clear_calls() CONF.min_segment_size = 5242880 diff --git a/tox.ini b/tox.ini index da3f5b78..f1ad2c82 100644 --- a/tox.ini +++ b/tox.ini @@ -7,10 +7,10 @@ skipsdist = True whitelist_externals =/bin/bash usedevelop = True install_command = pip install {opts} {packages} -# swift 2.7.0 from github +# swift stable/ocata (about 2.13.0) from openstack.org deps = -r{toxinidir}/test-requirements.txt - http://tarballs.openstack.org/swift/swift-2.7.0.tar.gz + http://tarballs.openstack.org/swift/swift-stable-ocata.tar.gz commands = nosetests {posargs:swift3/test/unit} setenv = VIRTUAL_ENV={envdir} NOSE_WITH_OPENSTACK=1