diff --git a/tempest/api/object_storage/test_object_services.py b/tempest/api/object_storage/test_object_services.py index 61cbe30a28..4dd8ab059c 100644 --- a/tempest/api/object_storage/test_object_services.py +++ b/tempest/api/object_storage/test_object_services.py @@ -48,8 +48,9 @@ class ObjectTest(base.BaseObjectTest): data_segments = [data + str(i) for i in range(segments)] # uploading segments for i in range(segments): - self.object_client.create_object_segments( - self.container_name, object_name, i, data_segments[i]) + obj_name = "%s/%s" % (object_name, i) + self.object_client.create_object( + self.container_name, obj_name, data_segments[i]) return object_name, data_segments @@ -184,12 +185,15 @@ class ObjectTest(base.BaseObjectTest): # create object with transfer_encoding object_name = data_utils.rand_name(name='TestObject') data = data_utils.random_bytes(1024) - _, _, resp_headers = self.object_client.put_object_with_chunk( - container=self.container_name, - name=object_name, - contents=data_utils.chunkify(data, 512) - ) - self.assertHeaders(resp_headers, 'Object', 'PUT') + headers = {'Transfer-Encoding': 'chunked'} + resp, _ = self.object_client.create_object( + self.container_name, + object_name, + data=data_utils.chunkify(data, 512), + headers=headers, + chunked=True) + + self.assertHeaders(resp, 'Object', 'PUT') # check uploaded content _, body = self.object_client.get_object(self.container_name, @@ -728,8 +732,13 @@ class ObjectTest(base.BaseObjectTest): dst_object_name, dst_data) # copy source object to destination - resp, _ = self.object_client.copy_object_in_same_container( - self.container_name, src_object_name, dst_object_name) + headers = {} + headers['X-Copy-From'] = "%s/%s" % (str(self.container_name), + str(src_object_name)) + resp, body = self.object_client.create_object(self.container_name, + dst_object_name, + data=None, + headers=headers) self.assertHeaders(resp, 'Object', 'PUT') # check data @@ -749,8 +758,14 @@ class ObjectTest(base.BaseObjectTest): # change the content type of the object metadata = {'content-type': 'text/plain; charset=UTF-8'} self.assertNotEqual(resp_tmp['content-type'], metadata['content-type']) - resp, _ = self.object_client.copy_object_in_same_container( - self.container_name, object_name, object_name, metadata) + headers = {} + headers['X-Copy-From'] = "%s/%s" % (str(self.container_name), + str(object_name)) + resp, body = self.object_client.create_object(self.container_name, + object_name, + data=None, + metadata=metadata, + headers=headers) self.assertHeaders(resp, 'Object', 'PUT') # check the content type @@ -808,9 +823,13 @@ class ObjectTest(base.BaseObjectTest): self.assertHeaders(resp, 'Object', 'POST') # copy object from source container to destination container - resp, _ = self.object_client.copy_object_across_containers( - src_container_name, object_name, dst_container_name, - object_name) + headers = {} + headers['X-Copy-From'] = "%s/%s" % (str(src_container_name), + str(object_name)) + resp, body = self.object_client.create_object(dst_container_name, + object_name, + data=None, + headers=headers) self.assertHeaders(resp, 'Object', 'PUT') # check if object is present in destination container @@ -897,8 +916,9 @@ class ObjectTest(base.BaseObjectTest): data_segments = [data + str(i) for i in range(segments)] # uploading segments for i in range(segments): - resp, _ = self.object_client.create_object_segments( - self.container_name, object_name, i, data_segments[i]) + obj_name = "%s/%s" % (object_name, i) + resp, _ = self.object_client.create_object( + self.container_name, obj_name, data_segments[i]) # creating a manifest file metadata = {'X-Object-Manifest': '%s/%s/' % (self.container_name, object_name)} diff --git a/tempest/services/object_storage/object_client.py b/tempest/services/object_storage/object_client.py index 6d656ec57a..24532dda3c 100644 --- a/tempest/services/object_storage/object_client.py +++ b/tempest/services/object_storage/object_client.py @@ -23,7 +23,8 @@ from tempest.lib import exceptions class ObjectClient(rest_client.RestClient): def create_object(self, container, object_name, data, - params=None, metadata=None, headers=None): + params=None, metadata=None, headers=None, + chunked=False): """Create storage object.""" if headers is None: @@ -37,7 +38,7 @@ class ObjectClient(rest_client.RestClient): if params: url += '?%s' % urlparse.urlencode(params) - resp, body = self.put(url, data, headers) + resp, body = self.put(url, data, headers, chunked=chunked) self.expected_success(201, resp.status) return resp, body @@ -84,41 +85,6 @@ class ObjectClient(rest_client.RestClient): self.expected_success([200, 206], resp.status) return resp, body - def copy_object_in_same_container(self, container, src_object_name, - dest_object_name, metadata=None): - """Copy storage object's data to the new object using PUT.""" - - url = "{0}/{1}".format(container, dest_object_name) - headers = {} - headers['X-Copy-From'] = "%s/%s" % (str(container), - str(src_object_name)) - headers['content-length'] = '0' - if metadata: - for key in metadata: - headers[str(key)] = metadata[key] - - resp, body = self.put(url, None, headers=headers) - self.expected_success(201, resp.status) - return resp, body - - def copy_object_across_containers(self, src_container, src_object_name, - dst_container, dst_object_name, - metadata=None): - """Copy storage object's data to the new object using PUT.""" - - url = "{0}/{1}".format(dst_container, dst_object_name) - headers = {} - headers['X-Copy-From'] = "%s/%s" % (str(src_container), - str(src_object_name)) - headers['content-length'] = '0' - if metadata: - for key in metadata: - headers[str(key)] = metadata[key] - - resp, body = self.put(url, None, headers=headers) - self.expected_success(201, resp.status) - return resp, body - def copy_object_2d_way(self, container, src_object_name, dest_object_name, metadata=None): """Copy storage object's data to the new object using COPY.""" @@ -135,38 +101,6 @@ class ObjectClient(rest_client.RestClient): self.expected_success(201, resp.status) return resp, body - def create_object_segments(self, container, object_name, segment, data): - """Creates object segments.""" - url = "{0}/{1}/{2}".format(container, object_name, segment) - resp, body = self.put(url, data) - self.expected_success(201, resp.status) - return resp, body - - def put_object_with_chunk(self, container, name, contents): - """Put an object with Transfer-Encoding header - - :param container: name of the container - :type container: string - :param name: name of the object - :type name: string - :param contents: object data - :type contents: iterable - """ - headers = {'Transfer-Encoding': 'chunked'} - if self.token: - headers['X-Auth-Token'] = self.token - - url = "%s/%s" % (container, name) - resp, body = self.put( - url, headers=headers, - body=contents, - chunked=True - ) - - self._error_checker(resp, body) - self.expected_success(201, resp.status) - return resp.status, resp.reason, resp - def create_object_continue(self, container, object_name, data, metadata=None): """Put an object using Expect:100-continue"""