Skip to content

Commit

Permalink
nydus-test: enable nydusd dynamic input prefetch files list
Browse files Browse the repository at this point in the history
Signed-off-by: Changwei Ge <gechangwei@bytedance.com>
  • Loading branch information
changweige committed Nov 2, 2022
1 parent b77b4d2 commit 377af4c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 20 deletions.
1 change: 0 additions & 1 deletion contrib/nydus-test/framework/distributor.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ def _create_new_source():
self.hardlinks[source_file] = []
self.hardlink_aliases = []
for i in range(0, count):

if randint(0, 16) % 4 == 0:
source_file = _create_new_source()
self.hardlinks[source_file] = []
Expand Down
40 changes: 21 additions & 19 deletions contrib/nydus-test/functional-test/test_nydus.py
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ def test_certain_files_prefetch(
rafs_conf.dump_rafs_conf()

rafs = NydusDaemon(nydus_anchor, nydus_scratch_image, rafs_conf)
rafs.thread_num(7).mount()
rafs.thread_num(7).mount()

wg = WorkloadGen(nydus_anchor.mountpoint, nydus_scratch_image.rootfs())

Expand Down Expand Up @@ -698,7 +698,6 @@ def test_digest_validate(
wg.finish_torture_read()


@pytest.mark.skip(reason="This test cases runs forever")
@pytest.mark.parametrize("backend", [Backend.BACKEND_PROXY])
def test_specified_prefetch(
nydus_anchor: NydusAnchor,
Expand All @@ -711,9 +710,8 @@ def test_specified_prefetch(
Nydusd can have a list including files and directories input when started.
Then it can prefetch files from backend per as to the list.
"""

rafs_conf.set_rafs_backend(backend)
rafs_conf.enable_fs_prefetch(prefetch_all=True)
rafs_conf.enable_fs_prefetch(prefetch_all=False)
rafs_conf.enable_rafs_blobcache()
rafs_conf.dump_rafs_conf()

Expand All @@ -729,35 +727,39 @@ def test_specified_prefetch(
nydus_scratch_image.set_backend(backend).create_image()

prefetching_files = dirs
prefetching_files += dist.files[:-10]
prefetching_files += dist.dirs[:-5]
prefetching_files += dist.symlinks[:-10]
prefetching_files += dist.files[:10]
prefetching_files += dist.dirs[:5]
prefetching_files += dist.symlinks[:10]
prefetching_files.append(list(dist.hardlinks.values())[1][0])
# Fuzz
prefetching_files.append("/a/b/c/d")
prefetching_files.append(os.path.join("/", "f/g/h/"))

specified_dirs = " ".join([os.path.join("/", d) for d in prefetching_files])
specified_files = " ".join([os.path.join("/", d) for d in prefetching_files])

rafs = NydusDaemon(nydus_anchor, nydus_scratch_image, rafs_conf)
rafs.prefetch_files(specified_dirs).mount()
wg = WorkloadGen(nydus_anchor.mountpoint, nydus_scratch_image.rootfs())
rafs.prefetch_files(specified_files).mount()

nc = NydusAPIClient(rafs.get_apisock())
wg.setup_workload_generator()
blobcache_metrics = nc.get_blobcache_metrics()
wg.torture_read(5, 10)

while blobcache_metrics["prefetch_workers"] != 0:
time.sleep(0.5)
blobcache_metrics = nc.get_blobcache_metrics()
# blobcache_metrics = nc.get_blobcache_metrics()
# Storage prefetch workers does not stop any more
# while blobcache_metrics["prefetch_workers"] != 0:
# time.sleep(0.5)
# blobcache_metrics = nc.get_blobcache_metrics()

begin = nc.get_backend_metrics()["read_amount_total"]
time.sleep(1)
end = nc.get_backend_metrics()["read_amount_total"]
begin = nc.get_backend_metrics()["read_amount_total"]
# end = nc.get_backend_metrics()["read_amount_total"]

assert end == begin
assert begin != 0
wg = WorkloadGen(nydus_anchor.mountpoint, nydus_scratch_image.rootfs())
wg.setup_workload_generator()
wg.torture_read(5, 10)
wg.finish_torture_read()

assert not wg.io_error


def test_build_image_param_blobid(
nydus_anchor, nydus_image: RafsImage, rafs_conf: RafsConf
Expand Down

0 comments on commit 377af4c

Please sign in to comment.