예제 #1
0
 def set_sysfs_property(self, property_name, value):
     TestRun.LOGGER.info(
         f"Setting {property_name} for device {self.get_device_id()} to {value}."
     )
     path = os.path.join(disk_utils.get_sysfs_path(self.get_device_id()),
                         "queue", property_name)
     fs_utils.write_file(path, str(value))
예제 #2
0
 def create_config(self, config, run_time: timedelta):
     self.run_time = run_time
     if config[-1] != ",":
         config += ","
     config += f"elapsed={int(run_time.total_seconds())}"
     TestRun.LOGGER.info(f"Vdbench config:\n{config}")
     fs_utils.write_file(os.path.join(self.working_dir, "param.ini"), config)
예제 #3
0
 def save_list_to_config_file(
         ioclass_list: [],
         add_default_rule: bool = True,
         ioclass_config_path: str = default_config_file_path):
     TestRun.LOGGER.info(f"Creating config file {ioclass_config_path}")
     fs_utils.write_file(
         ioclass_config_path,
         IoClass.list_to_csv(ioclass_list, add_default_rule))
예제 #4
0
 def save_config_file(self):
     config_lines = []
     InitConfig.create_default_init_config()
     if self.cache_config_lines:
         config_lines.append(CacheConfigLine.header)
         for c in self.cache_config_lines:
             config_lines.append(str(c))
     if self.core_config_lines:
         config_lines.append(CoreConfigLine.header)
         for c in self.core_config_lines:
             config_lines.append(str(c))
     fs_utils.write_file(opencas_conf_path, '\n'.join(config_lines), False)
예제 #5
0
def create_init_config_from_running_configuration(load: bool = None,
                                                  extra_flags=""):
    cache_lines = []
    core_lines = []
    for cache in casadm_parser.get_caches():
        cache_lines.append(
            CacheConfigLine(cache.cache_id, cache.cache_device,
                            cache.get_cache_mode(), load, extra_flags))
        for core in casadm_parser.get_cores(cache.cache_id):
            core_lines.append(
                CoreConfigLine(cache.cache_id, core.core_id, core.core_device))
    config_lines = []
    create_default_init_config()
    if len(cache_lines) > 0:
        config_lines.append(CacheConfigLine.header)
        for c in cache_lines:
            config_lines.append(str(c))
    if len(core_lines) > 0:
        config_lines.append(CoreConfigLine.header)
        for c in core_lines:
            config_lines.append(str(c))
    fs_utils.write_file(cas_init_config_path, '\n'.join(config_lines), False)
예제 #6
0
 def create_default_init_config(cls):
     cas_version = casadm_parser.get_casadm_version()
     fs_utils.write_file(opencas_conf_path, f"version={cas_version.base}")
예제 #7
0
 def create_default_init_config(cls):
     cas_version = casadm_parser.get_casadm_version()
     fs_utils.write_file(
         opencas_conf_path,
         f"version={'.'.join(str(x) for x in cas_version.release[0:3])}")
예제 #8
0
 def write(self, content, overwrite: bool = True):
     fs_utils.write_file(str(self), content, overwrite)
     self.refresh_item()
예제 #9
0
def test_fs_operations():
    TestRun.LOGGER.info("Testing file system events during tracing")
    iotrace = TestRun.plugins['iotrace']

    for disk in TestRun.dut.disks:
        try:
            with TestRun.step("Create file system"):
                disk.create_filesystem(Filesystem.ext4)
            with TestRun.step("Mount device"):
                disk.mount(mountpoint)
            with TestRun.step("Start tracing"):
                iotrace.start_tracing([disk.system_path])
                time.sleep(5)
            with TestRun.step("Create test directory and file"):
                write_file(f"{mountpoint}/test_file", content="foo")
                sync()
                test_file_inode = get_inode(f"{mountpoint}/test_file")
                create_directory(f"{mountpoint}/test_dir")
                sync()
            with TestRun.step("Write to test file"):
                write_file(f"{mountpoint}/test_file",
                           overwrite=False,
                           content="bar")
                sync()
            with TestRun.step("Create new test file"):
                create_file(f"{mountpoint}/test_file2")
                test_file2_inode = get_inode(f"{mountpoint}/test_file2")
                sync()
            with TestRun.step("Move test file"):
                move(f"{mountpoint}/test_file", f"{mountpoint}/test_dir")
                sync()
            with TestRun.step("Delete test file"):
                remove(f"{mountpoint}/test_dir/test_file")
                sync()
            with TestRun.step("Stop tracing"):
                sync()
                iotrace.stop_tracing()
            with TestRun.step("Verify trace correctness"):
                trace_path = iotrace.get_latest_trace_path()
                events = iotrace.get_trace_events(trace_path)
                events_parsed = iotrace.parse_json(events)
                result = any(
                    'file' in event and event['file']['eventType'] == 'Create'
                    and event['file']['id'] == test_file2_inode
                    for event in events_parsed)
                if not result:
                    raise Exception("Could not find Create event")
                result = any(
                    'file' in event and event['file']['eventType'] == 'Delete'
                    and event['file']['id'] == test_file_inode
                    for event in events_parsed)
                if not result:
                    raise Exception("Could not find Delete event")
                result = any(
                    'file' in event and event['file']['eventType'] == 'MoveTo'
                    and event['file']['id'] == test_file_inode
                    for event in events_parsed)
                if not result:
                    raise Exception("Could not find MoveTo event")
                result = any(
                    'file' in event and event['file']['eventType'] ==
                    'MoveFrom' and event['file']['id'] == test_file_inode
                    for event in events_parsed)
                if not result:
                    raise Exception("Could not find MoveFrom event")
                result = any(
                    'file' in event and event['file']['eventType'] == 'Access'
                    and event['file']['id'] == test_file_inode
                    for event in events_parsed)
                if not result:
                    raise Exception("Could not find Access event")
        finally:
            with TestRun.step("Unmount device"):
                disk.unmount()