def test_iostats(nydus_anchor: NydusAnchor, nydus_image: RafsImage, rafs_conf: RafsConf): rafs_id = "/" rafs_conf.enable_files_iostats().enable_latest_read_files( ).set_rafs_backend(Backend.OSS) nydus_image.set_backend(Backend.OSS).create_image() rafs = RafsMount(nydus_anchor, nydus_image, rafs_conf) rafs.mount() assert rafs.is_mounted() nc = NydusAPIClient(rafs.get_apisock()) duration = 5 wg = WorkloadGen(nydus_anchor.mount_point, nydus_image.rootfs()) wg.setup_workload_generator() wg.torture_read(4, duration) while duration: time.sleep(1) duration -= 1 nc.get_global_metrics() nc.get_files_metrics(rafs_id) nc.get_backend_metrics(rafs_id) wg.finish_torture_read() duration = 7 wg.torture_read(4, duration) # Disable it firstly and then enable it. # TODO: files metrics can't be toggled dynamically now. Try to implement it. # nc.disable_files_metrics(rafs_id) # nc.enable_files_metrics(rafs_id) r = nc.get_latest_files_metrics(rafs_id) print(r) while duration: time.sleep(1) duration -= 1 nc.get_files_metrics(rafs_id) wg.finish_torture_read() rafs.umount()
def test_global_metrics(nydus_anchor, nydus_image: RafsImage, rafs_conf: RafsConf): rafs_id = "/" rafs_conf.enable_files_iostats().set_rafs_backend(Backend.OSS) nydus_image.set_backend(Backend.OSS).create_image() rafs = RafsMount(nydus_anchor, nydus_image, rafs_conf) rafs.mount() nc = NydusAPIClient(rafs.get_apisock()) gm = nc.get_global_metrics() assert gm["files_account_enabled"] == True assert gm["measure_latency"] == True file_counters = nc.get_files_metrics(rafs_id) assert len(file_counters) logging.info("There are %d file counters created.", len(file_counters)) wg = WorkloadGen(nydus_anchor.mount_point, nydus_image.rootfs()) wg.setup_workload_generator() wg.io_read(4) file_counters = nc.get_files_metrics(rafs_id) assert file_counters is not None and len(file_counters) logging.info("There are %d file counters created after some read.", len(file_counters)) if len(file_counters): k = random.choice(list(file_counters)) logging.info("ino: %s, stats: %s", k, file_counters[k]) gm_old = nc.get_global_metrics() wg.io_read(4) gm_new = nc.get_global_metrics() assert gm_new["data_read"] > gm_old["data_read"] assert (gm_new["fop_hits"][nydusd_client.Fop.Read.get_value()] > gm_old["fop_hits"][nydusd_client.Fop.Read.get_value()]) rafs.umount()
def test_detect_io_hang(nydus_anchor, nydus_image: RafsImage, rafs_conf: RafsConf): rafs_conf.enable_files_iostats().set_rafs_backend(Backend.OSS) rafs_conf.dump_rafs_conf() nydus_image.set_backend(Backend.OSS).create_image() rafs = RafsMount(nydus_anchor, nydus_image, rafs_conf) rafs.thread_num(5).mount() wg = WorkloadGen(nydus_anchor.mount_point, nydus_image.rootfs()) wg.setup_workload_generator() wg.torture_read(4, 8) nc = NydusAPIClient(rafs.get_apisock()) for _ in range(0, 30): ops = nc.get_inflight_metrics() time.sleep(0.1) print(ops) wg.finish_torture_read()