def _init_params(self):
        """
        Retrieves and checks the test params
        """
        self.disk = self.params.get('disk', default=None)
        self.dirs = self.params.get('dir', default=self.workdir)
        self.fstype = self.params.get('fs', default='ext4')
        if self.fstype == 'btrfs':
            ver = int(distro.detect().version)
            rel = int(distro.detect().release)
            if distro.detect().name == 'rhel':
                if (ver == 7 and rel >= 4) or ver > 7:
                    self.cancel("btrfs is not supported with \
                                RHEL 7.4 onwards")

        if (lv_utils.get_device_total_space(self.disk) < 1073741824):
            self.cancel(
                "Device total space is lower than 1073741824 bytes. Need to provide a device with greater than 1 Gigabye size"
            )

        gigabytes = lv_utils.get_device_total_space(self.disk) // 1073741824
        if gigabytes == 0:
            self.cancel(
                "Gigabytes value is 0 which means that the disk provided as input is not of Gigabyte size"
            )
        memory_mb = memory.meminfo.MemTotal.m
        self.chunk_mb = gigabytes * 950
        if self.chunk_mb == 0:
            self.cancel(
                "chunk_mb is 0 which means that there is no sufficient chunks in MB available"
            )

        self.no_chunks = 1024 * gigabytes // self.chunk_mb
        if self.no_chunks == 0:
            self.cancel("Free disk space is lower than chunk size (%s, %s)" %
                        (1024 * gigabytes, self.chunk_mb))

        self.log.info(
            "Test will use %s chunks %sMB each in %sMB RAM using %s "
            "GB of disk space on %s dirs (%s).", self.no_chunks,
            self.chunk_mb, memory_mb, self.no_chunks * self.chunk_mb,
            len(self.dirs), self.dirs)

        if self.disk is not None:
            self.part_obj = Partition(self.disk, mountpoint=self.dirs)
            self.log.info("Unmounting the disk/dir if it is already mounted")
            self.part_obj.unmount()
            self.log.info("creating %s fs on %s", self.fstype, self.disk)
            self.part_obj.mkfs(self.fstype)
            self.log.info("mounting %s on %s", self.disk, self.dirs)
            try:
                self.part_obj.mount()
            except PartitionError:
                self.fail("Mounting disk %s on directory %s failed" %
                          (self.disk, self.dirs))
예제 #2
0
 def create_lv(self, l_disk):
     vgname = 'avocado_vg'
     lvname = 'avocado_lv'
     lv_size = lv_utils.get_device_total_space(l_disk) / 2330168
     lv_utils.vg_create(vgname, l_disk)
     lv_utils.lv_create(vgname, lvname, lv_size)
     return '/dev/%s/%s' % (vgname, lvname)
예제 #3
0
 def test(self):
     """
     Sectors are dicarded for the different values of OFFSET and LENGTH.
     """
     size = lv_utils.get_device_total_space(self.disk)
     cmd = "blkdiscard %s -o 0 -v -l %d" % (self.disk, size)
     process.run(cmd, shell=True)
     cmd = "blkdiscard %s -o %d \
            -v -l %d" % (self.disk, size, size)
     process.run(cmd, shell=True)
     cmd = "blkdiscard %s -o %d -v -l 0" % (self.disk, size)
     process.run(cmd, shell=True)
     for i in xrange(2, 10, 2):
         for j in xrange(2, 10, 2):
             if (size / i) % 4096 == 0 and (size / j) % 4096 == 0:
                 cmd = "blkdiscard %s -o %d -l %d -v" \
                     % (self.disk, size / i, size / j)
                 process.system(cmd, shell=True)
             else:
                 cmd = "blkdiscard %s -o %d -l %d -v" \
                     % (self.disk, size / i, size / j)
                 if process.system(cmd, ignore_status=True,
                                   shell=True) == 0:
                     self.fail("Blkdiscard passed for the values which is, \
                         not aligned to 4096 but actually it should fail")
예제 #4
0
    def create_lv(self, l_disk):
        """
        creates a volume group then logical volume on it and returns lv.

        :param l_disk: disk name on which a lv will be created
        :returns: Returns the lv name
        :rtype: str
        """
        lv_size = lv_utils.get_device_total_space(l_disk) / 2330168
        lv_utils.vg_create(self.vgname, l_disk)
        lv_utils.lv_create(self.vgname, self.lvname, lv_size)
        return '/dev/%s/%s' % (self.vgname, self.lvname)