def fsim_show_last_fault(cls): if not cls.is_installed(): raise Exception("Kedr is not installed!") if not cls.is_loaded(): raise Exception("Kedr is not loaded!") return fs_utils.read_file(f"{KMALLOC_FAULT_SIMULATION_PATH}/last_fault")
def test_device_capabilities(): """ title: Test whether CAS device capabilities are properly set. description: | Test if CAS device takes into consideration differences between devices which are used to create it. pass_criteria: - CAS device starts successfully using differently configured devices. - CAS device capabilities are as expected. """ core_device = TestRun.disks['core'] max_io_size_path = os.path.join(disk_utils.get_sysfs_path(core_device.get_device_id()), 'queue/max_sectors_kb') default_max_io_size = fs_utils.read_file(max_io_size_path) iteration_settings = [ {"device": "SCSI-debug module", "dev_size_mb": 1024, "logical_block_size": 512, "max_sectors_kb": 1024}, {"device": "SCSI-debug module", "dev_size_mb": 1024, "logical_block_size": 512, "max_sectors_kb": 256}, {"device": "SCSI-debug module", "dev_size_mb": 1024, "logical_block_size": 512, "max_sectors_kb": 128}, {"device": "SCSI-debug module", "dev_size_mb": 2048, "logical_block_size": 2048, "max_sectors_kb": 1024}, {"device": "standard core device", "max_sectors_kb": int(default_max_io_size)}, {"device": "standard core device", "max_sectors_kb": 128} ] for i in range(0, len(iteration_settings)): device = iteration_settings[i]["device"] group_title = f"{device} | " if device == "SCSI-debug module": group_title += f"dev_size_mb = {iteration_settings[i]['dev_size_mb']} | " \ f"logical_block_size = {iteration_settings[i]['logical_block_size']} | " group_title += f"max_sectors_kb = {iteration_settings[i]['max_sectors_kb']}" with TestRun.group(group_title): with TestRun.step("Prepare devices."): core_device = prepare_core_device(iteration_settings[i]) cache_device = TestRun.disks['cache'] with TestRun.step("Start cache and add prepared core device as core."): cache, core, error_output = prepare_cas_device(cache_device, core_device) with TestRun.step("Compare capabilities for CAS device, cache and core " "(or check proper error if logical sector mismatch occurs)."): compare_capabilities(cache_device, core_device, cache, core, error_output) with TestRun.step("Recreate CAS device with switched cache and core devices."): cache, core, error_output = prepare_cas_device(core_device, cache_device) with TestRun.step("Compare capabilities for CAS device, cache and core " "(or check proper error if logical sector mismatch occurs)."): compare_capabilities(core_device, cache_device, cache, core, error_output)
def check_for_mem_leaks(cls, module): if not cls.is_installed(): raise Exception("Kedr is not installed!") if not cls.is_loaded(): raise Exception("Kedr is not loaded!") if fs_utils.check_if_directory_exists(f"{LEAKS_LOGS_PATH}/{module}"): logs_path = f"{LEAKS_LOGS_PATH}/{module}" elif fs_utils.check_if_directory_exists(f"{DEBUGFS_MOUNT_POINT}"): logs_path = f"{LEAKS_LOGS_PATH}" else: raise Exception("Couldn't find kedr logs dir!") leaks = fs_utils.read_file(f"{logs_path}/possible_leaks") frees = fs_utils.read_file(f"{logs_path}/unallocated_frees") summary = fs_utils.read_file(f"{logs_path}/info") if leaks or frees: raise Exception("Memory leaks found!\n" f"Kedr summary: {summary}\n" f"Possible memory leaks: {leaks}\n" f"Unallocated frees: {frees}\n")
def analyze_log(self): output = TestRun.executor.run( f"ls -1td {self.result_dir[0:len(self.result_dir) - 3]}* | head -1") log_path = os.path.join(output.stdout if output.exit_code == 0 else self.result_dir, "logfile.html") log_file = fs_utils.read_file(log_path) if "Vdbench execution completed successfully" in log_file: TestRun.LOGGER.info("Vdbench execution completed successfully.") return True if "Data Validation error" in log_file or "data_errors=1" in log_file: TestRun.LOGGER.error("Data corruption occurred!") elif "Heartbeat monitor:" in log_file: TestRun.LOGGER.error("Vdbench: heartbeat.") else: TestRun.LOGGER.error("Vdbench unknown result.") return False
def test_ioclass_export_configuration(cache_mode): """ title: Export IO class configuration to a file description: | Test CAS ability to create a properly formatted file with current IO class configuration pass_criteria: - CAS default IO class configuration contains unclassified class only - CAS properly imports previously exported configuration """ with TestRun.LOGGER.step(f"Test prepare"): cache, core = prepare(cache_mode) saved_config_path = "/tmp/opencas_saved.conf" default_list = [IoClass.default()] with TestRun.LOGGER.step( f"Check IO class configuration (should contain only default class)" ): csv = casadm.list_io_classes(cache.cache_id, OutputFormat.csv).stdout if not IoClass.compare_ioclass_lists(IoClass.csv_to_list(csv), default_list): TestRun.LOGGER.error( "Default configuration does not match expected\n" f"Current:\n{csv}\n" f"Expected:{IoClass.list_to_csv(default_list)}") with TestRun.LOGGER.step( "Create and load configuration file for 33 IO classes " "with random names, allocation and priority values"): random_list = IoClass.generate_random_ioclass_list(33) IoClass.save_list_to_config_file( random_list, ioclass_config_path=ioclass_config_path) casadm.load_io_classes(cache.cache_id, ioclass_config_path) with TestRun.LOGGER.step( "Display and export IO class configuration - displayed configuration " "should be the same as created"): TestRun.executor.run( f"{casadm.list_io_classes_cmd(str(cache.cache_id), OutputFormat.csv.name)}" f" > {saved_config_path}") csv = fs_utils.read_file(saved_config_path) if not IoClass.compare_ioclass_lists(IoClass.csv_to_list(csv), random_list): TestRun.LOGGER.error( "Exported configuration does not match expected\n" f"Current:\n{csv}\n" f"Expected:{IoClass.list_to_csv(random_list)}") with TestRun.LOGGER.step("Stop Intel CAS"): casadm.stop_cache(cache.cache_id) with TestRun.LOGGER.step("Start cache and add core"): cache = casadm.start_cache(cache.cache_device, force=True) casadm.add_core(cache, core.core_device) with TestRun.LOGGER.step( "Check IO class configuration (should contain only default class)" ): csv = casadm.list_io_classes(cache.cache_id, OutputFormat.csv).stdout if not IoClass.compare_ioclass_lists(IoClass.csv_to_list(csv), default_list): TestRun.LOGGER.error( "Default configuration does not match expected\n" f"Current:\n{csv}\n" f"Expected:{IoClass.list_to_csv(default_list)}") with TestRun.LOGGER.step( "Load exported configuration file for 33 IO classes"): casadm.load_io_classes(cache.cache_id, saved_config_path) with TestRun.LOGGER.step( "Display IO class configuration - should be the same as created"): csv = casadm.list_io_classes(cache.cache_id, OutputFormat.csv).stdout if not IoClass.compare_ioclass_lists(IoClass.csv_to_list(csv), random_list): TestRun.LOGGER.error( "Exported configuration does not match expected\n" f"Current:\n{csv}\n" f"Expected:{IoClass.list_to_csv(random_list)}") with TestRun.LOGGER.step(f"Test cleanup"): fs_utils.remove(saved_config_path)
def read(self): return fs_utils.read_file(str(self))