Example #1
0
 def test_fail_invalid_block_volume_size(self, preallocate):
     with self.assertRaises(se.InvalidParameterException):
         max_size = BlockVolume.max_size(GIB, sc.COW_FORMAT)
         max_size_blk = max_size // sc.BLOCK_SIZE
         BlockVolume.calculate_volume_alloc_size(preallocate,
                                                 GIB_IN_SECTORS,
                                                 max_size_blk + 1)
Example #2
0
 def test_fail_invalid_block_volume_size(self, preallocate):
     with self.assertRaises(se.InvalidParameterException):
         max_size = BlockVolume.max_size(GIB, sc.COW_FORMAT)
         max_size_blk = max_size // sc.BLOCK_SIZE
         BlockVolume.calculate_volume_alloc_size(preallocate,
                                                 GIB_IN_SECTORS,
                                                 max_size_blk + 1)
Example #3
0
class BlockVolumeSizeTests(TestCaseBase):
    @permutations([
        # (preallocate, capacity in sectors, initial size in sectors),
        #   allocation size in MB
        # Preallocate, capacity 2048 sectors, No initial size.
        #      Expected 1 Mb allocated
        [(sc.PREALLOCATED_VOL, 2048, None), 1],
        # Preallocate, capacity 2049 sectors, No initial size.
        #      Expected 2 Mb allocated
        [(sc.PREALLOCATED_VOL, 2049, None), 2],
        # Preallocate, capacity 2097152 sectors, No initial size.
        #      Expected 1024 Mb allocated
        [(sc.PREALLOCATED_VOL, 2097152, None), 1024],
        # Sparse, capacity 9999 sectors, No initial size.
        #      Expected 1024 Mb allocated
        [(sc.SPARSE_VOL, 9999, None),
         config.getint("irs", "volume_utilization_chunk_mb")],
        # Sparse, capacity 8388608 sectors, initial size 1860.
        #      Expected 1 Mb allocated
        [(sc.SPARSE_VOL, 8388608, 1860), 1],
        # Sparse, capacity 8388608 sectors, initial size 1870.
        #      Expected 2 Mb allocated
        [(sc.SPARSE_VOL, 8388608, 1870), 2],
        # Sparse, capacity 2097152 sectors, initial size 2359296.
        #      Expected 1268 Mb allocated
        [(sc.SPARSE_VOL, GIB_IN_SECTORS,
          BlockVolume.max_size(GIB, sc.COW_FORMAT) // sc.BLOCK_SIZE), 1268],
    ])
    def test_block_volume_size(self, args, result):
        size = BlockVolume.calculate_volume_alloc_size(*args)
        self.assertEqual(size, result)

    @permutations(
        # preallocate
        [
            [sc.PREALLOCATED_VOL],
            [sc.SPARSE_VOL],
        ])
    def test_fail_invalid_block_volume_size(self, preallocate):
        with self.assertRaises(se.InvalidParameterException):
            max_size = BlockVolume.max_size(GIB, sc.COW_FORMAT)
            max_size_blk = max_size // sc.BLOCK_SIZE
            BlockVolume.calculate_volume_alloc_size(preallocate,
                                                    GIB_IN_SECTORS,
                                                    max_size_blk + 1)
Example #4
0
 def test_fail_invalid_block_volume_size(self, preallocate):
     with self.assertRaises(se.InvalidParameterException):
         BlockVolume._calculate_volume_alloc_size(preallocate, 2048, 2049)
Example #5
0
 def test_block_volume_size(self, args, result):
     size = BlockVolume._calculate_volume_alloc_size(*args)
     self.assertEqual(size, result)
Example #6
0
 def test_fail_invalid_block_volume_size(self, preallocate):
     with self.assertRaises(se.InvalidParameterException):
         BlockVolume.calculate_volume_alloc_size(preallocate, 2048, 2049)
Example #7
0
 def test_block_volume_size(self, args, result):
     size = BlockVolume.calculate_volume_alloc_size(*args)
     self.assertEqual(size, result)
Example #8
0
 def test_max_size_cow(self):
     # verify that max size equals to virtual size with estimated cow
     # overhead, aligned to vg extent size.
     self.assertEqual(BlockVolume.max_size(10 * GIB, sc.COW_FORMAT),
                      11811160064)
Example #9
0
 def test_max_size_raw(self):
     # verify that max size equals to virtual size.
     self.assertEqual(BlockVolume.max_size(1 * GIB, sc.RAW_FORMAT),
                      1 * GIB)
Example #10
0
 def test_max_size_cow(self):
     # verify that max size equals to virtual size with estimated cow
     # overhead, aligned to vg extent size.
     self.assertEqual(BlockVolume.max_size(10 * GIB, sc.COW_FORMAT),
                      11811160064)
Example #11
0
 def test_max_size_raw(self):
     # verify that max size equals to virtual size.
     self.assertEqual(BlockVolume.max_size(1 * GIB, sc.RAW_FORMAT), 1 * GIB)