示例#1
0
 def test_write_exception(self):
     checksum = self.checksum()
     source = empty_stream()
     meta_chunk = self.meta_chunk()
     size = CHUNK_SIZE
     resps = [500] * len(meta_chunk)
     with set_http_connect(*resps):
         handler = ReplicatedChunkWriteHandler(
             self.sysmeta, meta_chunk, checksum, self.storage_method)
         self.assertRaises(exc.OioException, handler.stream, source, size)
示例#2
0
 def test_write_exception(self):
     checksum = self.checksum()
     source = empty_stream()
     size = CHUNK_SIZE * self.storage_method.ec_nb_data
     nb = self.storage_method.ec_nb_data + self.storage_method.ec_nb_parity
     resps = [500] * nb
     with set_http_connect(*resps):
         handler = ECChunkWriteHandler(self.sysmeta, self.meta_chunk(),
                                       checksum, self.storage_method)
         self.assertRaises(exc.OioException, handler.stream, source, size)
示例#3
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 = ReplicatedChunkWriteHandler(
             self.sysmeta, meta_chunk, checksum, self.storage_method)
         self.assertRaises(exc.OioException, handler.stream, source, size)
示例#4
0
 def test_write_quorum_error(self):
     checksum = self.checksum()
     source = empty_stream()
     size = CHUNK_SIZE * self.storage_method.ec_nb_data
     nb = self.storage_method.ec_nb_data + self.storage_method.ec_nb_parity
     quorum_size = self.storage_method.quorum
     resps = [500] * quorum_size
     resps += [201] * (nb - quorum_size)
     with set_http_connect(*resps):
         handler = ECChunkWriteHandler(self.sysmeta, self.meta_chunk(),
                                       checksum, self.storage_method)
         # TODO use specialized Exception
         self.assertRaises(exc.OioException, handler.stream, source, size)
示例#5
0
 def test_write_simple(self):
     checksum = self.checksum()
     source = empty_stream()
     size = CHUNK_SIZE * self.storage_method.ec_nb_data
     nb = self.storage_method.ec_nb_data + self.storage_method.ec_nb_parity
     resps = [201] * nb
     with set_http_connect(*resps):
         handler = ECChunkWriteHandler(self.sysmeta, self.meta_chunk(),
                                       checksum, self.storage_method)
         bytes_transferred, checksum, chunks = handler.stream(source, size)
     self.assertEqual(len(chunks), nb)
     self.assertEqual(bytes_transferred, 0)
     self.assertEqual(checksum, EMPTY_CHECKSUM)
示例#6
0
 def test_write_simple(self):
     checksum = self.checksum()
     source = empty_stream()
     meta_chunk = self.meta_chunk()
     size = CHUNK_SIZE
     resps = [201] * len(meta_chunk)
     with set_http_connect(*resps):
         handler = ReplicatedChunkWriteHandler(
             self.sysmeta, meta_chunk, checksum, self.storage_method)
         bytes_transferred, checksum, chunks = handler.stream(
             source, size)
         self.assertEqual(len(chunks), len(meta_chunk))
         self.assertEqual(bytes_transferred, 0)
         self.assertEqual(checksum, EMPTY_CHECKSUM)
示例#7
0
    def test_write_partial_exception(self):
        checksum = self.checksum()
        source = empty_stream()
        size = CHUNK_SIZE * self.storage_method.ec_nb_data
        nb = self.storage_method.ec_nb_data + self.storage_method.ec_nb_parity
        resps = [201] * (nb - 1)
        resps.append(Exception("failure"))
        with set_http_connect(*resps):
            handler = ECChunkWriteHandler(self.sysmeta, self.meta_chunk(),
                                          checksum, self.storage_method)
            bytes_transferred, checksum, chunks = handler.stream(source, size)

        self.assertEqual(len(chunks), nb)
        for i in range(nb - 1):
            self.assertEqual(chunks[i].get('error'), None)
        self.assertEqual(chunks[nb - 1].get('error'), 'failure')

        self.assertEqual(bytes_transferred, 0)
        self.assertEqual(checksum, EMPTY_CHECKSUM)
示例#8
0
    def test_write_quorum_success(self):
        checksum = self.checksum()
        source = empty_stream()
        size = CHUNK_SIZE * self.storage_method.ec_nb_data
        nb = self.storage_method.ec_nb_data + self.storage_method.ec_nb_parity
        quorum_size = self.storage_method.quorum
        resps = [201] * quorum_size
        resps += [500] * (nb - quorum_size)
        with set_http_connect(*resps):
            handler = ECChunkWriteHandler(self.sysmeta, self.meta_chunk(),
                                          checksum, self.storage_method)
            bytes_transferred, checksum, chunks = handler.stream(source, size)
        self.assertEqual(len(chunks), nb)

        for i in range(quorum_size):
            self.assertEqual(chunks[i].get('error'), None)
        for i in xrange(quorum_size, nb):
            self.assertEqual(chunks[i].get('error'), 'HTTP 500')

        self.assertEqual(bytes_transferred, 0)
        self.assertEqual(checksum, EMPTY_CHECKSUM)
示例#9
0
    def test_write_timeout(self):
        checksum = self.checksum()
        source = empty_stream()
        size = CHUNK_SIZE
        meta_chunk = self.meta_chunk()
        resps = [201] * (len(meta_chunk) - 1)
        resps.append(Timeout(1.0))
        with set_http_connect(*resps):
            handler = ReplicatedChunkWriteHandler(
                self.sysmeta, meta_chunk, checksum, self.storage_method)
            bytes_transferred, checksum, chunks = handler.stream(source, size)

        self.assertEqual(len(chunks), len(meta_chunk))

        for i in range(len(meta_chunk) - 1):
            self.assertEqual(chunks[i].get('error'), None)
        self.assertEqual(
            chunks[len(meta_chunk) - 1].get('error'), '1.0 second')

        self.assertEqual(bytes_transferred, 0)
        self.assertEqual(checksum, EMPTY_CHECKSUM)