def _verify_volume_size(self, requested_size, expected_volume_size):
        dataset_id = uuid4()
        # Create a new volume.
        volume = self.api.create_volume(
            dataset_id=dataset_id,
            size=requested_size,
        )
        expected_device_size = allocated_size(
            self.device_allocation_unit, expected_volume_size
        )
        # Attach it, so that we can measure its size, as reported by
        # the kernel of the machine to which it's attached.
        self.api.attach_volume(
            volume.blockdevice_id, attach_to=self.this_node,
        )

        def validate(volume):
            # Reload the volume using ``IBlockDeviceAPI.list_volumes`` in
            # case the implementation hasn't verified that the requested
            # size has actually been stored.
            volume = get_blockdevice_volume(self.api, volume.blockdevice_id)

            device_path = self.api.get_device_path(volume.blockdevice_id).path

            command = [b"/bin/lsblk", b"--noheadings", b"--bytes",
                       b"--output", b"SIZE", device_path.encode("ascii")]
            command_output = check_output(command).split(b'\n')[0]
            device_size = int(command_output.strip().decode("ascii"))
            self.assertEqual(
                (expected_volume_size, expected_device_size),
                (volume.size, device_size)
            )
        self.repeat_until_consistent(validate, volume)
Assert the implementation of
dataset/ETHPy150Open ClusterHQ/flocker/flocker/node/agents/testtools/_blockdevice.py/IBlockDeviceAPITestsMixin._verify_volume_size