def test_compare_summary(): """ title: Compare trace summaries. description: | Verify the summary returned at the end of tracing (output of 'iotrace –S') is the same as the summary read from trace files (output of 'iotrace -M -G'). pass_criteria: - Trace summaries are the same. """ with TestRun.step("Run tracing for a while"): disk = TestRun.dut.disks[0] output = parse_json(TestRun.executor.run( f'iotrace -S -d {disk.system_path} -t {int(runtime.total_seconds())}').stdout)[-1] with TestRun.step("Compare tracing summaries."): summary = IotracePlugin.get_trace_summary(output["tracePath"]) if output != summary: err_output = "The summary read from trace file differs from summary " \ "returned at the end of tracing.\n" fault = False if summary["tracePath"] != output["tracePath"]: fault = True err_output += (f'Trace paths are different:' f'\ntrace path from file: "{summary["tracePath"]}"' f'\ntrace path from output: "{output["tracePath"]}"\n') if summary["state"] != output["state"]: fault = True err_output += (f'Trace states are different:' f'\ntrace state from file: "{summary["state"]}"' f'\ntrace state from output: "{output["state"]}"\n') if summary["sourceNode"]["node"][0]["id"] != output["sourceNode"]["node"][0]["id"]: fault = True err_output += (f'Node\'s IDs are different:' f'\nnode\'s ID from file: {summary["sourceNode"]["node"][0]["id"]}' f'\nnode\'s ID from output: ' f'{output["sourceNode"]["node"][0]["id"]}\n') if summary["traceStartDateTime"] != output["traceStartDateTime"]: fault = True err_output += (f'Trace start times are different:' f'\ntrace start time from file: {summary["traceStartDateTime"]}' f'\ntrace start time from output: {output["traceStartDateTime"]}\n') if summary["traceDuration"] != output["traceDuration"]: fault = True err_output += (f'Trace duration times are different:' f'\ntrace duration time from file: {summary["traceDuration"]}' f'\ntrace duration time from output: {output["traceDuration"]}\n') if summary["label"] != output["label"]: fault = True err_output += (f'Trace labels are different:' f'\ntrace label from output: "{summary["label"]}"' f'\nexpected trace label: "{output["label"]}"\n') if fault: TestRun.fail(err_output)
def test_source_package_installation(): TestRun.LOGGER.info("Testing source package installation") iotrace: IotracePlugin = TestRun.plugins['iotrace'] work_path: str = f"{iotrace.working_dir}/standalone-linux-io-tracer" disk = TestRun.dut.disks[0] with TestRun.step("Building iotrace source package"): TestRun.executor.run_expect_success( f"cd {work_path} && " "make package_source -j`nproc --all`") iotrace_installed = check_if_installed() if iotrace_installed: with TestRun.step("Uninstall existing iotrace if needed"): uninstall_iotrace() with TestRun.step("Remove old source package"): TestRun.executor.run_expect_success(f"cd {work_path} && " f"rm -rf iotrace-*-Source") with TestRun.step("Unpack and install source package"): TestRun.executor.run_expect_success( f"tar -xvf {work_path}/build/release/iotrace-*.tar.gz -C {work_path} &&" f"cd {work_path}/iotrace-*-Source &&" "./setup_dependencies.sh &&" "make install -j`nproc --all`") with TestRun.step("Check if iotrace is installed"): iotrace.version() iotrace.start_tracing([disk.system_path]) stopped = iotrace.stop_tracing() if not stopped: raise Exception("Could not stop active tracing.") trace_path = IotracePlugin.get_latest_trace_path() summary_parsed = IotracePlugin.get_trace_summary(trace_path) if summary_parsed['state'] != "COMPLETE": TestRun.LOGGER.error("Trace state is not complete") with TestRun.step("Uninstall iotrace"): uninstall_iotrace() with TestRun.step("Check if iotrace was uninstalled"): TestRun.executor.run_expect_fail("iotrace -V") if iotrace_installed: with TestRun.step("Reinstall iotrace"): install_iotrace()
def test_trace_start_stop(): TestRun.LOGGER.info("Testing starting and stopping of tracing") iotrace: IotracePlugin = TestRun.plugins['iotrace'] iotrace.start_tracing() stopped = iotrace.stop_tracing() if not stopped: raise Exception("Could not stop active tracing.") trace_path = IotracePlugin.get_latest_trace_path() summary_parsed = IotracePlugin.get_trace_summary(trace_path) if summary_parsed['state'] != "COMPLETE": raise Exception("Trace state is not complete")
def test_package_installation(): TestRun.LOGGER.info("Testing package installation") iotrace: IotracePlugin = TestRun.plugins['iotrace'] work_path: str = f"{iotrace.working_dir}/iotrace_package" disk = TestRun.dut.disks[0] with TestRun.step("Copying iotrace repository to DUT"): TestRun.executor.rsync_to(f"{iotrace.repo_dir}/", work_path, delete=True, symlinks=True, exclude_list=['build'] + ['*.pyc'], timeout=timedelta(minutes=2)) with TestRun.step("Setup dependencies"): TestRun.executor.run_expect_success(f"cd {work_path} && " "./setup_dependencies.sh") with TestRun.step("Remove old packages"): TestRun.executor.run_expect_success( f"rm -rf {work_path}/build/release/iotrace-*.deb && " f"rm -rf {work_path}/build/release/iotrace-*.rpm") with TestRun.step("Building iotrace package"): TestRun.executor.run_expect_success(f"cd {work_path} && " "make package -j`nproc --all`") iotrace_installed = check_if_installed() if iotrace_installed: with TestRun.step("Uninstall existing iotrace if needed"): uninstall_iotrace() with TestRun.step("Install from iotrace package"): if check_if_ubuntu(): TestRun.executor.run_expect_success( f"cd {work_path}/build/release && " "dpkg -i iotrace-*.deb") else: TestRun.executor.run_expect_success( f"cd {work_path}/build/release && " "rpm -i iotrace-*.rpm") with TestRun.step("Check if iotrace is installed"): iotrace.version() iotrace.start_tracing([disk.system_path]) time.sleep(1) stopped = iotrace.stop_tracing() if not stopped: raise Exception("Could not stop active tracing.") trace_path = IotracePlugin.get_latest_trace_path() summary_parsed = IotracePlugin.get_trace_summary(trace_path) if summary_parsed['state'] != "COMPLETE": TestRun.LOGGER.error("Trace state is not complete") with TestRun.step("Uninstall rpm package"): if check_if_ubuntu(): TestRun.executor.run_expect_success("apt remove -y iotrace") else: TestRun.executor.run_expect_success("rpm -e iotrace") with TestRun.step("Check if iotrace was uninstalled"): TestRun.executor.run_expect_fail("iotrace -V") if iotrace_installed: with TestRun.step("Reinstall iotrace"): install_iotrace()
def test_iotracer_limits(): """ title: Check if io-tracer respects its own tracing limits . description: | Check if io-tracer respects the time limit and the trace file size limit set with start command and finishes tracing when one of two limits is reached. pass_criteria: - No system crash. - Tracing stops when one of the limits is reached. """ with TestRun.step("Generate workload on device."): disk = TestRun.dut.disks[0] fio_pid = fio_workload(disk.system_path, fio_runtime).run_in_background() with TestRun.step("Prepare io-tracer."): iotracer: IotracePlugin = TestRun.plugins['iotrace'] with TestRun.step("Run io-tracer with duration limit set."): iotracer.start_tracing([disk.system_path], timeout=runtime_short) with TestRun.step("Wait for tracing to finish."): wait(iotracer) output = IotracePlugin.get_trace_summary(IotracePlugin.get_latest_trace_path()) with TestRun.step("Check tracing duration."): if not is_time_almost_equal(runtime_short, output['traceDuration']): TestRun.LOGGER.error("Tracing duration is different than set.") with TestRun.step("Run io-tracer with file size limit set."): iotracer.start_tracing([disk.system_path], trace_file_size=size_limit_low) with TestRun.step("Wait for tracing to finish."): wait(iotracer) output = IotracePlugin.get_trace_summary(IotracePlugin.get_latest_trace_path()) with TestRun.step("Check trace file size."): if not is_size_almost_equal(size_limit_low, output['traceSize']): TestRun.LOGGER.error("Tracing file size is different than set.") with TestRun.step("Run io-tracer with low file size limit and high duration limit set."): iotracer.start_tracing([disk.system_path], timeout=runtime_long, trace_file_size=size_limit_low) with TestRun.step("Wait for tracing to finish."): wait(iotracer) output = IotracePlugin.get_trace_summary(IotracePlugin.get_latest_trace_path()) with TestRun.step("Check tracing duration and trace file size."): if not ((is_time_almost_equal(runtime_long, output['traceDuration']) and is_size_lower_or_equal(output['traceSize'], size_limit_low)) or (is_time_lower_or_equal(output['traceDuration'], runtime_long) and is_size_almost_equal(size_limit_low, output['traceSize']))): TestRun.LOGGER.error("Tracing did not stop after reaching size nor time limit.") with TestRun.step("Run io-tracer with high file size limit and low duration limit set."): iotracer.start_tracing([disk.system_path], timeout=runtime_short, trace_file_size=size_limit_high) with TestRun.step("Wait for tracing to finish."): wait(iotracer) output = IotracePlugin.get_trace_summary(IotracePlugin.get_latest_trace_path()) with TestRun.step("Check tracing duration and trace file size."): if not ((is_time_almost_equal(runtime_short, output['traceDuration']) and is_size_lower_or_equal(output['traceSize'], size_limit_high)) or (is_time_lower_or_equal(output['traceDuration'], runtime_short) and is_size_almost_equal(size_limit_high, output['traceSize']))): TestRun.LOGGER.error("Tracing did not stop after reaching size nor time limit.") with TestRun.step("Stop fio workload."): TestRun.executor.kill_process(fio_pid)