def base_prepare(item): with TestRun.LOGGER.step("Cleanup before test"): Udev.enable() kill_all_io() if installer.check_if_installed(): try: unmount_cas_devices() casadm.stop_all_caches() except Exception: pass # TODO: Reboot DUT if test is executed remotely for disk in TestRun.dut.disks: disk.umount_all_partitions() if not create_partition_table(disk, PartitionTable.gpt): TestRun.exception(f"Failed to remove partitions from {disk}") if get_force_param( item) and not TestRun.plugins['opencas'].already_updated: installer.reinstall_opencas() elif not installer.check_if_installed(): installer.install_opencas() TestRun.plugins['opencas'].already_updated = True from api.cas import init_config init_config.create_default_init_config() TestRun.LOGGER.add_build_info(f'Commit hash:') TestRun.LOGGER.add_build_info(f"{git.get_current_commit_hash()}") TestRun.LOGGER.add_build_info(f'Commit message:') TestRun.LOGGER.add_build_info(f'{git.get_current_commit_message()}')
def base_prepare(item): with TestRun.LOGGER.step("Cleanup before test"): TestRun.executor.run("pkill --signal=SIGKILL fsck") Udev.enable() kill_all_io() DeviceMapper.remove_all() if installer.check_if_installed(): try: from api.cas.init_config import InitConfig InitConfig.create_default_init_config() unmount_cas_devices() casadm.stop_all_caches() casadm.remove_all_detached_cores() except Exception: pass # TODO: Reboot DUT if test is executed remotely for disk in TestRun.dut.disks: disk.umount_all_partitions() create_partition_table(disk, PartitionTable.gpt) if get_force_param(item) and not TestRun.usr.already_updated: installer.rsync_opencas_sources() installer.reinstall_opencas() elif not installer.check_if_installed(): installer.rsync_opencas_sources() installer.set_up_opencas() TestRun.usr.already_updated = True TestRun.LOGGER.add_build_info(f'Commit hash:') TestRun.LOGGER.add_build_info(f"{git.get_current_commit_hash()}") TestRun.LOGGER.add_build_info(f'Commit message:') TestRun.LOGGER.add_build_info(f'{git.get_current_commit_message()}')
def base_prepare(item): with TestRun.LOGGER.step("Cleanup before test"): TestRun.executor.run("pkill --signal=SIGKILL fsck") Udev.enable() kill_all_io() DeviceMapper.remove_all() if installer.check_if_installed(): try: from api.cas.init_config import InitConfig InitConfig.create_default_init_config() unmount_cas_devices() casadm.stop_all_caches() casadm.remove_all_detached_cores() except Exception: pass # TODO: Reboot DUT if test is executed remotely raids = Raid.discover() for raid in raids: # stop only those RAIDs, which are comprised of test disks if all(map(lambda device: any(map(lambda disk_path: disk_path in device.get_device_id(), [bd.get_device_id() for bd in TestRun.dut.disks])), raid.array_devices)): raid.umount_all_partitions() raid.remove_partitions() raid.stop() for device in raid.array_devices: Mdadm.zero_superblock(os.path.join('/dev', device.get_device_id())) Udev.settle() for disk in TestRun.dut.disks: disk_serial = get_disk_serial_number(disk.path) if disk.serial_number != disk_serial: raise Exception( f"Serial for {disk.path} doesn't match the one from the config." f"Serial from config {disk.serial_number}, actual serial {disk_serial}" ) disk.umount_all_partitions() Mdadm.zero_superblock(os.path.join('/dev', disk.get_device_id())) TestRun.executor.run_expect_success("udevadm settle") disk.remove_partitions() create_partition_table(disk, PartitionTable.gpt) if get_force_param(item) and not TestRun.usr.already_updated: installer.rsync_opencas_sources() installer.reinstall_opencas() elif not installer.check_if_installed(): installer.rsync_opencas_sources() installer.set_up_opencas() TestRun.usr.already_updated = True TestRun.LOGGER.add_build_info(f'Commit hash:') TestRun.LOGGER.add_build_info(f"{git.get_current_commit_hash()}") TestRun.LOGGER.add_build_info(f'Commit message:') TestRun.LOGGER.add_build_info(f'{git.get_current_commit_message()}')
def base_prepare(): TestRun.LOGGER.info("Base test prepare") TestRun.LOGGER.info(f"DUT info: {TestRun.dut}") Udev.enable() kill_all_io() if installer.check_if_installed(): try: unmount_cas_devices() casadm.stop_all_caches() except Exception: pass # TODO: Reboot DUT if test is executed remotely if get_force_param( ) is not "False" and not TestRun.plugins['opencas']['already_updated']: installer.reinstall_opencas() elif not installer.check_if_installed(): installer.install_opencas() TestRun.plugins['opencas']['already_updated'] = True