Esempio n. 1
0
 def test_handle_upload_object_head_first_missing(self):
     object_name = '/foo/bar/SP000001'
     object_info = {
         'type': ssbench.CREATE_OBJECT,
         'container': 'Picture',
         'name': object_name,
         'size': 99000,
         'head_first': True,
         'block_size': None,
         'delete_after': None,
     }
     self.mock_worker.should_receive('ignoring_http_responses').with_args(
         (503, ),
         client.head_object,
         object_info,
     ).and_raise(client.ClientException('oh noes!')).once
     self.mock_worker.should_receive('ignoring_http_responses').with_args(
         (503, ),
         client.put_object,
         object_info,
         content_length=99000,
         chunk_size=worker.DEFAULT_BLOCK_SIZE,
         contents='A' * worker.DEFAULT_BLOCK_SIZE,
         headers={},
     ).and_return({
         'x-swiftstack-first-byte-latency': 0.3248,
         'x-swiftstack-last-byte-latency': 4.493,
         'x-trans-id': 'evn',
         'retries': 0,
     }).once
     self.time_expectation.once
     exp_put = add_dicts(object_info,
                         worker_id=self.worker_id,
                         first_byte_latency=0.3248,
                         last_byte_latency=4.493,
                         trans_id='evn',
                         completed_at=self.stub_time,
                         retries=0)
     exp_put.pop('head_first')
     exp_put.pop('block_size')
     self.result_queue.should_receive('put').with_args(exp_put).once
     self.mock_worker.handle_upload_object(object_info)
Esempio n. 2
0
    def test_dispatching_client_exception(self):
        info = {'type': ssbench.READ_OBJECT, 'container': 'fun', 'a': 2}
        wrappedException = client.ClientException('slam bam')
        wrappedException.retries = 3
        self.mock_worker.should_receive('handle_get_object').with_args(
            info).and_raise(wrappedException).once
        got = []
        self.result_queue.should_receive('put').replace_with(
            lambda value: got.append(value)).once

        self.mock_worker.handle_job(info)
        assert_equal(1, len(got), repr(got))
        traceback = got[0].pop('traceback')
        assert_true(traceback.startswith('Traceback'),
                    'Traceback did not start with Traceback: %s' % traceback)
        assert_equal(
            add_dicts(
                info, worker_id=self.worker_id, completed_at=self.stub_time,
                exception=repr(wrappedException),
                retries=3),
            got[0])
Esempio n. 3
0
 def _raise_401(**args):
     raise client.ClientException('oh noes!', http_status=401)