Exemplo n.º 1
0
    def test_write_partial_exception(self):
        checksum = self.checksum()
        source = empty_stream()
        size = CHUNK_SIZE
        meta_chunk = self.meta_chunk()

        resps = [201] * (len(meta_chunk) - 1)
        resps.append(Exception("failure"))
        with set_http_connect(*resps):
            handler = ReplicatedMetachunkWriter(
                self.sysmeta, meta_chunk, checksum, self.storage_method)
            bytes_transferred, checksum, chunks = handler.stream(source, size)
        self.assertEqual(len(chunks), len(meta_chunk)-1)
        for i in range(len(meta_chunk) - 1):
            self.assertEqual(chunks[i].get('error'), None)
        # # JFS: starting at branche 3.x, it has been preferred to save only
        # #      the chunks that succeeded.
        # self.assertEqual(chunks[len(meta_chunk) - 1].get('error'), 'failure')

        self.assertEqual(bytes_transferred, 0)
        self.assertEqual(checksum, EMPTY_MD5)
Exemplo n.º 2
0
 def test_write_quorum_error(self):
     checksum = self.checksum()
     source = empty_stream()
     size = CHUNK_SIZE
     meta_chunk = self.meta_chunk()
     quorum_size = self.storage_method.quorum
     resps = [500] * quorum_size
     resps += [201] * (len(meta_chunk) - quorum_size)
     with set_http_connect(*resps):
         handler = ReplicatedMetachunkWriter(
             self.sysmeta, meta_chunk, checksum, self.storage_method)
         self.assertRaises(exc.OioException, handler.stream, source, size)
Exemplo n.º 3
0
    def test_write_timeout_source(self):
        class TestReader(object):
            def read(self, size):
                raise Timeout(1.0)

        checksum = self.checksum()
        source = TestReader()
        size = CHUNK_SIZE
        meta_chunk = self.meta_chunk()
        nb = len(meta_chunk)
        resps = [201] * nb
        with set_http_connect(*resps):
            handler = ReplicatedMetachunkWriter(self.sysmeta, meta_chunk,
                                                checksum, self.storage_method)
            self.assertRaises(exc.OioTimeout, handler.stream, source, size)
Exemplo n.º 4
0
    def test_write_exception_source(self):
        class TestReader(object):
            def read(self, size):
                raise Exception('failure')

        checksum = self.checksum()
        source = TestReader()
        size = CHUNK_SIZE
        meta_chunk = self.meta_chunk()
        nb = len(meta_chunk)
        resps = [201] * nb
        with set_http_connect(*resps):
            handler = ReplicatedMetachunkWriter(self.sysmeta, meta_chunk,
                                                checksum, self.storage_method)
            # TODO specialize exception
            self.assertRaises(Exception, handler.stream, source, size)